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/] [PC2FPGA.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:    13:29:11 03/02/2011 
6
-- Design Name: 
7
-- Module Name:    PC2FPGA - 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 PC2FPGA is
31
    Port ( rst : in  STD_LOGIC;
32
           clk : in  STD_LOGIC;
33
 
34
           locked : in  STD_LOGIC;
35
 
36
                          rx_sof : in  STD_LOGIC;
37
                          rx_eof : in  STD_LOGIC;
38
                          vld_i : in  STD_LOGIC;
39
                          val_i : in  STD_LOGIC_VECTOR(7 downto 0);
40
 
41
                          sod_o : out  STD_LOGIC;
42
                          eod_o : out  STD_LOGIC;
43
 
44
                          type_o : out  STD_LOGIC_VECTOR(2 downto 0); -- 000: no transmission
45
                                                                                                                                                 -- 001: receiving characters
46
                                                                                                                                                 -- 010: receiving short integers
47
                                                                                                                                                 -- 011: receiving integers
48
                                                                                                                                                 -- 100: receiving floats
49
                                                                                                                                                 -- 101: receiving doubles
50
 
51
                          vld_o : out  STD_LOGIC;
52
 
53
                          val_o_char : out  STD_LOGIC_VECTOR(7 downto 0);
54
                          val_o_short : out  STD_LOGIC_VECTOR(15 downto 0);
55
                          val_o_int_float : out  STD_LOGIC_VECTOR(31 downto 0);
56
                          val_o_long_double : out  STD_LOGIC_VECTOR(63 downto 0)
57
 
58
                          );
59
end PC2FPGA;
60
 
61
architecture Behavioral of PC2FPGA is
62
 
63
component MATCH_CMD is
64
    Port ( rst : in  STD_LOGIC;
65
           clk : in  STD_LOGIC;
66
           sof : in  STD_LOGIC;
67
           vld_i : in  STD_LOGIC;
68
           val_i : in  STD_LOGIC_VECTOR (7 downto 0);
69
                          cmd_to_match : in  STD_LOGIC_VECTOR(7 downto 0);
70
           cmd_match : out  STD_LOGIC);
71
end component;
72
 
73
component MODE_SEL_REGISTER is
74
    Port ( rst : in  STD_LOGIC;
75
           clk : in  STD_LOGIC;
76
           rx_sof : in  STD_LOGIC;
77
           rx_eof : in  STD_LOGIC;
78
           en : in  STD_LOGIC;
79
           sel : out  STD_LOGIC);
80
end component;
81
 
82
signal pack_is_chars, pack_is_shorts, pack_is_ints, pack_is_floats, pack_is_longs, pack_is_doubles,
83
       select_chars, select_shorts, select_ints, select_floats, select_longs, select_doubles,
84
                 vld_o_t, en_counter, en_counter_r, sod_o_t, vld_i_r, set_eod, rx_eof_reg: std_logic;
85
signal select_chars_v, select_shorts_v, select_ints_v, select_floats_v, select_ints_floats_v, select_longs_v, select_doubles_v, select_longs_doubles_v,
86
       type_o_t, type_o_t_r, match_t_1, match_t_2, match_t_3, match_t_4, counter_value: std_logic_vector(2 downto 0);
87
 
88
signal sel_val_o_chars_v: std_logic_vector(7 downto 0);
89
signal short_res, sel_val_o_shorts_v: std_logic_vector(15 downto 0);
90
signal int_float_res, sel_val_o_ints_floats_v: std_logic_vector(31 downto 0);
91
signal long_double_res, sel_val_o_longs_doubles_v: std_logic_vector(63 downto 0);
92
 
93
signal val_i_r2, val_i_r3, val_i_r4, val_i_r5, val_i_r6, val_i_r7, val_i_r8: std_logic_vector(7 downto 0);
94
signal user_length, user_counter: std_logic_vector(15 downto 0);
95
 
96
begin
97
 
98
sod_o_t <= (pack_is_chars or pack_is_shorts or pack_is_ints or pack_is_floats or pack_is_longs or pack_is_doubles) and locked;
99
 
100
sod_o <= sod_o_t;
101
 
102
eod_o <= (not rx_eof_reg) and locked;
103
 
104
MATCH_CHAR: MATCH_CMD Port Map
105
( rst => rst,
106
  clk => clk,
107
  sof => rx_sof,
108
  vld_i => vld_i,
109
  val_i => val_i,
110
  cmd_to_match => "00000001",
111
  cmd_match => pack_is_chars
112
);
113
 
114
MATCH_SHORT: MATCH_CMD Port Map
115
( rst => rst,
116
  clk => clk,
117
  sof => rx_sof,
118
  vld_i => vld_i,
119
  val_i => val_i,
120
  cmd_to_match => "00000010",
121
  cmd_match => pack_is_shorts
122
);
123
 
124
MATCH_INT: MATCH_CMD Port Map
125
( rst => rst,
126
  clk => clk,
127
  sof => rx_sof,
128
  vld_i => vld_i,
129
  val_i => val_i,
130
  cmd_to_match => "00000011",
131
  cmd_match => pack_is_ints
132
);
133
 
134
MATCH_FLOAT: MATCH_CMD Port Map
135
( rst => rst,
136
  clk => clk,
137
  sof => rx_sof,
138
  vld_i => vld_i,
139
  val_i => val_i,
140
  cmd_to_match => "00000100",
141
  cmd_match => pack_is_floats
142
);
143
 
144
MATCH_LONG: MATCH_CMD Port Map
145
( rst => rst,
146
  clk => clk,
147
  sof => rx_sof,
148
  vld_i => vld_i,
149
  val_i => val_i,
150
  cmd_to_match => "00000101",
151
  cmd_match => pack_is_longs
152
);
153
 
154
MATCH_DOUBLE: MATCH_CMD Port Map
155
( rst => rst,
156
  clk => clk,
157
  sof => rx_sof,
158
  vld_i => vld_i,
159
  val_i => val_i,
160
  cmd_to_match => "00000110",
161
  cmd_match => pack_is_doubles
162
);
163
 
164
SELECT_CHAR: MODE_SEL_REGISTER Port map
165
( rst => rst,
166
  clk => clk,
167
  rx_sof => rx_sof,
168
  rx_eof => rx_eof_reg,
169
  en => pack_is_chars,
170
  sel => select_chars
171
);
172
 
173
SELECT_SHORT: MODE_SEL_REGISTER Port map
174
( rst => rst,
175
  clk => clk,
176
  rx_sof => rx_sof,
177
  rx_eof => rx_eof_reg,
178
  en => pack_is_shorts,
179
  sel => select_shorts
180
);
181
 
182
SELECT_INT: MODE_SEL_REGISTER Port map
183
( rst => rst,
184
  clk => clk,
185
  rx_sof => rx_sof,
186
  rx_eof => rx_eof_reg,
187
  en => pack_is_ints,
188
  sel => select_ints
189
);
190
 
191
SELECT_FLOAT: MODE_SEL_REGISTER Port map
192
( rst => rst,
193
  clk => clk,
194
  rx_sof => rx_sof,
195
  rx_eof => rx_eof_reg,
196
  en => pack_is_floats,
197
  sel => select_floats
198
);
199
 
200
SELECT_LONG: MODE_SEL_REGISTER Port map
201
( rst => rst,
202
  clk => clk,
203
  rx_sof => rx_sof,
204
  rx_eof => rx_eof_reg,
205
  en => pack_is_longs,
206
  sel => select_longs
207
);
208
 
209
SELECT_DOUBLE: MODE_SEL_REGISTER Port map
210
( rst => rst,
211
  clk => clk,
212
  rx_sof => rx_sof,
213
  rx_eof => rx_eof_reg,
214
  en => pack_is_doubles,
215
  sel => select_doubles
216
);
217
 
218
select_chars_v <= (others=> select_chars and locked);
219
select_shorts_v <= (others=> select_shorts and locked);
220
select_ints_v <= (others=> select_ints and locked);
221
select_floats_v <= (others=> select_floats and locked);
222
select_ints_floats_v <= (others=> (select_ints or select_floats) and locked);
223
select_longs_v <= (others=> select_longs and locked);
224
select_doubles_v <= (others=> select_doubles and locked);
225
select_longs_doubles_v <= (others=> (select_longs or select_doubles) and locked);
226
 
227
 
228
sel_val_o_chars_v <= (others=> select_chars and locked);
229
sel_val_o_shorts_v <= (others=> select_shorts and locked);
230
sel_val_o_ints_floats_v <= (others=> (select_ints or select_floats) and locked);
231
sel_val_o_longs_doubles_v <= (others=> (select_longs or select_doubles) and locked);
232
 
233
type_o_t <=  (select_chars_v and "001") or
234
                 (select_shorts_v and "010") or
235
                                  (select_ints_v and "011") or
236
                                (select_floats_v and "100") or
237
                                 (select_longs_v and "101") or
238
                          (select_doubles_v and "110") ;
239
 
240
type_o <= type_o_t or type_o_t_r;
241
 
242
en_counter <= select_chars or
243
                                  select_shorts or
244
                                  select_ints or
245
                                  select_floats or
246
                                  select_longs or
247
                                  select_doubles;
248
 
249
process(clk)
250
begin
251
if clk'event and clk='1' then
252
        rx_eof_reg <= rx_eof;
253
        if en_counter='0' then
254
                counter_value <= "000";
255
        else
256
                counter_value <= counter_value + "001";
257
        end if;
258
end if;
259
end process;
260
 
261
match_t_1 <= (select_shorts_v and "000") or (select_ints_floats_v and "010") or (select_longs_doubles_v and "110");
262
match_t_2 <= (select_shorts_v and "010") or (select_ints_floats_v and "010") or (select_longs_doubles_v and "110");
263
match_t_3 <= (select_shorts_v and "100") or (select_ints_floats_v and "110") or (select_longs_doubles_v and "110");
264
match_t_4 <= (select_shorts_v and "110") or (select_ints_floats_v and "110") or (select_longs_doubles_v and "110");
265
 
266
process(clk)
267
begin
268
if clk'event and clk='1' then
269
        en_counter_r <= en_counter;
270
        type_o_t_r <= type_o_t;
271
        if counter_value = match_t_1 or counter_value = match_t_2 or counter_value = match_t_3 or counter_value = match_t_4 then
272
                vld_o_t <= '1';
273
        else
274
                vld_o_t <= '0';
275
        end if;
276
end if;
277
end process;
278
 
279
process(clk)
280
begin
281
if clk'event and clk='1' then
282
        val_i_r2 <= val_i;
283
        val_i_r3 <= val_i_r2;
284
        val_i_r4 <= val_i_r3;
285
        val_i_r5 <= val_i_r4;
286
        val_i_r6 <= val_i_r5;
287
        val_i_r7 <= val_i_r6;
288
        val_i_r8 <= val_i_r7;
289
end if;
290
end process;
291
 
292
short_res(15 downto 8) <= val_i_r2;
293
short_res(7 downto 0) <= val_i;
294
 
295
int_float_res(31 downto 24) <= val_i_r4;
296
int_float_res(23 downto 16) <= val_i_r3;
297
int_float_res(15 downto 0) <= short_res;
298
 
299
long_double_res(63 downto 56) <= val_i_r8;
300
long_double_res(55 downto 48) <= val_i_r7;
301
long_double_res(47 downto 40) <= val_i_r6;
302
long_double_res(39 downto 32) <= val_i_r5;
303
long_double_res(31 downto 0) <= int_float_res;
304
 
305
process(clk)
306
begin
307
if clk'event and clk='1' then
308
        vld_o <= (select_chars or ((select_shorts or select_ints or select_floats or select_longs or select_doubles) and vld_o_t and en_counter_r)) and locked;
309
        val_o_char <= val_i and sel_val_o_chars_v;
310
        val_o_short <= short_res and sel_val_o_shorts_v;
311
        val_o_int_float <= int_float_res and sel_val_o_ints_floats_v;
312
        val_o_long_double <= long_double_res and sel_val_o_longs_doubles_v;
313
end if;
314
end process;
315
 
316
end Behavioral;
317
 

powered by: WebSVN 2.1.0

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