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