SURF  1.0
Decoder8b10b.vhd
Go to the documentation of this file.
1 -------------------------------------------------------------------------------
2 -- File : Decoder8b10b.vhd
3 -- Company : SLAC National Accelerator Laboratory
4 -- Created : 2012-11-15
5 -- Last update: 2017-05-01
6 -------------------------------------------------------------------------------
7 -- Description: 8B10B Decoder Module
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 work.StdRtlPkg.all;
21 use work.Code8b10bPkg.all;
22 
23 --! @see entity
24  --! @ingroup base_general
25 entity Decoder8b10b is
26 
27  generic (
28  TPD_G : time := 1 ns;
29  NUM_BYTES_G : positive := 2;
30  RST_POLARITY_G : sl := '1';
31  RST_ASYNC_G : boolean := false);
32  port (
33  clk : in sl;
34  clkEn : in sl := '1'; -- Optional Clock Enable
35  rst : in sl := not RST_POLARITY_G; -- Optional Reset
36  validIn : in sl := '1';
37  dataIn : in slv(NUM_BYTES_G*10-1 downto 0);
38  dataOut : out slv(NUM_BYTES_G*8-1 downto 0);
39  dataKOut : out slv(NUM_BYTES_G-1 downto 0);
40  validOut : out sl;
41  codeErr : out slv(NUM_BYTES_G-1 downto 0);
42  dispErr : out slv(NUM_BYTES_G-1 downto 0));
43 
44 end entity Decoder8b10b;
45 
46 architecture rtl of Decoder8b10b is
47 
48  type RegType is record
49  runDisp : sl;
50  dataOut : slv(NUM_BYTES_G*8-1 downto 0);
51  dataKOut : slv(NUM_BYTES_G-1 downto 0);
52  validOut : sl;
53  codeErr : slv(NUM_BYTES_G-1 downto 0);
54  dispErr : slv(NUM_BYTES_G-1 downto 0);
55  end record RegType;
56 
57  constant REG_INIT_C : RegType := (
58  runDisp => '0',
59  dataOut => (others => '0'),
60  dataKOut => (others => '0'),
61  validOut => '0',
62  codeErr => (others => '0'),
63  dispErr => (others => '0'));
64 
65  signal r : RegType := REG_INIT_C;
66  signal rin : RegType;
67 
68 begin
69 
70  comb : process (dataIn, r, rst, validIn) is
71  variable v : RegType;
72  variable dispChainVar : sl;
73  begin
74  v := r;
75 
76  v.validOut := validIn;
77 
78  if (validIn = '1') then
79  dispChainVar := r.runDisp;
80  for i in 0 to NUM_BYTES_G-1 loop
81  decode8b10b(dataIn => dataIn(i*10+9 downto i*10),
82  dispIn => dispChainVar,
83  dataOut => v.dataOut(i*8+7 downto i*8),
84  dataKOut => v.dataKOut(i),
85  dispOut => dispChainVar,
86  codeErr => v.codeErr(i),
87  dispErr => v.dispErr(i));
88  end loop;
89  v.runDisp := dispChainVar;
90  end if;
91 
92  if (RST_ASYNC_G = false and rst = RST_POLARITY_G) then
93  v := REG_INIT_C;
94  end if;
95 
96  rin <= v;
97  dataOut <= r.dataOut;
98  dataKOut <= r.dataKOut;
99  validOut <= r.validOut;
100  codeErr <= r.codeErr;
101  dispErr <= r.dispErr;
102  end process comb;
103 
104  seq : process (clk, rst) is
105  begin
106  if (RST_ASYNC_G and rst = RST_POLARITY_G) then
107  r <= REG_INIT_C after TPD_G;
108  elsif (rising_edge(clk)) then
109  if (clkEn = '1') then
110  r <= rin after TPD_G;
111  end if;
112  end if;
113  end process seq;
114 
115 end architecture rtl;
NUM_BYTES_Gpositive := 2
RST_POLARITY_Gsl := '1'
std_logic sl
Definition: StdRtlPkg.vhd:28
TPD_Gtime := 1 ns
out dataOutslv( NUM_BYTES_G* 8- 1 downto 0)
out codeErrslv( NUM_BYTES_G- 1 downto 0)
in clkEnsl := '1'
out dispErrslv( NUM_BYTES_G- 1 downto 0)
_library_ ieeeieee
out validOutsl
in dataInslv( NUM_BYTES_G* 10- 1 downto 0)
out dataKOutslv( NUM_BYTES_G- 1 downto 0)
in rstsl :=not RST_POLARITY_G
in validInsl := '1'
RST_ASYNC_Gboolean := false
std_logic_vector slv
Definition: StdRtlPkg.vhd:29