Changeset 881
- Timestamp:
- Nov 12, 2014, 5:09:17 PM (10 years ago)
- Location:
- branches/reconfiguration/modules/vci_xicu
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/reconfiguration/modules/vci_xicu/caba/metadata/vci_xicu.sd
r880 r881 5 5 __version__ = "$Revision$" 6 6 7 Module('caba: vci_xicu',7 Module('caba:reconf:vci_xicu', 8 8 classname = 'soclib::caba::VciXicu', 9 9 tmpl_parameters = [ -
branches/reconfiguration/modules/vci_xicu/caba/source/include/vci_xicu.h
r880 r881 2 2 * 3 3 * SOCLIB_LGPL_HEADER_BEGIN 4 * 4 * 5 5 * This file is part of SoCLib, GNU LGPLv2.1. 6 * 6 * 7 7 * SoCLib is free software; you can redistribute it and/or modify it 8 8 * under the terms of the GNU Lesser General Public License as published 9 9 * by the Free Software Foundation; version 2.1 of the License. 10 * 10 * 11 11 * SoCLib is distributed in the hope that it will be useful, but 12 12 * WITHOUT ANY WARRANTY; without even the implied warranty of 13 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 14 * Lesser General Public License for more details. 15 * 15 * 16 16 * You should have received a copy of the GNU Lesser General Public 17 17 * License along with SoCLib; if not, write to the Free Software 18 18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 19 19 * 02110-1301 USA 20 * 20 * 21 21 * SOCLIB_LGPL_HEADER_END 22 22 * … … 39 39 template<typename vci_param> 40 40 class VciXicu 41 41 : public caba::BaseModule 42 42 { 43 43 private: … … 49 49 const size_t m_wti_count; 50 50 const size_t m_irq_count; 51 const size_t m_cfg_count; 51 52 52 53 uint32_t* r_msk_pti; … … 59 60 uint32_t *r_pti_val; 60 61 uint32_t *r_wti_reg; 62 uint32_t *r_cfg_reg; 61 63 62 64 uint32_t m_clock_cycles; 63 65 64 66 65 bool on_write( int seg, 66 typename vci_param::addr_t addr, 67 typename vci_param::data_t data, 67 bool on_write( int seg, 68 typename vci_param::addr_t addr, 69 typename vci_param::data_t data, 68 70 int be ); 69 bool on_read( int seg, 70 typename vci_param::addr_t addr, 71 bool on_read( int seg, 72 typename vci_param::addr_t addr, 71 73 typename vci_param::data_t &data ); 72 74 … … 84 86 sc_core::sc_out<bool>* p_irq; 85 87 sc_core::sc_in<bool>* p_hwi; 88 sc_core::sc_out<uint32_t>* p_cfg; 86 89 87 90 void print_trace( size_t channel ); 88 91 89 92 ~VciXicu(); 90 93 91 VciXicu( 92 sc_core::sc_module_name name,93 const soclib::common::MappingTable &mt,94 const soclib::common::IntTab &index,95 size_t pti_count,96 size_t hwi_count,97 size_t wti_count,98 size_t irq_count);94 VciXicu( sc_core::sc_module_name name, 95 const soclib::common::MappingTable &mt, 96 const soclib::common::IntTab &index, 97 size_t pti_count, 98 size_t hwi_count, 99 size_t wti_count, 100 size_t irq_count, 101 size_t cfg_count = 0 ); 99 102 100 103 soclib_static_assert(vci_param::B == 4); -
branches/reconfiguration/modules/vci_xicu/caba/source/src/vci_xicu.cpp
r880 r881 2 2 * 3 3 * SOCLIB_LGPL_HEADER_BEGIN 4 * 4 * 5 5 * This file is part of SoCLib, GNU LGPLv2.1. 6 * 6 * 7 7 * SoCLib is free software; you can redistribute it and/or modify it 8 8 * under the terms of the GNU Lesser General Public License as published 9 9 * by the Free Software Foundation; version 2.1 of the License. 10 * 10 * 11 11 * SoCLib is distributed in the hope that it will be useful, but 12 12 * WITHOUT ANY WARRANTY; without even the implied warranty of 13 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 14 * Lesser General Public License for more details. 15 * 15 * 16 16 * You should have received a copy of the GNU Lesser General Public 17 17 * License along with SoCLib; if not, write to the Free Software 18 18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 19 19 * 02110-1301 USA 20 * 20 * 21 21 * SOCLIB_LGPL_HEADER_END 22 22 * … … 56 56 57 57 ////////////////////////////////////////////////////// 58 tmpl(bool)::on_write( int seg, 59 typename vci_param::addr_t addr, 60 typename vci_param::data_t data, 58 tmpl(bool)::on_write( int seg, 59 typename vci_param::addr_t addr, 60 typename vci_param::data_t data, 61 61 int be) 62 62 { 63 64 65 63 size_t cell = (size_t)addr / vci_param::B; 64 size_t idx = cell & 0x1f; 65 size_t func = (cell >> 5) & 0x1f; 66 66 67 67 if ( be != 0xf ) 68 68 return false; 69 69 70 switch (func) 70 switch (func) 71 71 { 72 72 case XICU_WTI_REG: … … 76 76 77 77 #if SOCLIB_MODULE_DEBUG 78 std::cout << "[" << name() << "] Write WTI_REG[" << std::dec << idx << "] = " 78 std::cout << "[" << name() << "] Write WTI_REG[" << std::dec << idx << "] = " 79 79 << std::hex << (int)data << std::dec << " time = " << m_clock_cycles << std::endl; 80 80 #endif … … 84 84 CHECK_BOUNDS(pti); 85 85 r_pti_per[idx] = data; 86 if ( !data ) 86 if ( !data ) 87 87 { 88 88 r_pti_pending &= ~(1<<idx); 89 89 r_pti_val[idx] = 0; 90 } 91 else if (r_pti_val[idx] == 0) 90 } 91 else if (r_pti_val[idx] == 0) 92 92 { 93 93 r_pti_val[idx] = data; … … 95 95 96 96 #if SOCLIB_MODULE_DEBUG 97 std::cout << "[" << name() << "] Write PTI_PER[" << std::dec << idx << "] = " 97 std::cout << "[" << name() << "] Write PTI_PER[" << std::dec << idx << "] = " 98 98 << std::hex << (int)data << std::dec << " time = " << m_clock_cycles << std::endl; 99 99 #endif … … 105 105 106 106 #if SOCLIB_MODULE_DEBUG 107 std::cout << "[" << name() << "] Write PTI_VAL[" << std::dec << idx << "] = " 107 std::cout << "[" << name() << "] Write PTI_VAL[" << std::dec << idx << "] = " 108 108 << std::hex << (int)data << std::dec << " time = " << m_clock_cycles << std::endl; 109 109 #endif … … 115 115 116 116 #if SOCLIB_MODULE_DEBUG 117 std::cout << "[" << name() << "] Write MASK_PTI[" << std::dec << idx << "] = " 117 std::cout << "[" << name() << "] Write MASK_PTI[" << std::dec << idx << "] = " 118 118 << std::hex << (int)data << std::dec << " time = " << m_clock_cycles << std::endl; 119 119 #endif … … 125 125 126 126 #if SOCLIB_MODULE_DEBUG 127 std::cout << "[" << name() << "] Write PTI_ENABLE[" << std::dec << idx << "] = " 127 std::cout << "[" << name() << "] Write PTI_ENABLE[" << std::dec << idx << "] = " 128 128 << std::hex << (int)data << std::dec << " time = " << m_clock_cycles << std::endl; 129 129 #endif … … 135 135 136 136 #if SOCLIB_MODULE_DEBUG 137 std::cout << "[" << name() << "] Write PTI_DISABLE[" << std::dec << idx << "] = " 137 std::cout << "[" << name() << "] Write PTI_DISABLE[" << std::dec << idx << "] = " 138 138 << std::hex << (int)data << std::dec << " time = " << m_clock_cycles << std::endl; 139 139 #endif … … 145 145 146 146 #if SOCLIB_MODULE_DEBUG 147 std::cout << "[" << name() << "] Write MSK_HWI[" << std::dec << idx << "] = " 147 std::cout << "[" << name() << "] Write MSK_HWI[" << std::dec << idx << "] = " 148 148 << std::hex << (int)data << std::dec << " time = " << m_clock_cycles << std::endl; 149 149 #endif … … 155 155 156 156 #if SOCLIB_MODULE_DEBUG 157 std::cout << "[" << name() << "] Write HWI_ENABLE[" << std::dec << idx << "] = " 157 std::cout << "[" << name() << "] Write HWI_ENABLE[" << std::dec << idx << "] = " 158 158 << std::hex << (int)data << std::dec << " time = " << m_clock_cycles << std::endl; 159 159 #endif … … 165 165 166 166 #if SOCLIB_MODULE_DEBUG 167 std::cout << "[" << name() << "] Write HWI_DISABLE[" << std::dec << idx << "] = " 167 std::cout << "[" << name() << "] Write HWI_DISABLE[" << std::dec << idx << "] = " 168 168 << std::hex << (int)data << std::dec << " time = " << m_clock_cycles << std::endl; 169 169 #endif … … 175 175 176 176 #if SOCLIB_MODULE_DEBUG 177 std::cout << "[" << name() << "] Write MSK_WTI[" << std::dec << idx << "] = " 177 std::cout << "[" << name() << "] Write MSK_WTI[" << std::dec << idx << "] = " 178 178 << std::hex << (int)data << std::dec << " time = " << m_clock_cycles << std::endl; 179 179 #endif … … 185 185 186 186 #if SOCLIB_MODULE_DEBUG 187 std::cout << "[" << name() << "] Write WTI_ENABLE[" << std::dec << idx << "] = " 187 std::cout << "[" << name() << "] Write WTI_ENABLE[" << std::dec << idx << "] = " 188 188 << std::hex << (int)data << std::dec << " time = " << m_clock_cycles << std::endl; 189 189 #endif … … 195 195 196 196 #if SOCLIB_MODULE_DEBUG 197 std::cout << "[" << name() << "] Write WTI_DISABLE[" << std::dec << idx << "] = " 198 << std::hex << (int)data << std::dec << " time = " << m_clock_cycles << std::endl; 199 #endif 200 return true; 201 } 202 return false; 197 std::cout << "[" << name() << "] Write WTI_DISABLE[" << std::dec << idx << "] = " 198 << std::hex << (int)data << std::dec << " time = " << m_clock_cycles << std::endl; 199 #endif 200 return true; 201 202 case XICU_CFG_REG: 203 CHECK_BOUNDS(cfg); 204 r_cfg_reg[idx] = data; 205 206 #if SOCLIB_MODULE_DEBUG 207 std::cout << "[" << name() << "] Write CFG_REG[" << std::dec << idx << "] = " 208 << std::hex << (int)data << std::dec << " time = " << m_clock_cycles << std::endl; 209 #endif 210 return true; 211 } 212 return false; 203 213 } // end on_write() 204 214 205 215 ///////////////////////////////////////////////////// 206 tmpl(bool)::on_read( int seg, 207 typename vci_param::addr_t addr, 216 tmpl(bool)::on_read( int seg, 217 typename vci_param::addr_t addr, 208 218 typename vci_param::data_t &data) 209 219 { 210 220 size_t cell = (size_t)addr / vci_param::B; 211 221 size_t idx = cell & 0x1f; 212 213 214 switch (func) 222 size_t func = (cell >> 5) & 0x1f; 223 224 switch (func) 215 225 { 216 226 case XICU_WTI_REG: 217 227 CHECK_BOUNDS(wti); 218 228 data = r_wti_reg[idx]; 219 r_wti_pending &= ~(1<<idx); 220 221 #if SOCLIB_MODULE_DEBUG 222 std::cout << "[" << name() << "] Read XICU_WTI_REG[" << std::dec << idx << "] = " 229 r_wti_pending &= ~(1<<idx); 230 231 #if SOCLIB_MODULE_DEBUG 232 std::cout << "[" << name() << "] Read XICU_WTI_REG[" << std::dec << idx << "] = " 223 233 << std::hex << (int)data << std::dec << " time = " << m_clock_cycles << std::endl; 224 234 #endif … … 230 240 231 241 #if SOCLIB_MODULE_DEBUG 232 std::cout << "[" << name() << "] Read XICU_PTI_PER[" << std::dec << idx << "] = " 242 std::cout << "[" << name() << "] Read XICU_PTI_PER[" << std::dec << idx << "] = " 233 243 << std::hex << (int)data << std::dec << " time = " << m_clock_cycles << std::endl; 234 244 #endif … … 240 250 241 251 #if SOCLIB_MODULE_DEBUG 242 std::cout << "[" << name() << "] Read XICU_PTI_VAL[" << std::dec << idx << "] = " 252 std::cout << "[" << name() << "] Read XICU_PTI_VAL[" << std::dec << idx << "] = " 243 253 << std::hex << (int)data << std::dec << " time = " << m_clock_cycles << std::endl; 244 254 #endif … … 251 261 252 262 #if SOCLIB_MODULE_DEBUG 253 std::cout << "[" << name() << "] Read XICU_PTI_ACK[" << std::dec << idx << "] = " 263 std::cout << "[" << name() << "] Read XICU_PTI_ACK[" << std::dec << idx << "] = " 254 264 << std::hex << (int)data << std::dec << " time = " << m_clock_cycles << std::endl; 255 265 #endif … … 261 271 262 272 #if SOCLIB_MODULE_DEBUG 263 std::cout << "[" << name() << "] Read XICU_MSK_PTI[" << std::dec << idx << "] = " 273 std::cout << "[" << name() << "] Read XICU_MSK_PTI[" << std::dec << idx << "] = " 264 274 << std::hex << (int)data << std::dec << " time = " << m_clock_cycles << std::endl; 265 275 #endif … … 271 281 272 282 #if SOCLIB_MODULE_DEBUG 273 std::cout << "[" << name() << "] Read XICU_PTI_ACTIVE[" << std::dec << idx << "] = " 283 std::cout << "[" << name() << "] Read XICU_PTI_ACTIVE[" << std::dec << idx << "] = " 274 284 << std::hex << (int)data << std::dec << " time = " << m_clock_cycles << std::endl; 275 285 #endif … … 281 291 282 292 #if SOCLIB_MODULE_DEBUG 283 std::cout << "[" << name() << "] Read XICU_MSK_HWI[" << std::dec << idx << "] = " 293 std::cout << "[" << name() << "] Read XICU_MSK_HWI[" << std::dec << idx << "] = " 284 294 << std::hex << (int)data << std::dec << " time = " << m_clock_cycles << std::endl; 285 295 #endif … … 291 301 292 302 #if SOCLIB_MODULE_DEBUG 293 std::cout << "[" << name() << "] Read XICU_HWI_ACTIVE[" << std::dec << idx << "] = " 303 std::cout << "[" << name() << "] Read XICU_HWI_ACTIVE[" << std::dec << idx << "] = " 294 304 << std::hex << (int)data << std::dec << " time = " << m_clock_cycles << std::endl; 295 305 #endif … … 301 311 302 312 #if SOCLIB_MODULE_DEBUG 303 std::cout << "[" << name() << "] Read XICU_MSK_WTI[" << std::dec << idx << "] = " 313 std::cout << "[" << name() << "] Read XICU_MSK_WTI[" << std::dec << idx << "] = " 304 314 << std::hex << (int)data << std::dec << " time = " << m_clock_cycles << std::endl; 305 315 #endif … … 311 321 312 322 #if SOCLIB_MODULE_DEBUG 313 std::cout << "[" << name() << "] Read XICU_WTI_ACTIVE[" << std::dec << idx << "] = " 323 std::cout << "[" << name() << "] Read XICU_WTI_ACTIVE[" << std::dec << idx << "] = " 314 324 << std::hex << (int)data << std::dec << " time = " << m_clock_cycles << std::endl; 315 325 #endif … … 318 328 case XICU_PRIO: 319 329 CHECK_BOUNDS(irq); 320 data = 330 data = 321 331 (((r_msk_pti[idx] & r_pti_pending) ? 1 : 0) << 0) | 322 332 (((r_msk_hwi[idx] & r_hwi_pending) ? 1 : 0) << 1) | … … 327 337 328 338 #if SOCLIB_MODULE_DEBUG 329 std::cout << "[" << name() << "] Read XICU_PRIO[" << std::dec << idx << "] = " 339 std::cout << "[" << name() << "] Read XICU_PRIO[" << std::dec << idx << "] = " 330 340 << std::hex << (int)data << std::dec << " time = " << m_clock_cycles << std::endl; 331 341 #endif … … 338 348 #endif 339 349 return true; 340 } 341 return false; 350 351 case XICU_CFG_REG: 352 CHECK_BOUNDS(cfg); 353 data = r_cfg_reg[idx]; 354 355 #if SOCLIB_MODULE_DEBUG 356 std::cout << "[" << name() << "] Read XICU_CFG_REG[" << std::dec << idx << "] = " 357 << std::hex << (int)data << std::dec << " time = " << m_clock_cycles << std::endl; 358 #endif 359 return true; 360 } 361 return false; 342 362 } // end on_read() 343 363 … … 349 369 #endif 350 370 351 if (!p_resetn.read()) 352 { 353 354 355 for ( size_t i = 0; i<m_pti_count; ++i ) 371 if (!p_resetn.read()) 372 { 373 m_vci_fsm.reset(); 374 375 for ( size_t i = 0; i<m_pti_count; ++i ) 356 376 { 357 377 r_pti_per[i] = 0; … … 362 382 r_wti_reg[i] = 0; 363 383 } 364 for ( size_t i = 0; i<m_irq_count; ++i ) 384 for ( size_t i = 0; i<m_irq_count; ++i ) 365 385 { 366 386 r_msk_pti[i] = 0; … … 368 388 r_msk_hwi[i] = 0; 369 389 } 390 for ( size_t i = 0; i<m_cfg_count; ++i ) 391 { 392 r_cfg_reg[i] = 0; 393 } 370 394 r_pti_pending = 0; 371 395 r_wti_pending = 0; 372 396 r_hwi_pending = 0; 373 397 374 375 398 return; 399 } 376 400 377 401 // update timer interrupt vector 378 for ( size_t i = 0; i<m_pti_count; ++i ) 402 for ( size_t i = 0; i<m_pti_count; ++i ) 379 403 { 380 404 uint32_t per = r_pti_per[i]; 381 405 382 if ( per && --r_pti_val[i] == 0 ) 406 if ( per && --r_pti_val[i] == 0 ) 383 407 { 384 408 r_pti_pending |= 1<<i; … … 387 411 } 388 412 389 // update pending hardware interrupt vector 413 // update pending hardware interrupt vector 390 414 uint32_t hwi_pending = 0; 391 415 for ( size_t i = 0; i<m_hwi_count; ++i ) … … 393 417 r_hwi_pending = hwi_pending; 394 418 395 419 m_vci_fsm.transition(); 396 420 } 397 421 … … 401 425 assert( (channel < m_irq_count) and 402 426 "ERROR in XICU print_trace() : channel larger than proc number"); 403 427 404 428 std::cout << "XICU " << name() << std::hex 405 429 << " / HWI_MASK = " << r_msk_hwi[channel] 406 430 << " / SWI_MASK = " << r_msk_wti[channel] 407 << " / PTI_MASK = " << r_msk_pti[channel] 431 << " / PTI_MASK = " << r_msk_pti[channel] 408 432 << " / HWI = " << r_hwi_pending 409 433 << " / WTI = " << r_wti_pending … … 415 439 tmpl(void)::genMoore() 416 440 { 417 441 m_vci_fsm.genMoore(); 418 442 419 443 // output irqs 420 for ( size_t i = 0; i<m_irq_count; ++i ) 444 for ( size_t i = 0; i<m_irq_count; ++i ) 421 445 { 422 446 bool b = (r_msk_pti[i] & r_pti_pending) || … … 428 452 #endif 429 453 p_irq[i] = b; 454 } 455 456 // output cfg registers 457 for ( size_t i = 0; i<m_cfg_count; ++i ) 458 { 459 p_cfg[i] = r_cfg_reg[i]; 430 460 } 431 461 } … … 438 468 size_t hwi_count, 439 469 size_t wti_count, 440 size_t irq_count ) 470 size_t irq_count, 471 size_t cfg_count ) 441 472 : caba::BaseModule(name), 442 473 m_seglist(mt.getSegmentList(index)), … … 446 477 m_wti_count(wti_count), 447 478 m_irq_count(irq_count), 479 m_cfg_count(cfg_count), 448 480 r_msk_pti(new uint32_t[irq_count]), 449 481 r_msk_wti(new uint32_t[irq_count]), … … 469 501 std::cout << " => segment " << seg->name() 470 502 << " / base = " << std::hex << seg->baseAddress() 471 << " / size = " << seg->size() << std::endl; 472 } 473 474 m_vci_fsm.on_read_write( on_read, on_write ); 475 476 SC_METHOD(transition); 477 dont_initialize(); 478 sensitive << p_clk.pos(); 479 480 SC_METHOD(genMoore); 481 dont_initialize(); 482 sensitive << p_clk.neg(); 503 << " / size = " << seg->size() << std::endl; 504 } 505 506 if ( cfg_count > 0 ) 507 { 508 r_cfg_reg = new uint32_t[cfg_count]; 509 p_cfg = soclib::common::alloc_elems<sc_core::sc_out<uint32_t> >("cfg", cfg_count); 510 } 511 512 m_vci_fsm.on_read_write( on_read, on_write ); 513 514 SC_METHOD(transition); 515 dont_initialize(); 516 sensitive << p_clk.pos(); 517 518 SC_METHOD(genMoore); 519 dont_initialize(); 520 sensitive << p_clk.neg(); 483 521 } 484 522 … … 494 532 soclib::common::dealloc_elems(p_irq, m_irq_count); 495 533 soclib::common::dealloc_elems(p_hwi, m_hwi_count); 534 if ( m_cfg_count > 0 ) 535 { 536 delete [] r_cfg_reg; 537 soclib::common::dealloc_elems(p_cfg, m_cfg_count); 538 } 496 539 } 497 540 -
branches/reconfiguration/modules/vci_xicu/include/soclib/xicu.h
r880 r881 53 53 54 54 XICU_CONFIG = 16, 55 56 XICU_CFG_REG = 17, 55 57 }; 56 58
Note: See TracChangeset
for help on using the changeset viewer.