SURF  1.0
XauiReg.vhd
Go to the documentation of this file.
1 -------------------------------------------------------------------------------
2 -- File : XauiReg.vhd
3 -- Company : SLAC National Accelerator Laboratory
4 -- Created : 2015-04-07
5 -- Last update: 2016-10-06
6 -------------------------------------------------------------------------------
7 -- Description: AXI-Lite XAUI Register Interface
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_unsigned.all;
21 use ieee.std_logic_arith.all;
22 
23 use work.StdRtlPkg.all;
24 use work.AxiLitePkg.all;
25 use work.XauiPkg.all;
26 
27 --! @see entity
28  --! @ingroup ethernet_XauiCore_core
29 entity XauiReg is
30  generic (
31  TPD_G : time := 1 ns;
32  EN_AXI_REG_G : boolean := false;
34  port (
35  -- Local Configurations
36  localMac : in slv(47 downto 0) := MAC_ADDR_INIT_C;
37  -- AXI-Lite Register Interface
38  axiClk : in sl;
39  axiRst : in sl;
44  -- Configuration and Status Interface
45  phyClk : in sl;
46  phyRst : in sl;
47  config : out XauiConfig;
49 end XauiReg;
50 
51 architecture rtl of XauiReg is
52 
53  constant STATUS_SIZE_C : positive := 32;
54 
55  type RegType is record
56  hardRst : sl;
57  cntRst : sl;
58  rollOverEn : slv(STATUS_SIZE_C-1 downto 0);
59  config : XauiConfig;
62  end record RegType;
63 
64  constant REG_INIT_C : RegType := (
65  hardRst => '0',
66  cntRst => '1',
67  rollOverEn => (others => '0'),
68  config => XAUI_CONFIG_INIT_C,
71 
72  signal r : RegType := REG_INIT_C;
73  signal rin : RegType;
74 
75  signal statusOut : slv(STATUS_SIZE_C-1 downto 0);
76  signal cntOut : SlVectorArray(STATUS_SIZE_C-1 downto 0, 31 downto 0);
77  signal localMacSync : slv(47 downto 0);
78 
79 begin
80 
81  GEN_BYPASS : if (EN_AXI_REG_G = false) generate
82 
83  U_AxiLiteEmpty : entity work.AxiLiteEmpty
84  generic map (
85  TPD_G => TPD_G,
87  port map (
88  axiClk => axiClk,
89  axiClkRst => axiRst,
94 
95  Sync_Config : entity work.SynchronizerVector
96  generic map (
97  TPD_G => TPD_G,
98  WIDTH_G => 48)
99  port map (
100  clk => phyClk,
101  dataIn => localMac,
102  dataOut => localMacSync);
103 
104  process (localMacSync) is
105  variable retVar : XauiConfig;
106  begin
107  retVar := XAUI_CONFIG_INIT_C;
108  retVar.macConfig.macAddress := localMacSync;
109  config <= retVar;
110  end process;
111 
112  end generate;
113 
114  GEN_REG : if (EN_AXI_REG_G = true) generate
115 
116  SyncStatusVec_Inst : entity work.SyncStatusVector
117  generic map (
118  TPD_G => TPD_G,
119  OUT_POLARITY_G => '1',
120  CNT_RST_EDGE_G => true,
121  COMMON_CLK_G => false,
122  CNT_WIDTH_G => 32,
123  WIDTH_G => STATUS_SIZE_C)
124  port map (
125  -- Input Status bit Signals (wrClk domain)
126  statusIn(0) => status.phyReady,
127  statusIn(1) => status.macStatus.rxPauseCnt,
128  statusIn(2) => status.macStatus.txPauseCnt,
129  statusIn(3) => status.macStatus.rxCountEn,
130  statusIn(4) => status.macStatus.rxOverFlow,
131  statusIn(5) => status.macStatus.rxCrcErrorCnt,
132  statusIn(6) => status.macStatus.txCountEn,
133  statusIn(7) => status.macStatus.txUnderRunCnt,
134  statusIn(8) => status.macStatus.txNotReadyCnt,
135  statusIn(9) => status.areset,
136  statusIn(10) => status.clkLock,
137  statusIn(18 downto 11) => status.statusVector,
138  statusIn(24 downto 19) => status.debugVector,
139  statusIn(31 downto 25) => (others => '0'),
140  -- Output Status bit Signals (rdClk domain)
141  statusOut => statusOut,
142  -- Status Bit Counters Signals (rdClk domain)
143  cntRstIn => r.cntRst,
144  rollOverEnIn => r.rollOverEn,
145  cntOut => cntOut,
146  -- Clocks and Reset Ports
147  wrClk => phyClk,
148  rdClk => axiClk);
149 
150  -------------------------------
151  -- Configuration Register
152  -------------------------------
153  comb : process (axiReadMaster, axiRst, axiWriteMaster, cntOut, localMac, r, statusOut) is
154  variable v : RegType;
155  variable regCon : AxiLiteEndPointType;
156  variable rdPntr : natural;
157  begin
158  -- Latch the current value
159  v := r;
160 
161  -- Determine the transaction type
162  axiSlaveWaitTxn(regCon, axiWriteMaster, axiReadMaster, v.axiWriteSlave, v.axiReadSlave);
163 
164  -- Reset strobe signals
165  v.cntRst := '0';
166  v.config.softRst := '0';
167  v.hardRst := '0';
168 
169  -- Calculate the read pointer
170  rdPntr := conv_integer(axiReadMaster.araddr(9 downto 2));
171 
172  -- Register Mapping
173  axiSlaveRegisterR(regCon, "0000--------", 0, muxSlVectorArray(cntOut, rdPntr));
174  axiSlaveRegisterR(regCon, x"100", 0, statusOut);
175  --axiSlaveRegisterR(regCon, x"104", 0, status.macStatus.rxPauseValue);
176 
177  axiSlaveRegister(regCon, x"200", 0, v.config.macConfig.macAddress(31 downto 0));
178  axiSlaveRegister(regCon, x"204", 0, v.config.macConfig.macAddress(47 downto 32));
179  --axiSlaveRegister(regCon, x"208", 0, v.config.macConfig.byteSwap);
180 
181  --axiSlaveRegister(regCon, x"210", 0, v.config.macConfig.txShift);
182  --axiSlaveRegister(regCon, x"214", 0, v.config.macConfig.txShiftEn);
183  --axiSlaveRegister(regCon, x"218", 0, v.config.macConfig.interFrameGap);
184  axiSlaveRegister(regCon, x"21C", 0, v.config.macConfig.pauseTime);
185 
186  --axiSlaveRegister(regCon, x"220", 0, v.config.macConfig.rxShift);
187  --axiSlaveRegister(regCon, x"224", 0, v.config.macConfig.rxShiftEn);
188  axiSlaveRegister(regCon, x"228", 0, v.config.macConfig.filtEnable);
189  axiSlaveRegister(regCon, x"22C", 0, v.config.macConfig.pauseEnable);
190 
191  axiSlaveRegister(regCon, x"230", 0, v.config.configVector);
192 
193  axiSlaveRegister(regCon, x"F00", 0, v.rollOverEn);
194  axiSlaveRegister(regCon, x"FF4", 0, v.cntRst);
195  axiSlaveRegister(regCon, x"FF8", 0, v.config.softRst);
196  axiSlaveRegister(regCon, x"FFC", 0, v.hardRst);
197 
198  -- Closeout the transaction
199  axiSlaveDefault(regCon, v.axiWriteSlave, v.axiReadSlave, AXI_ERROR_RESP_G);
200 
201  -- Synchronous Reset
202  if (axiRst = '1') or (v.hardRst = '1') then
203  v.cntRst := '1';
204  v.rollOverEn := (others => '0');
206  if (axiRst = '1') then
209  end if;
210  end if;
211 
212  -- Update the MAC address
213  v.config.macConfig.macAddress := localMac;
214 
215  -- Register the variable for next clock cycle
216  rin <= v;
217 
218  -- Outputs
221 
222  end process comb;
223 
224  seq : process (axiClk) is
225  begin
226  if rising_edge(axiClk) then
227  r <= rin after TPD_G;
228  end if;
229  end process seq;
230 
231  -- There is a Synchronizer one layer up for software reset
232  config.softRst <= r.config.softRst;
233 
234  SyncIn_macAddress : entity work.SynchronizerFifo
235  generic map (
236  TPD_G => TPD_G,
237  DATA_WIDTH_G => 48)
238  port map (
239  wr_clk => axiClk,
240  din => r.config.macConfig.macAddress,
241  rd_clk => phyClk,
242  dout => config.macConfig.macAddress);
243 
244  SyncIn_pauseTime : entity work.SynchronizerFifo
245  generic map (
246  TPD_G => TPD_G,
247  DATA_WIDTH_G => 16)
248  port map (
249  wr_clk => axiClk,
250  din => r.config.macConfig.pauseTime,
251  rd_clk => phyClk,
252  dout => config.macConfig.pauseTime);
253 
254  SyncIn_macConfig : entity work.SynchronizerVector
255  generic map (
256  TPD_G => TPD_G,
257  STAGES_G => 2,
258  WIDTH_G => 5)
259  port map (
260  clk => phyClk,
261  -- Input Data
262  dataIn(0) => r.config.macConfig.filtEnable,
263  dataIn(1) => r.config.macConfig.pauseEnable,
264  dataIn(2) => r.config.macConfig.ipCsumEn,
265  dataIn(3) => r.config.macConfig.tcpCsumEn,
266  dataIn(4) => r.config.macConfig.udpCsumEn,
267  -- Output Data
268  dataOut(0) => config.macConfig.filtEnable,
269  dataOut(1) => config.macConfig.pauseEnable,
270  dataOut(2) => config.macConfig.ipCsumEn,
271  dataOut(3) => config.macConfig.tcpCsumEn,
272  dataOut(4) => config.macConfig.udpCsumEn);
273 
274  SyncIn_configVector : entity work.SynchronizerFifo
275  generic map (
276  TPD_G => TPD_G,
277  DATA_WIDTH_G => 7)
278  port map (
279  wr_clk => axiClk,
280  din => r.config.configVector,
281  rd_clk => phyClk,
282  dout => config.configVector);
283 
284  end generate;
285 
286 end rtl;
EthMacConfigType macConfig
Definition: XauiPkg.vhd:33
in statusXauiStatus
Definition: XauiReg.vhd:48
in localMacslv( 47 downto 0) := MAC_ADDR_INIT_C
Definition: XauiReg.vhd:36
in phyRstsl
Definition: XauiReg.vhd:46
AxiLiteWriteMasterType
Definition: AxiLitePkg.vhd:111
in axiRstsl
Definition: XauiReg.vhd:39
std_logic sl
Definition: StdRtlPkg.vhd:28
in phyClksl
Definition: XauiReg.vhd:45
out configXauiConfig
Definition: XauiReg.vhd:47
in dinslv( DATA_WIDTH_G- 1 downto 0)
AXI_ERROR_RESP_Gslv( 1 downto 0) := AXI_RESP_SLVERR_C
Definition: XauiReg.vhd:33
out axiWriteSlaveAxiLiteWriteSlaveType
in axiClksl
Definition: XauiReg.vhd:38
array(natural range <> ,natural range <> ) of sl SlVectorArray
Definition: StdRtlPkg.vhd:669
AXI_ERROR_RESP_Gslv( 1 downto 0) := AXI_RESP_OK_C
WIDTH_Gpositive := 16
XauiConfig
Definition: XauiPkg.vhd:31
COMMON_CLK_Gboolean := false
in dataInslv( WIDTH_G- 1 downto 0)
out cntOutSlVectorArray ( WIDTH_G- 1 downto 0, CNT_WIDTH_G- 1 downto 0)
in axiReadMasterAxiLiteReadMasterType
Definition: XauiReg.vhd:40
out doutslv( DATA_WIDTH_G- 1 downto 0)
TPD_Gtime := 1 ns
Definition: XauiReg.vhd:31
out axiReadSlaveAxiLiteReadSlaveType
Definition: XauiReg.vhd:41
_library_ ieeeieee
Definition: XauiPkg.vhd:18
slv( 6 downto 0) configVector
Definition: XauiPkg.vhd:34
TPD_Gtime := 1 ns
CNT_WIDTH_Gpositive := 32
slv( 1 downto 0) := "10" AXI_RESP_SLVERR_C
Definition: AxiLitePkg.vhd:36
XauiConfig :=(softRst => '0',macConfig => ETH_MAC_CONFIG_INIT_C,configVector =>( others => '0')) XAUI_CONFIG_INIT_C
Definition: XauiPkg.vhd:36
out axiReadSlaveAxiLiteReadSlaveType
in rollOverEnInslv( WIDTH_G- 1 downto 0) :=( others => '0')
AxiLiteReadMasterType
Definition: AxiLitePkg.vhd:59
in axiReadMasterAxiLiteReadMasterType
AxiLiteReadSlaveType :=(arready => '0',rdata =>( others => '0'),rresp =>( others => '0'),rvalid => '0') AXI_LITE_READ_SLAVE_INIT_C
Definition: AxiLitePkg.vhd:95
out dataOutslv( WIDTH_G- 1 downto 0)
XauiStatus
Definition: XauiPkg.vhd:41
CNT_RST_EDGE_Gboolean := true
EN_AXI_REG_Gboolean := false
Definition: XauiReg.vhd:32
sl softRst
Definition: XauiPkg.vhd:32
AxiLiteReadSlaveType
Definition: AxiLitePkg.vhd:85
in axiWriteMasterAxiLiteWriteMasterType
in axiWriteMasterAxiLiteWriteMasterType
Definition: XauiReg.vhd:42
slv( 31 downto 0) araddr
Definition: AxiLitePkg.vhd:61
out statusOutslv( WIDTH_G- 1 downto 0)
AxiLiteWriteSlaveType :=(awready => '0',wready => '0',bresp =>( others => '0'),bvalid => '0') AXI_LITE_WRITE_SLAVE_INIT_C
Definition: AxiLitePkg.vhd:156
DATA_WIDTH_Ginteger range 1 to ( 2** 24):= 16
std_logic_vector slv
Definition: StdRtlPkg.vhd:29
out axiWriteSlaveAxiLiteWriteSlaveType
Definition: XauiReg.vhd:43