SURF  1.0
GigEthReg.vhd
Go to the documentation of this file.
1 -------------------------------------------------------------------------------
2 -- File : GigEthReg.vhd
3 -- Company : SLAC National Accelerator Laboratory
4 -- Created : 2015-02-20
5 -- Last update: 2017-05-12
6 -------------------------------------------------------------------------------
7 -- Description: AXI-Lite 1GbE 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.GigEthPkg.all;
26 
27 --! @see entity
28  --! @ingroup ethernet_GigEthCore_core
29 entity GigEthReg 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  -- Clocks and resets
38  clk : in sl;
39  rst : in sl;
40  -- AXI-Lite Register Interface
45  -- Configuration and Status Interface
46  config : out GigEthConfigType;
48 end GigEthReg;
49 
50 architecture rtl of GigEthReg is
51 
52  constant STATUS_SIZE_C : positive := 32;
53 
54  type RegType is record
55  hardRst : sl;
56  cntRst : sl;
57  rollOverEn : slv(STATUS_SIZE_C-1 downto 0);
58  config : GigEthConfigType;
61  end record RegType;
62 
63  constant REG_INIT_C : RegType := (
64  hardRst => '0',
65  cntRst => '1',
66  rollOverEn => (others => '0'),
67  config => GIG_ETH_CONFIG_INIT_C,
70 
71  signal r : RegType := REG_INIT_C;
72  signal rin : RegType;
73 
74  signal statusOut : slv(STATUS_SIZE_C-1 downto 0);
75  signal cntOut : SlVectorArray(STATUS_SIZE_C-1 downto 0, 31 downto 0);
76  signal localMacSync : slv(47 downto 0);
77  signal wdtRst : sl;
78 
79 begin
80 
81  U_WatchDogRst : entity work.WatchDogRst
82  generic map(
83  TPD_G => TPD_G,
84  DURATION_G => getTimeRatio(125.0E+6, 0.5))
85  port map (
86  clk => clk,
87  monIn => status.phyReady,
88  rstOut => wdtRst);
89 
90  GEN_BYPASS : if (EN_AXI_REG_G = false) generate
91 
92  U_AxiLiteEmpty : entity work.AxiLiteEmpty
93  generic map (
94  TPD_G => TPD_G,
96  port map (
97  axiClk => clk,
98  axiClkRst => rst,
103 
104  Sync_Config : entity work.SynchronizerVector
105  generic map (
106  TPD_G => TPD_G,
107  WIDTH_G => 48)
108  port map (
109  clk => clk,
110  dataIn => localMac,
111  dataOut => localMacSync);
112 
113  process (localMacSync, wdtRst) is
114  variable retVar : GigEthConfigType;
115  begin
116  retVar := GIG_ETH_CONFIG_INIT_C;
117  retVar.macConfig.macAddress := localMacSync;
118  retVar.softRst := wdtRst;
119  config <= retVar;
120  end process;
121 
122  end generate;
123 
124  GEN_REG : if (EN_AXI_REG_G = true) generate
125 
126  SyncStatusVec_Inst : entity work.SyncStatusVector
127  generic map (
128  TPD_G => TPD_G,
129  OUT_POLARITY_G => '1',
130  CNT_RST_EDGE_G => false,
131  COMMON_CLK_G => true,
132  CNT_WIDTH_G => 32,
133  WIDTH_G => STATUS_SIZE_C)
134  port map (
135  -- Input Status bit Signals (wrClk domain)
136  statusIn(0) => status.phyReady,
137  statusIn(1) => status.macStatus.rxPauseCnt,
138  statusIn(2) => status.macStatus.txPauseCnt,
139  statusIn(3) => status.macStatus.rxCountEn,
140  statusIn(4) => status.macStatus.rxOverFlow,
141  statusIn(5) => status.macStatus.rxCrcErrorCnt,
142  statusIn(6) => status.macStatus.txCountEn,
143  statusIn(7) => status.macStatus.txUnderRunCnt,
144  statusIn(8) => status.macStatus.txNotReadyCnt,
145  statusIn(31 downto 9) => (others => '0'),
146  -- Output Status bit Signals (rdClk domain)
147  statusOut => statusOut,
148  -- Status Bit Counters Signals (rdClk domain)
149  cntRstIn => r.cntRst,
150  rollOverEnIn => r.rollOverEn,
151  cntOut => cntOut,
152  -- Clocks and Reset Ports
153  wrClk => clk,
154  rdClk => clk);
155 
156  -------------------------------
157  -- Configuration Register
158  -------------------------------
159  comb : process (axiReadMaster, axiWriteMaster, cntOut, localMac, r, rst,
160  status, statusOut, wdtRst) is
161  variable v : RegType;
162  variable regCon : AxiLiteEndPointType;
163  variable rdPntr : natural;
164  begin
165  -- Latch the current value
166  v := r;
167 
168  -- Determine the transaction type
169  axiSlaveWaitTxn(regCon, axiWriteMaster, axiReadMaster, v.axiWriteSlave, v.axiReadSlave);
170 
171  -- Reset strobe signals
172  v.cntRst := '0';
173  v.hardRst := '0';
174  v.config.softRst := wdtRst;
175 
176  -- Calculate the read pointer
177  rdPntr := conv_integer(axiReadMaster.araddr(9 downto 2));
178 
179  -- Register Mapping
180  axiSlaveRegisterR(regCon, "0000--------", 0, muxSlVectorArray(cntOut, rdPntr));
181  axiSlaveRegisterR(regCon, x"100", 0, statusOut);
182  --axiSlaveRegisterR(regCon,x"104", 0, status.macStatus.rxPauseValue);
183  axiSlaveRegisterR(regCon, x"108", 0, status.coreStatus);
184 
185  axiSlaveRegister(regCon, x"200", 0, v.config.macConfig.macAddress(31 downto 0));
186  axiSlaveRegister(regCon, x"204", 0, v.config.macConfig.macAddress(47 downto 32));
187  --axiSlaveRegister(regCon,x"208", 0, v.config.macConfig.byteSwap);
188 
189  --axiSlaveRegister(regCon,x"210", 0, v.config.macConfig.txShift);
190  --axiSlaveRegister(regCon,x"214", 0, v.config.macConfig.txShiftEn);
191  --axiSlaveRegister(regCon, x"218", 0, v.config.macConfig.interFrameGap);
192  axiSlaveRegister(regCon, x"21C", 0, v.config.macConfig.pauseTime);
193 
194  --axiSlaveRegister(regCon,x"220", 0, v.config.macConfig.rxShift);
195  --axiSlaveRegister(regCon,x"224", 0, v.config.macConfig.rxShiftEn);
196  axiSlaveRegister(regCon, x"228", 0, v.config.macConfig.filtEnable);
197  axiSlaveRegister(regCon, x"22C", 0, v.config.macConfig.pauseEnable);
198 
199  axiSlaveRegister(regCon, x"F00", 0, v.rollOverEn);
200  axiSlaveRegister(regCon, x"FF4", 0, v.cntRst);
201  axiSlaveRegister(regCon, x"FF8", 0, v.config.softRst);
202  axiSlaveRegister(regCon, x"FFC", 0, v.hardRst);
203 
204  -- Closeout the transaction
205  axiSlaveDefault(regCon, v.axiWriteSlave, v.axiReadSlave, AXI_ERROR_RESP_G);
206 
207  -- Synchronous Reset
208  if (rst = '1') or (v.hardRst = '1') then
209  v.cntRst := '1';
210  v.rollOverEn := (others => '0');
212  if (rst = '1') then
215  end if;
216  end if;
217 
218  -- Update the MAC address
219  v.config.macConfig.macAddress := localMac;
220 
221  -- Register the variable for next clock cycle
222  rin <= v;
223 
224  -- Outputs
227  config <= r.config;
228 
229  end process comb;
230 
231  seq : process (clk) is
232  begin
233  if rising_edge(clk) then
234  r <= rin after TPD_G;
235  end if;
236  end process seq;
237 
238  end generate;
239 
240 end rtl;
EN_AXI_REG_Gboolean := false
Definition: GigEthReg.vhd:32
in statusGigEthStatusType
Definition: GigEthReg.vhd:47
out axiReadSlaveAxiLiteReadSlaveType
Definition: GigEthReg.vhd:42
in rstsl
Definition: GigEthReg.vhd:39
out rstOutsl
Definition: WatchDogRst.vhd:37
TPD_Gtime := 1 ns
Definition: WatchDogRst.vhd:29
in axiWriteMasterAxiLiteWriteMasterType
Definition: GigEthReg.vhd:43
AxiLiteWriteMasterType
Definition: AxiLitePkg.vhd:111
std_logic sl
Definition: StdRtlPkg.vhd:28
DURATION_Gnatural range 0 to (( 2** 31)- 1):= 156250000
Definition: WatchDogRst.vhd:33
out axiWriteSlaveAxiLiteWriteSlaveType
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
COMMON_CLK_Gboolean := false
in dataInslv( WIDTH_G- 1 downto 0)
out cntOutSlVectorArray ( WIDTH_G- 1 downto 0, CNT_WIDTH_G- 1 downto 0)
TPD_Gtime := 1 ns
CNT_WIDTH_Gpositive := 32
slv( 1 downto 0) := "10" AXI_RESP_SLVERR_C
Definition: AxiLitePkg.vhd:36
EthMacConfigType macConfig
Definition: GigEthPkg.vhd:34
GigEthConfigType
Definition: GigEthPkg.vhd:31
out axiReadSlaveAxiLiteReadSlaveType
in rollOverEnInslv( WIDTH_G- 1 downto 0) :=( others => '0')
AxiLiteReadMasterType
Definition: AxiLitePkg.vhd:59
GigEthConfigType :=(softRst => '0',coreConfig => "00000",macConfig => ETH_MAC_CONFIG_INIT_C) GIG_ETH_CONFIG_INIT_C
Definition: GigEthPkg.vhd:36
in localMacslv( 47 downto 0) := MAC_ADDR_INIT_C
Definition: GigEthReg.vhd:36
in axiReadMasterAxiLiteReadMasterType
AxiLiteReadSlaveType :=(arready => '0',rdata =>( others => '0'),rresp =>( others => '0'),rvalid => '0') AXI_LITE_READ_SLAVE_INIT_C
Definition: AxiLitePkg.vhd:95
out configGigEthConfigType
Definition: GigEthReg.vhd:46
out dataOutslv( WIDTH_G- 1 downto 0)
slv( 15 downto 0) coreStatus
Definition: GigEthPkg.vhd:44
GigEthStatusType
Definition: GigEthPkg.vhd:41
CNT_RST_EDGE_Gboolean := true
AXI_ERROR_RESP_Gslv( 1 downto 0) := AXI_RESP_SLVERR_C
Definition: GigEthReg.vhd:33
in clksl
Definition: GigEthReg.vhd:38
AxiLiteReadSlaveType
Definition: AxiLitePkg.vhd:85
in axiReadMasterAxiLiteReadMasterType
Definition: GigEthReg.vhd:41
in axiWriteMasterAxiLiteWriteMasterType
slv( 31 downto 0) araddr
Definition: AxiLitePkg.vhd:61
_library_ ieeeieee
Definition: GigEthPkg.vhd:18
sl softRst
Definition: GigEthPkg.vhd:32
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
TPD_Gtime := 1 ns
Definition: GigEthReg.vhd:31
std_logic_vector slv
Definition: StdRtlPkg.vhd:29
out axiWriteSlaveAxiLiteWriteSlaveType
Definition: GigEthReg.vhd:44