📄 main_net.cpp
字号:
/*
* TU Eindhoven
* Eindhoven, The Netherlands
*
* Name :
*
* Author : A.S.Slusarczyk@tue.nl
*
* Uupdated : Jose Prats - jprats@step.es
*
* Function :
*
*/
#define NOVCD
//#define MIPSVCD
//#define MEMVCD
//#define ROUTERVCD
#include "netmips.h"
#include "net_remote_mem.h"
#include "router.h"
#include "_network2x2.h"
#include "mips_trace.h"
#ifdef MEM_DBG
#include "dbg_mem.h"
#endif
#include <time.h>
sc_signal<bool> clk;
unsigned sim_time = 0, period = 10;
int sc_main(int argc, char *argv[])
{
char stbuf[1024];
sc_signal< bool > rst, en;
sc_trace_file *tf;
tf = sc_create_vcd_trace_file("mips");
#include "_network2x2.cpp"
#ifdef MEM_DBG
dbg_mem_init( dp_x0y0.mips, dp_x0y1.mips, dp_x1y0.mips);
#endif
sc_initialize();
clk = 0; rst = 1; en = 0;
sc_cycle(period/2);
clk = 1;
sc_cycle(period/2);
rst = 0;
clk = 0;
sc_cycle(period/2);
en = 1;
/*
* Simulate program execution
*/
int max_time = 0;
if (argc == 2) max_time = atoi(argv[1]);
if (max_time == 0) max_time = 500;
bool e00=false, e10=false, e01=false, e11=false;
int dump_time = time(0);
while( max_time < 0 || sim_time < (unsigned)max_time )
{
clk = 0;
sc_cycle(period/2);
clk = 1;
sc_cycle(period/2);
sim_time += period;
if( sim_time % 10000 == 0 ){
cout << dec << sim_time << '/' << max_time << " @ " << sc_time_stamp() << " PC:";
hack_pc();
}
if( !e00 && dp_x0y0_pc.read().to_uint() == 0x28 ) {
cout << "FINISHED x0y0 @ " << sc_time_stamp() << endl;
e00 = true;
}
if( !e10 && dp_x1y0_pc.read().to_uint() == 0x28 ) {
cout << "FINISHED x1y0 @ " << sc_time_stamp() << endl;
e10 = true;
}
if( !e01 && dp_x0y1_pc.read().to_uint() == 0x28 ) {
cout << "FINISHED x0y1 @ " << sc_time_stamp() << endl;
e01 = true;
}
/*if( !e11 && dp_x1y1_pc.read().to_uint() == 0x28 ) {
cout << "FINISHED x1y1 @ " << sc_time_stamp() << endl;
e11 = true;
}*/
if( e00 && e10 && e01 ) { // e00 && e10 && e01 && e11
cout << "ALL FINISHED @ " << sc_time_stamp() << endl;
break;
}
if( time(0) - dump_time >= 60 ){
dump_time = time(0);
dp_x0y0.mips->dmem->mem_dump("mips_ram.x0y0.dump");
dp_x0y1.mips->dmem->mem_dump("mips_ram.x0y1.dump");
dp_x1y0.mips->dmem->mem_dump("mips_ram.x1y0.dump");
//dp_x1y1.mips->dmem->mem_dump("mips_ram.x1y1.dump");
dp_x1y1.remote_memory->remote_memory->mem_dump("rem_mem.x1y1.dump");
}
}
#ifndef CACHE
dp_x0y0.mips->dmem->mem_dump("mips_ram.x0y0.dump");
dp_x0y1.mips->dmem->mem_dump("mips_ram.x0y1.dump");
dp_x1y0.mips->dmem->mem_dump("mips_ram.x1y0.dump");
//dp_x1y1.mips->dmem->mem_dump("mips_ram.x1y1.dump");
dp_x1y1.remote_memory->remote_memory->mem_dump("rem_mem.x1y1.dump");
#else
dp_x0y0.mips->memory->memory->mem_dump("mem.x0y0.dump");
dp_x0y1.mips->memory->memory->mem_dump("mem.x0y1.dump");
dp_x1y0.mips->memory->memory->mem_dump("mem.x1y0.dump");
//dp_x1y1.mips->memory->memory->mem_dump("mem.x1y1.dump");
#endif
sc_close_vcd_trace_file(tf);
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -