1 | #ifdef VHDL |
---|
2 | /* |
---|
3 | * $Id: RegisterFile_Monolithic_vhdl_body.cpp 101 2009-01-15 17:19: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 | void RegisterFile_Monolithic::vhdl_body (Vhdl * & vhdl) |
---|
18 | { |
---|
19 | vhdl->set_body (0,""); |
---|
20 | vhdl->set_comment(0,"---------------------------------------------------------------------------"); |
---|
21 | vhdl->set_comment(0," Ackitement"); |
---|
22 | vhdl->set_comment(0,"---------------------------------------------------------------------------"); |
---|
23 | vhdl->set_body (0,""); |
---|
24 | |
---|
25 | for (uint32_t i = 0; i < _param->_nb_port_read; i++) |
---|
26 | vhdl->set_body (0,"out_READ_"+toString(i)+"_ACK <= '1';"); |
---|
27 | for (uint32_t i = 0; i < _param->_nb_port_write; i++) |
---|
28 | vhdl->set_body (0,"out_WRITE_"+toString(i)+"_ACK <= '1';"); |
---|
29 | for (uint32_t i = 0; i < _param->_nb_port_read_write; i++) |
---|
30 | vhdl->set_body (0,"out_READ_WRITE_"+toString(i)+"_ACK <= '1';"); |
---|
31 | |
---|
32 | vhdl->set_body (0,""); |
---|
33 | vhdl->set_comment(0,"---------------------------------------------------------------------------"); |
---|
34 | vhdl->set_comment(0," Read RegisterFile"); |
---|
35 | vhdl->set_comment(0,"---------------------------------------------------------------------------"); |
---|
36 | vhdl->set_body (0,""); |
---|
37 | |
---|
38 | for (uint32_t i = 0; i < _param->_nb_port_read; i++) |
---|
39 | { |
---|
40 | std::string str_address; |
---|
41 | if (_param->_have_port_address) |
---|
42 | str_address = "conv_integer(in_READ_"+toString(i)+"_ADDRESS)"; |
---|
43 | else |
---|
44 | str_address = "0"; |
---|
45 | |
---|
46 | vhdl->set_body (0,"out_READ_"+toString(i)+"_DATA <= reg_DATA ("+str_address+") when in_READ_"+toString(i)+"_VAL = '1' else "+std_logic_others(_param->_size_word,0)+";"); |
---|
47 | } |
---|
48 | for (uint32_t i = 0; i < _param->_nb_port_read_write; i++) |
---|
49 | { |
---|
50 | std::string str_address; |
---|
51 | if (_param->_have_port_address) |
---|
52 | str_address = "conv_integer(in_READ_WRITE_"+toString(i)+"_ADDRESS)"; |
---|
53 | else |
---|
54 | str_address = "0"; |
---|
55 | vhdl->set_body (0,"out_READ_WRITE_"+toString(i)+"_RDATA <= reg_DATA ("+str_address+") when in_READ_WRITE_"+toString(i)+"_VAL = '1' and in_READ_WRITE_"+toString(i)+"_RW = '"+toString(RW_READ)+"' else "+std_logic_others(_param->_size_word,0)+";"); |
---|
56 | } |
---|
57 | |
---|
58 | vhdl->set_body (0,""); |
---|
59 | vhdl->set_comment(0,"---------------------------------------------------------------------------"); |
---|
60 | vhdl->set_comment(0," Write RegisterFile"); |
---|
61 | vhdl->set_comment(0,"---------------------------------------------------------------------------"); |
---|
62 | vhdl->set_body (0,""); |
---|
63 | |
---|
64 | vhdl->set_body (0,"RegisterFile_write: process (in_CLOCK)"); |
---|
65 | vhdl->set_body (0,"begin -- process RegisterFile_write"); |
---|
66 | vhdl->set_body (1,"if in_CLOCK'event and in_CLOCK = '1' then"); |
---|
67 | |
---|
68 | if (_param->_have_init_value) |
---|
69 | { |
---|
70 | vhdl->set_body (2,"if in_NRESET = '0' then"); |
---|
71 | |
---|
72 | std::string init_value = ((_param->_size_word>1)?"\"":"'")+_param->_init_value+((_param->_size_word>1)?"\"":"'"); |
---|
73 | |
---|
74 | for (uint32_t i=0; i<_param->_nb_word; ++i) |
---|
75 | vhdl->set_body (3,"reg_DATA("+toString(i)+") <= "+init_value+";"); |
---|
76 | |
---|
77 | vhdl->set_body (2,"else"); |
---|
78 | } |
---|
79 | |
---|
80 | for (uint32_t i = 0; i < _param->_nb_port_write; i++) |
---|
81 | { |
---|
82 | std::string str_address; |
---|
83 | if (_param->_have_port_address) |
---|
84 | str_address = "conv_integer(in_WRITE_"+toString(i)+"_ADDRESS)"; |
---|
85 | else |
---|
86 | str_address = "0"; |
---|
87 | |
---|
88 | vhdl->set_body (2,"if (in_WRITE_"+toString(i)+"_VAL = '1') then"); |
---|
89 | vhdl->set_body (3,"reg_DATA("+str_address+") <= in_WRITE_"+toString(i)+"_DATA;"); |
---|
90 | vhdl->set_body (2,"end if;"); |
---|
91 | } |
---|
92 | for (uint32_t i = 0; i < _param->_nb_port_read_write; i++) |
---|
93 | { |
---|
94 | std::string str_address; |
---|
95 | if (_param->_have_port_address) |
---|
96 | str_address = "conv_integer(in_READ_WRITE_"+toString(i)+"_ADDRESS)"; |
---|
97 | else |
---|
98 | str_address = "0"; |
---|
99 | |
---|
100 | vhdl->set_body (2,"if (in_READ_WRITE_"+toString(i)+"_VAL = '1' and in_READ_WRITE_"+toString(i)+"_RW = '"+toString(RW_WRITE)+"') then"); |
---|
101 | vhdl->set_body (3,"reg_DATA("+str_address+") <= in_READ_WRITE_"+toString(i)+"_WDATA;"); |
---|
102 | vhdl->set_body (2,"end if;"); |
---|
103 | } |
---|
104 | |
---|
105 | vhdl->set_body (1,"end if;"); |
---|
106 | |
---|
107 | if (_param->_have_init_value) |
---|
108 | vhdl->set_body (1,"end if;"); |
---|
109 | |
---|
110 | vhdl->set_body (0,"end process RegisterFile_write;"); |
---|
111 | }; |
---|
112 | |
---|
113 | }; // end namespace registerfile_monolithic |
---|
114 | }; // end namespace registerfile |
---|
115 | }; // end namespace generic |
---|
116 | }; // end namespace behavioural |
---|
117 | }; // end namespace morpheo |
---|
118 | #endif |
---|