source: PROJECT_CORE_MPI/SWITCH_GEN/BRANCHES/v0.03/proto_send.vhd @ 69

Last change on this file since 69 was 69, checked in by rolagamo, 11 years ago
File size: 3.4 KB
Line 
1----------------------------------------------------------------------------------
2-- Company:
3-- Engineer:
4--
5-- Create Date:    18:01:21 10/23/2012
6-- Design Name:
7-- Module Name:    proto_send - 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----------------------------------------------------------------------------------
20library IEEE;
21use IEEE.STD_LOGIC_1164.ALL;
22USE ieee.numeric_std.ALL;
23use 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
33entity proto_send is
34generic (sizemem : natural := 64);
35 port (
36 clk,reset : in std_logic;
37 fifo_empty,fifo_full : in std_logic;
38  push : out std_logic:='0';
39 fifo_in : out std_logic_vector(Word-1 downto 0);
40 snd_start : in std_logic; --début de la réception
41 snd_ack :in std_logic;   -- acquittement de la réception
42 snd_comp : out std_logic; -- fin de la réception
43 mem :in memory(0 to sizemem-1));
44
45end proto_send;
46
47architecture Behavioral of proto_send is
48type typ_send is (s_head,s_len,s_len2,s_data,s_pulse,s_end);
49 signal etsnd : typ_send;
50 signal sfifo_in : std_logic_vector(Word-1 downto 0);
51 signal spush : std_logic:='0';
52 signal err : std_logic_vector(Word-1 downto 0):=(others =>'0');
53begin
54
55proc_send : process (clk,reset)
56variable dlen,i: natural range 0 to 255 :=0;
57        begin
58        if reset='1' then 
59                                 etsnd<=s_head;
60                                 err<=(others =>'0');
61                                else 
62                                                if rising_edge(clk) then -- le process s'exécute sur chaque front
63                                                                                                                        -- montant de l'horloge
64                                                case etsnd is
65                                                when s_head  =>
66                                                        sfifo_in<=mem(0);
67                                                        snd_comp<='0';
68                                                        i:=0;
69                                                       
70                                                        if fifo_empty='1' and snd_start='1' then
71                                                        spush<='1';
72                                                        snd_comp<='0';
73                                                        etsnd<=s_len;
74                                                        end if;
75                                                when s_pulse =>
76                                                        spush<='1';
77                                                        etsnd<=s_len;
78                                                when s_len  =>
79                                                        sfifo_in<=mem(1); --8 données
80                                                        i:=i+1;
81                                                        dlen:=to_integer(unsigned(mem(i)));
82                                                        if dlen > 2 then
83                                                                spush<='1';
84                                                                snd_comp<='0';
85                                                                etsnd<=s_data;
86                                                        else
87                                                                spush<='1';
88                                                                snd_comp<='1';
89                                                                etsnd<=s_end;
90                                                       
91                                                        end if;
92                                                when s_len2 =>
93                                                        snd_comp<='0';
94                                                                etsnd<=s_data;
95                                                               
96                                                when s_data  =>
97                                                                if (fifo_full='0') and (dlen >2) then 
98                                                                i:=i+1;
99                                                                sfifo_in<=mem(i);
100                                                                        if i>=dlen-1 then --les indices 0 et 1 étant réservés
101                                                                                                                        --les données sont comptés à partir de 2
102                                                                                etsnd<=s_end;
103                                                                                snd_comp<='1';
104                                                                                spush<='1';
105                                                                        else
106                                                                                spush<='1';
107                                                                        end if;
108                                                                       
109                                                                else
110                                                                spush<='0';
111                                                                end if;
112                                               
113                                                when s_end  =>
114                                                                spush<='0';
115                                                                etsnd<=s_head;
116                                                                sfifo_in<=(others=>'-');
117                                                                if snd_ack='1' then
118                                                                        etsnd<=s_head;
119                                                                end if;
120                                                when others =>
121                                                                spush<='0';
122                                                                etsnd<=s_head;
123                                                                sfifo_in<=(others=>'0');
124                                                end case;
125                                                end if;
126                                end if;
127        end process;
128       
129        -- affectation concurentes
130       
131        push<=spush;
132        fifo_in<=sfifo_in;
133end Behavioral;
134
Note: See TracBrowser for help on using the repository browser.