[226] | 1 | #include "tsar_cluster_v1.h" |
---|
| 2 | |
---|
| 3 | #define DIRECT_TRACE |
---|
| 4 | #define COHERENCE_TRACE |
---|
| 5 | |
---|
| 6 | namespace soclib { |
---|
| 7 | namespace caba { |
---|
| 8 | |
---|
| 9 | template<typename vci_param, size_t cmd_width, size_t rsp_width> |
---|
| 10 | TsarClusterV1<vci_param, cmd_width, rsp_width>::TsarClusterV1( |
---|
| 11 | sc_module_name nm, |
---|
| 12 | |
---|
| 13 | // Cluster Index |
---|
| 14 | int cluster_idx, |
---|
| 15 | |
---|
| 16 | // Dspin Routers parameters |
---|
| 17 | int infifo_depth, |
---|
| 18 | int outfifo_depth, |
---|
| 19 | int x_local, |
---|
| 20 | int y_local, |
---|
| 21 | |
---|
| 22 | // Bits for global routing |
---|
| 23 | size_t x_width, |
---|
| 24 | size_t y_width, |
---|
| 25 | |
---|
| 26 | // Mapping tables |
---|
| 27 | const MappingTable & md, |
---|
| 28 | const MappingTable & mc, |
---|
| 29 | const MappingTable & mx, |
---|
| 30 | |
---|
| 31 | // Processor Number |
---|
| 32 | size_t nprocs, |
---|
| 33 | size_t max_nprocs, |
---|
| 34 | |
---|
| 35 | // Cache L1 sizes |
---|
| 36 | size_t iways, |
---|
| 37 | size_t isets, |
---|
| 38 | size_t iwords, |
---|
| 39 | size_t dways, |
---|
| 40 | size_t dsets, |
---|
| 41 | size_t dwords, |
---|
| 42 | |
---|
| 43 | // MemCache sizes |
---|
| 44 | size_t mcways, |
---|
| 45 | size_t mcsets, |
---|
| 46 | size_t mcwords, |
---|
| 47 | |
---|
| 48 | int is_io, |
---|
| 49 | |
---|
| 50 | Loader & loader |
---|
| 51 | ) : soclib::caba::BaseModule(nm), |
---|
| 52 | m_nprocs(nprocs) |
---|
| 53 | { |
---|
| 54 | std::ostringstream sd; |
---|
| 55 | sd << "ringd_" << x_local << "_" << y_local; |
---|
| 56 | ringd = new VciSimpleRingFast<vci_param, cmd_width, rsp_width> ( |
---|
| 57 | sd.str().c_str(), |
---|
| 58 | md, // Direct Mapping Table |
---|
| 59 | IntTab(), // Cluster index |
---|
| 60 | 2, // Wrapper fifo depth |
---|
| 61 | nprocs, // Number of initiators |
---|
| 62 | 2 + is_io // Number of targets |
---|
| 63 | ); |
---|
| 64 | |
---|
| 65 | #ifdef DEBUG_TSAR_CLUSTER_V1 |
---|
| 66 | std::cout << ringd->name() << " instantiated" << std::endl; |
---|
| 67 | #endif |
---|
| 68 | |
---|
| 69 | std::ostringstream sc; |
---|
| 70 | sc << "ringc_" << x_local << "_" << y_local; |
---|
| 71 | ringc = new VciSimpleRingFast<vci_param, cmd_width, rsp_width> ( |
---|
| 72 | sc.str().c_str(), |
---|
| 73 | mc, // Direct Mapping Table |
---|
| 74 | IntTab(), // Cluster index |
---|
| 75 | 2, // Wrapper fifo depth |
---|
| 76 | nprocs + 1, // Number of initiators |
---|
| 77 | max_nprocs + 1 // Number of targets |
---|
| 78 | ); |
---|
| 79 | |
---|
| 80 | #ifdef DEBUG_TSAR_CLUSTER_V1 |
---|
| 81 | std::cout << ringc->name() << " instantiated" << std::endl; |
---|
| 82 | #endif |
---|
| 83 | |
---|
| 84 | proc_iss::set_loader(loader); |
---|
| 85 | procs = new VciCcXCacheWrapperV1<vci_param, proc_iss> * [nprocs]; |
---|
| 86 | for(size_t p=0; p < nprocs; p++) { |
---|
| 87 | std::ostringstream sp; |
---|
| 88 | sp << "proc_" << x_local << "_" << y_local << "_" << p; |
---|
| 89 | |
---|
| 90 | procs[p] = new VciCcXCacheWrapperV1<vci_param, proc_iss> ( |
---|
| 91 | sp.str().c_str(), |
---|
| 92 | p + nprocs*cluster_idx, // Processor Id |
---|
| 93 | md, mc, // Mapping Tables |
---|
| 94 | IntTab(p), // SRCID_D |
---|
| 95 | IntTab(p), // SRCID_C |
---|
| 96 | IntTab(p), // TGTID_C |
---|
| 97 | iways, isets, iwords, // ICache Size |
---|
| 98 | dways, dsets, dwords, // DCache Size |
---|
| 99 | x_width, y_width, max_nprocs // Coherence Parameters |
---|
| 100 | ); |
---|
| 101 | |
---|
| 102 | #ifdef DEBUG_TSAR_CLUSTER_V1 |
---|
| 103 | std::cout << procs[p]->name() << " instantiated" << std::endl; |
---|
| 104 | #endif |
---|
| 105 | } |
---|
| 106 | |
---|
| 107 | std::ostringstream sm; |
---|
| 108 | sm << "memc_" << x_local << "_" << y_local; |
---|
| 109 | memc = new VciMemCacheV1<vci_param> ( |
---|
| 110 | sm.str().c_str(), |
---|
| 111 | md, mc, mx, // Mapping Tables |
---|
| 112 | IntTab(0), // SRCID_X |
---|
| 113 | IntTab(max_nprocs), // SRCID_C |
---|
| 114 | IntTab(0), // TGTID_D |
---|
| 115 | IntTab(max_nprocs), // TGTID_C |
---|
| 116 | mcways, mcsets, mcwords // MemCache Size |
---|
| 117 | ); |
---|
| 118 | |
---|
| 119 | #ifdef DEBUG_TSAR_CLUSTER_V1 |
---|
| 120 | std::cout << memc->name() << " instantiated" << std::endl; |
---|
| 121 | #endif |
---|
| 122 | |
---|
| 123 | std::ostringstream sx; |
---|
| 124 | sx << "xicu_" << x_local << "_" << y_local; |
---|
| 125 | xicu = new VciXicu<vci_param> ( |
---|
| 126 | sx.str().c_str(), |
---|
| 127 | md, |
---|
| 128 | IntTab(1), // TGTID_D |
---|
| 129 | nprocs, // number of TIMERS |
---|
| 130 | is_io, // number of hard IRQs |
---|
| 131 | nprocs, // number of soft IRQs |
---|
| 132 | nprocs // number of output IRQ lines |
---|
| 133 | ); |
---|
| 134 | |
---|
| 135 | #ifdef DEBUG_TSAR_CLUSTER_V1 |
---|
| 136 | std::cout << xicu->name() << " instantiated" << std::endl; |
---|
| 137 | #endif |
---|
| 138 | |
---|
| 139 | std::ostringstream stty; |
---|
| 140 | mtty = NULL; |
---|
| 141 | if (is_io == 1) { |
---|
| 142 | stty << "mtty_" << x_local << "_" << y_local; |
---|
| 143 | |
---|
| 144 | mtty = new VciMultiTty<vci_param> ( |
---|
| 145 | stty.str().c_str(), |
---|
| 146 | IntTab(2), |
---|
| 147 | md, |
---|
| 148 | "tty0", NULL |
---|
| 149 | ); |
---|
| 150 | |
---|
| 151 | #ifdef DEBUG_TSAR_CLUSTER_V1 |
---|
| 152 | std::cout << mtty->name() << " instantiated" << std::endl; |
---|
| 153 | #endif |
---|
| 154 | } |
---|
| 155 | |
---|
| 156 | ////////////////////////////////////////////////////////////// |
---|
| 157 | // Netlist |
---|
| 158 | |
---|
| 159 | signal_vci_ini_d = alloc_elems<VciSignals<vci_param> >("s_vci_ini_d", nprocs); |
---|
| 160 | signal_vci_tgt_d = alloc_elems<VciSignals<vci_param> >("s_vci_tgt_d", 2 + is_io); |
---|
| 161 | signal_vci_ini_c = alloc_elems<VciSignals<vci_param> >("s_vci_ini_c", nprocs + 1); |
---|
| 162 | signal_vci_tgt_c = alloc_elems<VciSignals<vci_param> >("s_vci_tgt_c", nprocs + 1); |
---|
| 163 | |
---|
| 164 | signal_proc_irq = new sc_signal<bool>[nprocs]; |
---|
| 165 | |
---|
| 166 | memc->p_clk (p_clk); |
---|
| 167 | memc->p_resetn (p_resetn); |
---|
| 168 | memc->p_vci_tgt (signal_vci_tgt_d[0]); |
---|
| 169 | memc->p_vci_ini (signal_vci_ini_c[nprocs]); |
---|
| 170 | memc->p_vci_tgt_cleanup (signal_vci_tgt_c[max_nprocs]); |
---|
| 171 | memc->p_vci_ixr (p_vci_ixr); |
---|
| 172 | |
---|
| 173 | for ( size_t p = 0 ; p < nprocs ; p++ ) { |
---|
| 174 | procs[p]->p_clk (p_clk); |
---|
| 175 | procs[p]->p_resetn (p_resetn); |
---|
| 176 | procs[p]->p_vci_ini_rw (signal_vci_ini_d[p]); |
---|
| 177 | procs[p]->p_vci_ini_c (signal_vci_ini_c[p]); |
---|
| 178 | procs[p]->p_vci_tgt (signal_vci_tgt_c[p]); |
---|
| 179 | procs[p]->p_irq[0] (signal_proc_irq[p]); |
---|
| 180 | |
---|
| 181 | for ( size_t j = 1 ; j < 6 ; j++ ) { |
---|
| 182 | procs[p]->p_irq[j] (signal_false); |
---|
| 183 | } |
---|
| 184 | } |
---|
| 185 | |
---|
| 186 | // XICU |
---|
| 187 | xicu->p_clk (p_clk); |
---|
| 188 | xicu->p_resetn (p_resetn); |
---|
| 189 | xicu->p_vci (signal_vci_tgt_d[1]); |
---|
| 190 | |
---|
| 191 | if(is_io == 1) { |
---|
| 192 | xicu->p_hwi[0] (signal_mtty_irq); |
---|
| 193 | |
---|
| 194 | mtty->p_clk (p_clk); |
---|
| 195 | mtty->p_resetn (p_resetn); |
---|
| 196 | mtty->p_vci (signal_vci_tgt_d[2]); |
---|
| 197 | mtty->p_irq[0] (signal_mtty_irq); |
---|
| 198 | } |
---|
| 199 | |
---|
| 200 | for ( size_t p = 0 ; p < nprocs ; p++ ) { |
---|
| 201 | xicu->p_irq[p] (signal_proc_irq[p]); |
---|
| 202 | } |
---|
| 203 | |
---|
| 204 | // Direct ring |
---|
| 205 | ringd->p_clk (p_clk); |
---|
| 206 | ringd->p_resetn (p_resetn); |
---|
| 207 | |
---|
| 208 | for ( size_t p = 0 ; p < nprocs ; p++ ) { |
---|
| 209 | ringd->p_to_initiator[p] (signal_vci_ini_d[p]); |
---|
| 210 | } |
---|
| 211 | |
---|
| 212 | for ( int t = 0 ; t < (2 + is_io) ; t++ ) { |
---|
| 213 | ringd->p_to_target[t] (signal_vci_tgt_d[t]); |
---|
| 214 | } |
---|
| 215 | |
---|
| 216 | // Coherence ring |
---|
| 217 | ringc->p_clk (p_clk); |
---|
| 218 | ringc->p_resetn (p_resetn); |
---|
| 219 | |
---|
| 220 | for ( size_t i = 0 ; i < (nprocs + 1) ; i++ ) { |
---|
| 221 | ringc->p_to_initiator[i] (signal_vci_ini_c[i]); |
---|
| 222 | } |
---|
| 223 | |
---|
| 224 | for ( size_t t = 0 ; t < (max_nprocs + 1) ; t++ ) { |
---|
| 225 | ringc->p_to_target[t] (signal_vci_tgt_c[t]); |
---|
| 226 | } |
---|
| 227 | } // End TsarClusterV1 |
---|
| 228 | |
---|
| 229 | template<typename vci_param, size_t cmd_width, size_t rsp_width> |
---|
| 230 | void TsarClusterV1<vci_param, cmd_width, rsp_width>::print_trace() { |
---|
| 231 | #ifdef DIRECT_TRACE |
---|
| 232 | ringd->print_trace(); |
---|
| 233 | #endif |
---|
| 234 | #ifdef COHERENCE_TRACE |
---|
| 235 | ringc->print_trace(); |
---|
| 236 | #endif |
---|
| 237 | } |
---|
| 238 | |
---|
| 239 | template<typename vci_param, size_t cmd_width, size_t rsp_width> |
---|
| 240 | TsarClusterV1<vci_param, cmd_width, rsp_width>::~TsarClusterV1() { |
---|
| 241 | for(size_t p=0; p < m_nprocs; p++) { |
---|
| 242 | delete procs[p]; |
---|
| 243 | } |
---|
| 244 | delete [] procs; |
---|
| 245 | delete ringd; |
---|
| 246 | delete ringc; |
---|
| 247 | delete memc; |
---|
| 248 | delete xicu; |
---|
| 249 | |
---|
| 250 | if(mtty) { |
---|
| 251 | delete mtty; |
---|
| 252 | dealloc_elems<VciSignals<vci_param> >(signal_vci_tgt_d, 3); |
---|
| 253 | } else { |
---|
| 254 | dealloc_elems<VciSignals<vci_param> >(signal_vci_tgt_d, 2); |
---|
| 255 | } |
---|
| 256 | |
---|
| 257 | dealloc_elems<VciSignals<vci_param> >(signal_vci_ini_d, m_nprocs); |
---|
| 258 | dealloc_elems<VciSignals<vci_param> >(signal_vci_ini_c, m_nprocs + 1); |
---|
| 259 | dealloc_elems<VciSignals<vci_param> >(signal_vci_tgt_c, m_nprocs + 1); |
---|
| 260 | delete [] signal_proc_irq; |
---|
| 261 | } |
---|
| 262 | } |
---|
| 263 | } |
---|
| 264 | |
---|
| 265 | // vim: tabstop=2 : shiftwidth=2 : expandtab |
---|