SURF  1.0
TenGigEthReg.vhd
Go to the documentation of this file.
1 -------------------------------------------------------------------------------
2 -- File : TenGigEthReg.vhd
3 -- Company : SLAC National Accelerator Laboratory
4 -- Created : 2015-02-20
5 -- Last update: 2016-10-06
6 -------------------------------------------------------------------------------
7 -- Description: AXI-Lite 10GbE 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.TenGigEthPkg.all;
26 
27 --! @see entity
28  --! @ingroup ethernet_TenGigEthCore_core
29 entity TenGigEthReg 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 TenGigEthConfig;
48 end TenGigEthReg;
49 
50 architecture rtl of TenGigEthReg 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 : TenGigEthConfig;
61  end record RegType;
62 
63  constant REG_INIT_C : RegType := (
64  hardRst => '0',
65  cntRst => '1',
66  rollOverEn => (others => '0'),
67  config => TEN_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 
78 begin
79 
80  GEN_BYPASS : if (EN_AXI_REG_G = false) generate
81 
82  U_AxiLiteEmpty : entity work.AxiLiteEmpty
83  generic map (
84  TPD_G => TPD_G,
86  port map (
87  axiClk => clk,
88  axiClkRst => rst,
93 
94  Sync_Config : entity work.SynchronizerVector
95  generic map (
96  TPD_G => TPD_G,
97  WIDTH_G => 48)
98  port map (
99  clk => clk,
100  dataIn => localMac,
101  dataOut => localMacSync);
102 
103  process (localMacSync) is
104  variable retVar : TenGigEthConfig;
105  begin
106  retVar := TEN_GIG_ETH_CONFIG_INIT_C;
107  retVar.macConfig.macAddress := localMacSync;
108  config <= retVar;
109  end process;
110 
111  end generate;
112 
113  GEN_REG : if (EN_AXI_REG_G = true) generate
114 
115  SyncStatusVec_Inst : entity work.SyncStatusVector
116  generic map (
117  TPD_G => TPD_G,
118  OUT_POLARITY_G => '1',
119  CNT_RST_EDGE_G => false,
120  COMMON_CLK_G => true,
121  CNT_WIDTH_G => 32,
122  WIDTH_G => STATUS_SIZE_C)
123  port map (
124  -- Input Status bit Signals (wrClk domain)
125  statusIn(0) => status.phyReady,
126  statusIn(1) => status.macStatus.rxPauseCnt,
127  statusIn(2) => status.macStatus.txPauseCnt,
128  statusIn(3) => status.macStatus.rxCountEn,
129  statusIn(4) => status.macStatus.rxOverFlow,
130  statusIn(5) => status.macStatus.rxCrcErrorCnt,
131  statusIn(6) => status.macStatus.txCountEn,
132  statusIn(7) => status.macStatus.txUnderRunCnt,
133  statusIn(8) => status.macStatus.txNotReadyCnt,
134  statusIn(9) => status.txDisable,
135  statusIn(10) => status.sigDet,
136  statusIn(11) => status.txFault,
137  statusIn(12) => status.gtTxRst,
138  statusIn(13) => status.gtRxRst,
139  statusIn(14) => status.rstCntDone,
140  statusIn(15) => status.qplllock,
141  statusIn(16) => status.txRstdone,
142  statusIn(17) => status.rxRstdone,
143  statusIn(18) => status.txUsrRdy,
144  statusIn(31 downto 19) => (others => '0'),
145  -- Output Status bit Signals (rdClk domain)
146  statusOut => statusOut,
147  -- Status Bit Counters Signals (rdClk domain)
148  cntRstIn => r.cntRst,
149  rollOverEnIn => r.rollOverEn,
150  cntOut => cntOut,
151  -- Clocks and Reset Ports
152  wrClk => clk,
153  rdClk => clk);
154 
155  -------------------------------
156  -- Configuration Register
157  -------------------------------
158  comb : process (axiReadMaster, axiWriteMaster, cntOut, localMac, r, rst, status, statusOut) is
159  variable v : RegType;
160  variable regCon : AxiLiteEndPointType;
161  variable rdPntr : natural;
162  begin
163  -- Latch the current value
164  v := r;
165 
166  -- Determine the transaction type
167  axiSlaveWaitTxn(regCon, axiWriteMaster, axiReadMaster, v.axiWriteSlave, v.axiReadSlave);
168 
169  -- Reset strobe signals
170  v.cntRst := '0';
171  v.config.softRst := '0';
172  v.hardRst := '0';
173 
174  -- Calculate the read pointer
175  rdPntr := conv_integer(axiReadMaster.araddr(9 downto 2));
176 
177  -- Register Mapping
178  axiSlaveRegisterR(regCon, "0000--------", 0, muxSlVectorArray(cntOut, rdPntr));
179  axiSlaveRegisterR(regCon, x"100", 0, statusOut);
180  --axiSlaveRegisterR(regCon, x"104", 0, status.macStatus.rxPauseValue);
181  axiSlaveRegisterR(regCon, x"108", 0, status.core_status);
182 
183  axiSlaveRegister(regCon, x"200", 0, v.config.macConfig.macAddress(31 downto 0));
184  axiSlaveRegister(regCon, x"204", 0, v.config.macConfig.macAddress(47 downto 32));
185  --axiSlaveRegister(regCon, x"208", 0, v.config.macConfig.byteSwap);
186 
187  --axiSlaveRegister(regCon, x"210", 0, v.config.macConfig.txShift);
188  --axiSlaveRegister(regCon, x"214", 0, v.config.macConfig.txShiftEn);
189  --axiSlaveRegister(regCon, x"218", 0, v.config.macConfig.interFrameGap);
190  axiSlaveRegister(regCon, x"21C", 0, v.config.macConfig.pauseTime);
191 
192  --axiSlaveRegister(regCon, x"220", 0, v.config.macConfig.rxShift);
193  --axiSlaveRegister(regCon, x"224", 0, v.config.macConfig.rxShiftEn);
194  axiSlaveRegister(regCon, x"228", 0, v.config.macConfig.filtEnable);
195  axiSlaveRegister(regCon, x"22C", 0, v.config.macConfig.pauseEnable);
196 
197  axiSlaveRegister(regCon, x"230", 0, v.config.pma_pmd_type);
198  axiSlaveRegister(regCon, x"234", 0, v.config.pma_loopback);
199  axiSlaveRegister(regCon, x"238", 0, v.config.pma_reset);
200  axiSlaveRegister(regCon, x"23C", 0, v.config.pcs_loopback);
201  axiSlaveRegister(regCon, x"240", 0, v.config.pcs_reset);
202 
203  axiSlaveRegister(regCon, x"F00", 0, v.rollOverEn);
204  axiSlaveRegister(regCon, x"FF4", 0, v.cntRst);
205  axiSlaveRegister(regCon, x"FF8", 0, v.config.softRst);
206  axiSlaveRegister(regCon, x"FFC", 0, v.hardRst);
207 
208  -- Closeout the transaction
209  axiSlaveDefault(regCon, v.axiWriteSlave, v.axiReadSlave, AXI_ERROR_RESP_G);
210 
211  -- Synchronous Reset
212  if (rst = '1') or (v.hardRst = '1') then
213  v.cntRst := '1';
214  v.rollOverEn := (others => '0');
216  if (rst = '1') then
219  end if;
220  end if;
221 
222  -- Update the MAC address
223  v.config.macConfig.macAddress := localMac;
224 
225  -- Register the variable for next clock cycle
226  rin <= v;
227 
228  -- Outputs
231  config <= r.config;
232 
233  end process comb;
234 
235  seq : process (clk) is
236  begin
237  if rising_edge(clk) then
238  r <= rin after TPD_G;
239  end if;
240  end process seq;
241 
242  end generate;
243 
244 end rtl;
in axiReadMasterAxiLiteReadMasterType
EN_AXI_REG_Gboolean := false
AxiLiteWriteMasterType
Definition: AxiLitePkg.vhd:111
std_logic sl
Definition: StdRtlPkg.vhd:28
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
out axiReadSlaveAxiLiteReadSlaveType
slv( 7 downto 0) core_status
EthMacConfigType macConfig
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 statusTenGigEthStatus
TPD_Gtime := 1 ns
CNT_WIDTH_Gpositive := 32
slv( 1 downto 0) := "10" AXI_RESP_SLVERR_C
Definition: AxiLitePkg.vhd:36
slv( 2 downto 0) pma_pmd_type
out axiReadSlaveAxiLiteReadSlaveType
in rollOverEnInslv( WIDTH_G- 1 downto 0) :=( others => '0')
AxiLiteReadMasterType
Definition: AxiLitePkg.vhd:59
out axiWriteSlaveAxiLiteWriteSlaveType
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)
AXI_ERROR_RESP_Gslv( 1 downto 0) := AXI_RESP_SLVERR_C
in axiWriteMasterAxiLiteWriteMasterType
CNT_RST_EDGE_Gboolean := true
out configTenGigEthConfig
_library_ ieeeieee
AxiLiteReadSlaveType
Definition: AxiLitePkg.vhd:85
in axiWriteMasterAxiLiteWriteMasterType
in localMacslv( 47 downto 0) := MAC_ADDR_INIT_C
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
TPD_Gtime := 1 ns
TenGigEthConfig :=(softRst => '0',macConfig => ETH_MAC_CONFIG_INIT_C,pma_pmd_type => "111",pma_loopback => '0',pma_reset => '0',pcs_loopback => '0',pcs_reset => '0') TEN_GIG_ETH_CONFIG_INIT_C
std_logic_vector slv
Definition: StdRtlPkg.vhd:29