1 |
7 |
tantos |
--
|
2 |
|
|
-- Wishbone bus toolkit.
|
3 |
|
|
--
|
4 |
|
|
-- (c) Copyright Andras Tantos <andras_tantos@yahoo.com> 2001/03/31
|
5 |
|
|
-- This code is distributed under the terms and conditions of the GNU General Public Lince.
|
6 |
|
|
--
|
7 |
|
|
--
|
8 |
|
|
-- ELEMENTS:
|
9 |
|
|
-- wb_bus_resize: bus resizer.
|
10 |
|
|
|
11 |
|
|
-------------------------------------------------------------------------------
|
12 |
|
|
--
|
13 |
|
|
-- wb_bus_resize
|
14 |
|
|
--
|
15 |
|
|
-------------------------------------------------------------------------------
|
16 |
|
|
|
17 |
|
|
library IEEE;
|
18 |
|
|
use IEEE.std_logic_1164.all;
|
19 |
|
|
|
20 |
|
|
library wb_tk;
|
21 |
|
|
use wb_tk.technology.all;
|
22 |
|
|
use wb_tk.all;
|
23 |
|
|
|
24 |
|
|
entity wb_bus_resize is
|
25 |
|
|
generic (
|
26 |
|
|
m_bus_width: positive := 32; -- master bus width
|
27 |
|
|
m_addr_width: positive := 19; -- master bus width
|
28 |
|
|
s_bus_width: positive := 16; -- slave bus width
|
29 |
|
|
s_addr_width: positive := 20; -- master bus width
|
30 |
|
|
little_endien: boolean := true -- if set to false, big endien
|
31 |
|
|
);
|
32 |
|
|
port (
|
33 |
|
|
-- clk_i: in std_logic;
|
34 |
|
|
-- rst_i: in std_logic := '0';
|
35 |
|
|
|
36 |
|
|
-- Master bus interface
|
37 |
|
|
m_adr_i: in std_logic_vector (m_addr_width-1 downto 0);
|
38 |
|
|
m_sel_i: in std_logic_vector ((m_bus_width/8)-1 downto 0) := (others => '1');
|
39 |
|
|
m_dat_i: in std_logic_vector (m_bus_width-1 downto 0);
|
40 |
|
|
m_dat_oi: in std_logic_vector (m_bus_width-1 downto 0) := (others => '-');
|
41 |
|
|
m_dat_o: out std_logic_vector (m_bus_width-1 downto 0);
|
42 |
|
|
m_cyc_i: in std_logic;
|
43 |
|
|
m_ack_o: out std_logic;
|
44 |
|
|
m_ack_oi: in std_logic := '-';
|
45 |
|
|
m_err_o: out std_logic;
|
46 |
|
|
m_err_oi: in std_logic := '-';
|
47 |
|
|
m_rty_o: out std_logic;
|
48 |
|
|
m_rty_oi: in std_logic := '-';
|
49 |
|
|
m_we_i: in std_logic;
|
50 |
|
|
m_stb_i: in std_logic;
|
51 |
|
|
|
52 |
|
|
-- Slave bus interface
|
53 |
|
|
s_adr_o: out std_logic_vector (s_addr_width-1 downto 0);
|
54 |
|
|
s_sel_o: out std_logic_vector ((s_bus_width/8)-1 downto 0);
|
55 |
|
|
s_dat_i: in std_logic_vector (s_bus_width-1 downto 0);
|
56 |
|
|
s_dat_o: out std_logic_vector (s_bus_width-1 downto 0);
|
57 |
|
|
s_cyc_o: out std_logic;
|
58 |
|
|
s_ack_i: in std_logic;
|
59 |
|
|
s_err_i: in std_logic := '-';
|
60 |
|
|
s_rty_i: in std_logic := '-';
|
61 |
|
|
s_we_o: out std_logic;
|
62 |
|
|
s_stb_o: out std_logic
|
63 |
|
|
);
|
64 |
|
|
end wb_bus_resize;
|
65 |
|
|
|
66 |
|
|
architecture wb_bus_resize of wb_bus_resize is
|
67 |
|
|
component wb_bus_upsize is
|
68 |
|
|
generic (
|
69 |
|
|
m_bus_width: positive := 8; -- master bus width
|
70 |
|
|
m_addr_width: positive := 21; -- master bus width
|
71 |
|
|
s_bus_width: positive := 16; -- slave bus width
|
72 |
|
|
s_addr_width: positive := 20; -- master bus width
|
73 |
|
|
little_endien: boolean := true -- if set to false, big endien
|
74 |
|
|
);
|
75 |
|
|
port (
|
76 |
|
|
-- clk_i: in std_logic;
|
77 |
|
|
-- rst_i: in std_logic := '0';
|
78 |
|
|
|
79 |
|
|
-- Master bus interface
|
80 |
|
|
m_adr_i: in std_logic_vector (m_addr_width-1 downto 0);
|
81 |
|
|
m_sel_i: in std_logic_vector ((m_bus_width/8)-1 downto 0) := (others => '1');
|
82 |
|
|
m_dat_i: in std_logic_vector (m_bus_width-1 downto 0);
|
83 |
|
|
m_dat_oi: in std_logic_vector (m_bus_width-1 downto 0) := (others => '-');
|
84 |
|
|
m_dat_o: out std_logic_vector (m_bus_width-1 downto 0);
|
85 |
|
|
m_cyc_i: in std_logic;
|
86 |
|
|
m_ack_o: out std_logic;
|
87 |
|
|
m_ack_oi: in std_logic := '-';
|
88 |
|
|
m_err_o: out std_logic;
|
89 |
|
|
m_err_oi: in std_logic := '-';
|
90 |
|
|
m_rty_o: out std_logic;
|
91 |
|
|
m_rty_oi: in std_logic := '-';
|
92 |
|
|
m_we_i: in std_logic;
|
93 |
|
|
m_stb_i: in std_logic;
|
94 |
|
|
|
95 |
|
|
-- Slave bus interface
|
96 |
|
|
s_adr_o: out std_logic_vector (s_addr_width-1 downto 0);
|
97 |
|
|
s_sel_o: out std_logic_vector ((s_bus_width/8)-1 downto 0);
|
98 |
|
|
s_dat_i: in std_logic_vector (s_bus_width-1 downto 0);
|
99 |
|
|
s_dat_o: out std_logic_vector (s_bus_width-1 downto 0);
|
100 |
|
|
s_cyc_o: out std_logic;
|
101 |
|
|
s_ack_i: in std_logic;
|
102 |
|
|
s_err_i: in std_logic := '-';
|
103 |
|
|
s_rty_i: in std_logic := '-';
|
104 |
|
|
s_we_o: out std_logic;
|
105 |
|
|
s_stb_o: out std_logic
|
106 |
|
|
);
|
107 |
|
|
end component;
|
108 |
|
|
|
109 |
|
|
component wb_bus_dnsize is
|
110 |
|
|
generic (
|
111 |
|
|
m_bus_width: positive := 32; -- master bus width
|
112 |
|
|
m_addr_width: positive := 20; -- master bus width
|
113 |
|
|
s_bus_width: positive := 16; -- slave bus width
|
114 |
|
|
s_addr_width: positive := 21; -- master bus width
|
115 |
|
|
little_endien: boolean := true -- if set to false, big endien
|
116 |
|
|
);
|
117 |
|
|
port (
|
118 |
|
|
-- clk_i: in std_logic;
|
119 |
|
|
-- rst_i: in std_logic := '0';
|
120 |
|
|
|
121 |
|
|
-- Master bus interface
|
122 |
|
|
m_adr_i: in std_logic_vector (m_addr_width-1 downto 0);
|
123 |
|
|
m_sel_i: in std_logic_vector ((m_bus_width/8)-1 downto 0) := (others => '1');
|
124 |
|
|
m_dat_i: in std_logic_vector (m_bus_width-1 downto 0);
|
125 |
|
|
m_dat_oi: in std_logic_vector (m_bus_width-1 downto 0) := (others => '-');
|
126 |
|
|
m_dat_o: out std_logic_vector (m_bus_width-1 downto 0);
|
127 |
|
|
m_cyc_i: in std_logic;
|
128 |
|
|
m_ack_o: out std_logic;
|
129 |
|
|
m_ack_oi: in std_logic := '-';
|
130 |
|
|
m_err_o: out std_logic;
|
131 |
|
|
m_err_oi: in std_logic := '-';
|
132 |
|
|
m_rty_o: out std_logic;
|
133 |
|
|
m_rty_oi: in std_logic := '-';
|
134 |
|
|
m_we_i: in std_logic;
|
135 |
|
|
m_stb_i: in std_logic;
|
136 |
|
|
|
137 |
|
|
-- Slave bus interface
|
138 |
|
|
s_adr_o: out std_logic_vector (s_addr_width-1 downto 0);
|
139 |
|
|
s_sel_o: out std_logic_vector ((s_bus_width/8)-1 downto 0);
|
140 |
|
|
s_dat_i: in std_logic_vector (s_bus_width-1 downto 0);
|
141 |
|
|
s_dat_o: out std_logic_vector (s_bus_width-1 downto 0);
|
142 |
|
|
s_cyc_o: out std_logic;
|
143 |
|
|
s_ack_i: in std_logic;
|
144 |
|
|
s_err_i: in std_logic := '-';
|
145 |
|
|
s_rty_i: in std_logic := '-';
|
146 |
|
|
s_we_o: out std_logic;
|
147 |
|
|
s_stb_o: out std_logic
|
148 |
|
|
);
|
149 |
|
|
end component;
|
150 |
|
|
begin
|
151 |
|
|
dn_sel: if (m_bus_width > s_bus_width) generate
|
152 |
|
|
dnsizer: wb_bus_dnsize
|
153 |
|
|
generic map (
|
154 |
|
|
m_bus_width => m_bus_width,
|
155 |
|
|
m_addr_width => m_addr_width,
|
156 |
|
|
s_bus_width => s_bus_width,
|
157 |
|
|
s_addr_width => s_addr_width,
|
158 |
|
|
little_endien => little_endien
|
159 |
|
|
)
|
160 |
|
|
port map
|
161 |
|
|
(m_adr_i => m_adr_i,
|
162 |
|
|
m_sel_i => m_sel_i,
|
163 |
|
|
m_dat_i => m_dat_i,
|
164 |
|
|
m_dat_oi => m_dat_oi,
|
165 |
|
|
m_dat_o => m_dat_o,
|
166 |
|
|
m_cyc_i => m_cyc_i,
|
167 |
|
|
m_ack_o => m_ack_o,
|
168 |
|
|
m_ack_oi => m_ack_oi,
|
169 |
|
|
m_err_o => m_err_o,
|
170 |
|
|
m_err_oi => m_err_oi,
|
171 |
|
|
m_rty_o => m_rty_o,
|
172 |
|
|
m_rty_oi => m_rty_oi,
|
173 |
|
|
m_we_i => m_we_i,
|
174 |
|
|
m_stb_i => m_stb_i,
|
175 |
|
|
s_adr_o => s_adr_o,
|
176 |
|
|
s_sel_o => s_sel_o,
|
177 |
|
|
s_dat_i => s_dat_i,
|
178 |
|
|
s_dat_o => s_dat_o,
|
179 |
|
|
s_cyc_o => s_cyc_o,
|
180 |
|
|
s_ack_i => s_ack_i,
|
181 |
|
|
s_err_i => s_err_i,
|
182 |
|
|
s_rty_i => s_rty_i,
|
183 |
|
|
s_we_o => s_we_o,
|
184 |
|
|
s_stb_o => s_stb_o
|
185 |
|
|
);
|
186 |
|
|
end generate;
|
187 |
|
|
up_sel: if (m_bus_width < s_bus_width) generate
|
188 |
|
|
upsizer: wb_bus_upsize
|
189 |
|
|
generic map (
|
190 |
|
|
m_bus_width => m_bus_width,
|
191 |
|
|
m_addr_width => m_addr_width,
|
192 |
|
|
s_bus_width => s_bus_width,
|
193 |
|
|
s_addr_width => s_addr_width,
|
194 |
|
|
little_endien => little_endien
|
195 |
|
|
)
|
196 |
|
|
port map
|
197 |
|
|
(m_adr_i => m_adr_i,
|
198 |
|
|
m_sel_i => m_sel_i,
|
199 |
|
|
m_dat_i => m_dat_i,
|
200 |
|
|
m_dat_oi => m_dat_oi,
|
201 |
|
|
m_dat_o => m_dat_o,
|
202 |
|
|
m_cyc_i => m_cyc_i,
|
203 |
|
|
m_ack_o => m_ack_o,
|
204 |
|
|
m_ack_oi => m_ack_oi,
|
205 |
|
|
m_err_o => m_err_o,
|
206 |
|
|
m_err_oi => m_err_oi,
|
207 |
|
|
m_rty_o => m_rty_o,
|
208 |
|
|
m_rty_oi => m_rty_oi,
|
209 |
|
|
m_we_i => m_we_i,
|
210 |
|
|
m_stb_i => m_stb_i,
|
211 |
|
|
s_adr_o => s_adr_o,
|
212 |
|
|
s_sel_o => s_sel_o,
|
213 |
|
|
s_dat_i => s_dat_i,
|
214 |
|
|
s_dat_o => s_dat_o,
|
215 |
|
|
s_cyc_o => s_cyc_o,
|
216 |
|
|
s_ack_i => s_ack_i,
|
217 |
|
|
s_err_i => s_err_i,
|
218 |
|
|
s_rty_i => s_rty_i,
|
219 |
|
|
s_we_o => s_we_o,
|
220 |
|
|
s_stb_o => s_stb_o
|
221 |
|
|
);
|
222 |
|
|
end generate;
|
223 |
|
|
eq_sel: if (m_bus_width = s_bus_width) generate
|
224 |
|
|
dat_o_for: for i in m_dat_o'RANGE generate
|
225 |
|
|
dat_o_gen: m_dat_o(i) <= (s_dat_i(i) and m_stb_i and not m_we_i) or (m_dat_oi(i) and not (m_stb_i and not m_we_i));
|
226 |
|
|
end generate;
|
227 |
|
|
m_ack_o <= (s_ack_i and m_stb_i and not m_we_i) or (m_ack_oi and not (m_stb_i and not m_we_i));
|
228 |
|
|
m_err_o <= (s_err_i and m_stb_i and not m_we_i) or (m_err_oi and not (m_stb_i and not m_we_i));
|
229 |
|
|
m_rty_o <= (s_rty_i and m_stb_i and not m_we_i) or (m_rty_oi and not (m_stb_i and not m_we_i));
|
230 |
|
|
s_adr_o <= m_adr_i;
|
231 |
|
|
s_sel_o <= m_sel_i;
|
232 |
|
|
s_dat_o <= m_dat_i;
|
233 |
|
|
s_cyc_o <= m_cyc_i;
|
234 |
|
|
s_we_o <= m_we_i;
|
235 |
|
|
s_stb_o <= m_stb_i;
|
236 |
|
|
end generate;
|
237 |
|
|
end wb_bus_resize;
|
238 |
|
|
|
239 |
|
|
--configuration c_wb_bus_resize of wb_bus_resize is
|
240 |
|
|
-- for wb_bus_resize
|
241 |
|
|
-- for dnsizer: wb_bus_dnsize
|
242 |
|
|
-- use entity wb_bus_dnsize(wb_bus_dnsize);
|
243 |
|
|
-- end for;
|
244 |
|
|
-- for upsizer: wb_bus_upsize
|
245 |
|
|
-- use entity wb_bus_upsize(wb_bus_upsize);
|
246 |
|
|
-- end for;
|
247 |
|
|
-- end for;
|
248 |
|
|
--end c_wb_bus_resize;
|
249 |
|
|
|