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

Back to eFEX documentation
reconfig.vhd
Go to the documentation of this file.
1 
16 
17 library IEEE;
18 use IEEE.STD_LOGIC_1164.all;
19 use ieee.numeric_std.all;
20 
21 library UNISIM;
22 use UNISIM.vcomponents.all;
23 
25 entity reconfig is
26  generic (MAX_COUNT : integer := 65535);
27  port (
29  WBSTAR : in std_logic_vector(31 downto 0);
31  TRIGGER : in std_logic;
33  SYSCLK : in std_logic
34  );
35 end reconfig;
36 
38 architecture behavioral of reconfig is
39 
40  type FSM_STATE is (IDLE, DATA_00, DATA_01, DATA_02, DATA_03, DATA_04, DATA_05, DATA_06, DATA_07);
41 
42  signal NEXT_STATE : FSM_STATE := IDLE;
43  signal CE_n : std_logic := '1';
44  signal ICAP_DATA : std_logic_vector(31 downto 0) := (others => '0');
45  signal ICAP_WRITE_n : std_logic := '1';
46 
47  attribute dont_touch : string;
48  attribute dont_touch of ICAP_DATA : signal is "true";
49  attribute dont_touch of ICAP_WRITE_n : signal is "true";
50  attribute dont_touch of CE_n : signal is "true";
51 
52  signal ICAP_DATA_BITSWAP : std_logic_vector(31 downto 0) := (others => '0');
53 
54  signal reconfig_delay : integer range 0 to MAX_COUNT := 0 ;
55  signal trigger_reconfig : std_logic := '0';
56 
57 
58 begin
59 
60 
61 --ICAP_DATA_BITSWAP <= ICAP_DATA (24 downto 31) & ICAP_DATA (16 downto 23) & ICAP_DATA (8 downto 15) &ICAP_DATA (0 downto 7) ;
62  bit_swap : for i in 0 to 7 generate
63  ICAP_DATA_BITSWAP(i) <= ICAP_DATA(7-i);
64  ICAP_DATA_BITSWAP(i+8) <= ICAP_DATA(15-i);
65  ICAP_DATA_BITSWAP(i+16) <= ICAP_DATA(23-i);
66  ICAP_DATA_BITSWAP(i+24) <= ICAP_DATA(31-i);
67  end generate;
68 
69 
70  ICAPE2_inst : ICAPE2
71  generic map (
72  ICAP_WIDTH => "X32",
73  SIM_CFG_FILE_NAME => "NONE"
74  )
75  port map (
76  O => open, -- 32-bit output (not used)
77  CLK => SYSCLK, -- 1-bit Clock Input
78  CSIB => CE_n, -- 1-bit Active-Low ICAP Enable
79  I => ICAP_DATA_BITSWAP, -- 32-bit iConfiguration data input bus
80  RDWRB => ICAP_WRITE_n -- 1-bit input: Read/Write Select input
81  );
82 
83 
84  process(SYSCLK) -- give ipbus time to acknowledge data
85  begin
86  if (rising_edge(SYSCLK)) then
87  trigger_reconfig <= '0';
88  if trigger = '0' then
89  reconfig_delay <= 0;
90  else
91  if reconfig_delay < MAX_COUNT then
92  reconfig_delay <= reconfig_delay + 1;
93  else
94  reconfig_delay <= reconfig_delay;
95  trigger_reconfig <= '1';
96  end if;
97  end if;
98  end if;
99  end process;
100 
101 
102  process(SYSCLK)
103  begin
104  if (rising_edge(SYSCLK)) then
105  case NEXT_STATE is
106  when IDLE =>
107  ICAP_WRITE_n <= '1';
108  CE_n <= '1';
109  ICAP_DATA <= x"FFFFFFFF"; -- dummy word
110 
111  if trigger_reconfig = '1' then
112  NEXT_STATE <= DATA_00;
113  end if;
114 
115  when DATA_00 =>
116  ICAP_WRITE_n <= '0';
117  CE_n <= '0';
118  ICAP_DATA <= x"FFFFFFFF"; -- dummy word
119  NEXT_STATE <= DATA_01;
120  when DATA_01 =>
121  ICAP_WRITE_n <= '0';
122  CE_n <= '0';
123  ICAP_DATA <= x"AA995566"; -- sync word
124  NEXT_STATE <= DATA_02;
125  when DATA_02 =>
126  ICAP_WRITE_n <= '0';
127  CE_n <= '0';
128  ICAP_DATA <= x"20000000"; -- Type 1 NO OP
129  NEXT_STATE <= DATA_03;
130  when DATA_03 =>
131  ICAP_WRITE_n <= '0';
132  CE_n <= '0';
133  ICAP_DATA <= x"30020001"; -- Type 1 Write 1 word to WBSTAR
134  NEXT_STATE <= DATA_04;
135  when DATA_04 =>
136  ICAP_WRITE_n <= '0';
137  CE_n <= '0';
138  ICAP_DATA <= WBSTAR; -- Warm boot start address
139  NEXT_STATE <= DATA_05;
140  when DATA_05 =>
141  ICAP_WRITE_n <= '0';
142  CE_n <= '0';
143  ICAP_DATA <= x"30008001"; -- Type 1 write 1 word to CMD
144  NEXT_STATE <= DATA_06;
145  when DATA_06 =>
146  ICAP_WRITE_n <= '0';
147  CE_n <= '0';
148  ICAP_DATA <= x"0000000F"; -- IPROG command
149  NEXT_STATE <= DATA_07;
150  when DATA_07 =>
151  ICAP_WRITE_n <= '0';
152  CE_n <= '0';
153  ICAP_DATA <= x"20000000"; -- Type 1 NO OP
154  NEXT_STATE <= IDLE;
155  when others =>
156  ICAP_WRITE_n <= '1';
157  CE_n <= '1';
158  ICAP_DATA <= x"FFFFFFFF"; -- dummy word
159  NEXT_STATE <= IDLE;
160  end case;
161  end if;
162  end process;
163 
164 end behavioral;
FPGA Reconfiguration State Machine.
Definition: reconfig.vhd:38
FPGA Reconfiguration State Machine.
Definition: reconfig.vhd:25
in TRIGGER std_logic
Trigger input to start reconfigureation of the FPGA from the WBSTAR.
Definition: reconfig.vhd:31
in SYSCLK std_logic
Clock input to ICAP 31.25MHz.
Definition: reconfig.vhd:34
in WBSTAR std_logic_vector( 31 downto 0)
Warm Boot Start Address.
Definition: reconfig.vhd:29