-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathudp_dualportram_tx.vhd
63 lines (57 loc) · 1.61 KB
/
udp_dualportram_tx.vhd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
LIBRARY ieee;
USE ieee.std_logic_1164.all;
use ieee.numeric_std.all;
ENTITY udp_DualPortRAM_tx IS
generic(
BUFWIDTH: natural := 0;
ADDRWIDTH: natural := 0
);
port (
clk : in std_logic;
clk125 : in std_logic;
tx_wea : in std_logic;
tx_addra : in std_logic_vector(BUFWIDTH + ADDRWIDTH - 3 downto 0);
tx_addrb : in std_logic_vector(BUFWIDTH + ADDRWIDTH - 1 downto 0);
tx_dia : in std_logic_vector(31 downto 0);
tx_dob : out std_logic_vector(7 downto 0)
);
END ENTITY udp_DualPortRAM_tx;
--
ARCHITECTURE v3 OF udp_DualPortRAM_tx IS
type ram_type is array (2**(BUFWIDTH + ADDRWIDTH - 2) - 1 downto 0) of std_logic_vector (31 downto 0);
signal ram : ram_type;
attribute block_ram : boolean;
attribute block_ram of ram : signal is TRUE;
signal ram_out : std_logic_vector(31 downto 0);
signal bytesel: std_logic_vector(1 downto 0);
BEGIN
write: process (clk)
begin
if (rising_edge(clk)) then
if (tx_wea = '1') then
ram(to_integer(unsigned(tx_addra))) <= tx_dia;
end if;
end if;
end process write;
read: process (clk125)
begin
if (rising_edge(clk125)) then
ram_out <= ram(to_integer(unsigned(tx_addrb(BUFWIDTH + ADDRWIDTH - 1 downto 2))))
-- pragma translate_off
after 4 ns
-- pragma translate_on
;
bytesel <= tx_addrb(1 downto 0)
-- pragma translate_off
after 4 ns
-- pragma translate_on
;
end if;
end process read;
with bytesel select
tx_dob <= ram_out(31 downto 24) when "00",
ram_out(23 downto 16) when "01",
ram_out(15 downto 8) when "10",
ram_out(7 downto 0) when "11",
(Others => '0') when Others;
END ARCHITECTURE v3;