[145] | 1 | #ifdef SYSTEMC |
---|
| 2 | /* |
---|
| 3 | * $Id: RegisterFile_Internal_Banked_transition.cpp 145 2010-10-13 18:15:51Z rosiere $ |
---|
| 4 | * |
---|
| 5 | * [ Description ] |
---|
| 6 | * |
---|
| 7 | */ |
---|
| 8 | |
---|
| 9 | #include "Behavioural/Generic/RegisterFile/RegisterFile_Internal_Banked/include/RegisterFile_Internal_Banked.h" |
---|
| 10 | |
---|
| 11 | namespace morpheo { |
---|
| 12 | namespace behavioural { |
---|
| 13 | namespace generic { |
---|
| 14 | namespace registerfile { |
---|
| 15 | namespace registerfile_internal_banked { |
---|
| 16 | |
---|
| 17 | #undef FUNCTION |
---|
| 18 | #define FUNCTION "RegisterFile_Internal_Banked::transition" |
---|
| 19 | void RegisterFile_Internal_Banked::transition (void) |
---|
| 20 | { |
---|
| 21 | log_begin(RegisterFile_Internal_Banked,FUNCTION); |
---|
| 22 | log_function(RegisterFile_Internal_Banked,FUNCTION,_name.c_str()); |
---|
| 23 | |
---|
| 24 | if (PORT_READ(in_NRESET) == 0) |
---|
| 25 | { |
---|
| 26 | if (_param->_have_init_value) |
---|
| 27 | { |
---|
| 28 | for (uint32_t i=0; i<_param->_nb_word; ++i) |
---|
| 29 | reg_DATA[i] = fromString<Tdata_t>(_param->_init_value); |
---|
| 30 | } |
---|
| 31 | else |
---|
| 32 | { |
---|
| 33 | for (uint32_t i=0; i<_param->_nb_word; ++i) |
---|
| 34 | reg_DATA[i] = 0; |
---|
| 35 | } |
---|
| 36 | } |
---|
| 37 | else |
---|
| 38 | { |
---|
| 39 | #ifdef STATISTICS |
---|
| 40 | uint32_t stat_nb_read =0; |
---|
| 41 | uint32_t stat_nb_write =0; |
---|
| 42 | #endif |
---|
| 43 | for (uint32_t i=0; i<_param->_nb_port_write; i++) |
---|
| 44 | { |
---|
| 45 | log_printf(TRACE,RegisterFile,FUNCTION," * WRITE [%d] : %d",i,PORT_READ(in_WRITE_VAL[i])); |
---|
| 46 | |
---|
| 47 | // Have a write? |
---|
| 48 | if ( PORT_READ(in_WRITE_VAL[i]) == true) |
---|
| 49 | { |
---|
| 50 | #ifdef STATISTICS |
---|
| 51 | stat_nb_write++; |
---|
| 52 | #endif |
---|
| 53 | |
---|
| 54 | // #ifdef STATISTICS |
---|
| 55 | // if (usage_is_set(_usage,USE_STATISTICS)) |
---|
| 56 | // (*_stat_nb_write) ++; |
---|
| 57 | // #endif |
---|
| 58 | |
---|
| 59 | Taddress_t address = (_param->_have_port_address)?PORT_READ(in_WRITE_ADDRESS[i]):0; |
---|
| 60 | Tdata_t data = PORT_READ(in_WRITE_DATA [i]); |
---|
| 61 | |
---|
| 62 | log_printf(TRACE,RegisterFile,FUNCTION," * address : %d",address); |
---|
| 63 | log_printf(TRACE,RegisterFile,FUNCTION," * gloup"); |
---|
| 64 | log_printf(TRACE,RegisterFile,FUNCTION," * data : %d",data); |
---|
| 65 | |
---|
| 66 | log_printf(TRACE,RegisterFile,FUNCTION," * [%d] <- %.8x",static_cast<uint32_t>(address),static_cast<uint32_t>(data)); |
---|
| 67 | |
---|
| 68 | #ifdef DEBUG_TEST |
---|
| 69 | if (address >= _param->_nb_word) |
---|
| 70 | throw ERRORMORPHEO(FUNCTION,toString(_("Address (%d) is invalid (size : %d).\n"),address,_param->_nb_word)); |
---|
| 71 | #endif |
---|
| 72 | |
---|
| 73 | // Write in registerFile |
---|
| 74 | reg_DATA[address] = data; |
---|
| 75 | } |
---|
| 76 | } |
---|
| 77 | |
---|
| 78 | #ifdef STATISTICS |
---|
| 79 | if (usage_is_set(_usage,USE_STATISTICS)) |
---|
| 80 | { |
---|
| 81 | for (uint32_t i=0; i<_param->_nb_port_read; i++) |
---|
| 82 | if ( PORT_READ(in_READ_VAL [i]) == 1) |
---|
| 83 | { |
---|
| 84 | stat_nb_read ++; |
---|
| 85 | // (*_stat_nb_read) ++; |
---|
| 86 | } |
---|
| 87 | |
---|
| 88 | if (_param->_nb_port_read>0) |
---|
| 89 | (*_stat_port_read ) += stat_nb_read; |
---|
| 90 | if (_param->_nb_port_write>0) |
---|
| 91 | (*_stat_port_write ) += stat_nb_write; |
---|
| 92 | } |
---|
| 93 | #endif |
---|
| 94 | } |
---|
| 95 | |
---|
| 96 | #if defined(DEBUG_RegisterFile_Internal_Banked) and DEBUG_RegisterFile_Internal_Banked and (DEBUG >= DEBUG_TRACE) |
---|
| 97 | # if 1 |
---|
| 98 | { |
---|
| 99 | log_printf(TRACE,RegisterFile,FUNCTION," * Dump RegisterFile"); |
---|
| 100 | |
---|
| 101 | uint32_t limit = 4; |
---|
| 102 | |
---|
| 103 | for (uint32_t i=0; i<_param->_nb_word; i+=limit) |
---|
| 104 | { |
---|
| 105 | std::string str = ""; |
---|
| 106 | |
---|
| 107 | for (uint32_t j=0; j<limit; j++) |
---|
| 108 | { |
---|
| 109 | uint32_t index = i+j; |
---|
| 110 | if (index >= _param->_nb_word) |
---|
| 111 | break; |
---|
| 112 | else |
---|
| 113 | str+=toString("[%.4d] %.8x ",index,reg_DATA[index]); |
---|
| 114 | } |
---|
| 115 | |
---|
| 116 | log_printf(TRACE,RegisterFile,FUNCTION," %s",str.c_str()); |
---|
| 117 | } |
---|
| 118 | } |
---|
| 119 | # endif |
---|
| 120 | #endif |
---|
| 121 | |
---|
| 122 | #if defined(STATISTICS) or defined(VHDL_TESTBENCH) |
---|
| 123 | end_cycle(); |
---|
| 124 | #endif |
---|
| 125 | |
---|
| 126 | log_end(RegisterFile_Internal_Banked,FUNCTION); |
---|
| 127 | }; |
---|
| 128 | |
---|
| 129 | }; // end namespace registerfile_internal_banked |
---|
| 130 | }; // end namespace registerfile |
---|
| 131 | }; // end namespace generic |
---|
| 132 | }; // end namespace behavioural |
---|
| 133 | }; // end namespace morpheo |
---|
| 134 | #endif |
---|