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