SURF  1.0
Encoder10b12b.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: 10B12B 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.Code10b12bPkg.all;
22 
23 --! @see entity
24  --! @ingroup base_general
25 entity Encoder10b12b 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  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(9 downto 0);
40  dataKIn : in sl;
41  validOut : out sl;
42  readyOut : in sl := '1';
43  dataOut : out slv(11 downto 0);
44  dispOut : out sl);
45 
46 end entity Encoder10b12b;
47 
48 architecture rtl of Encoder10b12b is
49 
50  type RegType is record
51  validOut : sl;
52  readyIn : sl;
53  dispOut : sl;
54  dataOut : slv(11 downto 0);
55  end record RegType;
56 
57  constant REG_INIT_C : RegType := (
58  validOut => toSl(not FLOW_CTRL_EN_G),
59  readyIn => '0',
60  dispOut => '0',
61  dataOut => (others => '0'));
62 
63  signal r : RegType := REG_INIT_C;
64  signal rin : RegType;
65 
66 begin
67 
68  comb : process (dataIn, dataKIn, r, readyOut, rst) is
69  variable v : RegType;
70  begin
71  v := r;
72 
73  v.readyIn := readyOut;
74  if (readyOut = '1' and FLOW_CTRL_EN_G) then
75  v.validOut := '0';
76  end if;
77 
78  if (v.validOut = '0' or FLOW_CTRL_EN_G = false) then
79  v.validOut := '1';
80  encode10b12b(
81  dataIn => dataIn,
82  dataKIn => dataKIn,
83  dispIn => r.dispOut,
84  dataOut => v.dataOut,
85  dispOut => v.dispOut);
86  end if;
87 
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  dispOut <= r.dispOut;
97  readyIn <= v.readyIn;
98  validOut <= r.validOut;
99  end process comb;
100 
101  seq : process (clk, rst) is
102  begin
103  if (RST_ASYNC_G and rst = RST_POLARITY_G) then
104  r <= REG_INIT_C after TPD_G;
105  elsif (rising_edge(clk)) then
106  if (USE_CLK_EN_G = false or clkEn = '1') then
107  r <= rin after TPD_G;
108  end if;
109  end if;
110  end process seq;
111 
112 end architecture rtl;
FLOW_CTRL_EN_Gboolean := false
std_logic sl
Definition: StdRtlPkg.vhd:28
in clkEnsl := '1'
USE_CLK_EN_Gboolean := false
_library_ ieeeieee
Definition: DspCounter.vhd:18
RST_POLARITY_Gsl := '0'
out dataOutslv( 11 downto 0)
in validInsl := '1'
RST_ASYNC_Gboolean := true
in dataInslv( 9 downto 0)
TPD_Gtime := 1 ns
in rstsl :=not RST_POLARITY_G
in readyOutsl := '1'
std_logic_vector slv
Definition: StdRtlPkg.vhd:29