SURF  1.0
IprogUltraScale.vhd
Go to the documentation of this file.
1 -------------------------------------------------------------------------------
2 -- File : IprogUltraScale.vhd
3 -- Company : SLAC National Accelerator Laboratory
4 -- Created : 2015-06-18
5 -- Last update: 2016-04-13
6 -------------------------------------------------------------------------------
7 -- Description: Uses the ICAP primitive to internally
8 -- toggle the PROG_B via IPROG command
9 -------------------------------------------------------------------------------
10 -- This file is part of 'SLAC Firmware Standard Library'.
11 -- It is subject to the license terms in the LICENSE.txt file found in the
12 -- top-level directory of this distribution and at:
13 -- https://confluence.slac.stanford.edu/display/ppareg/LICENSE.html.
14 -- No part of 'SLAC Firmware Standard Library', including this file,
15 -- may be copied, modified, propagated, or distributed except according to
16 -- the terms contained in the LICENSE.txt file.
17 -------------------------------------------------------------------------------
18 
19 library ieee;
20 use ieee.std_logic_1164.all;
21 use ieee.std_logic_arith.all;
22 use ieee.std_logic_unsigned.all;
23 
24 use work.StdRtlPkg.all;
25 
26 library unisim;
27 use unisim.vcomponents.all;
28 
29 --! @see entity
30  --! @ingroup xilinx_UltraScale_general
31 entity IprogUltraScale is
32  generic (
33  TPD_G : time := 1 ns;
34  USE_SLOWCLK_G : boolean := false;
35  BUFR_CLK_DIV_G : natural := 8;
36  RST_POLARITY_G : sl := '1');
37  port (
38  clk : in sl;
39  rst : in sl;
40  slowClk : in sl := '0';
41  start : in sl;
42  bootAddress : in slv(31 downto 0) := X"00000000");
43 end IprogUltraScale;
44 
45 architecture rtl of IprogUltraScale is
46 
47  function selectMapBitSwapping (input : slv) return slv is
48  variable i : integer;
49  variable j : integer;
50  variable output : slv(0 to 31);
51  begin
52  for i in 0 to 3 loop
53  for j in 0 to 7 loop
54  output((8*i)+j) := input((8*i)+(7-j));
55  end loop;
56  end loop;
57  return output;
58  end function selectMapBitSwapping;
59 
60  type StateType is (IDLE_S, PROG_S);
61 
62  type RegType is record
63  state : StateType;
64  csl : sl;
65  rdy : sl;
66  rnw : sl;
67  cnt : slv(3 downto 0);
68  configData : slv(31 downto 0);
69  bootAddress : slv(31 downto 0);
70  end record RegType;
71 
72  constant REG_INIT_C : RegType := (
73  state => IDLE_S,
74  csl => '1',
75  rdy => '1',
76  rnw => '1',
77  cnt => (others => '0'),
78  configData => (others => '0'),
79  bootAddress => (others => '0'));
80 
81  signal r : RegType := REG_INIT_C;
82  signal rin : RegType;
83 
84  signal divClk : sl;
85  signal icape2Clk : sl;
86  signal icape2Rst : sl;
87  signal startEdge : sl;
88  signal rdy : sl;
89 
90 begin
91 
92  icape2Clk <= slowClk when(USE_SLOWCLK_G) else divClk;
93 
94  BUFGCE_DIV_Inst : BUFGCE_DIV
95  generic map (
96  BUFGCE_DIVIDE => BUFR_CLK_DIV_G)
97  port map (
98  I => clk,
99  CE => '1',
100  CLR => '0',
101  O => divClk);
102 
103  RstSync_Inst : entity work.RstSync
104  generic map (
105  TPD_G => TPD_G,
107  port map (
108  clk => icape2Clk,
109  asyncRst => rst,
110  syncRst => icape2Rst);
111 
112  SynchronizerOneShot_1 : entity work.SynchronizerOneShot
113  generic map (
114  TPD_G => TPD_G)
115  port map (
116  clk => icape2Clk,
117  rst => icape2Rst,
118  dataIn => start,
119  dataOut => startEdge);
120 
121  ICAPE3_Inst : ICAPE3
122  generic map (
123  DEVICE_ID => X"03628093", -- Specifies the pre-programmed Device ID value to be used for simulation purposes
124  ICAP_AUTO_SWITCH => "DISABLE", -- Enable switch ICAP using sync word
125  SIM_CFG_FILE_NAME => "NONE") -- Specifies the Raw Bitstream (RBT) file to be parsed by the simulation model
126  port map (
127  AVAIL => rdy, -- 1-bit output: Availability status of ICAP
128  O => open, -- 32-bit output: Configuration data output bus
129  PRDONE => open, -- 1-bit output: Indicates completion of Partial Reconfiguration
130  PRERROR => open, -- 1-bit output: Indicates Error during Partial Reconfiguration
131  CLK => icape2Clk, -- 1-bit input: Clock input
132  CSIB => r.csl, -- 1-bit input: Active-Low ICAP enable
133  I => r.configData, -- 32-bit input: Configuration data input bus
134  RDWRB => r.rnw); -- 1-bit input: Read/Write Select input
135 
136  comb : process (bootAddress, icape2Rst, r, rdy, startEdge) is
137  variable v : RegType;
138  begin
139  v := r;
140 
141  v.rdy := rdy;
142 
143  case (r.state) is
144  when IDLE_S =>
145  v.csl := '1';
146  v.rnw := '1';
147  v.cnt := (others => '0');
149  if (startEdge = '1') then
150  v.state := PROG_S;
151  end if;
152 
153  when PROG_S =>
154  if rdy = '1' then
155  v.csl := '0';
156  v.rnw := '0';
157  v.cnt := r.cnt + 1;
158  case (r.cnt) is
159  when X"0" =>
160  --Sync Word
161  v.configData := selectMapBitSwapping(X"AA995566");
162  when X"1" =>
163  --Type 1 NO OP
164  v.configData := selectMapBitSwapping(X"20000000");
165  when X"2" =>
166  --Type 1 Write 1 Words to WBSTAR
167  v.configData := selectMapBitSwapping(X"30020001");
168  when X"3" =>
169  --Warm Boot Start Address (Load the Desired Address)
170  v.configData := selectMapBitSwapping(bitReverse(r.bootAddress));
171  when X"4" =>
172  --Type 1 Write 1 Words to CMD
173  v.configData := selectMapBitSwapping(X"30008001");
174  when X"5" =>
175  --IPROG Command
176  v.configData := selectMapBitSwapping(X"0000000F");
177  when X"6" =>
178  --Type 1 NO OP
179  v.configData := selectMapBitSwapping(X"20000000");
180  v.state := IDLE_S;
181  when others => null;
182  end case;
183  end if;
184  -- Check for interrupt
185  if (r.rdy = '1') and (rdy = '0') then
186  -- Reset the IPROG procedure
187  v.csl := '1';
188  v.rnw := '1';
189  v.cnt := (others => '0');
190  end if;
191  when others => null;
192  end case;
193 
194  if (icape2Rst = '1') then
195  v := REG_INIT_C;
196  end if;
197 
198  rin <= v;
199 
200  end process comb;
201 
202  seq : process (icape2Clk) is
203  begin
204  if (rising_edge(icape2Clk)) then
205  r <= rin after TPD_G;
206  end if;
207  end process seq;
208 
209 end rtl;
in slowClksl := '0'
out syncRstsl
Definition: RstSync.vhd:36
IN_POLARITY_Gsl := '1'
Definition: RstSync.vhd:28
std_logic sl
Definition: StdRtlPkg.vhd:28
USE_SLOWCLK_Gboolean := false
in asyncRstsl
Definition: RstSync.vhd:35
in clksl
Definition: RstSync.vhd:34
RST_POLARITY_Gsl := '1'
TPD_Gtime := 1 ns
in rstsl :=not RST_POLARITY_G
TPD_Gtime := 1 ns
Definition: RstSync.vhd:27
BUFR_CLK_DIV_Gnatural := 8
in bootAddressslv( 31 downto 0) := X"00000000"
std_logic_vector slv
Definition: StdRtlPkg.vhd:29