SURF  1.0
Encoder12b14b.vhd
Go to the documentation of this file.
1 -------------------------------------------------------------------------------
2 -- File : Encode12b14b.vhd
3 -- Company : SLAC National Accelerator Laboratory
4 -- Created : 2016-10-07
5 -- Last update: 2017-05-01
6 -------------------------------------------------------------------------------
7 -- Description: 12B14B Encoder 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 Encoder12b14b 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  FLOW_CTRL_EN_G : boolean := false);
33  port (
34  clk : in sl;
35  clkEn : in sl := '1'; -- Optional Clock Enable
36  rst : in sl := not RST_POLARITY_G; -- Optional Reset
37  validIn : in sl := '1';
38  readyIn : out sl;
39  dataIn : in slv(11 downto 0);
40  dispIn : in slv(1 downto 0) := "00";
41  dataKIn : in sl;
42  validOut : out sl;
43  readyOut : in sl := '1';
44  dataOut : out slv(13 downto 0);
45  dispOut : out slv(1 downto 0));
46 
47 end entity Encoder12b14b;
48 
49 architecture rtl of Encoder12b14b is
50 
51  type RegType is record
52  validOut : sl;
53  readyIn : sl;
54  dispOut : slv(1 downto 0);
55  dataOut : slv(13 downto 0);
56 -- invalidK : sl;
57  end record RegType;
58 
59  constant REG_INIT_C : RegType := (
60  validOut => toSl(not FLOW_CTRL_EN_G),
61  readyIn => '0',
62  dispOut => "00",
63  dataOut => (others => '0'));
64 -- invalidK => '0');
65 
66  signal r : RegType := REG_INIT_C;
67  signal rin : RegType;
68 
69 begin
70 
71  comb : process (dataIn, dataKIn, dispIn, r, rst) is
72  variable v : RegType;
73  variable dispInTmp : slv(1 downto 0);
74  variable invalidK : sl;
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.readyIn := readyOut;
85  if (readyOut = '1' and FLOW_CTRL_EN_G) then
86  v.validOut := '0';
87  end if;
88 
89  if (v.validOut = '0' or FLOW_CTRL_EN_G = false) then
90  v.validOut := '1';
91  encode12b14b(
92  CODES_C => ENCODE_TABLE_C,
93  dataIn => dataIn,
94  dataKIn => dataKIn,
95  dispIn => dispInTmp,
96  dataOut => v.dataOut,
97  dispOut => v.dispOut,
98  invalidK => invalidK);
99  end if;
100 
101  -- Synchronous reset
102  if (RST_ASYNC_G = false and rst = RST_POLARITY_G) then
103  v := REG_INIT_C;
104  end if;
105 
106  rin <= v;
107  dataOut <= r.dataOut;
108  dispOut <= r.dispOut;
109 -- invalidK <= r.invalidK;
110  readyIn <= v.readyIn;
111  validOut <= r.validOut;
112  end process comb;
113 
114  seq : process (clk, rst) is
115  begin
116  if (RST_ASYNC_G and rst = RST_POLARITY_G) then
117  r <= REG_INIT_C after TPD_G;
118  elsif (rising_edge(clk)) then
119  if clkEn = '1' then
120  r <= rin after TPD_G;
121  end if;
122  end if;
123  end process seq;
124 
125 end architecture rtl;
FLOW_CTRL_EN_Gboolean := false
in readyOutsl := '1'
DEBUG_DISP_Gboolean := false
out dataOutslv( 13 downto 0)
std_logic sl
Definition: StdRtlPkg.vhd:28
out dispOutslv( 1 downto 0)
in clkEnsl := '1'
_library_ ieeeieee
RST_POLARITY_Gsl := '0'
in dispInslv( 1 downto 0) := "00"
in validInsl := '1'
EncodeTableType ENCODE_TABLE_C
TPD_Gtime := 1 ns
RST_ASYNC_Gboolean := false
in dataInslv( 11 downto 0)
std_logic_vector slv
Definition: StdRtlPkg.vhd:29
in rstsl :=not RST_POLARITY_G