lpgbtfpga_txgearbox.vhd
Go to the documentation of this file.
1 -------------------------------------------------------
6 -------------------------------------------------------
7 
9 LIBRARY ieee;
10 USE ieee.std_logic_1164.all;
11 USE ieee.numeric_std.all;
12 
20  GENERIC (
21  c_clockRatio : integer;
22  c_inputWidth : integer;
23  c_outputWidth : integer
24  );
25  PORT (
26  -- Clock and reset
27  clk_inClk_i : in std_logic;
28  clk_clkEn_i : in std_logic;
29  clk_outClk_i : in std_logic;
30 
31  rst_gearbox_i : in std_logic;
32 
33  -- Data
34  dat_inFrame_i : in std_logic_vector((c_inputWidth-1) downto 0);
35  dat_outFrame_o : out std_logic_vector((c_outputWidth-1) downto 0);
36 
37  -- Status
38  sta_gbRdy_o : out std_logic
39  );
40 END lpgbtfpga_txGearbox;
41 
47 ARCHITECTURE behavioral OF lpgbtfpga_txGearbox is
48 
49  --================================ Signal Declarations ================================--
50  CONSTANT c_oversampling : integer := c_clockRatio/(c_inputWidth/c_outputWidth);
51 
52  SIGNAL gearboxSyncReset : std_logic;
53  SIGNAL rst_gearbox_s : std_logic;
54 
55  SIGNAL txFrame_from_frameInverter_pipe_s : std_logic_vector (c_inputWidth-1 downto 0);
56  SIGNAL in_txFrame_from_frameInverter_s : std_logic_vector (c_inputWidth-1 downto 0);
57  SIGNAL txFrame_from_frameInverter_reg_s : std_logic_vector (c_inputWidth-1 downto 0);
58  SIGNAL txWord_beforeOversampling_s : std_logic_vector((c_inputWidth/c_clockRatio)-1 downto 0);
59 
60  SIGNAL dat_outFrame_s : std_logic_vector((c_outputWidth-1) downto 0);
61 
62  --=====================================================================================--
63 
64 --=================================================================================================--
65 BEGIN --========#### Architecture Body ####========--
66 --=================================================================================================--
67 
68  --==================================== User Logic =====================================--
69 
70  -- Comment: Bits are inverted to transmit the MSB first on the MGT.
71  frameInverter: FOR i IN (c_inputWidth-1) downto 0 GENERATE
72  in_txFrame_from_frameInverter_s(i) <= dat_inFrame_i((c_inputWidth-1)-i);
73  END GENERATE;
74 
75  -- Comment: Note!! The reset of the gearbox is synchronous to TX_FRAMECLK in order to align the address 0
76  -- of the gearbox with the rising edge of TX_FRAMECLK after reset.
77  sta_gbRdy_o <= not(gearboxSyncReset);
78 
79  -- Sync reset
80  rst_pipeline_proc: PROCESS(rst_gearbox_i, clk_inClk_i)
81  BEGIN
82  IF rst_gearbox_i = '1' THEN
83  rst_gearbox_s <= '1';
84 
85  ELSIF rising_edge(clk_inClk_i) THEN
86  IF clk_clkEn_i = '1' THEN
87  rst_gearbox_s <= '0';
88  END IF;
89  END IF;
90  END PROCESS;
91 
92  gbRstSynch_proc: PROCESS(rst_gearbox_s, clk_outClk_i)
93  BEGIN
94  IF rst_gearbox_s = '1' THEN
95  gearboxSyncReset <= '1';
96 
97  ELSIF rising_edge(clk_outClk_i) THEN
98  gearboxSyncReset <= '0';
99  END IF;
100  END PROCESS;
101 
102  pipeline_proc: PROCESS(clk_outClk_i)
103  BEGIN
104  IF rising_edge(clk_outClk_i) THEN
105  txFrame_from_frameInverter_pipe_s <= in_txFrame_from_frameInverter_s;
106  END IF;
107  END PROCESS;
108 
109  gb_proc: PROCESS(gearboxSyncReset, clk_outClk_i)
110  VARIABLE address : integer RANGE 0 TO (c_clockRatio-1);
111  BEGIN
112 
113  IF gearboxSyncReset = '1' THEN
114  txWord_beforeOversampling_s <= (OTHERS => '0');
115  address := 0;
116 
117  ELSIF rising_edge(clk_outClk_i) THEN
118  IF address = 0 THEN
119  txWord_beforeOversampling_s <= txFrame_from_frameInverter_pipe_s((c_inputWidth/c_clockRatio)-1 downto 0);
120  txFrame_from_frameInverter_reg_s <= txFrame_from_frameInverter_pipe_s;
121  ELSE
122  txWord_beforeOversampling_s <= txFrame_from_frameInverter_reg_s(((c_inputWidth/c_clockRatio)*(address+1))-1 downto ((c_inputWidth/c_clockRatio)*(address)));
123  END IF;
124 
125  IF address = (c_clockRatio-1) THEN
126  address := 0;
127  ELSE
128  address := address + 1;
129  END IF;
130 
131  END IF;
132  END PROCESS;
133 
134  -- Comment: Oversampling generator loop.
135  oversamplerMultPh: FOR i IN 0 TO (c_inputWidth/c_clockRatio)-1 GENERATE
136  oversamplerPhN: FOR j IN 0 TO (c_oversampling-1) GENERATE
137  dat_outFrame_s((i*c_oversampling)+j) <= txWord_beforeOversampling_s(i);
138  END GENERATE;
139  END GENERATE;
140 
141  PROCESS(clk_outClk_i)
142  BEGIN
143  IF rising_edge(clk_outClk_i) THEN
144  dat_outFrame_o <= dat_outFrame_s;
145  END IF;
146  END PROCESS;
147  --=====================================================================================--
148 END behavioral;
149 --=================================================================================================--
150 --#################################################################################################--
151 --=================================================================================================--
in rst_gearbox_istd_logic%
Reset SIGNAL.
c_outputWidthinteger%
Bus size of the output word (Warning: c_clockRatio/(c_inputWidth/c_outputWidth) shall be an integer) ...
c_clockRatiointeger%
Clock ratio is clock_out / clock_in (shall be an integer)
in clk_clkEn_istd_logic%
Input clock enable WHEN multicycle path or &#39;1&#39;.
_library_ ieeeieee
Include the IEEE VHDL standard LIBRARY.
in dat_inFrame_istd_logic_vector%(%(c_inputWidth%-%1)%%%downto%%%0%)
Input data.
in clk_inClk_istd_logic%
Input clock (frame clock)
in clk_outClk_istd_logic%
Output clock (from the MGT)
c_inputWidthinteger%
Bus size of the input word.
out dat_outFrame_ostd_logic_vector%(%(c_outputWidth%-%1)%%%downto%%%0%)
Output data.
out sta_gbRdy_ostd_logic%
Ready SIGNAL.
lpgbtfpga_txGearbox - Tx Gearbox