📄 producer.h
字号:
/************************************************************************
* 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 + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -