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