1 | #ifdef SYSTEMC |
---|
2 | /* |
---|
3 | * $Id: RegisterFile_Monolithic_transition.cpp 131 2009-07-08 18:40:08Z rosiere $ |
---|
4 | * |
---|
5 | * [ Description ] |
---|
6 | * |
---|
7 | */ |
---|
8 | |
---|
9 | #include "Behavioural/Generic/RegisterFile/RegisterFile_Monolithic/include/RegisterFile_Monolithic.h" |
---|
10 | |
---|
11 | namespace morpheo { |
---|
12 | namespace behavioural { |
---|
13 | namespace generic { |
---|
14 | namespace registerfile { |
---|
15 | namespace registerfile_monolithic { |
---|
16 | |
---|
17 | #undef FUNCTION |
---|
18 | #define FUNCTION "RegisterFile_Monolithic::transition" |
---|
19 | void RegisterFile_Monolithic::transition (void) |
---|
20 | { |
---|
21 | log_begin(RegisterFile_Monolithic,FUNCTION); |
---|
22 | log_function(RegisterFile_Monolithic,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 | for (uint32_t i=0; i<_param->_nb_port_write; i++) |
---|
40 | { |
---|
41 | log_printf(TRACE,RegisterFile,FUNCTION," * WRITE [%d] : %d",i,PORT_READ(in_WRITE_VAL[i])); |
---|
42 | |
---|
43 | // Have a write? |
---|
44 | if ( PORT_READ(in_WRITE_VAL[i]) == true) |
---|
45 | { |
---|
46 | #ifdef STATISTICS |
---|
47 | if (usage_is_set(_usage,USE_STATISTICS)) |
---|
48 | (*_stat_nb_write) ++; |
---|
49 | #endif |
---|
50 | |
---|
51 | Taddress_t address = (_param->_have_port_address)?PORT_READ(in_WRITE_ADDRESS[i]):0; |
---|
52 | Tdata_t data = PORT_READ(in_WRITE_DATA [i]); |
---|
53 | |
---|
54 | log_printf(TRACE,RegisterFile,FUNCTION," * address : %d",address); |
---|
55 | log_printf(TRACE,RegisterFile,FUNCTION," * gloup"); |
---|
56 | log_printf(TRACE,RegisterFile,FUNCTION," * data : %d",data); |
---|
57 | |
---|
58 | log_printf(TRACE,RegisterFile,FUNCTION," * [%d] <- %.8x",static_cast<uint32_t>(address),static_cast<uint32_t>(data)); |
---|
59 | |
---|
60 | #ifdef DEBUG_TEST |
---|
61 | if (address >= _param->_nb_word) |
---|
62 | throw ERRORMORPHEO(FUNCTION,toString(_("Address (%d) is invalid (size : %d).\n"),address,_param->_nb_word)); |
---|
63 | #endif |
---|
64 | |
---|
65 | // Write in registerFile |
---|
66 | reg_DATA[address] = data; |
---|
67 | } |
---|
68 | } |
---|
69 | for (uint32_t i=0; i<_param->_nb_port_read_write; i++) |
---|
70 | { |
---|
71 | log_printf(TRACE,RegisterFile,FUNCTION," * READ_WRITE [%d] : %d",i,PORT_READ(in_READ_WRITE_VAL[i])); |
---|
72 | |
---|
73 | // Have a read_write? |
---|
74 | if (PORT_READ(in_READ_WRITE_VAL[i]) == true) |
---|
75 | { |
---|
76 | if (PORT_READ(in_READ_WRITE_RW [i]) == RW_WRITE) |
---|
77 | { |
---|
78 | #ifdef STATISTICS |
---|
79 | if (usage_is_set(_usage,USE_STATISTICS)) |
---|
80 | (*_stat_nb_write) ++; |
---|
81 | #endif |
---|
82 | |
---|
83 | Taddress_t address = (_param->_have_port_address)?PORT_READ(in_READ_WRITE_ADDRESS[i]):0; |
---|
84 | Tdata_t data = PORT_READ(in_READ_WRITE_WDATA [i]); |
---|
85 | |
---|
86 | log_printf(TRACE,RegisterFile,FUNCTION," * [%d] <- %.8x",static_cast<uint32_t>(address),static_cast<uint32_t>(data)); |
---|
87 | |
---|
88 | |
---|
89 | #ifdef DEBUG_TEST |
---|
90 | if (address >= _param->_nb_word) |
---|
91 | throw ERRORMORPHEO(FUNCTION,toString(_("Address (%d) is invalid (size : %d).\n"),address,_param->_nb_word)); |
---|
92 | #endif |
---|
93 | |
---|
94 | // Write in registerFile |
---|
95 | reg_DATA[address] = data; |
---|
96 | } |
---|
97 | #ifdef STATISTICS |
---|
98 | else |
---|
99 | { |
---|
100 | if (usage_is_set(_usage,USE_STATISTICS)) |
---|
101 | (*_stat_nb_read) ++; |
---|
102 | } |
---|
103 | #endif |
---|
104 | } |
---|
105 | } |
---|
106 | } |
---|
107 | |
---|
108 | #ifdef STATISTICS |
---|
109 | if (usage_is_set(_usage,USE_STATISTICS)) |
---|
110 | for (uint32_t i=0; i<_param->_nb_port_read; i++) |
---|
111 | if ( PORT_READ(in_READ_VAL [i]) == 1) |
---|
112 | (*_stat_nb_read) ++; |
---|
113 | #endif |
---|
114 | |
---|
115 | #if defined(DEBUG_RegisterFile_Monolithic) and DEBUG_RegisterFile_Monolithic and (DEBUG >= DEBUG_TRACE) |
---|
116 | # if 1 |
---|
117 | { |
---|
118 | log_printf(TRACE,RegisterFile,FUNCTION," * Dump RegisterFile"); |
---|
119 | |
---|
120 | uint32_t limit = 4; |
---|
121 | |
---|
122 | for (uint32_t i=0; i<_param->_nb_word; i+=limit) |
---|
123 | { |
---|
124 | std::string str = ""; |
---|
125 | |
---|
126 | for (uint32_t j=0; j<limit; j++) |
---|
127 | { |
---|
128 | uint32_t index = i+j; |
---|
129 | if (index >= _param->_nb_word) |
---|
130 | break; |
---|
131 | else |
---|
132 | str+=toString("[%.4d] %.8x ",index,reg_DATA[index]); |
---|
133 | } |
---|
134 | |
---|
135 | log_printf(TRACE,RegisterFile,FUNCTION," %s",str.c_str()); |
---|
136 | } |
---|
137 | } |
---|
138 | # endif |
---|
139 | #endif |
---|
140 | |
---|
141 | #if defined(STATISTICS) or defined(VHDL_TESTBENCH) |
---|
142 | end_cycle(); |
---|
143 | #endif |
---|
144 | |
---|
145 | log_end(RegisterFile_Monolithic,FUNCTION); |
---|
146 | }; |
---|
147 | |
---|
148 | }; // end namespace registerfile_monolithic |
---|
149 | }; // end namespace registerfile |
---|
150 | }; // end namespace generic |
---|
151 | }; // end namespace behavioural |
---|
152 | }; // end namespace morpheo |
---|
153 | #endif |
---|