AMC13
Firmwares for the different applications of the AMC13 uTCA board made at Boston University
 All Classes Variables
udp_dualportram_rx.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  clk125 : in std_logic;
12  clk : in std_logic;
13  rx_wea : in std_logic;
14  rx_addra : in std_logic_vector(BUFWIDTH + ADDRWIDTH - 1 downto 0);
15  rx_addrb : in std_logic_vector(BUFWIDTH + ADDRWIDTH - 3 downto 0);
16  rx_dia : in std_logic_vector(7 downto 0);
17  rx_dob : out std_logic_vector(31 downto 0)
18  );
19 END ENTITY udp_DualPortRAM_rx;
20 
21 --
22 ARCHITECTURE striped OF udp_DualPortRAM_rx IS
23 type ram_type is array (2**(BUFWIDTH + ADDRWIDTH - 2) - 1 downto 0) of std_logic_vector (7 downto 0);
24 signal ram1,ram2, ram3, ram4 : ram_type;
25 attribute block_ram : boolean;
26 attribute block_ram of RAM1 : signal is TRUE;
27 attribute block_ram of RAM2 : signal is TRUE;
28 attribute block_ram of RAM3 : signal is TRUE;
29 attribute block_ram of RAM4 : signal is TRUE;
30 BEGIN
31 
32 write: process (clk125)
33 begin
34  if (rising_edge(clk125)) then
35  if (rx_wea = '1') then
36  case rx_addra(1 downto 0) is
37  when "00" =>
38  ram4(to_integer(unsigned(rx_addra(BUFWIDTH + ADDRWIDTH - 1 downto 2)))) <= rx_dia;
39  when "01" =>
40  ram3(to_integer(unsigned(rx_addra(BUFWIDTH + ADDRWIDTH - 1 downto 2)))) <= rx_dia;
41  when "10" =>
42  ram2(to_integer(unsigned(rx_addra(BUFWIDTH + ADDRWIDTH - 1 downto 2)))) <= rx_dia;
43  when "11" =>
44  ram1(to_integer(unsigned(rx_addra(BUFWIDTH + ADDRWIDTH - 1 downto 2)))) <= rx_dia;
45  when Others =>
46  end case;
47  end if;
48  end if;
49 end process write;
50 
51 read: process (clk)
52  variable byte1, byte2, byte3, byte4 : std_logic_vector (7 downto 0);
53 begin
54  if (rising_edge(clk)) then
55  byte4 := ram4(to_integer(unsigned(rx_addrb)));
56  byte3 := ram3(to_integer(unsigned(rx_addrb)));
57  byte2 := ram2(to_integer(unsigned(rx_addrb)));
58  byte1 := ram1(to_integer(unsigned(rx_addrb)));
59  rx_dob <= byte4 & byte3 & byte2 & byte1;
60  end if;
61 end process read;
62 
63 
64 END ARCHITECTURE striped;