source: PROJECT_CORE_MPI/MPI_HCL/TRUNK/CORE_MPI/sim_fifo.vhd @ 100

Last change on this file since 100 was 100, checked in by rolagamo, 10 years ago
File size: 4.4 KB
Line 
1-- TestBench Template
2-- ce module permet de tester le FIFO et de valider son fonctionnement.
3  LIBRARY ieee;
4  USE ieee.std_logic_1164.ALL;
5  USE ieee.numeric_std.ALL;
6  Library  NocLib ;
7 use NocLib.CoreTypes.all;
8  ENTITY testbench IS
9  END testbench;
10
11  ARCHITECTURE behavior OF testbench IS 
12constant clk_period : time := 10 ns;
13constant MSIZE :natural :=256;
14  signal clk : std_logic := '0';
15  signal reset : std_logic := '0';
16  -- Component Declaration
17         
18component FIFO_256_FWFT  --Le FIFO à tester
19        port (
20        clk: IN std_logic;
21        din: IN std_logic_VECTOR(7 downto 0);
22        rd_en: IN std_logic;
23        srst: IN std_logic;
24        wr_en: IN std_logic;
25        dout: OUT std_logic_VECTOR(7 downto 0);
26        empty: OUT std_logic;
27        full: OUT std_logic);
28end component;
29component proto_receiv -- permet de tester la lecture dans le FIFO
30generic (sizemem : natural := 64);
31 port (
32 clk,reset : in std_logic;
33 fifo_empty,fifo_full : in std_logic;
34  pop : out std_logic:='0';
35 fifo_out : in std_logic_vector(Word-1 downto 0);
36 rcv_start : in std_logic; --début de la réception
37 rcv_ack :in std_logic;   -- acquittement de la réception
38 rcv_comp : out std_logic; -- fin de la réception
39 mem :out memory(0 to sizemem-1));
40end component;
41
42component proto_send
43generic (sizemem : natural := 64);
44 port (
45 clk,reset : in std_logic;
46 fifo_empty,fifo_full : in std_logic;
47  push : out std_logic:='0';
48 fifo_in : out std_logic_vector(Word-1 downto 0);
49 snd_start : in std_logic; --début de l'emission
50 snd_ack :in std_logic;   -- acquittement de l'émission
51 snd_comp : out std_logic; -- fin de l'émission
52 mem :in memory(0 to sizemem-1));
53 
54 end component;
55 
56type typ_snd_rec is ( fillmem,send1, send2, recv1,recv2);
57type typ_receiv is (r_wait,r_head,r_dlen,r_glen,r_start,r_end);
58                        signal storage1,storage2 : memory (0 to MSIZE-1);
59          SIGNAL fifo_empty,fifo_full :  std_logic:='0';
60                         signal push,pop ,spush,spop:  std_logic:='0';
61          SIGNAL data_in,data_out:  std_logic_vector(7 downto 0);
62          signal ROn,Rdone,RAck:std_logic:='0';
63                         signal SOn,Sdone,SAck:std_logic:='0';
64                         signal etreceiv :typ_receiv;
65                       
66                         signal pipo : typ_snd_rec;
67
68  BEGIN
69                       
70 
71
72uut : FIFO_256_FWFT
73                port map (
74                        clk => clk,
75                        din => data_in,
76                        rd_en => pop,
77                        srst => reset,
78                        wr_en => push,
79                        dout => data_out,
80                        empty => fifo_empty,
81                        full => fifo_full);
82                       
83rec_pro: proto_receiv generic map(sizemem =>MSIZE)
84        port map (clk=>clk,
85                                reset=>reset,
86                                fifo_empty=>fifo_empty,
87                                fifo_full=>fifo_full,
88                                rcv_start =>Ron,
89                                rcv_ack => Rack,
90                                rcv_comp=> Rdone,
91                                pop=>pop,
92                                fifo_out =>data_out,
93                                mem=>storage2
94                                );
95snd_pro: proto_send generic map (sizemem =>MSIZE)
96port map (clk=>clk,
97                                reset=>reset,
98                                fifo_empty=>fifo_empty,
99                                fifo_full=>fifo_full,
100                                snd_start =>Son,
101                                snd_ack => Sack,
102                                snd_comp=> Sdone,
103                                push=>push,
104                                fifo_in =>data_in,
105                                mem=>storage1
106                                );
107 clk_process :process
108   begin
109                clk <= '0';
110                wait for clk_period/2;
111                clk <= '1';
112                wait for clk_period/2;
113               
114   end process;
115reset_proc: process 
116   begin               
117      -- hold reset state for 100 ns.
118      reset<='0';
119                wait for 1 ns; 
120                reset<='1';
121      wait for clk_period*10;
122                reset<='0';
123                wait;
124      -- insert stimulus here
125end process;
126pr_pingpong : process(clk,reset)
127variable i: natural range 0 to MSIZE-1;
128begin
129if reset='1' then
130        pipo<=fillmem;
131        i:=0;
132        else
133        if rising_edge(clk) then
134        case pipo is
135                when fillmem => -- remplissage de la mémoire d'envoie
136                if i=0 then
137                storage1(0)<=x"51"; -- le code de la fonction
138                elsif i=1 then
139                storage1(1)<=x"05"; -- le nombre d'octets à envoyer dans le tampon.
140                elsif (i>=2) and (i<= MSIZE-2) then
141                storage1(i)<=std_logic_vector(to_unsigned(i-2,Word));
142               
143                else
144                        pipo<=send1;
145                        i:=0;
146                end if;
147                i:=i+1;
148                when send1 =>
149                       
150                        Son<='1'; --activer l'emission des données
151                        Sack<='0';
152                        if i=2 then --activer la réception des données
153                                Ron<='1';
154                        else 
155                                Ron<='0';
156                                i:=i+1;
157                        end if;
158                        if sdone='1' then
159                                pipo<=send2;
160                                               
161                        end if;
162                when send2 =>
163                        i:=0;
164                        Son<='0';
165                        Sack<='1';
166                        pipo<=recv1;
167                when recv1 =>
168                        ron<='1';
169                        rack<='0';
170                        if Rdone='1' then
171                                pipo<=recv2;
172                        end if;
173                when recv2 =>
174                        Ron<='0';
175                        Rack<='1';
176                        pipo<=send1;
177                        i:=0;
178        end case;
179               
180       
181        end if;
182end if;
183end process;
184
185END;
Note: See TracBrowser for help on using the repository browser.