⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main.cpp

📁 SYSTEMC经典案例,很好的SYSTEMC参考资料.SYSTEMC系统验证测试强大语言.
💻 CPP
字号:
/************************************************************************
 * file name:	main.cpp
 * description:	for test use.
 * modification history
 * --------------------
 * 2003-5-3 9:27:49, created by zhuwei
 */ 

/* includes----------------------------------------------------------- */
//#include <iostream.h>
#include <time.h>    /* zhuwei (2003-5-3 10:39:12) */
#include "packet.h"
#include "timer.h"
#include "transmit.h"
#include "channel.h"
#include "receiver.h"
#include "display.h"

/* defines------------------------------------------------------------ */
//#define __glibcpp_function_requires(args...)  
/* typedefs----------------------------------------------------------- */
/* externs------------------------------------------------------------ */
/* globals------------------------------------------------------------ */
/* forward declarations----------------------------------------------- */

/************************************************************************
 * function:	sc_main()
 * purpose:
 * caller:	main() in Sc_main.cpp
 */
int sc_main(int argc, char* argv[]) 
{
	sc_signal<packet_type> PACKET1, PACKET2, PACKET3, PACKET4;
	sc_signal<long> DOUT;
	sc_signal<bool> TIMEOUT, START;

	//SCV_REPORT_ERROR("hello, ", "world");  /* zhuwei (2003-5-10 20:39:30) 在SCV中 */

/*-------------------zhuwei add(2003-5-8 9:28:24)--------------------
	推荐使用这种方式:
	sc_clock clk1( “clk1”, 15, SC_NS );
	sc_start( 1000, SC_NS );
----------------------end(2003-5-8 9:28:24)------------------------*/
	sc_clock CLOCK("clock", 20); // transmit clock
	sc_clock RCLK("rclk", 15); // receive clock

	/* zhuwei (2003-5-4 16:22:27) signal和port对应,named connection */

	transmit t1("transmit");    /* zhuwei (2003-5-4 16:53:42) 声明module,实例化*/
	t1.tpackin(PACKET2);    
	t1.timeout(TIMEOUT);
	t1.tpackout(PACKET1);
	t1.start_timer(START);
	t1.clock(CLOCK);

	srand( (unsigned)time( NULL ) );    /* zhuwei (2003-5-3 10:34:50) */

	channel c1("channel");
	c1.tpackin(PACKET1);
	c1.rpackin(PACKET3);
	c1.tpackout(PACKET2);
	c1.rpackout(PACKET4);

	receiver r1("receiver");
	r1.rpackin(PACKET4);
	r1.rpackout(PACKET3);
	r1.dout(DOUT);
	r1.rclk(RCLK);

	/* zhuwei (2003-5-4 16:25:17) positional connections */
	display d1("display");    
	d1 <<DOUT; 
	//d1(DOUT);  /* zhuwei (2003-5-5 11:10:40) positional connections的另一种方式*/

	/* 
	SC_MODULE(timer) 
	{
		sc_inout<bool> start; // input port
		sc_out<bool> timeout; // output port
		sc_in<bool> clock; // input port
		.....
	*/
	timer tm1("timer");
	/* zhuwei (2003-5-4 16:57:06) 注意transmit也有TIMEOUT,START信号,它是全局变量 */
	tm1 <<START<<TIMEOUT<<CLOCK.signal();    /* zhuwei (2003-5-4 16:32:38) port和signal依次对应 */
	//tm1(START, TIMEOUT, CLOCK.signal());  /* zhuwei (2003-5-5 11:10:40) positional connections的另一种方式*/

	// tracing:
	// trace file creation
	sc_trace_file *tf = sc_create_vcd_trace_file("simplex");
	// External Signals
	/* zhuwei (2003-5-4 16:35:42) 设置要trace的signal和variable */
	sc_trace(tf, CLOCK.signal(), "clock");
	sc_trace(tf, TIMEOUT, "timeout");
	sc_trace(tf, START, "start");
	sc_trace(tf, PACKET1, "packet1");
	sc_trace(tf, PACKET2, "packet2");
	sc_trace(tf, PACKET3, "packet3");
	sc_trace(tf, PACKET4, "packet4");
	sc_trace(tf, DOUT, "dout");

	/* zhuwei (2003-5-4 20:01:44) sc_start()在Sc_simcontext.cpp中 */
	sc_start(1000);    /* zhuwei (2003-5-3 15:46:53) 参数为仿真时间,-1代表永远 */
	sc_close_vcd_trace_file(tf);
	return(0);
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -