producer.h
来自「systemc源码」· C头文件 代码 · 共 78 行
H
78 行
/************************************************************************
* file name: producer.h
* description:
*
* modification history
* --------------------
* 2003-7-7 19:32:19, created by zhuwei
*/
#ifndef _PRODUCER_H
#define _PRODUCER_H
/* includes----------------------------------------------------------- */
#include "systemc.h"
#include "config.h"
#include "zhuwei_debug.h"
/* defines------------------------------------------------------------ */
/* typedefs----------------------------------------------------------- */
struct producer: sc_module
{
sc_in<bool> clk;
sc_out<bool> reset, wen;
sc_in<bool> fifo_full;
sc_out<int> dout;
// internal variables
int count;
// process function
void write_fifo()
{
while(true)
{
wait();
if(reset.read() || fifo_full.read())
{
wen = false;
continue;
}
assert(CLK_CYCLE > 2);
wait(2, SC_NS);
wen = true;
dout = count++;
wait(CLK_CYCLE-2, SC_NS);
wen = false;
dout = -1;
}
}
void initial()
{
reset = 1;
dout = -1;
wait(CLK_CYCLE * 2, SC_NS);
reset = 0;
}
// Constructor
SC_CTOR(producer): count(0)
{
SC_THREAD(write_fifo);
sensitive_neg << clk;
SC_THREAD(initial);
}
};
/* externs------------------------------------------------------------ */
/* globals------------------------------------------------------------ */
/* forward declarations----------------------------------------------- */
#endif /* _PRODUCER_H */
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?