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

Last change on this file since 71 was 71, checked in by rolagamo, 11 years ago
File size: 4.7 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 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
33entity proto_send is
34generic (sizemem : natural := 64);
35 port (
36 clk,reset : in std_logic;
37 fifo_in_empty,fifo_in_full : in std_logic; --signaux pour le fifo d'entrée
38 fifo_out_empty,fifo_out_full : in std_logic; --signaux pour le fifo de sortie
39 fifo_out_wr_en : out std_logic:='0'; --écriture autorisée dans la fifo de sortie
40 fifo_in_rd_en : out std_logic:='0'; --lecture autorisée dans la fifo d'entrée
41 fifo_in_data_out : in std_logic_vector(Word-1 downto 0);
42 fifo_out_data_in : out std_logic_vector(Word-1 downto 0);
43 packet_len : in std_logic_vector(Word-1 downto 0); --la longueur du paquet
44 copy_mode : in std_logic; --Fifo_to_mem ou Fifo_to_fifo
45 snd_start : in std_logic; --début de la réception
46 snd_ack :in std_logic;   -- acquittement de la réception
47 snd_comp : out std_logic; -- fin de la réception
48 mem :in memory(0 to sizemem-1)); --données à copier vers le fifo
49
50end proto_send;
51
52architecture Behavioral of proto_send is
53type typ_send is (s_head,s_len,s_len2,s_data,s_pulse,s_end);
54 signal etsnd : typ_send;
55 signal snd_state,next_snd_state:natural range 0 to 7:=0;
56 signal p_len,p_len_i : natural range 0 to 255;
57 signal n,n_i:natural range 0 to 7;
58 signal wr_ok,rd_ok:std_logic:='0';
59 signal sfifo_in,Data_to_send : std_logic_vector(Word-1 downto 0);
60 signal spush : std_logic:='0';
61 signal err : std_logic_vector(Word-1 downto 0):=(others =>'0');
62begin
63
64Fifo_copy_sync:process(clk)
65
66begin
67if rising_edge(clk) then
68
69  if reset='1' then
70  n<=0;
71  Snd_state<=0;
72  P_len<=0;
73else
74  Snd_state<=Next_Snd_state;
75  n<=n_i;       
76  p_len<=P_len_i;
77end if;
78end if;
79end process fifo_copy_sync;
80        -- affectation concurentes
81         Fifo_copy_val:process (Snd_state,Etsnd,copy_mode,data_to_send,rd_ok,wr_ok,spush)
82begin
83        if copy_mode='0' then 
84          fifo_out_wr_en<=wr_ok;
85          fifo_out_data_in<=data_to_send;
86          fifo_in_rd_en<='0';
87else
88    if (Snd_state=1) or (snd_state=2) then
89                  fifo_out_wr_en<=wr_ok;
90                  fifo_in_rd_en<=rd_ok;
91                  fifo_out_data_in<=data_to_send;
92          end if;
93end if;
94end process fifo_copy_val;
95        -- process qui envoie des données en provenance d'un Fifo vers un Fifo
96        FIfo_to_fifo:process(snd_state,copy_mode,snd_start,snd_ack,fifo_in_empty,
97        fifo_out_full,Fifo_in_data_out,p_len)
98        variable onepop:std_logic:='0';
99        begin
100                  Next_snd_state<=snd_state; --valeur par defaut
101          case snd_state is
102
103          when 0 => if snd_start='1' then
104                       P_len_i<=to_integer(unsigned(packet_len));
105                         next_snd_state<=1;
106                         n_i<=0;
107                     end if;
108                     wr_ok<='0';rd_ok<='0';onepop:='0';
109                     snd_comp<='0';
110          when 1=>         if P_len>0 then 
111                                                                                    if copy_mode='1' then 
112                                                                                                if  fifo_in_empty='0' and onepop='0' then
113                                                                                                                data_to_send <=fifo_in_data_out ;
114                                                                                                                rd_Ok<='1';
115                                                                                                                        onepop:=not onepop; --une donnée lue il faut arrêter de dépiler
116                                                                                                                       
117                                                                                                else
118                                                                                                                        rd_Ok<='0';
119                                                                                                end if;
120                                                                                                else
121                                                                                                  onepop:='1';
122                                                                                                  data_to_send<=mem(n);
123                                                                                                 end if;
124
125                                                                                          if (fifo_out_full = '0') and onepop='1'   then                                                                                        wr_ok<='1';
126                                                                                                        onepop:=not onepop;
127                                                                                                        wr_ok<='1';
128                                                                                                        p_len_i<=p_len-1;
129                                                                                                        n_i<=n+1;
130                                                                                                       
131                                                                                                else
132                                                                                                                wr_Ok<='0';
133                                                                                                       
134                                                                                                end if;
135                                                                                        else
136                                                                                         rd_ok<='0';wr_ok<='0';
137                                                                                         next_snd_state<=2;
138                                                                                         snd_comp<='1';
139                                                                                        end if; 
140                when 2 =>  --fin de la copie
141                                                                                                if  snd_ack='1' then 
142                                                                                               
143                                                                                                    next_snd_state<=3;
144                                                                                                end if;
145                                                                                                wr_ok<='0';rd_ok<='0';
146                                                                                                snd_comp<='1';         
147                                                                                                                data_to_send <=(others=>'-');
148        when 3 =>next_snd_state<=0;
149                 snd_comp<='0';
150                                                                                                                       
151when others => next_snd_state<=0;
152                  snd_comp<='0';
153                  rd_ok<='0';
154                  wr_ok<='0';
155                  data_to_send <=(others=>'-');
156  end case;
157        end process FIfo_to_fifo;
158       
159end Behavioral;
160
Note: See TracBrowser for help on using the repository browser.