SURF  1.0
Jesd16bTo32b.vhd
Go to the documentation of this file.
1 -------------------------------------------------------------------------------
2 -- File : Jesd16bTo32b.vhd
3 -- Company : SLAC National Accelerator Laboratory
4 -- Created : 2016-02-24
5 -- Last update: 2016-02-24
6 -------------------------------------------------------------------------------
7 -- Description: Converts the 16-bit interface to 32-bit JESD interface
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 ieee.std_logic_unsigned.all;
21 use ieee.std_logic_arith.all;
22 
23 use work.StdRtlPkg.all;
24 
25 --! @see entity
26  --! @ingroup protocols_jesd204b
27 entity Jesd16bTo32b is
28  generic (
29  TPD_G : time := 1 ns);
30  port (
31  -- 16-bit Write Interface
32  wrClk : in sl;
33  wrRst : in sl;
34  validIn : in sl;
35  overflow : out sl;
36  dataIn : in slv(15 downto 0);
37  -- 32-bit Read Interface
38  rdClk : in sl;
39  rdRst : in sl;
40  validOut : out sl;
41  underflow: out sl;
42  dataOut : out slv(31 downto 0));
43 end Jesd16bTo32b;
44 
45 architecture rtl of Jesd16bTo32b is
46 
47  type RegType is record
48  wordSel : sl;
49  wrEn : sl;
50  data : slv(31 downto 0);
51  end record;
52 
53  constant REG_INIT_C : RegType := (
54  wordSel => '0',
55  wrEn => '0',
56  data => (others => '0'));
57 
58  signal r : RegType := REG_INIT_C;
59  signal rin : RegType;
60  signal s_valid : sl;
61 
62 begin
63 
64  comb : process (r, wrRst, validIn, dataIn) is
65  variable v : RegType;
66  begin
67  -- Latch the current value
68  v := r;
69 
70  -- Check if data valid
71  if validIn = '1' then
72  if r.wordSel = '0' then
73  -- Set the flags and data bus
74  v.wordSel := '1';
75  v.data(15 downto 0) := dataIn;
76  v.wrEn := '0';
77  else
78  -- Set the flags and data bus
79  v.wordSel := '0';
80  v.data(31 downto 16) := dataIn;
81  v.wrEn := '1';
82  end if;
83  else
84  v := REG_INIT_C;
85  end if;
86 
87  -- Synchronous Reset
88  if (wrRst = '1') then
89  v := REG_INIT_C;
90  end if;
91 
92  -- Register the variable for next clock cycle
93  rin <= v;
94 
95  end process comb;
96 
97 
98  U_FIFO : entity work.FifoAsync
99  generic map (
100  TPD_G => TPD_G,
101  BRAM_EN_G => false,
102  FWFT_EN_G => true,
103  ALTERA_SYN_G => false,
104  SYNC_STAGES_G => 3,
105  DATA_WIDTH_G => 32,
106  ADDR_WIDTH_G => 5)
107  port map (
108  -- Asynchronous Reset
109  rst => wrRst,
110  -- Write Ports (wr_clk domain)
111  wr_clk => wrClk,
112  wr_en => r.wrEn,
113  din => r.data,
114  overflow => overflow,
115  -- Read Ports (rd_clk domain)
116  rd_clk => rdClk,
117  rd_en => s_valid,
118  dout => dataOut,
119  underflow => underflow,
120  valid => s_valid);
121 
122  validOut <= s_valid;
123 
124  seq : process (wrClk) is
125  begin
126  if (rising_edge(wrClk)) then
127  r <= rin after TPD_G;
128  end if;
129  end process seq;
130 
131 end rtl;
in dataInslv( 15 downto 0)
in rstsl
Definition: FifoAsync.vhd:45
in wr_clksl
Definition: FifoAsync.vhd:47
out underflowsl
_library_ ieeeieee
std_logic sl
Definition: StdRtlPkg.vhd:28
in rd_clksl
Definition: FifoAsync.vhd:58
in wr_ensl
Definition: FifoAsync.vhd:48
SYNC_STAGES_Ginteger range 3 to ( 2** 24):= 3
Definition: FifoAsync.vhd:36
in rd_ensl
Definition: FifoAsync.vhd:59
out underflowsl
Definition: FifoAsync.vhd:63
out doutslv( DATA_WIDTH_G- 1 downto 0)
Definition: FifoAsync.vhd:60
DATA_WIDTH_Ginteger range 1 to ( 2** 24):= 16
Definition: FifoAsync.vhd:38
out dataOutslv( 31 downto 0)
ALTERA_SYN_Gboolean := false
Definition: FifoAsync.vhd:34
out validOutsl
ADDR_WIDTH_Ginteger range 2 to 48:= 4
Definition: FifoAsync.vhd:39
out overflowsl
out overflowsl
Definition: FifoAsync.vhd:52
FWFT_EN_Gboolean := false
Definition: FifoAsync.vhd:32
in dinslv( DATA_WIDTH_G- 1 downto 0)
Definition: FifoAsync.vhd:49
TPD_Gtime := 1 ns
out validsl
Definition: FifoAsync.vhd:62
BRAM_EN_Gboolean := true
Definition: FifoAsync.vhd:31
std_logic_vector slv
Definition: StdRtlPkg.vhd:29
TPD_Gtime := 1 ns
Definition: FifoAsync.vhd:29