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