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

Subversion Repositories pc_fpga_com

[/] [pc_fpga_com/] [trunk/] [PC_FPGA_PLATFPORM/] [HARDWARE/] [FPGA2PC.vhd] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 NikosAl
----------------------------------------------------------------------------------
2
-- Company: 
3
-- Engineer: 
4
-- 
5
-- Create Date:    11:19:53 05/03/2011 
6
-- Design Name: 
7
-- Module Name:    FPGA2PC - Behavioral 
8
-- Project Name: 
9
-- Target Devices: 
10
-- Tool versions: 
11
-- Description: 
12
--
13
-- Dependencies: 
14
--
15
-- Revision: 
16
-- Revision 0.01 - File Created
17
-- Additional Comments: 
18
--
19
----------------------------------------------------------------------------------
20
library IEEE;
21
use IEEE.STD_LOGIC_1164.ALL;
22
use IEEE.STD_LOGIC_ARITH.ALL;
23
use IEEE.STD_LOGIC_UNSIGNED.ALL;
24
 
25
---- Uncomment the following library declaration if instantiating
26
---- any Xilinx primitives in this code.
27
--library UNISIM;
28
--use UNISIM.VComponents.all;
29
 
30
entity FPGA2PC is
31
    Port ( rst : in  STD_LOGIC;
32
           clk : in  STD_LOGIC;
33
 
34
           locked : in  STD_LOGIC;
35
 
36
           trans_en : in  STD_LOGIC;
37
           d_type : in  STD_LOGIC_VECTOR (2 downto 0);
38
           d_len : in  STD_LOGIC_VECTOR (15 downto 0);
39
 
40
                          rd_addr : out  STD_LOGIC_VECTOR (31 downto 0);
41
 
42
           data_in_8 : in  STD_LOGIC_VECTOR (7 downto 0); -- type 001
43
                          data_in_16 : in  STD_LOGIC_VECTOR (15 downto 0); -- type 010
44
           data_in_32 : in  STD_LOGIC_VECTOR (31 downto 0); -- type 011 or 100
45
           data_in_64 : in  STD_LOGIC_VECTOR (63 downto 0); -- type 101
46
 
47
                          start_trans : out  STD_LOGIC;
48
                          trans_length : out  STD_LOGIC_VECTOR(15 downto 0);
49
                          usr_data_phase_on : in  STD_LOGIC;
50
                          usr_data_to_trasmit : out  STD_LOGIC_VECTOR(7 downto 0);
51
 
52
                          tx_eof_in: in STD_LOGIC;
53
                          trans_ov : out  STD_LOGIC);
54
end FPGA2PC;
55
 
56
architecture Behavioral of FPGA2PC is
57
 
58
component D_TYPE_LEN_CNTRL is
59
    Port ( rst : in  STD_LOGIC;
60
           clk : in  STD_LOGIC;
61
           locked : in  STD_LOGIC;
62
           trans_en : in  STD_LOGIC;
63
           d_type : in  STD_LOGIC_VECTOR (2 downto 0);
64
           d_len : in  STD_LOGIC_VECTOR (15 downto 0);
65
           d_type_byte : out  STD_LOGIC_VECTOR (7 downto 0);
66
           d_length_out : out  STD_LOGIC_VECTOR (15 downto 0));
67
end component;
68
 
69
component FSM_SEL_HEADER is
70
    Port ( rst : in  STD_LOGIC;
71
           clk : in  STD_LOGIC;
72
           usr_phase_en : in  STD_LOGIC;
73
           sel : out  STD_LOGIC);
74
end component;
75
 
76
signal header_byte, usr_data_to_trasmit_t, usr_data_to_trasmit_tt, sel_char_v, sel_rest_v, selected_usr_data_to_transmit: std_logic_vector(7 downto 0);
77
signal packet_size: std_logic_Vector(15 downto 0);
78
signal rst_count, en_count, start_trans_tmp,
79
       sel_header, rst_addrgen, en_addrgen,
80
                 en_addrgen_t, sel_char, sel_rest : std_logic;
81
signal counter, counter_r, d_type_loc: std_logic_Vector(2 downto 0);
82
signal rdaddr_t: std_logic_vector(31 downto 0);
83
 
84
component DATA_OUT_MUX is
85
    Port ( status : in  STD_LOGIC_VECTOR (2 downto 0);
86
           addr : in  STD_LOGIC_VECTOR (2 downto 0);
87
                          usr_d_on: in  STD_LOGIC;
88
           data_8 : in  STD_LOGIC_VECTOR (7 downto 0);
89
           data_16 : in  STD_LOGIC_VECTOR (15 downto 0);
90
           data_32 : in  STD_LOGIC_VECTOR (31 downto 0);
91
           data_64 : in  STD_LOGIC_VECTOR (63 downto 0);
92
           data_out : out  STD_LOGIC_VECTOR (7 downto 0));
93
end component;
94
 
95
signal select_header_v, select_data_v : std_logic_Vector(7 downto 0);
96
 
97
begin
98
 
99
start_trans_tmp <= trans_en and locked;
100
 
101
process(clk)
102
begin
103
if clk'event and clk='1' then
104
        usr_data_to_trasmit_tt <= usr_data_to_trasmit_t;
105
        start_trans <= start_trans_tmp;
106
        counter_r <= counter;
107
end if;
108
end process;
109
 
110
D_TYPE_LEN_CNTRL_C: D_TYPE_LEN_CNTRL Port Map
111
( rst => rst,
112
  clk => clk,
113
  locked => locked,
114
  trans_en => trans_en,
115
  d_type => d_type,
116
  d_len => d_len,
117
  d_type_byte => header_byte,
118
  d_length_out => packet_size
119
);
120
 
121
trans_length <= packet_size;
122
 
123
en_count <= usr_data_phase_on;
124
 
125
rst_count <= rst or start_trans_tmp;
126
 
127
process(clk)
128
begin
129
if rst_count='1' then
130
        counter <= "000";
131
else
132
        if clk'event and clk='1' then
133
                if en_count='1' then
134
                        counter <= counter + "001";
135
                end if;
136
        end if;
137
end if;
138
end process;
139
 
140
 
141
process(clk)
142
begin
143
if clk'event and clk='1' then
144
        if header_byte(2 downto 0)="001" then -- char
145
                en_addrgen_t <= usr_data_phase_on;
146
        elsif header_byte(2 downto 0)="010" then -- short
147
                if usr_data_phase_on='1' then
148
                        if counter="000" or counter="010" or counter="100" or counter="110" then
149
                                en_addrgen_t <= '1';
150
                        else
151
                                en_addrgen_t <= '0';
152
                        end if;
153
                else
154
                        en_addrgen_t <= '0';
155
                end if;
156
 
157
        elsif header_byte(2 downto 0)="011" or header_byte(2 downto 0)="100"  then -- int/float
158
                if usr_data_phase_on='1' then
159
                        if counter="010" or counter="110" then
160
                                en_addrgen_t <= '1';
161
                        else
162
                                en_addrgen_t <= '0';
163
                        end if;
164
                else
165
                        en_addrgen_t <= '0';
166
                end if;
167
        else -- d_type="00": double
168
                if usr_data_phase_on='1' then
169
                        if counter="110" then
170
                                en_addrgen_t <= '1';
171
                        else
172
                                en_addrgen_t <= '0';
173
                        end if;
174
                else
175
                        en_addrgen_t <= '0';
176
                end if;
177
        end if;
178
end if;
179
end process;
180
 
181
sel_char <= (not header_byte(2)) and (not header_byte(1)) and (header_byte(0));
182
sel_rest <= not sel_char;
183
 
184
sel_char_v <= (others=> sel_char);
185
sel_rest_v <= (others=> sel_rest);
186
 
187
 
188
en_addrgen <= (sel_char and usr_data_phase_on) or (sel_rest and en_addrgen_t);
189
 
190
rst_addrgen <= rst or start_trans_tmp;
191
 
192
process(clk)
193
begin
194
if rst_addrgen='1' then
195
        rdaddr_t <= (others=>'0');
196
else
197
        if clk'event and clk='1' then
198
                if en_addrgen='1' then
199
                        rdaddr_t <= rdaddr_t + "00000000000000000000000000000001";
200
                end if;
201
        end if;
202
end if;
203
end process;
204
 
205
rd_addr<=rdaddr_t;
206
 
207
 
208
FSM_SEL_HEADER_C: FSM_SEL_HEADER Port Map
209
( rst => rst,
210
  clk => clk,
211
  usr_phase_en => usr_data_phase_on,
212
  sel => sel_header
213
);
214
 
215
select_header_v <= (others=> sel_header);
216
select_data_v <= (others=> not sel_header);
217
 
218
 
219
DATA_OUT_MUX_C: DATA_OUT_MUX Port Map
220
( status => header_byte(2 downto 0),
221
  addr => counter_r,
222
  usr_d_on => usr_data_phase_on,
223
  data_8 => data_in_8,
224
  data_16 => data_in_16,
225
  data_32 => data_in_32,
226
  data_64 => data_in_64,
227
  data_out => usr_data_to_trasmit_t
228
);
229
 
230
usr_data_to_trasmit <= (select_header_v and header_byte) or (select_data_v and usr_data_to_trasmit_tt);
231
 
232
trans_ov <= not tx_eof_in;
233
 
234
end Behavioral;
235
 

powered by: WebSVN 2.1.0

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