?? main.cpp
字號:
/************************************************************************
* file name: main.cpp
* description: 使用類摸板,使你的信號可以方便地更改為各種數據類型。
*
* modification history
* --------------------
* 2003-8-6, created by zhuwei
*/
/* includes----------------------------------------------------------- */
#include "systemc.h"
/* defines------------------------------------------------------------ */
/* typedefs----------------------------------------------------------- */
template <int L> class DFF: public sc_module
{
public:
sc_in<bool> clk;
sc_in<sc_bv<L> > din;
sc_out<sc_bv<L> > dout;
void run()
{
dout = din;
cout << dout.read().to_uint() << endl;
}
// Constructor
SC_CTOR(DFF)
{
SC_METHOD(run);
sensitive_pos << clk;
}
};
struct output: sc_module
{
sc_in<bool> clk;
sc_out<sc_bv<3> > dout;
sc_bv<3> bv;
void run()
{
dout = bv;
}
// Constructor
SC_CTOR(output): bv(7)
{
SC_METHOD(run);
sensitive_pos << clk;
}
};
/* externs------------------------------------------------------------ */
/* globals------------------------------------------------------------ */
/* forward declarations----------------------------------------------- */
int sc_main(int argc, char *argv[])
{
sc_clock clk("clk", 10, SC_NS);
sc_signal<sc_bv<3> > din; //如果你的din,dout是整型的,申明為“sc_signal<int> din”即可。
sc_signal<sc_bv<3> > dout;
output op1("op1");
op1(clk, din);
DFF<3> dff1("dff1");
dff1(clk, din, dout);
sc_start(100, SC_NS);
return 0;
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -