SURF  1.0
Decoder10b12b.vhd
Go to the documentation of this file.
1 -------------------------------------------------------------------------------
2 -- File : Decoder10b12b.vhd
3 -- Company : SLAC National Accelerator Laboratory
4 -- Created : 2016-10-07
5 -- Last update: 2017-05-01
6 -------------------------------------------------------------------------------
7 -- Description: 10B12B 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.Code10b12bPkg.all;
22 
23 --! @see entity
24  --! @ingroup base_general
25 entity Decoder10b12b is
26 
27  generic (
28  TPD_G : time := 1 ns;
29  RST_POLARITY_G : sl := '0';
30  RST_ASYNC_G : boolean := true;
31  USE_CLK_EN_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(11 downto 0);
38  dataOut : out slv(9 downto 0);
39  dataKOut : out sl;
40  validOut : out sl;
41  dispOut : out sl;
42  codeError : out sl;
43  dispError : out sl);
44 
45 end entity Decoder10b12b;
46 
47 architecture rtl of Decoder10b12b is
48 
49  type RegType is record
50  dispOut : sl;
51  dataOut : slv(9 downto 0);
52  dataKOut : sl;
53  validOut : sl;
54  codeError : sl;
55  dispError : sl;
56  end record RegType;
57 
58  constant REG_INIT_C : RegType := (
59  dispOut => '0',
60  dataOut => (others => '0'),
61  dataKOut => '0',
62  validOut => '0',
63  codeError => '0',
64  dispError => '0');
65 
66  signal r : RegType := REG_INIT_C;
67  signal rin : RegType;
68 
69 begin
70 
71  comb : process (dataIn, r, rst, validIn) is
72  variable v : RegType;
73  begin
74  v := r;
75 
76  v.validOut := validIn;
77 
78  if (validIn = '1') then
79  decode10b12b(
80  dataIn => dataIn,
81  dispIn => r.dispOut,
82  dataOut => v.dataOut,
83  dataKOut => v.dataKOut,
84  dispOut => v.dispOut,
85  codeError => v.codeError,
86  dispError => v.dispError);
87  end if;
88 
89  -- Synchronous reset
90  if (RST_ASYNC_G = false and rst = RST_POLARITY_G) then
91  v := REG_INIT_C;
92  end if;
93 
94  rin <= v;
95  dataOut <= r.dataOut;
96  dataKOut <= r.dataKOut;
97  validOut <= r.validOut;
98  dispOut <= r.dispOut;
99  codeError <= r.codeError;
100  dispError <= r.dispError;
101  end process comb;
102 
103  seq : process (clk, rst) is
104  begin
105  if (RST_ASYNC_G and rst = RST_POLARITY_G) then
106  r <= REG_INIT_C after TPD_G;
107  elsif (rising_edge(clk)) then
108  if (USE_CLK_EN_G = false or clkEn = '1') then
109  r <= rin after TPD_G;
110  end if;
111  end if;
112  end process seq;
113 
114 end architecture rtl;
RST_POLARITY_Gsl := '0'
std_logic sl
Definition: StdRtlPkg.vhd:28
USE_CLK_EN_Gboolean := false
in rstsl :=not RST_POLARITY_G
in validInsl := '1'
in clkEnsl := '1'
in dataInslv( 11 downto 0)
RST_ASYNC_Gboolean := true
TPD_Gtime := 1 ns
_library_ ieeeieee
Definition: Debouncer.vhd:18
std_logic_vector slv
Definition: StdRtlPkg.vhd:29
out dataOutslv( 9 downto 0)