| 1 |
|
|---|
| 2 | #include <systemc>
|
|---|
| 3 | #include <sys/time.h>
|
|---|
| 4 | #include <iostream>
|
|---|
| 5 | #include <cstdlib>
|
|---|
| 6 | #include <cstdarg>
|
|---|
| 7 |
|
|---|
| 8 | #include "mapping_table.h"
|
|---|
| 9 | #include "mips.h"
|
|---|
| 10 | #include "ississ2.h"
|
|---|
| 11 | #include "iss_simhelper.h"
|
|---|
| 12 | #include "vci_simple_ram.h"
|
|---|
| 13 | #include "vci_multi_tty.h"
|
|---|
| 14 | #include "vci_simple_ring_network.h"
|
|---|
| 15 | #include "vci_mem_cache.h"
|
|---|
| 16 | #include "vci_cc_xcache_wrapper.h"
|
|---|
| 17 |
|
|---|
| 18 |
|
|---|
| 19 | //#define SOCVIEW 1
|
|---|
| 20 |
|
|---|
| 21 | #ifdef USE_GDB_SERVER
|
|---|
| 22 | #include "iss/gdbserver.h"
|
|---|
| 23 | #endif
|
|---|
| 24 |
|
|---|
| 25 | #include "segmentation.h"
|
|---|
| 26 |
|
|---|
| 27 | int _main(int argc, char *argv[])
|
|---|
| 28 | {
|
|---|
| 29 | using namespace sc_core;
|
|---|
| 30 | // Avoid repeating these everywhere
|
|---|
| 31 | using soclib::common::IntTab;
|
|---|
| 32 | using soclib::common::Segment;
|
|---|
| 33 |
|
|---|
| 34 | // Define VCI parameters
|
|---|
| 35 | typedef soclib::caba::VciParams<4,8,32,1,1,1,8,4,4,1> vci_param;
|
|---|
| 36 | typedef soclib::common::IssIss2<soclib::common::IssSimhelper<soclib::common::MipsElIss> > proc_iss;
|
|---|
| 37 |
|
|---|
| 38 | // Mapping table
|
|---|
| 39 |
|
|---|
| 40 | soclib::common::MappingTable maptabp(32, IntTab(8), IntTab(8), 0x00300000);
|
|---|
| 41 |
|
|---|
| 42 | maptabp.add(Segment("reset", RESET_BASE, RESET_SIZE, IntTab(0), true));
|
|---|
| 43 | maptabp.add(Segment("excep", EXCEP_BASE, EXCEP_SIZE, IntTab(0), true));
|
|---|
| 44 | maptabp.add(Segment("tty" , TTY_BASE , TTY_SIZE , IntTab(1), false));
|
|---|
| 45 | maptabp.add(Segment("mc_r" , MC_R_BASE , MC_R_SIZE , IntTab(2), false, true, IntTab(0)));
|
|---|
| 46 | maptabp.add(Segment("mc_m" , MC_M_BASE , MC_M_SIZE , IntTab(2), true ));
|
|---|
| 47 |
|
|---|
| 48 | std::cout << maptabp << std::endl;
|
|---|
| 49 |
|
|---|
| 50 | soclib::common::MappingTable maptabc(32, IntTab(8), IntTab(8), 0x00300000);
|
|---|
| 51 | maptabc.add(Segment("proc" , PROC0_BASE , PROC_SIZE , IntTab(0), false, true, IntTab(0)));
|
|---|
| 52 | std::cout << maptabc << std::endl;
|
|---|
| 53 |
|
|---|
| 54 | soclib::common::MappingTable maptabx(32, IntTab(8), IntTab(8), 0x00300000);
|
|---|
| 55 | maptabx.add(Segment("xram" , MC_M_BASE , MC_M_SIZE , IntTab(0), false));
|
|---|
| 56 |
|
|---|
| 57 | std::cout << maptabx << std::endl;
|
|---|
| 58 |
|
|---|
| 59 | // Signals
|
|---|
| 60 |
|
|---|
| 61 | sc_clock signal_clk("clk");
|
|---|
| 62 | sc_signal<bool> signal_resetn("resetn");
|
|---|
| 63 |
|
|---|
| 64 | sc_signal<bool> signal_proc_it0("proc_it0");
|
|---|
| 65 | sc_signal<bool> signal_proc_it1("proc_it1");
|
|---|
| 66 | sc_signal<bool> signal_proc_it2("proc_it2");
|
|---|
| 67 | sc_signal<bool> signal_proc_it3("proc_it3");
|
|---|
| 68 | sc_signal<bool> signal_proc_it4("proc_it4");
|
|---|
| 69 | sc_signal<bool> signal_proc_it5("proc_it5");
|
|---|
| 70 |
|
|---|
| 71 | soclib::caba::VciSignals<vci_param> signal_vci_ini_proc("vci_ini_proc");
|
|---|
| 72 | soclib::caba::VciSignals<vci_param> signal_vci_tgt_proc("vci_tgt_proc");
|
|---|
| 73 |
|
|---|
| 74 | soclib::caba::VciSignals<vci_param> signal_vci_tgt_tty("vci_tgt_tty");
|
|---|
| 75 |
|
|---|
| 76 | soclib::caba::VciSignals<vci_param> signal_vci_tgt_rom("vci_tgt_rom");
|
|---|
| 77 |
|
|---|
| 78 | soclib::caba::VciSignals<vci_param> signal_vci_tgt_xram("vci_tgt_xram");
|
|---|
| 79 |
|
|---|
| 80 | soclib::caba::VciSignals<vci_param> signal_vci_ixr_memc("vci_ixr_memc");
|
|---|
| 81 | soclib::caba::VciSignals<vci_param> signal_vci_ini_memc("vci_ini_memc");
|
|---|
| 82 | soclib::caba::VciSignals<vci_param> signal_vci_tgt_memc("vci_tgt_memc");
|
|---|
| 83 |
|
|---|
| 84 | sc_signal<bool> signal_tty_irq("signal_tty_irq");
|
|---|
| 85 |
|
|---|
| 86 | // Components
|
|---|
| 87 | // VCI ports indexation : 3 intiateurs et 5 cibles
|
|---|
| 88 |
|
|---|
| 89 | // INIT0 : proc_ini
|
|---|
| 90 | // INIT1 : memc_ini
|
|---|
| 91 | // INIT2 : memc_ixr
|
|---|
| 92 |
|
|---|
| 93 | // TGT 0 : rom_tgt
|
|---|
| 94 | // TGT 1 : tty_tgt
|
|---|
| 95 | // TGT 2 : xram_tgt
|
|---|
| 96 | // TGT 3 : memc_tgt
|
|---|
| 97 | // TGT 4 : proc_tgt
|
|---|
| 98 |
|
|---|
| 99 | soclib::common::Loader loader("soft/bin.soft");
|
|---|
| 100 |
|
|---|
| 101 | soclib::caba::VciCcXcacheWrapper<vci_param, proc_iss >
|
|---|
| 102 | proc("proc", 0, maptabp,maptabc,IntTab(0),IntTab(0),4,64,16,4,64,16,CLEANUP_OFFSET);
|
|---|
| 103 |
|
|---|
| 104 | soclib::caba::VciSimpleRam<vci_param>
|
|---|
| 105 | rom("rom", IntTab(0), maptabp, loader);
|
|---|
| 106 |
|
|---|
| 107 | soclib::caba::VciSimpleRam<vci_param>
|
|---|
| 108 | xram("xram",IntTab(0),maptabx, loader);
|
|---|
| 109 |
|
|---|
| 110 | soclib::caba::VciMemCache<vci_param>
|
|---|
| 111 | memc("memc",maptabp,maptabc,maptabx,IntTab(0),IntTab(0),IntTab(2),16,256,16);
|
|---|
| 112 |
|
|---|
| 113 | soclib::caba::VciMultiTty<vci_param>
|
|---|
| 114 | tty("tty",IntTab(1),maptabp,"tty",NULL);
|
|---|
| 115 |
|
|---|
| 116 | soclib::caba::VciSimpleRingNetwork<vci_param>
|
|---|
| 117 | ringp("ringp",maptabp, IntTab(), 2, 2, 1, 3);
|
|---|
| 118 |
|
|---|
| 119 | soclib::caba::VciSimpleRingNetwork<vci_param>
|
|---|
| 120 | ringc("ringc",maptabc, IntTab(), 2, 2, 1, 1);
|
|---|
| 121 |
|
|---|
| 122 | soclib::caba::VciSimpleRingNetwork<vci_param>
|
|---|
| 123 | ringx("ringx",maptabx, IntTab(), 2, 2, 1, 1);
|
|---|
| 124 |
|
|---|
| 125 | // Net-List
|
|---|
| 126 |
|
|---|
| 127 | proc.p_clk(signal_clk);
|
|---|
| 128 | proc.p_resetn(signal_resetn);
|
|---|
| 129 | proc.p_irq[0](signal_proc_it0);
|
|---|
| 130 | proc.p_irq[1](signal_proc_it1);
|
|---|
| 131 | proc.p_irq[2](signal_proc_it2);
|
|---|
| 132 | proc.p_irq[3](signal_proc_it3);
|
|---|
| 133 | proc.p_irq[4](signal_proc_it4);
|
|---|
| 134 | proc.p_irq[5](signal_proc_it5);
|
|---|
| 135 | proc.p_vci_ini(signal_vci_ini_proc);
|
|---|
| 136 | proc.p_vci_tgt(signal_vci_tgt_proc);
|
|---|
| 137 |
|
|---|
| 138 | rom.p_clk(signal_clk);
|
|---|
| 139 | rom.p_resetn(signal_resetn);
|
|---|
| 140 | rom.p_vci(signal_vci_tgt_rom);
|
|---|
| 141 |
|
|---|
| 142 | tty.p_clk(signal_clk);
|
|---|
| 143 | tty.p_resetn(signal_resetn);
|
|---|
| 144 | tty.p_vci(signal_vci_tgt_tty);
|
|---|
| 145 | tty.p_irq[0](signal_tty_irq);
|
|---|
| 146 |
|
|---|
| 147 | memc.p_clk(signal_clk);
|
|---|
| 148 | memc.p_resetn(signal_resetn);
|
|---|
| 149 | memc.p_vci_tgt(signal_vci_tgt_memc);
|
|---|
| 150 | memc.p_vci_ini(signal_vci_ini_memc);
|
|---|
| 151 | memc.p_vci_ixr(signal_vci_ixr_memc);
|
|---|
| 152 |
|
|---|
| 153 | xram.p_clk(signal_clk);
|
|---|
| 154 | xram.p_resetn(signal_resetn);
|
|---|
| 155 | xram.p_vci(signal_vci_tgt_xram);
|
|---|
| 156 |
|
|---|
| 157 | ringp.p_clk(signal_clk);
|
|---|
| 158 | ringp.p_resetn(signal_resetn);
|
|---|
| 159 |
|
|---|
| 160 | ringc.p_clk(signal_clk);
|
|---|
| 161 | ringc.p_resetn(signal_resetn);
|
|---|
| 162 |
|
|---|
| 163 | ringx.p_clk(signal_clk);
|
|---|
| 164 | ringx.p_resetn(signal_resetn);
|
|---|
| 165 |
|
|---|
| 166 | ringp.p_to_initiator[0](signal_vci_ini_proc);
|
|---|
| 167 |
|
|---|
| 168 | ringc.p_to_initiator[0](signal_vci_ini_memc);
|
|---|
| 169 |
|
|---|
| 170 | ringx.p_to_initiator[0](signal_vci_ixr_memc);
|
|---|
| 171 |
|
|---|
| 172 |
|
|---|
| 173 | ringp.p_to_target[0](signal_vci_tgt_rom);
|
|---|
| 174 | ringp.p_to_target[1](signal_vci_tgt_tty);
|
|---|
| 175 | ringp.p_to_target[2](signal_vci_tgt_memc);
|
|---|
| 176 |
|
|---|
| 177 | ringc.p_to_target[0](signal_vci_tgt_proc);
|
|---|
| 178 |
|
|---|
| 179 | ringx.p_to_target[0](signal_vci_tgt_xram);
|
|---|
| 180 |
|
|---|
| 181 | int ncycles;
|
|---|
| 182 |
|
|---|
| 183 | #ifndef SOCVIEW
|
|---|
| 184 | if (argc == 2) {
|
|---|
| 185 | ncycles = std::atoi(argv[1]);
|
|---|
| 186 | } else {
|
|---|
| 187 | std::cerr
|
|---|
| 188 | << std::endl
|
|---|
| 189 | << "The number of simulation cycles must "
|
|---|
| 190 | "be defined in the command line"
|
|---|
| 191 | << std::endl;
|
|---|
| 192 | exit(1);
|
|---|
| 193 | }
|
|---|
| 194 |
|
|---|
| 195 | sc_start(sc_core::sc_time(0, SC_NS));
|
|---|
| 196 | signal_resetn = false;
|
|---|
| 197 |
|
|---|
| 198 | sc_start(sc_core::sc_time(1, SC_NS));
|
|---|
| 199 | signal_resetn = true;
|
|---|
| 200 |
|
|---|
| 201 | for (int i = 0; i < ncycles ; i+=1000) {
|
|---|
| 202 | sc_start(sc_core::sc_time(1000, SC_NS));
|
|---|
| 203 | //proc.print_stats();
|
|---|
| 204 | //memc.print_stats();
|
|---|
| 205 | }
|
|---|
| 206 |
|
|---|
| 207 | //------------- stats
|
|---|
| 208 | //ringp.t_initiator_wrapper[0]->print_charge();
|
|---|
| 209 | //fprintf(stdout, " tot flits : %d\n", ringp.t_initiator_wrapper[0]->get_tot_cmd_flits());
|
|---|
| 210 |
|
|---|
| 211 | float p = 100 * (float) (ringp.t_initiator_wrapper[0]->get_tot_cmd_flits()) /
|
|---|
| 212 | ringp.t_initiator_wrapper[0]->get_tot_cycles();
|
|---|
| 213 | std::cout << " charge réseau P : " << p << std::endl;
|
|---|
| 214 | //--------------------
|
|---|
| 215 | std::cout << "Hit ENTER to end simulation" << std::endl;
|
|---|
| 216 |
|
|---|
| 217 | char buf[1];
|
|---|
| 218 |
|
|---|
| 219 | std::cin.getline(buf,1);
|
|---|
| 220 | return EXIT_SUCCESS;
|
|---|
| 221 | #else
|
|---|
| 222 | ncycles = 1;
|
|---|
| 223 | sc_start(sc_core::sc_time(0, SC_NS));
|
|---|
| 224 | signal_resetn = false;
|
|---|
| 225 | sc_start(sc_core::sc_time(1, SC_NS));
|
|---|
| 226 | signal_resetn = true;
|
|---|
| 227 |
|
|---|
| 228 | debug();
|
|---|
| 229 | return EXIT_SUCCESS;
|
|---|
| 230 | #endif
|
|---|
| 231 | }
|
|---|
| 232 |
|
|---|
| 233 | int sc_main (int argc, char *argv[])
|
|---|
| 234 | {
|
|---|
| 235 | try {
|
|---|
| 236 | return _main(argc, argv);
|
|---|
| 237 | } catch (std::exception &e) {
|
|---|
| 238 | std::cout << e.what() << std::endl;
|
|---|
| 239 | } catch (...) {
|
|---|
| 240 | std::cout << "Unknown exception occured" << std::endl;
|
|---|
| 241 | throw;
|
|---|
| 242 | }
|
|---|
| 243 | return 1;
|
|---|
| 244 | }
|
|---|