1 | ---------------------------------------------------------------------------------- |
---|
2 | -- Company: |
---|
3 | -- Engineer: |
---|
4 | -- |
---|
5 | -- Create Date: 17:03:41 10/22/2012 |
---|
6 | -- Design Name: |
---|
7 | -- Module Name: Proto_receiv - ReceiveProto |
---|
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.numeric_std.ALL; |
---|
23 | use work.CoreTypes.all; |
---|
24 | -- Uncomment the following library declaration if using |
---|
25 | -- arithmetic functions with Signed or Unsigned values |
---|
26 | --use IEEE.NUMERIC_STD.ALL; |
---|
27 | |
---|
28 | -- Uncomment the following library declaration if instantiating |
---|
29 | -- any Xilinx primitives in this code. |
---|
30 | --library UNISIM; |
---|
31 | --use UNISIM.VComponents.all; |
---|
32 | |
---|
33 | entity Proto_receiv is |
---|
34 | generic (sizemem : natural := 64); |
---|
35 | port ( |
---|
36 | clk,reset : in std_logic; |
---|
37 | fifo_empty,fifo_full : in std_logic; |
---|
38 | rcv_start : in std_logic; --début de la réception |
---|
39 | rcv_ack :in std_logic; -- acquittement de la réception |
---|
40 | rcv_comp : out std_logic; -- fin de la réception |
---|
41 | pop : out std_logic:='0'; |
---|
42 | fifo_out : in std_logic_vector(Word-1 downto 0); |
---|
43 | mem :out memory(0 to sizemem-1)); |
---|
44 | end Proto_receiv; |
---|
45 | |
---|
46 | architecture ReceiveProto of Proto_receiv is |
---|
47 | type typ_receiv is (r_wait,r_head,r_len,r_glen,r_data,r_pulse,r_end); |
---|
48 | |
---|
49 | signal spush,spop : std_logic:='0'; |
---|
50 | SIGNAL data_in: std_logic_vector(7 downto 0); |
---|
51 | signal etrec :typ_receiv; |
---|
52 | begin |
---|
53 | |
---|
54 | proc_receiv : process (clk,reset) |
---|
55 | variable dlen,i: natural range 0 to 255 :=0; |
---|
56 | |
---|
57 | begin |
---|
58 | if reset='1' then |
---|
59 | etrec<=r_wait; |
---|
60 | |
---|
61 | else |
---|
62 | if rising_edge(clk) then -- le process s'exécute sur chaque front |
---|
63 | -- montant de l'horloge |
---|
64 | case etrec is |
---|
65 | when r_wait => |
---|
66 | |
---|
67 | i:=0; |
---|
68 | if fifo_empty='0' and rcv_start='1' then |
---|
69 | |
---|
70 | etrec<=r_head; |
---|
71 | mem(0)<=fifo_out; |
---|
72 | |
---|
73 | end if; |
---|
74 | when r_head => |
---|
75 | mem(0)<=fifo_out; --l'en-tête |
---|
76 | |
---|
77 | etrec<=r_len; |
---|
78 | |
---|
79 | |
---|
80 | when r_len => |
---|
81 | dlen:=to_integer(unsigned(fifo_out)); |
---|
82 | mem(1)<=fifo_out; -- la longueur |
---|
83 | etrec<=r_data; |
---|
84 | |
---|
85 | i:=1; |
---|
86 | |
---|
87 | when r_data => |
---|
88 | if fifo_empty='0' then |
---|
89 | if i<dlen-3 then |
---|
90 | i:=i+1; |
---|
91 | mem(i)<=fifo_out; |
---|
92 | |
---|
93 | |
---|
94 | else |
---|
95 | etrec<=r_pulse; |
---|
96 | |
---|
97 | mem(i+1)<=fifo_out; |
---|
98 | end if; |
---|
99 | -- time out à prévoir ici |
---|
100 | end if; |
---|
101 | when r_pulse => |
---|
102 | etrec<=r_end; |
---|
103 | |
---|
104 | when r_end => |
---|
105 | if rcv_ack='1' then |
---|
106 | etrec<=r_wait; |
---|
107 | end if; |
---|
108 | |
---|
109 | when others => |
---|
110 | |
---|
111 | |
---|
112 | etrec<=r_wait; |
---|
113 | end case; |
---|
114 | end if; |
---|
115 | end if; |
---|
116 | end process; |
---|
117 | |
---|
118 | pop<=spop; |
---|
119 | |
---|
120 | rec_value : process (etrec) |
---|
121 | begin |
---|
122 | case etrec is |
---|
123 | when r_wait => |
---|
124 | spop<='0'; |
---|
125 | rcv_comp<='0'; |
---|
126 | when r_head => |
---|
127 | |
---|
128 | spop<='1'; |
---|
129 | rcv_comp<='0'; |
---|
130 | -- when r_sync => |
---|
131 | -- spop<='1'; |
---|
132 | -- rcv_comp<='0'; |
---|
133 | when r_len => |
---|
134 | spop<='1'; |
---|
135 | when r_data => |
---|
136 | spop<='1'; |
---|
137 | when r_pulse => |
---|
138 | spop<='0'; |
---|
139 | rcv_comp<='1'; |
---|
140 | when r_end => |
---|
141 | spop<='0'; |
---|
142 | rcv_comp<='1'; |
---|
143 | when others => |
---|
144 | spop<='0'; |
---|
145 | rcv_comp<='0'; |
---|
146 | end case; |
---|
147 | end process; |
---|
148 | end ReceiveProto; |
---|
149 | |
---|