1 | #ifdef SYSTEMC |
---|
2 | /* |
---|
3 | * $Id: RegisterFile_Monolithic_transition.cpp 111 2009-02-27 18:37:40Z 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 (_param->_have_init_value and (PORT_READ(in_NRESET) == 0)) |
---|
25 | { |
---|
26 | for (uint32_t i=0; i<_param->_nb_word; ++i) |
---|
27 | reg_DATA[i] = fromString<Tdata_t>(_param->_init_value); |
---|
28 | } |
---|
29 | else |
---|
30 | { |
---|
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 | { |
---|
36 | #ifdef STATISTICS |
---|
37 | if (usage_is_set(_usage,USE_STATISTICS)) |
---|
38 | (*_stat_nb_write) ++; |
---|
39 | #endif |
---|
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 | |
---|
44 | log_printf(TRACE,RegisterFile,FUNCTION," * [%d] <- %.8x",static_cast<uint32_t>(address),static_cast<uint32_t>(data)); |
---|
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 | { |
---|
57 | #ifdef STATISTICS |
---|
58 | if (usage_is_set(_usage,USE_STATISTICS)) |
---|
59 | (*_stat_nb_write) ++; |
---|
60 | #endif |
---|
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 | |
---|
65 | log_printf(TRACE,RegisterFile,FUNCTION," * [%d] <- %.8x",static_cast<uint32_t>(address),static_cast<uint32_t>(data)); |
---|
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 | } |
---|
79 | } |
---|
80 | |
---|
81 | #ifdef STATISTICS |
---|
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) ++; |
---|
86 | #endif |
---|
87 | |
---|
88 | #if defined(DEBUG_RegisterFile_Monolithic) and DEBUG_RegisterFile_Monolithic and (DEBUG >= DEBUG_TRACE) |
---|
89 | if (0) |
---|
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 | |
---|
113 | #if defined(STATISTICS) or defined(VHDL_TESTBENCH) |
---|
114 | end_cycle(); |
---|
115 | #endif |
---|
116 | |
---|
117 | log_end(RegisterFile_Monolithic,FUNCTION); |
---|
118 | }; |
---|
119 | |
---|
120 | }; // end namespace registerfile_monolithic |
---|
121 | }; // end namespace registerfile |
---|
122 | }; // end namespace generic |
---|
123 | }; // end namespace behavioural |
---|
124 | }; // end namespace morpheo |
---|
125 | #endif |
---|