1 |
2 |
tarookumic |
|
2 |
|
|
|
3 |
|
|
|
4 |
|
|
|
5 |
|
|
----------------------------------------------------------------------------
|
6 |
|
|
-- This file is a part of the LEON VHDL model
|
7 |
|
|
-- Copyright (C) 1999 European Space Agency (ESA)
|
8 |
|
|
--
|
9 |
|
|
-- This library is free software; you can redistribute it and/or
|
10 |
|
|
-- modify it under the terms of the GNU Lesser General Public
|
11 |
|
|
-- License as published by the Free Software Foundation; either
|
12 |
|
|
-- version 2 of the License, or (at your option) any later version.
|
13 |
|
|
--
|
14 |
|
|
-- See the file COPYING.LGPL for the full details of the license.
|
15 |
|
|
|
16 |
|
|
|
17 |
|
|
-----------------------------------------------------------------------------
|
18 |
|
|
-- Entity: tech_generic
|
19 |
|
|
-- File: tech_generic.vhd
|
20 |
|
|
-- Author: Jiri Gaisler - ESA/ESTEC
|
21 |
|
|
-- Description: Contains behavioural pads and ram generators
|
22 |
|
|
------------------------------------------------------------------------------
|
23 |
|
|
|
24 |
|
|
LIBRARY ieee;
|
25 |
|
|
use IEEE.std_logic_1164.all;
|
26 |
|
|
use work.leon_iface.all;
|
27 |
|
|
package tech_generic is
|
28 |
|
|
|
29 |
|
|
-- generic sync ram
|
30 |
|
|
|
31 |
|
|
component generic_syncram
|
32 |
|
|
generic ( abits : integer := 10; dbits : integer := 8 );
|
33 |
|
|
port (
|
34 |
|
|
address : in std_logic_vector((abits -1) downto 0);
|
35 |
|
|
clk : in std_logic;
|
36 |
|
|
datain : in std_logic_vector((dbits -1) downto 0);
|
37 |
|
|
dataout : out std_logic_vector((dbits -1) downto 0);
|
38 |
|
|
enable : in std_logic;
|
39 |
|
|
write : in std_logic
|
40 |
|
|
);
|
41 |
|
|
end component;
|
42 |
|
|
|
43 |
|
|
-- regfile generator
|
44 |
|
|
|
45 |
|
|
component generic_regfile_iu
|
46 |
|
|
generic (
|
47 |
|
|
rftype : integer := 1;
|
48 |
|
|
abits : integer := 8; dbits : integer := 32; words : integer := 128
|
49 |
|
|
);
|
50 |
|
|
port (
|
51 |
|
|
rst : in std_logic;
|
52 |
|
|
clk : in std_logic;
|
53 |
|
|
clkn : in std_logic;
|
54 |
|
|
rfi : in rf_in_type;
|
55 |
|
|
rfo : out rf_out_type);
|
56 |
|
|
end component;
|
57 |
|
|
|
58 |
|
|
component generic_regfile_cp
|
59 |
|
|
generic (
|
60 |
|
|
abits : integer := 4; dbits : integer := 32; words : integer := 16
|
61 |
|
|
);
|
62 |
|
|
port (
|
63 |
|
|
rst : in std_logic;
|
64 |
|
|
clk : in std_logic;
|
65 |
|
|
rfi : in rf_cp_in_type;
|
66 |
|
|
rfo : out rf_cp_out_type);
|
67 |
|
|
end component;
|
68 |
|
|
|
69 |
|
|
-- bypass logic for async-read/sync-write regfiles
|
70 |
|
|
|
71 |
|
|
component rfbypass
|
72 |
|
|
generic (
|
73 |
|
|
abits : integer := 8;
|
74 |
|
|
dbits : integer := 32
|
75 |
|
|
);
|
76 |
|
|
port (
|
77 |
|
|
clk : in clk_type;
|
78 |
|
|
write : in std_logic;
|
79 |
|
|
datain: in std_logic_vector (dbits -1 downto 0);
|
80 |
|
|
raddr1: in std_logic_vector (abits -1 downto 0);
|
81 |
|
|
raddr2: in std_logic_vector (abits -1 downto 0);
|
82 |
|
|
waddr : in std_logic_vector (abits -1 downto 0);
|
83 |
|
|
q1 : in std_logic_vector (dbits -1 downto 0);
|
84 |
|
|
q2 : in std_logic_vector (dbits -1 downto 0);
|
85 |
|
|
dataout1 : out std_logic_vector (dbits -1 downto 0);
|
86 |
|
|
dataout2 : out std_logic_vector (dbits -1 downto 0)
|
87 |
|
|
);
|
88 |
|
|
end component;
|
89 |
|
|
|
90 |
|
|
-- generic multipler
|
91 |
|
|
|
92 |
|
|
component generic_smult
|
93 |
|
|
generic ( abits : integer := 10; bbits : integer := 8 );
|
94 |
|
|
port (
|
95 |
|
|
a : in std_logic_vector(abits-1 downto 0);
|
96 |
|
|
b : in std_logic_vector(bbits-1 downto 0);
|
97 |
|
|
c : out std_logic_vector(abits+bbits-1 downto 0)
|
98 |
|
|
);
|
99 |
|
|
end component;
|
100 |
|
|
|
101 |
|
|
-- generic clock generator
|
102 |
|
|
|
103 |
|
|
component generic_clkgen
|
104 |
|
|
port (
|
105 |
|
|
clkin : in std_logic;
|
106 |
|
|
pciclkin: in std_logic;
|
107 |
|
|
clk : out std_logic; -- main clock
|
108 |
|
|
clkn : out std_logic; -- inverted main clock
|
109 |
|
|
sdclk : out std_logic; -- SDRAM clock
|
110 |
|
|
pciclk : out std_logic; -- PCI clock
|
111 |
|
|
cgi : in clkgen_in_type;
|
112 |
|
|
cgo : out clkgen_out_type
|
113 |
|
|
);
|
114 |
|
|
end component;
|
115 |
|
|
|
116 |
|
|
component generic_dpram_as
|
117 |
|
|
generic (
|
118 |
|
|
abits : integer := 8;
|
119 |
|
|
dbits : integer := 32;
|
120 |
|
|
words : integer := 256
|
121 |
|
|
);
|
122 |
|
|
port (
|
123 |
|
|
clk : in std_logic;
|
124 |
|
|
rdaddress: in std_logic_vector (abits -1 downto 0);
|
125 |
|
|
wraddress: in std_logic_vector (abits -1 downto 0);
|
126 |
|
|
data: in std_logic_vector (dbits -1 downto 0);
|
127 |
|
|
wren : in std_logic;
|
128 |
|
|
q: out std_logic_vector (dbits -1 downto 0)
|
129 |
|
|
);
|
130 |
|
|
end component;
|
131 |
|
|
|
132 |
|
|
component generic_dpram_ss
|
133 |
|
|
generic (
|
134 |
|
|
abits : integer := 8;
|
135 |
|
|
dbits : integer := 32;
|
136 |
|
|
words : integer := 256
|
137 |
|
|
);
|
138 |
|
|
port (
|
139 |
|
|
clk : in std_logic;
|
140 |
|
|
rdaddress: in std_logic_vector (abits -1 downto 0);
|
141 |
|
|
wraddress: in std_logic_vector (abits -1 downto 0);
|
142 |
|
|
data: in std_logic_vector (dbits -1 downto 0);
|
143 |
|
|
wren : in std_logic;
|
144 |
|
|
q: out std_logic_vector (dbits -1 downto 0)
|
145 |
|
|
);
|
146 |
|
|
end component;
|
147 |
|
|
|
148 |
|
|
-- pads
|
149 |
|
|
|
150 |
|
|
component geninpad port (pad : in std_logic; q : out std_logic); end component;
|
151 |
|
|
component gensmpad port (pad : in std_logic; q : out std_logic); end component;
|
152 |
|
|
component genoutpad port (d : in std_logic; pad : out std_logic); end component;
|
153 |
|
|
component gentoutpadu port (d, en : in std_logic; pad : out std_logic); end component;
|
154 |
|
|
component geniopad
|
155 |
|
|
port ( d, en : in std_logic; q : out std_logic; pad : inout std_logic);
|
156 |
|
|
end component;
|
157 |
|
|
component geniodpad
|
158 |
|
|
port ( d : in std_logic; q : out std_logic; pad : inout std_logic);
|
159 |
|
|
end component;
|
160 |
|
|
component genodpad port ( d : in std_logic; pad : out std_logic); end component;
|
161 |
|
|
|
162 |
|
|
end;
|
163 |
|
|
|
164 |
|
|
library IEEE;
|
165 |
|
|
use IEEE.std_logic_1164.all;
|
166 |
|
|
|
167 |
|
|
------------------------------------------------------------------
|
168 |
|
|
-- behavioural ram models --------------------------------------------
|
169 |
|
|
------------------------------------------------------------------
|
170 |
|
|
|
171 |
|
|
-- synchronous ram for direct interference
|
172 |
|
|
|
173 |
|
|
library ieee;
|
174 |
|
|
use ieee.std_logic_1164.all;
|
175 |
|
|
use ieee.std_logic_arith.all;
|
176 |
|
|
use work.leon_iface.all;
|
177 |
|
|
|
178 |
|
|
entity generic_syncram is
|
179 |
|
|
generic ( abits : integer := 10; dbits : integer := 8 );
|
180 |
|
|
port (
|
181 |
|
|
address : in std_logic_vector((abits -1) downto 0);
|
182 |
|
|
clk : in std_logic;
|
183 |
|
|
datain : in std_logic_vector((dbits -1) downto 0);
|
184 |
|
|
dataout : out std_logic_vector((dbits -1) downto 0);
|
185 |
|
|
enable : in std_logic;
|
186 |
|
|
write : in std_logic
|
187 |
|
|
);
|
188 |
|
|
end;
|
189 |
|
|
|
190 |
|
|
architecture behavioral of generic_syncram is
|
191 |
|
|
|
192 |
|
|
type mem is array(0 to (2**abits -1))
|
193 |
|
|
of std_logic_vector((dbits -1) downto 0);
|
194 |
|
|
signal memarr : mem;
|
195 |
|
|
signal ra : std_logic_vector((abits -1) downto 0);
|
196 |
|
|
attribute syn_ramstyle : string;
|
197 |
|
|
attribute syn_ramstyle of memarr: signal is "block_ram";
|
198 |
|
|
-- pragma translate_off
|
199 |
|
|
signal rw : std_logic;
|
200 |
|
|
-- pragma translate_on
|
201 |
|
|
|
202 |
|
|
begin
|
203 |
|
|
|
204 |
|
|
main : process(clk, memarr, ra)
|
205 |
|
|
begin
|
206 |
|
|
if rising_edge(clk) then
|
207 |
|
|
if write = '1' then
|
208 |
|
|
-- pragma translate_off
|
209 |
|
|
if not is_x(address) then
|
210 |
|
|
-- pragma translate_on
|
211 |
|
|
memarr(conv_integer(unsigned(address))) <= datain;
|
212 |
|
|
-- pragma translate_off
|
213 |
|
|
end if;
|
214 |
|
|
-- pragma translate_on
|
215 |
|
|
end if;
|
216 |
|
|
ra <= address;
|
217 |
|
|
-- pragma translate_off
|
218 |
|
|
rw <= write;
|
219 |
|
|
-- pragma translate_on
|
220 |
|
|
end if;
|
221 |
|
|
end process;
|
222 |
|
|
|
223 |
|
|
-- pragma translate_off
|
224 |
|
|
readport : process(memarr, ra, rw)
|
225 |
|
|
begin
|
226 |
|
|
if not (is_x(ra) or (rw = '1')) then
|
227 |
|
|
-- pragma translate_on
|
228 |
|
|
dataout <= memarr(conv_integer(unsigned(ra)));
|
229 |
|
|
-- pragma translate_off
|
230 |
|
|
else
|
231 |
|
|
dataout <= (others => 'X');
|
232 |
|
|
end if;
|
233 |
|
|
end process;
|
234 |
|
|
-- pragma translate_on
|
235 |
|
|
end;
|
236 |
|
|
|
237 |
|
|
-- synchronous dpram for direct instantiation
|
238 |
|
|
|
239 |
|
|
LIBRARY ieee;
|
240 |
|
|
use IEEE.std_logic_1164.all;
|
241 |
|
|
use IEEE.std_logic_arith.all;
|
242 |
|
|
use work.leon_iface.all;
|
243 |
|
|
|
244 |
|
|
entity generic_dpram_ss is
|
245 |
|
|
generic (
|
246 |
|
|
abits : integer := 8;
|
247 |
|
|
dbits : integer := 32;
|
248 |
|
|
words : integer := 256
|
249 |
|
|
);
|
250 |
|
|
port (
|
251 |
|
|
clk : in std_logic;
|
252 |
|
|
rdaddress: in std_logic_vector (abits -1 downto 0);
|
253 |
|
|
wraddress: in std_logic_vector (abits -1 downto 0);
|
254 |
|
|
data: in std_logic_vector (dbits -1 downto 0);
|
255 |
|
|
wren : in std_logic;
|
256 |
|
|
q: out std_logic_vector (dbits -1 downto 0)
|
257 |
|
|
);
|
258 |
|
|
end;
|
259 |
|
|
|
260 |
|
|
architecture behav of generic_dpram_ss is
|
261 |
|
|
type dregtype is array (0 to words - 1)
|
262 |
|
|
of std_logic_vector(dbits -1 downto 0);
|
263 |
|
|
signal rfd : dregtype;
|
264 |
|
|
signal wa, ra : std_logic_vector (abits -1 downto 0);
|
265 |
|
|
attribute syn_ramstyle : string;
|
266 |
|
|
attribute syn_ramstyle of rfd: signal is "block_ram";
|
267 |
|
|
-- pragma translate_off
|
268 |
|
|
signal drivex : boolean;
|
269 |
|
|
-- pragma translate_on
|
270 |
|
|
begin
|
271 |
|
|
|
272 |
|
|
rp : process(clk)
|
273 |
|
|
begin
|
274 |
|
|
if rising_edge(clk) then
|
275 |
|
|
if wren = '1' then
|
276 |
|
|
-- pragma translate_off
|
277 |
|
|
if not ( is_x(wraddress) or
|
278 |
|
|
(conv_integer(unsigned(wraddress)) >= words))
|
279 |
|
|
then
|
280 |
|
|
-- pragma translate_on
|
281 |
|
|
rfd(conv_integer(unsigned(wraddress))) <= data;
|
282 |
|
|
-- pragma translate_off
|
283 |
|
|
end if;
|
284 |
|
|
-- pragma translate_on
|
285 |
|
|
end if;
|
286 |
|
|
-- pragma translate_off
|
287 |
|
|
drivex <= (wren = '1') and (wraddress = rdaddress);
|
288 |
|
|
-- pragma translate_on
|
289 |
|
|
ra <= rdaddress;
|
290 |
|
|
end if;
|
291 |
|
|
end process;
|
292 |
|
|
|
293 |
|
|
-- pragma translate_off
|
294 |
|
|
readport : process(rfd, ra, drivex)
|
295 |
|
|
begin
|
296 |
|
|
if not (is_x(ra) or (conv_integer(unsigned(ra)) >= words) or drivex)
|
297 |
|
|
then
|
298 |
|
|
-- pragma translate_on
|
299 |
|
|
q <= rfd(conv_integer(unsigned(ra)));
|
300 |
|
|
-- pragma translate_off
|
301 |
|
|
else
|
302 |
|
|
q <= (others => 'X');
|
303 |
|
|
end if;
|
304 |
|
|
end process;
|
305 |
|
|
-- pragma translate_on
|
306 |
|
|
end;
|
307 |
|
|
|
308 |
|
|
-- async dpram for direct instantiation
|
309 |
|
|
|
310 |
|
|
LIBRARY ieee;
|
311 |
|
|
use IEEE.std_logic_1164.all;
|
312 |
|
|
use IEEE.std_logic_arith.all;
|
313 |
|
|
use work.leon_iface.all;
|
314 |
|
|
|
315 |
|
|
entity generic_dpram_as is
|
316 |
|
|
generic (
|
317 |
|
|
abits : integer := 8;
|
318 |
|
|
dbits : integer := 32;
|
319 |
|
|
words : integer := 256
|
320 |
|
|
);
|
321 |
|
|
port (
|
322 |
|
|
clk : in std_logic;
|
323 |
|
|
rdaddress: in std_logic_vector (abits -1 downto 0);
|
324 |
|
|
wraddress: in std_logic_vector (abits -1 downto 0);
|
325 |
|
|
data: in std_logic_vector (dbits -1 downto 0);
|
326 |
|
|
wren : in std_logic;
|
327 |
|
|
q: out std_logic_vector (dbits -1 downto 0)
|
328 |
|
|
);
|
329 |
|
|
end;
|
330 |
|
|
|
331 |
|
|
architecture behav of generic_dpram_as is
|
332 |
|
|
type dregtype is array (0 to words - 1)
|
333 |
|
|
of std_logic_vector(dbits -1 downto 0);
|
334 |
|
|
signal rfd : dregtype;
|
335 |
|
|
signal wa : std_logic_vector (abits -1 downto 0);
|
336 |
|
|
attribute syn_ramstyle : string;
|
337 |
|
|
attribute syn_ramstyle of rfd: signal is "block_ram";
|
338 |
|
|
begin
|
339 |
|
|
|
340 |
|
|
rp : process(clk)
|
341 |
|
|
begin
|
342 |
|
|
if rising_edge(clk) then
|
343 |
|
|
if wren = '1' then
|
344 |
|
|
-- pragma translate_off
|
345 |
|
|
if not ( is_x(wraddress) or
|
346 |
|
|
(conv_integer(unsigned(wraddress)) >= words))
|
347 |
|
|
then
|
348 |
|
|
-- pragma translate_on
|
349 |
|
|
rfd(conv_integer(unsigned(wraddress))) <= data;
|
350 |
|
|
-- pragma translate_off
|
351 |
|
|
end if;
|
352 |
|
|
-- pragma translate_on
|
353 |
|
|
end if;
|
354 |
|
|
-- wa <= wraddress;
|
355 |
|
|
end if;
|
356 |
|
|
end process;
|
357 |
|
|
-- pragma translate_off
|
358 |
|
|
|
359 |
|
|
comb : process(rdaddress, rfd)
|
360 |
|
|
begin
|
361 |
|
|
if not (is_x(rdaddress) or (conv_integer(unsigned(rdaddress)) >= words))
|
362 |
|
|
then
|
363 |
|
|
-- pragma translate_on
|
364 |
|
|
q <= rfd(conv_integer(unsigned(rdaddress)));
|
365 |
|
|
-- pragma translate_off
|
366 |
|
|
else
|
367 |
|
|
q <= (others => 'X');
|
368 |
|
|
end if;
|
369 |
|
|
end process;
|
370 |
|
|
-- pragma translate_on
|
371 |
|
|
|
372 |
|
|
end;
|
373 |
|
|
|
374 |
|
|
-- Bypass logic for async regfiles with delayed (synchronous) write
|
375 |
|
|
-- Bypass written data to read port if write enabled
|
376 |
|
|
-- and read and write address are equal.
|
377 |
|
|
|
378 |
|
|
library IEEE;
|
379 |
|
|
use IEEE.std_logic_1164.all;
|
380 |
|
|
use work.leon_iface.all;
|
381 |
|
|
|
382 |
|
|
entity rfbypass is
|
383 |
|
|
generic (
|
384 |
|
|
abits : integer := 8;
|
385 |
|
|
dbits : integer := 32
|
386 |
|
|
);
|
387 |
|
|
port (
|
388 |
|
|
clk : in clk_type;
|
389 |
|
|
write : in std_logic;
|
390 |
|
|
datain: in std_logic_vector (dbits -1 downto 0);
|
391 |
|
|
raddr1: in std_logic_vector (abits -1 downto 0);
|
392 |
|
|
raddr2: in std_logic_vector (abits -1 downto 0);
|
393 |
|
|
waddr : in std_logic_vector (abits -1 downto 0);
|
394 |
|
|
q1 : in std_logic_vector (dbits -1 downto 0);
|
395 |
|
|
q2 : in std_logic_vector (dbits -1 downto 0);
|
396 |
|
|
dataout1 : out std_logic_vector (dbits -1 downto 0);
|
397 |
|
|
dataout2 : out std_logic_vector (dbits -1 downto 0)
|
398 |
|
|
);
|
399 |
|
|
end;
|
400 |
|
|
architecture rtl of rfbypass is
|
401 |
|
|
type wbypass_type is record
|
402 |
|
|
wraddr : std_logic_vector(abits-1 downto 0);
|
403 |
|
|
wrdata : std_logic_vector(dbits-1 downto 0);
|
404 |
|
|
wren : std_logic;
|
405 |
|
|
end record;
|
406 |
|
|
signal wbpr : wbypass_type;
|
407 |
|
|
begin
|
408 |
|
|
|
409 |
|
|
wbp_comb : process(q1, q2, wbpr, raddr1, raddr2)
|
410 |
|
|
begin
|
411 |
|
|
if (wbpr.wren = '1') and (wbpr.wraddr = raddr1) then
|
412 |
|
|
dataout1 <= wbpr.wrdata;
|
413 |
|
|
else dataout1 <= q1(dbits-1 downto 0); end if;
|
414 |
|
|
if (wbpr.wren = '1') and (wbpr.wraddr = raddr2) then
|
415 |
|
|
dataout2 <= wbpr.wrdata;
|
416 |
|
|
else dataout2 <= q2(dbits-1 downto 0); end if;
|
417 |
|
|
end process;
|
418 |
|
|
|
419 |
|
|
wbp_reg : process(clk)
|
420 |
|
|
begin
|
421 |
|
|
if rising_edge(clk) then
|
422 |
|
|
wbpr.wraddr <= waddr;
|
423 |
|
|
wbpr.wrdata <= datain;
|
424 |
|
|
wbpr.wren <= write;
|
425 |
|
|
end if;
|
426 |
|
|
end process;
|
427 |
|
|
|
428 |
|
|
end;
|
429 |
|
|
|
430 |
|
|
--------------------------------------------------------------------
|
431 |
|
|
-- regfile generators
|
432 |
|
|
--------------------------------------------------------------------
|
433 |
|
|
|
434 |
|
|
-- integer unit regfile
|
435 |
|
|
LIBRARY ieee;
|
436 |
|
|
use IEEE.std_logic_1164.all;
|
437 |
|
|
use work.leon_config.all;
|
438 |
|
|
use work.leon_iface.all;
|
439 |
|
|
entity generic_regfile_iu is
|
440 |
|
|
generic (
|
441 |
|
|
rftype : integer := 1;
|
442 |
|
|
abits : integer := 8; dbits : integer := 32; words : integer := 128
|
443 |
|
|
);
|
444 |
|
|
port (
|
445 |
|
|
rst : in std_logic;
|
446 |
|
|
clk : in std_logic;
|
447 |
|
|
clkn : in std_logic;
|
448 |
|
|
rfi : in rf_in_type;
|
449 |
|
|
rfo : out rf_out_type);
|
450 |
|
|
end;
|
451 |
|
|
|
452 |
|
|
architecture rtl of generic_regfile_iu is
|
453 |
|
|
component generic_dpram_ss
|
454 |
|
|
generic (
|
455 |
|
|
abits : integer := 8;
|
456 |
|
|
dbits : integer := 32;
|
457 |
|
|
words : integer := 256
|
458 |
|
|
);
|
459 |
|
|
port (
|
460 |
|
|
clk : in std_logic;
|
461 |
|
|
rdaddress: in std_logic_vector (abits -1 downto 0);
|
462 |
|
|
wraddress: in std_logic_vector (abits -1 downto 0);
|
463 |
|
|
data: in std_logic_vector (dbits -1 downto 0);
|
464 |
|
|
wren : in std_logic;
|
465 |
|
|
q: out std_logic_vector (dbits -1 downto 0)
|
466 |
|
|
);
|
467 |
|
|
end component;
|
468 |
|
|
|
469 |
|
|
component generic_dpram_as
|
470 |
|
|
generic (
|
471 |
|
|
abits : integer := 8;
|
472 |
|
|
dbits : integer := 32;
|
473 |
|
|
words : integer := 256
|
474 |
|
|
);
|
475 |
|
|
port (
|
476 |
|
|
clk : in std_logic;
|
477 |
|
|
rdaddress: in std_logic_vector (abits -1 downto 0);
|
478 |
|
|
wraddress: in std_logic_vector (abits -1 downto 0);
|
479 |
|
|
data: in std_logic_vector (dbits -1 downto 0);
|
480 |
|
|
wren : in std_logic;
|
481 |
|
|
q: out std_logic_vector (dbits -1 downto 0)
|
482 |
|
|
);
|
483 |
|
|
end component;
|
484 |
|
|
|
485 |
|
|
component rfbypass
|
486 |
|
|
generic (
|
487 |
|
|
abits : integer := 8;
|
488 |
|
|
dbits : integer := 32
|
489 |
|
|
);
|
490 |
|
|
port (
|
491 |
|
|
clk : in clk_type;
|
492 |
|
|
write : in std_logic;
|
493 |
|
|
datain: in std_logic_vector (dbits -1 downto 0);
|
494 |
|
|
raddr1: in std_logic_vector (abits -1 downto 0);
|
495 |
|
|
raddr2: in std_logic_vector (abits -1 downto 0);
|
496 |
|
|
waddr : in std_logic_vector (abits -1 downto 0);
|
497 |
|
|
q1 : in std_logic_vector (dbits -1 downto 0);
|
498 |
|
|
q2 : in std_logic_vector (dbits -1 downto 0);
|
499 |
|
|
dataout1 : out std_logic_vector (dbits -1 downto 0);
|
500 |
|
|
dataout2 : out std_logic_vector (dbits -1 downto 0)
|
501 |
|
|
);
|
502 |
|
|
end component;
|
503 |
|
|
|
504 |
|
|
signal qq1, qq2 : std_logic_vector (dbits -1 downto 0);
|
505 |
|
|
begin
|
506 |
|
|
|
507 |
|
|
rfss : if rftype = 1 generate
|
508 |
|
|
u0 : generic_dpram_ss
|
509 |
|
|
generic map (abits => abits, dbits => dbits, words => words)
|
510 |
|
|
port map (clk => clkn, rdaddress => rfi.rd1addr, wraddress => rfi.wraddr,
|
511 |
|
|
data => rfi.wrdata, wren => rfi.wren, q => rfo.data1);
|
512 |
|
|
|
513 |
|
|
u1 : generic_dpram_ss
|
514 |
|
|
generic map (abits => abits, dbits => dbits, words => words)
|
515 |
|
|
port map (clk => clkn, rdaddress => rfi.rd2addr, wraddress => rfi.wraddr,
|
516 |
|
|
data => rfi.wrdata, wren => rfi.wren, q => rfo.data2);
|
517 |
|
|
end generate;
|
518 |
|
|
|
519 |
|
|
rfas : if rftype = 2 generate
|
520 |
|
|
u0 : generic_dpram_as
|
521 |
|
|
generic map (abits => abits, dbits => dbits, words => words)
|
522 |
|
|
port map (clk => clk, rdaddress => rfi.rd1addr, wraddress => rfi.wraddr,
|
523 |
|
|
data => rfi.wrdata, wren => rfi.wren, q => rfo.data1);
|
524 |
|
|
|
525 |
|
|
u1 : generic_dpram_as
|
526 |
|
|
generic map (abits => abits, dbits => dbits, words => words)
|
527 |
|
|
port map (clk => clk, rdaddress => rfi.rd2addr, wraddress => rfi.wraddr,
|
528 |
|
|
data => rfi.wrdata, wren => rfi.wren, q => rfo.data2);
|
529 |
|
|
end generate;
|
530 |
|
|
|
531 |
|
|
end;
|
532 |
|
|
|
533 |
|
|
-- co-processor regfile
|
534 |
|
|
-- synchronous operation without write-through support
|
535 |
|
|
LIBRARY ieee;
|
536 |
|
|
use IEEE.std_logic_1164.all;
|
537 |
|
|
use work.leon_config.all;
|
538 |
|
|
use work.leon_iface.all;
|
539 |
|
|
entity generic_regfile_cp is
|
540 |
|
|
generic (
|
541 |
|
|
abits : integer := 4; dbits : integer := 32; words : integer := 16
|
542 |
|
|
);
|
543 |
|
|
port (
|
544 |
|
|
rst : in std_logic;
|
545 |
|
|
clk : in std_logic;
|
546 |
|
|
rfi : in rf_cp_in_type;
|
547 |
|
|
rfo : out rf_cp_out_type);
|
548 |
|
|
end;
|
549 |
|
|
|
550 |
|
|
architecture rtl of generic_regfile_cp is
|
551 |
|
|
component generic_dpram_ss
|
552 |
|
|
generic (
|
553 |
|
|
abits : integer := 8;
|
554 |
|
|
dbits : integer := 32;
|
555 |
|
|
words : integer := 256
|
556 |
|
|
);
|
557 |
|
|
port (
|
558 |
|
|
clk : in std_logic;
|
559 |
|
|
rdaddress: in std_logic_vector (abits -1 downto 0);
|
560 |
|
|
wraddress: in std_logic_vector (abits -1 downto 0);
|
561 |
|
|
data: in std_logic_vector (dbits -1 downto 0);
|
562 |
|
|
wren : in std_logic;
|
563 |
|
|
q: out std_logic_vector (dbits -1 downto 0)
|
564 |
|
|
);
|
565 |
|
|
end component;
|
566 |
|
|
|
567 |
|
|
begin
|
568 |
|
|
u0 : generic_dpram_ss
|
569 |
|
|
generic map (abits => abits, dbits => dbits, words => words)
|
570 |
|
|
port map (clk => clk, rdaddress => rfi.rd1addr, wraddress => rfi.wraddr,
|
571 |
|
|
data => rfi.wrdata, wren => rfi.wren, q => rfo.data1);
|
572 |
|
|
u1 : generic_dpram_ss
|
573 |
|
|
generic map (abits => abits, dbits => dbits, words => words)
|
574 |
|
|
port map (clk => clk, rdaddress => rfi.rd2addr, wraddress => rfi.wraddr,
|
575 |
|
|
data => rfi.wrdata, wren => rfi.wren, q => rfo.data2);
|
576 |
|
|
end;
|
577 |
|
|
|
578 |
|
|
------------------------------------------------------------------
|
579 |
|
|
-- multiplier ----------------------------------------------------
|
580 |
|
|
------------------------------------------------------------------
|
581 |
|
|
|
582 |
|
|
library IEEE;
|
583 |
|
|
use IEEE.std_logic_1164.all;
|
584 |
|
|
use IEEE.std_logic_arith.all;
|
585 |
|
|
entity generic_smult is
|
586 |
|
|
generic ( abits : integer := 10; bbits : integer := 8 );
|
587 |
|
|
port (
|
588 |
|
|
a : in std_logic_vector(abits-1 downto 0);
|
589 |
|
|
b : in std_logic_vector(bbits-1 downto 0);
|
590 |
|
|
c : out std_logic_vector(abits+bbits-1 downto 0)
|
591 |
|
|
);
|
592 |
|
|
end;
|
593 |
|
|
architecture rtl of generic_smult is
|
594 |
|
|
begin
|
595 |
|
|
|
596 |
|
|
m: process(a, b)
|
597 |
|
|
variable w : std_logic_vector(abits+bbits-1 downto 0);
|
598 |
|
|
begin
|
599 |
|
|
-- pragma translate_off
|
600 |
|
|
if is_x(a) or is_x(b) then
|
601 |
|
|
w := (others => 'X');
|
602 |
|
|
else
|
603 |
|
|
-- pragma translate_on
|
604 |
|
|
w := std_logic_vector'(signed(a) * signed(b)); --'
|
605 |
|
|
-- pragma translate_off
|
606 |
|
|
end if;
|
607 |
|
|
-- pragma translate_on
|
608 |
|
|
c <= w;
|
609 |
|
|
end process;
|
610 |
|
|
end;
|
611 |
|
|
|
612 |
|
|
|
613 |
|
|
------------------------------------------------------------------
|
614 |
|
|
-- generic clock generator ---------------------------------------
|
615 |
|
|
------------------------------------------------------------------
|
616 |
|
|
|
617 |
|
|
library IEEE;
|
618 |
|
|
use IEEE.std_logic_1164.all;
|
619 |
|
|
use work.leon_target.all;
|
620 |
|
|
use work.leon_iface.all;
|
621 |
|
|
use work.leon_config.all;
|
622 |
|
|
|
623 |
|
|
entity generic_clkgen is
|
624 |
|
|
port (
|
625 |
|
|
clkin : in std_logic;
|
626 |
|
|
pciclkin: in std_logic;
|
627 |
|
|
clk : out std_logic; -- main clock
|
628 |
|
|
clkn : out std_logic; -- inverted main clock
|
629 |
|
|
sdclk : out std_logic; -- SDRAM clock
|
630 |
|
|
pciclk : out std_logic; -- PCI clock
|
631 |
|
|
cgi : in clkgen_in_type;
|
632 |
|
|
cgo : out clkgen_out_type
|
633 |
|
|
);
|
634 |
|
|
end;
|
635 |
|
|
|
636 |
|
|
architecture rtl of generic_clkgen is
|
637 |
|
|
signal pciclk_actel : clk_type;
|
638 |
|
|
begin
|
639 |
|
|
|
640 |
|
|
pciclk_actel <= pciclkin after 1 ns; -- need this to stay synced with Actel core
|
641 |
|
|
cgo.clklock <= '1'; cgo.pcilock <= '1';
|
642 |
|
|
|
643 |
|
|
cp : process (pciclk_actel, clkin, pciclkin)
|
644 |
|
|
begin
|
645 |
|
|
if PCI_SYSCLK then
|
646 |
|
|
clk <= pciclk_actel; clkn <= not pciclk_actel; pciclk <= pciclk_actel;
|
647 |
|
|
|
648 |
|
|
if SDINVCLK then sdclk <= not pciclk_actel; else sdclk <= pciclk_actel; end if;
|
649 |
|
|
|
650 |
|
|
else
|
651 |
|
|
|
652 |
|
|
clk <= clkin; clkn <= not clkin; pciclk <= pciclkin;
|
653 |
|
|
|
654 |
|
|
if SDINVCLK then sdclk <= not clkin; else sdclk <= clkin; end if;
|
655 |
|
|
end if;
|
656 |
|
|
end process;
|
657 |
|
|
end;
|
658 |
|
|
|
659 |
|
|
------------------------------------------------------------------
|
660 |
|
|
-- behavioural pad models --------------------------------------------
|
661 |
|
|
------------------------------------------------------------------
|
662 |
|
|
|
663 |
|
|
-- input pad
|
664 |
|
|
library IEEE;
|
665 |
|
|
use IEEE.std_logic_1164.all;
|
666 |
|
|
entity geninpad is port (pad : in std_logic; q : out std_logic); end;
|
667 |
|
|
architecture rtl of geninpad is begin q <= to_x01(pad); end;
|
668 |
|
|
|
669 |
|
|
-- input schmitt pad
|
670 |
|
|
library IEEE;
|
671 |
|
|
use IEEE.std_logic_1164.all;
|
672 |
|
|
entity gensmpad is port (pad : in std_logic; q : out std_logic); end;
|
673 |
|
|
architecture rtl of gensmpad is begin q <= to_x01(pad); end;
|
674 |
|
|
|
675 |
|
|
-- output pad
|
676 |
|
|
library IEEE;
|
677 |
|
|
use IEEE.std_logic_1164.all;
|
678 |
|
|
entity genoutpad is port (d : in std_logic; pad : out std_logic); end;
|
679 |
|
|
architecture rtl of genoutpad is begin pad <= to_x01(d) after 2 ns; end;
|
680 |
|
|
|
681 |
|
|
-- tri-state outpad with pull-up pad
|
682 |
|
|
library IEEE;
|
683 |
|
|
use IEEE.std_logic_1164.all;
|
684 |
|
|
entity gentoutpadu is port (d, en : in std_logic; pad : out std_logic); end;
|
685 |
|
|
architecture rtl of gentoutpadu is
|
686 |
|
|
begin pad <= to_x01(d) after 2 ns when en = '0' else 'H' after 2 ns; end;
|
687 |
|
|
|
688 |
|
|
-- bidirectional pad
|
689 |
|
|
library IEEE;
|
690 |
|
|
use IEEE.std_logic_1164.all;
|
691 |
|
|
entity geniopad is
|
692 |
|
|
port ( d, en : in std_logic; q : out std_logic; pad : inout std_logic);
|
693 |
|
|
end;
|
694 |
|
|
architecture rtl of geniopad is
|
695 |
|
|
begin pad <= to_x01(d) after 2 ns when en = '0' else 'Z' after 2 ns; q <= to_x01(pad); end;
|
696 |
|
|
|
697 |
|
|
-- bidirectional open-drain pad
|
698 |
|
|
library IEEE;
|
699 |
|
|
use IEEE.std_logic_1164.all;
|
700 |
|
|
entity geniodpad is
|
701 |
|
|
port ( d : in std_logic; q : out std_logic; pad : inout std_logic);
|
702 |
|
|
end;
|
703 |
|
|
architecture rtl of geniodpad is
|
704 |
|
|
begin pad <= '0' after 2 ns when d = '0' else 'Z' after 2 ns; q <= to_x01(pad); end;
|
705 |
|
|
|
706 |
|
|
-- open-drain pad
|
707 |
|
|
library IEEE;
|
708 |
|
|
use IEEE.std_logic_1164.all;
|
709 |
|
|
entity genodpad is port ( d : in std_logic; pad : out std_logic); end;
|
710 |
|
|
architecture rtl of genodpad is begin pad <= '0' after 2 ns when d = '0' else 'Z'; end;
|
711 |
|
|
|