1 ----------------------------------------------------------------------------------
13 ----------------------------------------------------------------------------------
15 use IEEE.STD_LOGIC_1164.
ALL;
21 -- Uncomment the following library declaration if using
22 -- arithmetic functions with Signed or Unsigned values
25 -- Uncomment the following library declaration if instantiating
26 -- any Xilinx primitives in this code.
28 --use UNISIM.VComponents.all;
33 --- ratio : integer := 8 -- input length : output length ratio
41 clk_slow : in ;
-- DATA_in is synced to this clock
42 clk_fast : in ;
-- DATA_out is synced to this clock
45 end time_multiplex_8to1;
59 --the select signal that combines the send_align bit and the subtick counter
60 signal sel: (3 downto 0);
64 DATA_out(17)<='0';
--the K character only possibly appears on the LS byte.
65 --never on the higher byte so the flag for the
70 --combine the two signals into one as the input to the multiplexer
74 --normally when no align data is to be sent the multiplexer picks off the
75 --successive chunks of the input data starting with the MS word '0' is added
76 --in the front to signify that the data (lower byte) is not a K character
77 --however when the align bit is set first 3 words are the same but then
78 --a K character is spliced in in st 3 and BCID on st 4, the rest of the data
82 ('0' & DATA_in( 8*16 - 1 downto 7*16)) when "0000", --subtick: 0 --send_align from previous event
83 ('0' & DATA_in( 8*16 - 1 downto 7*16)) when "1000", --but thats ok sice
84 ('0' & DATA_in( 7*16 - 1 downto 6*16)) when "0001", --subtick: 1 --till subtick 3 no difference
85 ('0' & DATA_in( 7*16 - 1 downto 6*16)) when "1001", --still old send_align_reg
86 ('0' & DATA_in( 6*16 - 1 downto 5*16)) when "0010", --subtick: 2
87 ('0' & DATA_in( 6*16 - 1 downto 5*16)) when "1010", --still old send_align_reg
88 ('0' & DATA_in( 5*16 - 1 downto 4*16)) when "0011", --subtick: 3
89 ('1' & DATA_in( 5*16 - 1 downto 4*16+8) & "10111100") when "1011", --add K
90 ('0' & DATA_in( 4*16 - 1 downto 3*16)) when "0100", --subtick: 4
91 ('0' & BCID & DATA_in( 3*16 + 3 downto 3*16)) when "1100", --add BCID
92 ('0' & DATA_in( 3*16 - 1 downto 2*16)) when "0101", --subtick: 5
93 ('0' & DATA_in( 3*16 - 1 downto 2*16)) when "1101", --continue sending
94 ('0' & DATA_in( 2*16 - 1 downto 1*16)) when "0110", --subtick: 6
95 ('0' & DATA_in( 2*16 - 1 downto 1*16)) when "1110",
96 ('0' & DATA_in( 1*16 - 1 downto 0*16)) when "0111", --subtick: 7
97 ('0' & DATA_in( 1*16 - 1 downto 0*16)) when "1111";
99 --process to sync the pll locked signal to the clk_slow
114 --process to select a range of the input data and register it into the output
121 DATA_out(16 downto 0)<=(others => '0');
126 if subtick_counter=to_unsigned(2,3) then --note the 2; alignment word is not used till second half of the serialisation
in BCIDstd_logic_vector (11 downto 0)
unsigned (2 downto 0) subtick_counter
out subtick_counter_outunsigned (2 downto 0)
unsigned (2 downto 0) subtick_counter_next
std_logic pll_locked_synced
in DATA_instd_logic_vector (16 * 8 - 1 downto 0)
std_logic_vector (16 downto 0) DATA_out_next
out DATA_outstd_logic_vector (17 downto 0)
std_logic_vector (3 downto 0) sel