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;
37 use UNISIM.VComponents.
all;
39 use UNIMACRO.vcomponents.
all;
61 local_TTC :
in ; --! Controls TCDS DDR
or TTC clock output
62 TTS : in (3 downto 0);
82 d_current :
IN (
4 downto 0);
83 d_next :
OUT (
4 downto 0)
86 signal TTS_out : := '0';
87 signal TTS_fifo_empty : := '1';
88 signal TTS_q : (3 downto 0) := (others =>'0');
89 signal TTS_fifo_wa : (4 downto 0) := (others =>'0');
90 signal TTS_fifo_ra : (4 downto 0) := (others =>'0');
91 signal next_TTS_fifo_wa : (4 downto 0) := (others =>'0');
92 signal next_TTS_fifo_ra : (4 downto 0) := (others =>'0');
93 signal TTS_fifo_waSync : (4 downto 0) := (others =>'0');
94 signal TTS_fifo_di : (5 downto 0) := (others =>'0');
95 signal TTS_fifo_do : (5 downto 0) := (others =>'0');
96 signal sr : (9 downto 0) := (others =>'0');
97 signal TTS_fifo_we : := '0';
98 signal TTS_fifo_re : := '0';
99 signal NewTTS : := '0';
100 signal TTS_clk_div : (2 downto 0) := (others =>'0');
101 signal SameTTS_cnt : (1 downto 0) := (others =>'0');
102 signal IS_K : := '0';
103 signal enc_di : (7 downto 0) := (others =>'0');
104 signal enc_do : (9 downto 0) := (others =>'0');
105 signal bcnt : (11 downto 0) := x"ff8";
106 signal LastBcnt : (11 downto 0);
107 signal SendBC0 : := '0';
108 signal SendBC0_O : := '0';
110 LastBcnt <= x"fff" when flavor = "G2" else x"deb";
124 TTS_q <= (others =>'0');
125 TTS_fifo_wa <= (others =>'0');
128 if(TTS_FIFO_we = '1')then
129 TTS_fifo_wa <= next_TTS_fifo_wa;
133 i_next_TTS_fifo_wa :
Gray5 PORT MAP(
134 d_current => TTS_fifo_wa,
135 d_next => next_TTS_fifo_wa
137 i_TTS_FIFO : RAM32X6D
148 TTS_FIFO_di(3 downto 0) <= TTS_q;
149 i_next_TTS_fifo_ra :
Gray5 PORT MAP(
150 d_current => TTS_fifo_ra,
151 d_next => next_TTS_fifo_ra
156 TTS_fifo_waSync <= (others =>'0');
161 TTS_fifo_ra <= (others =>'0');
164 if(TTS_clk_div(2) = '1')then
165 TTS_fifo_waSync <= TTS_fifo_wa;
169 SameTTS_cnt <= SameTTS_cnt + 1;
171 if(NewTTS = '1' or SameTTS_cnt = "11")then
172 enc_di <= x"0" & TTS_FIFO_do(3 downto 0);
175 enc_di <= x"bc";
-- K28.5
179 if(TTS_fifo_waSync /= TTS_fifo_ra and TTS_clk_div(1 downto 0) = "01")then
184 if(TTS_FIFO_re = '1')then
185 TTS_fifo_ra <= next_TTS_fifo_ra;
187 if(TTS_FIFO_re = '1')then
189 elsif(TTS_clk_div(2) = '1')then
197 C_HAS_FORCE_CODE =>
0,
198 C_FORCE_CODE_VAL => "
1010101010",
199 C_FORCE_CODE_DISP =>
0,
209 CE => TTS_clk_div
(2),
219 -- 5 state counter
for 10bit 8b10char
in groups
of two
220 if((TTS_clk_div(2) = '1' and local_TTC = '0') or (TTS_clk_div(1 downto 0) = "11" and local_TTC = '1'))then
221 TTS_clk_div <= "000";
223 TTS_clk_div <= TTS_clk_div + 1;
225 if(TTS_clk_div(1 downto 0) = "11")then
226 if(local_TTC = '0' or bcnt = LastBcnt)then
227 bcnt <= (others => '0');
233 elsif(bcnt = LastBcnt)then
235 elsif(bcnt(3 downto 0) = x"f")then
240 -- sr(1) <=
not sr(
0);
241 -- sr(0) <=
not sr(
0);
242 if(TTS_clk_div(0) = '0')then
245 elsif(TTS_clk_div(1) = '0' and SendBC0_O = '1')then
249 elsif(TTS_clk_div(2) = '1')then
253 sr(i*2+1 downto i*2) <= sr(i*2+3 downto i*2+2);
262 O => SendBC0_O,
-- ROM output
263 A0 => bcnt
(0),
-- ROM address[0]
264 A1 => bcnt
(1),
-- ROM address[1]
265 A2 => bcnt
(2),
-- ROM address[2]
266 A3 => bcnt
(3),
-- ROM address[3]
267 A4 => SendBC0
-- ROM address[4]
269 i_TTS_out: OBUFDS
generic map(IOSTANDARD =>
"LVDS_25") port map (O =>
TTS_out_p, OB =>
TTS_out_n, I => TTS_out
);
272 DDR_CLK_EDGE =>
"SAME_EDGE",
-- "OPPOSITE_EDGE" or "SAME_EDGE"
273 INIT => '0',
-- Initial value for Q port ('1' or '0')
274 SRTYPE =>
"SYNC") -- Reset Type ("ASYNC" or "SYNC")
276 Q => TTS_out,
-- 1-bit DDR output
277 C =>
TTS_clk,
-- 1-bit clock input
278 CE => '1',
-- 1-bit clock enable input
279 D1 => sr
(0),
-- 1-bit data input (positive edge)
280 D2 => sr
(1),
-- 1-bit data input (negative edge)
281 R => '0',
-- 1-bit reset input
282 S => '0'
-- 1-bit set input