?? main.cpp
字號:
/************************************************************************
* file name: main.cpp
* description:
*
* modification history
* --------------------
* 2003-6-21 19:19:21, created by zhuwei
*/
/* includes----------------------------------------------------------- */
#include "systemc.h"
/* defines------------------------------------------------------------ */
/* typedefs----------------------------------------------------------- */
typedef struct MEM_S
{
int mem[10];
int index;
inline bool operator == (const MEM_S& m) const
{
bool equal = true;
for(int i=0; i<10; i++)
if(mem[i] != m.mem[i])
{
equal = false;
break;
}
return equal;
}
inline MEM_S& operator = (const MEM_S& m)
{
for(int i=0; i<10; i++) mem[i] = m.mem[i];
return *this;
}
inline friend ostream& operator << ( ostream& os, MEM_S const & m )
{
for(int i=0; i<10; i++) cout << m.mem[i] << "/";
return os;
}
inline friend void sc_trace(sc_trace_file *tf, MEM_S const & m,const sc_string& NAME)
{
for(int i=0; i<10; i++)
sc_trace(tf, m.mem[i], "mem");
}
}MEM_T;
struct module_a: sc_module
{
sc_in_clk clk;
sc_signal<MEM_T> s_mem;
MEM_T v_mem;
int j;
void run()
{
for(int i=0; i<10; i++) v_mem.mem[i] = j + i;
s_mem = v_mem;
j++;
}
// Constructor
SC_CTOR(module_a):j(0)
{
SC_METHOD(run);
sensitive_pos << clk;
}
};
/* externs------------------------------------------------------------ */
/* globals------------------------------------------------------------ */
/* forward declarations----------------------------------------------- */
int sc_main(int argc, char *argv[])
{
sc_clock clk("clk", 10, SC_NS);
module_a ma("ma");
ma(clk);
sc_trace_file *tf = sc_create_vcd_trace_file("mem_vcd");
sc_trace(tf, clk, "clk");
sc_trace(tf, ma.s_mem, "ma.s_mem");
sc_start(500, SC_NS);
sc_close_vcd_trace_file(tf);
return 0;
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -