-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgearbox32to66.vhd
executable file
·64 lines (61 loc) · 2.1 KB
/
gearbox32to66.vhd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
-- ####################################
-- # Project: Yarr
-- # Author: Timon Heim
-- # E-Mail: timon.heim at cern.ch
-- # Comments: RX channel
-- # Aurora style rx code
-- ####################################
library IEEE;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
entity gearbox32to66 is
port (
-- Sys connect
rst_i : in std_logic;
clk_i : in std_logic;
-- Input
data32_i : in std_logic_vector(31 downto 0);
data32_valid_i : in std_logic;
slip_i : in std_logic;
-- Outoput
data66_o : out std_logic_vector(65 downto 0);
data66_valid_o : out std_logic
);
end gearbox32to66;
architecture rtl of gearbox32to66 is
signal gearbox_cnt : unsigned(7 downto 0);
signal shift_cnt : std_logic;
signal buffer128 : std_logic_vector(127 downto 0);
signal slip_cnt : std_logic;
begin
shift_proc: process(clk_i, rst_i)
begin
if (rst_i = '1') then
buffer128 <= (others => '0');
gearbox_cnt <= (others => '0');
data66_valid_o <= '0';
data66_o <= (others => '0');
shift_cnt <= '0';
slip_cnt <= '0';
elsif rising_edge(clk_i) then
data66_valid_o <= '0';
if (data32_valid_i = '1') then
shift_cnt <= not shift_cnt;
buffer128(127 downto 0) <= buffer128(95 downto 0) & data32_i;
data66_o <= buffer128(128-(to_integer(gearbox_cnt(4 downto 0))*2)-1 downto 62-(to_integer(gearbox_cnt(4 downto 0))*2));
if (shift_cnt = '1') then
if (slip_i = '1') then
gearbox_cnt <= gearbox_cnt;
data66_valid_o <= '1';
elsif (gearbox_cnt = 32) then
gearbox_cnt <= (others => '0');
data66_valid_o <= '0';
else
gearbox_cnt <= gearbox_cnt + 1;
data66_valid_o <= '1';
end if;
end if;
end if;
end if;
end process shift_proc;
end rtl;