SURF  1.0
Iprog7SeriesCore.vhd
Go to the documentation of this file.
1 -------------------------------------------------------------------------------
2 -- File : Iprog7SeriesCore.vhd
3 -- Company : SLAC National Accelerator Laboratory
4 -- Created : 2015-09-09
5 -- Last update: 2015-09-10
6 -------------------------------------------------------------------------------
7 -- Description: Wrapper for Xilinx 7-Series IPROG CMD
8 -------------------------------------------------------------------------------
9 -- This file is part of 'SLAC Firmware Standard Library'.
10 -- It is subject to the license terms in the LICENSE.txt file found in the
11 -- top-level directory of this distribution and at:
12 -- https://confluence.slac.stanford.edu/display/ppareg/LICENSE.html.
13 -- No part of 'SLAC Firmware Standard Library', including this file,
14 -- may be copied, modified, propagated, or distributed except according to
15 -- the terms contained in the LICENSE.txt file.
16 -------------------------------------------------------------------------------
17 
18 library ieee;
19 use ieee.std_logic_1164.all;
20 use ieee.std_logic_arith.all;
21 use ieee.std_logic_unsigned.all;
22 
23 use work.StdRtlPkg.all;
24 
25 --! @see entity
26  --! @ingroup xilinx_7Series_general
28  generic (
29  TPD_G : time := 1 ns;
30  SYNC_RELOAD_G : boolean := true);
31  port (
32  -- Can be asynchronous if SYNC_RELOAD_G=false
33  reload : in sl;
34  reloadAddr : in slv(31 downto 0) := X"00000000";
35 
36  icapClk : in sl;
37  icapClkRst : in sl;
38  icapReq : out sl;
39  icapGrant : in sl := '1';
40  icapCsl : out sl;
41  icapRnw : out sl;
42  icapI : out slv(31 downto 0));
43 
44 end Iprog7SeriesCore;
45 
46 architecture rtl of Iprog7SeriesCore is
47 
48  constant BYPASS_SYNC_C : boolean := not SYNC_RELOAD_G;
49 
50  function selectMapBitSwapping (input : slv) return slv is
51  variable i : integer;
52  variable j : integer;
53  variable output : slv(0 to 31);
54  begin
55  for i in 0 to 3 loop
56  for j in 0 to 7 loop
57  output((8*i)+j) := input((8*i)+(7-j));
58  end loop;
59  end loop;
60  return output;
61  end function selectMapBitSwapping;
62 
63  type StateType is (IDLE_S, REQ_S, PROG_S);
64 
65  type RegType is record
66  state : StateType;
67  req : sl;
68  csl : sl;
69  rnw : sl;
70  cnt : slv(3 downto 0);
71  configData : slv(31 downto 0);
72  end record RegType;
73 
74  constant REG_INIT_C : RegType := (
75  state => IDLE_S,
76  req => '0',
77  csl => '1',
78  rnw => '1',
79  cnt => (others => '0'),
80  configData => (others => '0'));
81 
82  signal r : RegType := REG_INIT_C;
83  signal rin : RegType;
84 
85  signal icapReloadAddr : slv(31 downto 0);
86  signal icapReload : sl;
87 
88 begin
89 
90  -- Synchronize reload addr to icap clk
91  SynchronizerAddress_1 : entity work.SynchronizerVector
92  generic map (
93  TPD_G => TPD_G,
94  BYPASS_SYNC_G => BYPASS_SYNC_C,
95  STAGES_G => 2,
96  WIDTH_G => 32)
97  port map (
98  clk => icapClk,
99  rst => icapClkRst,
100  dataIn => reloadAddr,
101  dataOut => icapReloadAddr);
102 
103  -- Capture edge of start on icapClk
104  SynchronizerStart_1 : entity work.SynchronizerEdge
105  generic map (
106  TPD_G => TPD_G,
107  STAGES_G => 3)
108  port map (
109  clk => icapClk,
110  rst => icapClkRst,
111  dataIn => reload,
112  risingEdge => icapReload);
113 
114  comb : process (icapClkRst, icapGrant, icapReload, icapReloadAddr, r) is
115  variable v : RegType;
116  begin
117  v := r;
118 
119  case (r.state) is
120  when IDLE_S =>
121  v.csl := '1';
122  v.rnw := '1';
123  v.cnt := (others => '0');
124  if (icapReload = '1') then
125  if (icapGrant = '1') then
126  v.state := PROG_S;
127  else
128  v.state := REQ_S;
129  end if;
130  v.req := '1';
131  end if;
132 
133  when REQ_S =>
134  -- Wait to be granted access to the ICAP
135  if (icapGrant = '1') then
136  v.state := PROG_S;
137  end if;
138 
139  when PROG_S =>
140  v.csl := '0';
141  v.rnw := '0';
142  v.cnt := r.cnt + 1;
143  case (r.cnt) is
144  when X"0" =>
145  --Sync Word
146  v.configData := selectMapBitSwapping(X"AA995566");
147  when X"1" =>
148  --Type 1 NO OP
149  v.configData := selectMapBitSwapping(X"20000000");
150  when X"2" =>
151  --Type 1 Write 1 Words to WBSTAR
152  v.configData := selectMapBitSwapping(X"30020001");
153  when X"3" =>
154  --Warm Boot Start Address (Load the Desired Address)
155  v.configData := selectMapBitSwapping(bitReverse(icapReloadAddr));
156  when X"4" =>
157  --Type 1 Write 1 Words to CMD
158  v.configData := selectMapBitSwapping(X"30008001");
159  when X"5" =>
160  --IPROG Command
161  v.configData := selectMapBitSwapping(X"0000000F");
162  when X"6" =>
163  --Type 1 NO OP
164  v.configData := selectMapBitSwapping(X"20000000");
165  v.state := IDLE_S;
166  when others => null;
167  end case;
168 
169  when others => null;
170  end case;
171 
172  if (icapClkRst = '1') then
173  v := REG_INIT_C;
174  end if;
175 
176  rin <= v;
177 
178  icapRnw <= r.rnw;
179  icapCsl <= r.csl;
180  icapI <= r.configData;
181  icapReq <= r.req;
182 
183  end process comb;
184 
185  seq : process (icapClk) is
186  begin
187  if (rising_edge(icapClk)) then
188  r <= rin after TPD_G;
189  end if;
190  end process seq;
191 
192 end architecture rtl;
_library_ ieeeieee
std_logic sl
Definition: StdRtlPkg.vhd:28
BYPASS_SYNC_Gboolean := false
in dataInslv( WIDTH_G- 1 downto 0)
out icapIslv( 31 downto 0)
in reloadAddrslv( 31 downto 0) := X"00000000"
SYNC_RELOAD_Gboolean := true
in icapGrantsl := '1'
in rstsl :=not RST_POLARITY_G
out dataOutslv( WIDTH_G- 1 downto 0)
STAGES_Gpositive := 3
in rstsl :=not RST_POLARITY_G
std_logic_vector slv
Definition: StdRtlPkg.vhd:29