OpenCores
URL https://opencores.org/ocsvn/core1990_interlaken/core1990_interlaken/trunk

Subversion Repositories core1990_interlaken

[/] [core1990_interlaken/] [trunk/] [gateware/] [sources/] [interlaken/] [transmitter/] [interlaken_transmitter.vhd] - Blame information for rev 11

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 11 N.Boukadid
library ieee;
2
use ieee.std_logic_1164.all;
3
library work;
4
 
5
entity Interlaken_Transmitter is
6
    generic(
7
         BurstMax   : positive;      -- Configurable value of BurstMax
8
         BurstShort : positive;      -- Configurable value of BurstShort
9
         PacketLength : positive     -- Configurable value of PacketLength
10
    );
11
        port (
12
            write_clk : in std_logic;
13
                clk   : in std_logic;
14
                reset : in std_logic;
15
 
16
                TX_Data_In      : in std_logic_vector(63 downto 0);
17
                TX_Data_Out : out std_logic_vector (66 downto 0);       -- Data ready to transmit
18
 
19
                TX_SOP          : in std_logic;                         -- Start of Packet
20
                TX_EOP_Valid    : in std_logic_vector(2 downto 0);      -- Valid bytes packet contains
21
                TX_EOP          : in std_logic;                         -- End of Packet
22
                TX_Channel      : in std_logic_vector(7 downto 0);      -- Select transmit channel (yet unutilized)
23
                TX_Gearboxready : in std_logic;
24
                TX_Startseq     : in std_logic;
25
 
26
                TX_FlowControl  : in std_logic_vector(15 downto 0);     -- Flow control data (yet unutilized)
27
                RX_prog_full    : in std_logic_vector(15 downto 0);
28
 
29
                FIFO_Write_Data : in std_logic;
30
                FIFO_prog_full  : out std_logic;
31
                FIFO_Full       : out std_logic;
32
                --FIFO_Empty      : out std_logic;
33
                Link_up         : in std_logic;
34
                TX_valid_out    : out std_logic
35
                --TX_Link_Up      : out std_logic
36
        );
37
end entity Interlaken_Transmitter;
38
 
39
architecture Transmitter of Interlaken_Transmitter is
40
    type state_type is (IDLE, DATA);
41
        signal pres_state, next_state: state_type;
42
 
43
    signal FIFO_Read_Data, FIFO_Read_Burst : std_logic;
44
    signal FIFO_Read_Count, FIFO_Write_Count : std_logic_vector(4 downto 0);
45
    signal FIFO_prog_empty : std_logic;
46
 
47
    --signal Data_Input : std_logic_vector (68 downto 0);
48
    signal Data_FIFO_In : std_logic_vector (68 downto 0);
49
 
50
    signal Data_Burst_In : std_logic_vector(68 downto 0);
51
        signal Data_Burst_Out : std_logic_vector(66 downto 0);
52
        signal Data_Valid_Burst_Out : std_logic;
53
        signal Data_Control_Burst_Out : std_logic;
54
 
55
        signal Data_Control_Meta_Out : std_logic;
56
        signal Data_Valid_Meta_Out : std_logic;
57
        signal Data_Meta_Out : std_logic_vector(66 downto 0);
58
        signal HealthStatus : std_logic_vector(1 downto 0) := "11";  -- TODO: derive this from the actual transceiver (Status bits in the diagnostic word)
59
        signal FIFO_Read_Meta : std_logic;
60
 
61
        signal Data_Control_Scrambler_Out : std_logic;
62
    signal Data_Valid_Scrambler_Out : std_logic;
63
        signal Data_Scrambler_Out : std_logic_vector(66 downto 0);
64
 
65
        signal Gearbox_Count : integer range 0 to 67;
66
        signal Gearbox_Pause : std_logic;
67
        signal GearboxSignal : std_logic;
68
        signal FIFO_Empty : std_logic;
69
        signal TX_Enable : std_logic;
70
        signal FIFO_dout_valid : std_logic;
71
 
72
    COMPONENT TX_FIFO
73
        PORT (
74
            rst : IN STD_LOGIC;
75
            wr_clk : IN STD_LOGIC;
76
            rd_clk : IN STD_LOGIC;
77
            din : IN STD_LOGIC_VECTOR(68 DOWNTO 0);
78
            wr_en : IN STD_LOGIC;
79
            rd_en : IN STD_LOGIC;
80
            dout : OUT STD_LOGIC_VECTOR(68 DOWNTO 0);
81
            full : OUT STD_LOGIC;
82
            empty : OUT STD_LOGIC;
83
            rd_data_count : OUT STD_LOGIC_VECTOR(4 DOWNTO 0);
84
            wr_data_count : OUT STD_LOGIC_VECTOR(4 DOWNTO 0);
85
            prog_full : OUT STD_LOGIC;
86
            prog_empty : OUT STD_LOGIC;
87
            valid : OUT STD_LOGIC
88
        );
89
    END COMPONENT;
90
 
91
begin
92
 
93
    TX_Enable <= '1';
94
 
95
    FIFO_Transmitter : TX_FIFO
96
    port map (
97
        rst             => Reset,
98
        wr_clk          => write_clk,
99
        rd_clk          => clk,
100
        din             => Data_FIFO_In,
101
        wr_en           => FIFO_Write_Data,
102
        rd_en           => FIFO_Read_Data,
103
        dout            => Data_Burst_In,
104
        full            => FIFO_Full,
105
        empty           => FIFO_Empty,
106
        rd_data_count   => FIFO_Read_Count,
107
        wr_data_count   => FIFO_Write_Count,
108
        prog_full       => FIFO_prog_full,
109
        prog_empty      => FIFO_prog_empty,
110
        valid           => FIFO_dout_valid
111
    );
112
 
113
    FIFO_Read_Data <= FIFO_Read_Burst and link_up;
114
    Data_FIFO_In <= TX_SOP & TX_EOP & TX_EOP_Valid & TX_Data_In;
115
 
116
        Framing_Burst : entity work.Burst_Framer  -- Define the connections of the Burst component
117
        generic map (
118
                BurstMax      => BurstMax,
119
                BurstShort    => BurstShort
120
        )
121
        port map (
122
                Clk           => clk,
123
                Reset         => Reset,
124
                TX_Enable     => TX_Enable,
125
                TX_SOP        => Data_Burst_In(68),
126
                TX_EOP        => Data_Burst_In(67),
127
                TX_ValidBytes => Data_Burst_In(66 downto 64),
128
                TX_FlowControl=> TX_FlowControl,
129
                RX_prog_full  => RX_prog_full,
130
                TX_Channel    => TX_Channel,
131
 
132
                Data_in           => Data_Burst_In(63 downto 0),--TX_Data_In,
133
                Data_in_valid     => FIFO_dout_valid,
134
                Data_out          => Data_Burst_Out,
135
                Data_valid_out    => Data_Valid_Burst_Out,
136
                --Data_control_out  => Data_Control_Burst_Out,
137
                Gearboxready      => Gearbox_Pause,
138
 
139
                FIFO_Empty => FIFO_Empty,
140
                FIFO_meta => FIFO_Read_Meta,
141
                FIFO_data => FIFO_Write_Count,
142
                FIFO_read => FIFO_Read_Burst
143
        );
144
 
145
        Framing_Meta : entity work.Meta_Framer -- Define the connections of the Metaframing component
146
        generic map (
147
                PacketLength => PacketLength
148
        )
149
        port map (
150
                Clk               => Clk,
151
                reset             => Reset,
152
                TX_Enable         => TX_Enable,
153
                HealthLane        => HealthStatus(0),
154
                HealthInterface   => HealthStatus(1),
155
 
156
                Data_In           => Data_Burst_Out,
157
                Data_Out          => Data_Meta_Out,--TX_Data_Out,
158
                Data_Valid_In     => Data_Valid_Burst_Out,
159
                Data_Valid_Out    => Data_Valid_Meta_Out,
160
                --Data_Control_In   => Data_Control_Burst_Out,
161
                --Data_Control_Out  => Data_Control_Meta_Out,
162
 
163
                Gearboxready      => Gearbox_Pause,
164
 
165
                FIFO_Read         => FIFO_Read_Meta
166
        );
167
 
168
        Scrambling : entity work.Scrambler
169
        port map (
170
        Clk               => Clk,
171
        Scram_Rst         => Reset,
172
        Data_In           => Data_Meta_Out,
173
        Data_Out          => Data_Scrambler_Out,
174
        Lane_Number       => "0001",
175
        Scrambler_En      => '1',
176
        Gearboxready      => Gearbox_Pause,
177
--        Data_Control_In   => Data_Control_Meta_Out,
178
  --      Data_Control_Out  => Data_Control_Scrambler_Out,
179
        Data_Valid_In     => Data_Valid_Meta_Out,
180
        Data_Valid_Out    => Data_Valid_Scrambler_Out
181
        );
182
 
183
        Encoding : entity work.Encoder
184
        port map (
185
        Clk             => Clk,
186
        Data_In         => Data_Scrambler_Out,
187
        Data_Out        => TX_Data_Out,
188
 
189
        Data_valid_in   => Data_valid_scrambler_out,
190
        Data_valid_out  => TX_valid_out,
191
       -- Data_Control    => Data_Control_Scrambler_Out,
192
        Encoder_En      => '1',
193
        Encoder_Rst     => Reset,
194
        Gearboxready    => Gearbox_Pause
195
        );
196
 
197
        Gearbox_Pause <= TX_GearboxReady ;--or GearboxSignal;
198
 
199
        Gearbox : process(clk, reset, TX_Gearboxready, Gearbox_Count, TX_Startseq)
200
        begin
201
        if reset = '1' then
202
--            Gearbox_Count <= 0;
203
        elsif(rising_edge(clk)) then
204
            GearboxSignal <= TX_GearboxReady;
205
        end if;
206
    end process Gearbox;
207
 
208
--    state_register : process (write_clk)
209
--    begin
210
--        if (rising_edge(write_clk)) then
211
--            pres_state <= next_state;
212
--        end if;
213
--    end process state_register;
214
 
215
--    state_decoder : process (pres_state, TX_SOP, TX_Enable, TX_EOP, Data_Input)--, TX_FlowControl) is
216
--    begin
217
--        case pres_state is
218
--        when IDLE =>
219
----            if  (TX_FlowControl(0) = '1') then
220
--                if(Data_Input(68) = '1' and Data_Input(67) = '0' and TX_Enable = '1') then
221
--                    next_state <= DATA;
222
--                else
223
--                    next_state <= IDLE;
224
--                end if;
225
----            else
226
----                    next_state <= IDLE;
227
----            end if;
228
 
229
--        when DATA =>
230
--            if(Data_Input(67) = '1') then
231
--                next_state <= IDLE;
232
--            else
233
--                next_state <= DATA;
234
--            end if;
235
--        when others =>
236
--            next_state <= IDLE;
237
--        end case;
238
--    end process state_decoder;
239
 
240
--    output : process (pres_state, write_clk) is
241
--    begin
242
--        if rising_edge(write_clk) then
243
--            Data_FIFO_In <= (others => '0');
244
--            case pres_state is
245
--            when IDLE =>
246
--                FIFO_Write_Data <= '0';
247
----                if  (TX_FlowControl(0) = '1') then
248
--                    if(Data_Input(68) = '1' and TX_Enable = '1') then
249
--                        Data_FIFO_In <= Data_Input;
250
--                        FIFO_Write_Data <= '1';
251
--                    elsif(Data_Input(68) = '1' and Data_Input(67) = '1') then
252
--                        NULL;
253
--                    else
254
--                        Data_FIFO_In <= (others => '0');
255
--                    end if;
256
----                end if;
257
 
258
--            when DATA =>
259
--                FIFO_Write_Data <= '1';
260
--                Data_FIFO_In <= Data_Input;                
261
--            end case;
262
--        end if;
263
--    end process output;
264
 
265
--    ready : process (clk, reset) is --Ready for data pin (test purposes)
266
--    begin
267
--        if (reset = '1') then
268
--            TX_Link_Up <= '0';
269
--        elsif (rising_edge(clk)) then
270
--            TX_Link_Up <= TX_FlowControl(0);
271
--        end if;
272
--    end process ready;
273
 
274
end architecture Transmitter;

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.