cours2: main.cpp

File main.cpp, 3.3 KB (added by fpecheux, 15 years ago)
Line 
1#include "systemc.h"
2#include "ram.h"
3#include "cpu.h"
4
5int sc_main(int argc,char **argv)
6{
7        sc_report_handler::set_actions("/IEEE_Std_1666/deprecated", SC_DO_NOTHING);
8
9        cpu *cpu_1;
10        ram *ram_1;
11
12        sc_clock clk("clk");
13        sc_signal<bool> reset("reset");
14        sc_signal<sc_uint<32> > address("address");
15        sc_signal<sc_uint<2> > memrw("memrw");
16        sc_signal<sc_uint<32> > datain("datain");
17        sc_signal<sc_uint<32> > dataout("dataout");
18
19        // CPU 1
20        cpu_1=new cpu("cpu_1");
21        cpu_1->clk(clk);
22        cpu_1->reset(reset);
23        cpu_1->address(address);
24        cpu_1->memrw(memrw);
25        cpu_1->dataout(dataout);
26        cpu_1->datain(datain);
27
28        // RAM 1
29        ram_1=new ram("ram_1");
30        ram_1->clk(clk);
31        ram_1->addr(address);
32        ram_1->dout(datain);
33        ram_1->din(dataout);
34        ram_1->memrw(memrw);
35               
36        sc_trace_file *tfile=sc_create_vcd_trace_file("results");
37
38        sc_trace(tfile,clk,"clk") ;
39        sc_trace(tfile,reset,"reset") ;
40        sc_trace(tfile,address,"address") ;
41        sc_trace(tfile,datain,"datain") ;
42        sc_trace(tfile,dataout,"dataout") ;
43        sc_trace(tfile,cpu_1->pcout,"cpu_1.pcout") ;
44        sc_trace(tfile,cpu_1->fsm_1->state,"cpu_1.fsm_1.state") ;
45
46        sc_trace(tfile,cpu_1->rf32_1->regFile[00],"cpu_1.rf32_1.reg(0)") ;
47        sc_trace(tfile,cpu_1->rf32_1->regFile[01],"cpu_1.rf32_1.reg(1)") ;
48        sc_trace(tfile,cpu_1->rf32_1->regFile[02],"cpu_1.rf32_1.reg(2)") ;
49        sc_trace(tfile,cpu_1->rf32_1->regFile[03],"cpu_1.rf32_1.reg(3)") ;
50        sc_trace(tfile,cpu_1->rf32_1->regFile[04],"cpu_1.rf32_1.reg(4)") ;
51        sc_trace(tfile,cpu_1->rf32_1->regFile[05],"cpu_1.rf32_1.reg(5)") ;
52        sc_trace(tfile,cpu_1->rf32_1->regFile[06],"cpu_1.rf32_1.reg(6)") ;
53        sc_trace(tfile,cpu_1->rf32_1->regFile[07],"cpu_1.rf32_1.reg(7)") ;
54
55        sc_trace(tfile,cpu_1->cst0out,"cst0out");
56        sc_trace(tfile,cpu_1->cst4out,"cst4out");
57        sc_trace(tfile,cpu_1->pcout,"pcout");
58        sc_trace(tfile,cpu_1->rfout,"rfout");
59        sc_trace(tfile,cpu_1->adout,"adout");
60        sc_trace(tfile,cpu_1->dtout,"dtout");
61        sc_trace(tfile,cpu_1->irsextout,"irsextout");
62        sc_trace(tfile,cpu_1->irextout,"irextout");
63        sc_trace(tfile,cpu_1->irshiftout,"irshiftout");
64        sc_trace(tfile,cpu_1->mux_x_out,"mux_x_out");
65        sc_trace(tfile,cpu_1->mux_y_out,"mux_y_out");
66        sc_trace(tfile,cpu_1->int_dataout,"int_dataout");
67        sc_trace(tfile,cpu_1->irout15_0,"irout15_0");
68        sc_trace(tfile,cpu_1->irout15_11,"irout15_11");
69        sc_trace(tfile,cpu_1->irout20_16,"irout20_16");
70        sc_trace(tfile,cpu_1->irout25_21,"irout25_21");
71
72        sc_trace(tfile,cpu_1->write_pc,"write_pc");;
73        sc_trace(tfile,cpu_1->mux_rf_w,"mux_rf_w");;
74        sc_trace(tfile,cpu_1->mux_rf_r,"mux_rf_r");;
75        sc_trace(tfile,cpu_1->write_rf,"write_rf");;
76        sc_trace(tfile,cpu_1->adr_rf_w,"adr_rf_w");;
77        sc_trace(tfile,cpu_1->adr_rf_r,"adr_rf_r");;
78        sc_trace(tfile,cpu_1->write_ad,"write_ad");;
79        sc_trace(tfile,cpu_1->write_dt,"write_dt");;
80        sc_trace(tfile,cpu_1->write_ir,"write_ir");;
81        sc_trace(tfile,cpu_1->mux_x,"mux_x");;
82        sc_trace(tfile,cpu_1->mux_y,"mux_y");;
83        sc_trace(tfile,cpu_1->mux_addr,"mux_addr");;
84        sc_trace(tfile,cpu_1->alu_op,"amu_op");;
85        sc_trace(tfile,cpu_1->zero,"zero");;
86        sc_trace(tfile,cpu_1->ir,"ir");;
87
88        sc_start(0);
89        reset=0;
90        sc_start(1);
91        reset=1;
92        for (int i=0;i<100;i++)
93        {
94                sc_start(1);
95        }
96
97        sc_close_vcd_trace_file(tfile);
98
99        return(0);
100}
101