📄 consumer.h
字号:
/************************************************************************
* file name: consumer.h
* description:
*
* modification history
* --------------------
* 2003-7-8 14:10:59, created by zhuwei
*/
#ifndef _CONSUMER_H
#define _CONSUMER_H
/* includes----------------------------------------------------------- */
#include <assert.h>
#include "config.h"
/* defines------------------------------------------------------------ */
/* typedefs----------------------------------------------------------- */
struct consumer: sc_module
{
sc_in<bool> clk, reset, fifo_empty;
sc_in<int> din;
sc_out<bool> ren;
// internal variables
// process function
void run()
{
while(true)
{
wait();
if(reset.read() || fifo_empty.read())
{
ren = false;
continue;
}
assert(CLK_CYCLE > 2);
wait(2, SC_NS);
ren = true;
cout << "fifo out: " << din << endl;
wait(CLK_CYCLE-2, SC_NS);
ren = false;
}
}
// Constructor
SC_CTOR(consumer)
{
SC_THREAD(run);
sensitive_neg << clk;
}
};
/* externs------------------------------------------------------------ */
/* globals------------------------------------------------------------ */
/* forward declarations----------------------------------------------- */
#endif /* _CONSUMER_H */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -