1 ----------------------------------------------------------------------------------
5 -- Create Date: 09:
49:
10 06/14/2012
7 -- Module Name: TTS_if - Behavioral
16 -- Revision 0.
01 -
File Created
17 -- Additional Comments:
19 -- TTC Hamming encoding
20 -- hmg[0] = d[0]^d[1]^d[2]^d[3];
21 -- hmg[1] = d[0]^d[4]^d[5]^d[6];
22 -- hmg[2] = d[1]^d[2]^d[4]^d[5]^d[7];
23 -- hmg[3] = d[1]^d[3]^d[4]^d[6]^d[7];
24 -- hmg[4] = d[0]^d[2]^d[3]^d[5]^d[6]^d[7];
26 -- L1A trigger from CTR module takes the position of L1A in TTC
27 -- message format takes that of TTC broadcast message.(FMT = 0)
28 -- BcntRes uses brcst_data(0), TTS signals uses brcst_data(
7 downto 4), brcst_data(
3 downto 1) are reserved
and are always
0
29 ----------------------------------------------------------------------------------
31 use IEEE.STD_LOGIC_1164.
ALL;
32 use IEEE.STD_LOGIC_ARITH.
ALL;
33 use IEEE.STD_LOGIC_UNSIGNED.
ALL;
34 use IEEE.std_logic_misc.
all;
36 use UNISIM.VComponents.
all;
38 use UNIMACRO.vcomponents.
all;
60 local_TTC :
in ; --! Controls TCDS DDR
or TTC clock output
61 TTS : in (3 downto 0);
81 d_current :
IN (
4 downto 0);
82 d_next :
OUT (
4 downto 0)
85 --COMPONENT enc_8b10b_wrapper
88 -- reset_i : in ; -- Global asynchronous reset (active high)
89 -- clk_i : in ; -- Master synchronous send byte clock
90 -- strobe_i : in ; -- Master synchronous send byte clock
91 -- k_i : in ; -- Control (K) input(active high)
92 -- data_i : in (7 downto 0); -- Unencoded input data
93 -- data_o : out (9 downto 0) -- Encoded
out
96 signal TTS_out : := '0';
97 signal TTS_fifo_empty : := '1';
98 signal TTS_q : (3 downto 0) := (others =>'0');
99 signal TTS_fifo_wa : (4 downto 0) := (others =>'0');
100 signal TTS_fifo_ra : (4 downto 0) := (others =>'0');
101 signal next_TTS_fifo_wa : (4 downto 0) := (others =>'0');
102 signal next_TTS_fifo_ra : (4 downto 0) := (others =>'0');
103 signal TTS_fifo_waSync : (4 downto 0) := (others =>'0');
104 signal TTS_fifo_di : (5 downto 0) := (others =>'0');
105 signal TTS_fifo_do : (5 downto 0) := (others =>'0');
106 signal sr : (9 downto 0) := (others =>'0');
107 signal TTS_fifo_we : := '0';
108 signal TTS_fifo_re : := '0';
109 signal NewTTS : := '0';
110 signal TTS_clk_div : (2 downto 0) := (others =>'0');
111 signal SameTTS_cnt : (1 downto 0) := (others =>'0');
112 signal IS_K : := '0';
113 signal enc_di : (7 downto 0) := (others =>'0');
114 signal enc_do : (9 downto 0) := (others =>'0');
129 TTS_q <= (others =>'0');
130 TTS_fifo_wa <= (others =>'0');
133 if(TTS_FIFO_we = '1')then
134 TTS_fifo_wa <= next_TTS_fifo_wa;
138 i_next_TTS_fifo_wa :
Gray5 PORT MAP(
139 d_current => TTS_fifo_wa ,
140 d_next => next_TTS_fifo_wa
142 i_TTS_FIFO : RAM32X6D
153 TTS_FIFO_di(3 downto 0) <= TTS_q;
154 i_next_TTS_fifo_ra :
Gray5 PORT MAP(
155 d_current => TTS_fifo_ra ,
156 d_next => next_TTS_fifo_ra
161 TTS_fifo_waSync <= (others =>'0');
166 TTS_fifo_ra <= (others =>'0');
169 if(TTS_clk_div(2) = '1')then
170 TTS_fifo_waSync <= TTS_fifo_wa;
174 SameTTS_cnt <= SameTTS_cnt + 1;
176 if(NewTTS = '1' or SameTTS_cnt = "11")then
177 enc_di <= x"0" & TTS_FIFO_do(3 downto 0);
180 enc_di <= x"bc";
-- K28.5
184 if(TTS_fifo_waSync /= TTS_fifo_ra and TTS_clk_div(1 downto 0) = "01")then
189 if(TTS_FIFO_re = '1')then
190 TTS_fifo_ra <= next_TTS_fifo_ra;
192 if(TTS_FIFO_re = '1')then
194 elsif(TTS_clk_div(2) = '1')then
199 --i_8b10b_enc: enc_8b10b_wrapper
204 -- strobe_i => TTS_clk_div(2),
212 C_HAS_FORCE_CODE =>
0,
213 C_FORCE_CODE_VAL => "
1010101010",
214 C_FORCE_CODE_DISP =>
0,
224 CE => TTS_clk_div
(2),
234 -- 5 state counter
for 10bit 8b10char
in groups
of two
235 if(TTS_clk_div(2) = '1')then
236 TTS_clk_div <= "000";
238 TTS_clk_div <= TTS_clk_div + 1;
244 elsif(TTS_clk_div(2) = '1')then
248 sr(i*2+1 downto i*2) <= sr(i*2+3 downto i*2+2);
253 i_TTS_out: OBUFDS
generic map(IOSTANDARD =>
"LVDS_25") port map (O =>
TTS_out_p, OB =>
TTS_out_n , I => TTS_out
);
256 DDR_CLK_EDGE =>
"SAME_EDGE",
-- "OPPOSITE_EDGE" or "SAME_EDGE"
257 INIT => '0',
-- Initial value for Q port ('1' or '0')
258 SRTYPE =>
"SYNC") -- Reset Type ("ASYNC" or "SYNC")
260 Q => TTS_out,
-- 1-bit DDR output
261 C =>
TTS_clk,
-- 1-bit clock input
262 CE => '1',
-- 1-bit clock enable input
263 D1 => sr
(0),
-- 1-bit data input (positive edge)
264 D2 => sr
(1),
-- 1-bit data input (negative edge)
265 R => '0',
-- 1-bit reset input
266 S => '0'
-- 1-bit set input