?? main.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 + -