eFEX firmware  1.7.3
ATLAS l1-calo - electron and tau feature extraction firmware for eFEX boards

Back to eFEX documentation
ipbus_dpram_flash.vhd
Go to the documentation of this file.
1 
8 
9 library IEEE;
10 use IEEE.STD_LOGIC_1164.ALL;
11 use ieee.numeric_std.all;
12 library ipbus_lib;
13 use ipbus_lib.ipbus.all;
14 
17  generic(
18  ADDR_WIDTH: natural
19  );
20  port(
22  clk: in std_logic;
24  rst: in std_logic;
26  ipb_in: in ipb_wbus;
28  ipb_out: out ipb_rbus;
30  rclk: in std_logic;
32  we: in std_logic := '0';
34  d: in std_logic_vector(31 downto 0) := (others => '0');
36  q: out std_logic_vector(31 downto 0);
38  addr: in std_logic_vector(ADDR_WIDTH - 1 downto 0)
39  );
40 
43 
44 architecture rtl of ipbus_dpram_flash is
45 
46  type ram_array is array(0 to 2 ** ADDR_WIDTH - 1 ) of std_logic_vector(31 downto 0);-- order reversed to allow initialisation from 0
47 
48  shared variable ram: ram_array :=(
49 -- X"9F000000", others => X"00000000" ); -- read ID codes
50  X"03000000", others => X"00000000" ); -- read from address 0
51 
52  signal sel, rsel: integer range 0 to 2 ** ADDR_WIDTH - 1 := 0;
53  signal ack: std_logic;
54 
55 begin
56 
57  sel <= to_integer(unsigned(ipb_in.ipb_addr(ADDR_WIDTH - 1 downto 0)));
58 
59  process(clk)
60  begin
61  if rising_edge(clk) then
62  ipb_out.ipb_rdata <= ram(sel); -- Order of statements is important to infer read-first RAM!
63  if ipb_in.ipb_strobe='1' and ipb_in.ipb_write='1' then
64  ram(sel) := ipb_in.ipb_wdata;
65  end if;
66  ack <= ipb_in.ipb_strobe and not ack;
67  end if;
68  end process;
69 
70  ipb_out.ipb_ack <= ack;
71  ipb_out.ipb_err <= '0';
72 
73  rsel <= to_integer(unsigned(addr));
74 
75  process(rclk)
76  begin
77  if rising_edge(rclk) then
78  q <= ram(rsel); -- Order of statements is important to infer read-first RAM!
79  if we = '1' then
80  ram(rsel) := d;
81  end if;
82  end if;
83  end process;
84 
85 end rtl;
ipbus dpram flash
in clk std_logic
write clock
in addr std_logic_vector( ADDR_WIDTH- 1 downto 0)
address
out ipb_out ipb_rbus
IPBus output bus going from slaves to master.
in rclk std_logic
read clock
in we std_logic := '0'
write enable
in ipb_in ipb_wbus
IPBus input bus going from master to slaves.
in rst std_logic
reset
in d std_logic_vector( 31 downto 0) :=( others => '0')
data in
out q std_logic_vector( 31 downto 0)
data out