source: PROJECT_CORE_MPI/MPI_HCL/BRANCHES/v2.1/CORE_MPI/MultiMPITest_new.vhd @ 142

Last change on this file since 142 was 142, checked in by rolagamo, 10 years ago
File size: 12.1 KB
Line 
1--------------------------------------------------------------------------------
2-- Company:
3-- Engineer: GAMOM Roland Christian
4--
5-- Create Date:   16:44:13 08/01/2012
6-- Design Name:   
7-- Module Name:   C:/Core MPI/CORE_MPI/MultiMPITest.vhd
8-- Project Name:  MPI_CORE_COMPONENTS
9-- Target Device: 
10-- Tool versions: 
11-- Description:   
12--
13-- VHDL Test Bench Created by ISE for module: MPI_NOC
14--
15-- Dependencies:
16--
17-- Revision:
18-- Revision 0.01 - File Created
19-- Additional Comments:
20--
21--
22--
23--------------------------------------------------------------------------------
24LIBRARY ieee;
25USE ieee.std_logic_1164.ALL;
26 
27library NocLib ;
28
29use NocLib.CoreTypes.all;
30LIbrary MPI_HCL;
31use MPI_HCL.Packet_type.all;
32use work.Hcl_Arch_conf.all;
33USE ieee.numeric_std.ALL;
34 
35ENTITY Mpi_template IS
36--simulation translate_off
37port (clkm : in std_logic;
38reset : in std_logic;
39sw : in std_logic_vector(3 downto 0); --bouton bascule
40Led : out std_logic_vector(Word-1 downto 0));
41--simulation translate_on
42END MPi_template;
43 
44ARCHITECTURE behavior OF MPI_Template IS 
45 
46    -- Component Declaration for the Unit Under Test (UUT)
47 
48    COMPONENT MPI_NOC
49         generic (NPROC: natural:=2);
50    PORT(
51         MPI_Node_in : IN   Ar_MPIPort_in(1 to NPROC);
52         MPI_Node_Out : OUT   Ar_MPIPort_out(1 to NPROC)
53        );
54    END COMPONENT;
55         component proto_send is
56generic (sizemem : natural := 64);
57 port (
58 clk,reset : in std_logic;
59 fifo_in_empty,fifo_in_full : in std_logic; --signaux pour le fifo d'entrée
60 fifo_out_empty,fifo_out_full : in std_logic; --signaux pour le fifo de sortie
61 fifo_out_wr_en : out std_logic:='0'; --écriture autorisée dans la fifo de sortie
62 fifo_in_rd_en : out std_logic:='0'; --lecture autorisée dans la fifo d'entrée
63 fifo_in_data_out : in std_logic_vector(Word-1 downto 0);
64 fifo_out_data_in : out std_logic_vector(Word-1 downto 0);
65 packet_len : in std_logic_vector(Word-1 downto 0); --la longueur du paquet
66 copy_mode : in std_logic; --Fifo_to_mem ou Fifo_to_fifo
67 snd_start : in std_logic; --début de la réception
68 snd_ack :in std_logic;   -- acquittement de la réception
69 snd_comp : out std_logic; -- fin de la réception
70 mem :in memory(0 to sizemem-1)); --données à copier vers le fifo
71 end component proto_send;
72Component Fifo2mem is
73Port ( clk : in  STD_LOGIC;
74           reset : in  STD_LOGIC;
75                          wr_start : in STD_LOGIC;
76           fifo_data_out : in  STD_LOGIC_VECTOR (Word-1 downto 0);
77           fifo_data_available : in  STD_LOGIC;
78                          datalen :   STD_LOGIC_VECTOR (Word-1 downto 0);
79           fifo_data_out_en : out  STD_LOGIC;
80           fifo_empty : in  STD_LOGIC;
81                          ram_busy : in  STD_LOGIC;
82           ram_addr_start : in  STD_LOGIC_VECTOR (ADRLEN-1 downto 0);
83                          ram_addr : out  STD_LOGIC_VECTOR (ADRLEN-1 downto 0);
84           ram_data_in : out  STD_LOGIC_VECTOR (Word-1 downto 0);
85           ram_wr : out  STD_LOGIC;
86           ram_en : out  STD_LOGIC;
87                          wr_comp :out STD_LOGIC);
88end component fifo2mem;
89 Component PE
90  generic(destid : natural;
91                                use_dyn:natural);
92  Port ( Instruction : out  STD_LOGIC_VECTOR (Word-1 downto 0);
93           Instruction_en : out  STD_LOGIC;
94                          Core_PushOut : in STD_LOGIC_VECTOR (Word-1 downto 0);
95           clk : in  STD_LOGIC;
96           reset : in  STD_LOGIC;
97                          CE : in  STD_LOGIC;
98           Core_RAM_Data_Out : out  STD_LOGIC_VECTOR (Word-1 downto 0);
99           Core_RAM_Data_In : in  STD_LOGIC_VECTOR (Word-1 downto 0);
100           Core_RAM_WE : in  STD_LOGIC;
101           Core_RAM_EN : in  STD_LOGIC;
102           --Core_RAM_ENB : in  STD_LOGIC;
103           Core_RAM_ADDRESS_WR : in  STD_LOGIC_VECTOR (ADRLEN-1 downto 0);
104           Core_RAM_ADDRESS_RD : in  STD_LOGIC_VECTOR (ADRLEN-1 downto 0);
105           Core_Hold_req : in  STD_LOGIC;
106           Core_Hold_Ack : out  STD_LOGIC);
107end Component; 
108 
109        constant clk_period : time := 15 ns;
110   constant PROC : positive :=NOC_SIZE; --4
111-- synthesis translate_off
112--===================signaux pour l'horloge ==============================
113--signal reset,clkm : std_logic := '0';
114--========================================================================
115-- synthesis translate_on
116 --signaux pour la gestion de la MAE
117 type typ_mae is (start,Fillmem,NextFill,InitApp,InitCompleted,writeptr,InstrCopy, 
118 putdata,putdata2,putcompleted,getdata,getdata2,getcompleted,terminate,st_timeout);
119
120--groupe de signaux utilisé pour communiquer avec l'extérieur de la plateforme
121type arDpRam is array (natural range <>) of typ_dpRam;
122type typ_Pconsole is(idle,get_bus,get_ht_mem,rd_ht_mem,wr_ht_mem,et_end);
123signal et_Pconsole,Next_et_Pconsole : typ_pconsole;
124signal Pcons_ram :typ_dpram; --signaux pour accès à la ram par la console
125signal pcons_hold_req,pcons_hold_ack: std_logic;--pour accès à la Ram du HT
126signal pcons_wr_comp,pcons_wr_start : std_logic;--pour contrôler l'écriture dans la Ram du HT
127signal pcons_rd_comp,pcons_rd_start :std_logic;
128signal pcons_ram_busy : std_logic:='0';
129signal pcons_ht : natural range 0 to 15;--le numéro du HT qui est sollicité
130signal mux_hold_req,dmux_hold_ack: std_logic_vector(1 to PROC); --multiplexer les signaux d'accès RAM HT entre Core_MPI et console
131signal mux_ram : Ar_DpRam(1 to PROC); 
132signal pcons_sel:std_logic_vector(1 to PROC);--état de la sélection du MUX entre Console et Core MPI
133--
134--signaux pour le module de communication RS232C
135signal rs_cmd,rs_rw,rs_comp:std_logic;
136signal rs_addr_start:std_logic_vector(adrlen-1 downto 0);
137signal rs_plen :std_logic_vector(word-1 downto 0);
138signal rs_fifo_data_out_en:std_logic;
139signal rs_fifo_data_available : std_logic;
140signal rs_fifo_data_out :std_logic_vector(word-1 downto 0);
141--
142signal dcount : natural range 0 to 255:=0; --permet de compter le packet de données envoyées
143signal count,count_i : natural range 0 to 15:=0;
144
145signal MPI_Node_in : Ar_MPIPort_in(1 to PROC) ;
146signal MPI_Node_Out : Ar_MPIPort_out(1 to PROC);
147
148 
149
150 
151BEGIN
152SysMPI: MPI_NOC GENERIC MAP (NPROC=>NOC_SIZE)
153                PORT MAP (
154          MPI_Node_in => MPI_Node_in,
155          MPI_Node_Out => MPI_Node_Out
156        );
157
158res_Led_sw:process (MPi_Node_out(1).PushOut,MPi_Node_out(1).PushOut)
159variable p:natural range 0 to 15:=0;
160begin
161p:=to_integer(unsigned(sw)); --récupérer les switchs pour définir les entrées
162Led<=MPi_Node_out(p).PushOut;
163end process;
164
165S_Grp:for i in 1 to STATIC_HT generate
166S: PE   Generic map (DestId=>i-1,
167                                                         use_dyn=>0)
168                        Port Map (
169                                Instruction => MPi_Node_in(i).Instruction,
170           Instruction_en => MPi_Node_in(i).Instruction_en,
171                          Core_PushOut => MPi_Node_out(i).PushOut,
172           clk =>clkm,
173           reset =>reset,
174                          CE => '1',
175                                Core_RAM_Data_Out =>mux_ram(i).i.Data_out,
176           Core_RAM_Data_IN => mux_ram(i).o.data_in,
177           Core_RAM_WE => mux_ram(i).o.we,
178           Core_RAM_EN => mux_ram(i).o.enb,
179           Core_RAM_Address_Wr => mux_ram(i).o.addr_wr,
180           Core_RAM_Address_Rd => mux_ram(i).o.addr_rd,
181           Core_Hold_req => mux_hold_req(i),
182           Core_Hold_Ack => dmux_hold_ack(i)                     
183--           Core_RAM_Data_Out =>MPi_Node_in(i).Ram_Data_out,
184--           Core_RAM_Data_IN => MPI_Node_out(i).ram_data_in,
185--           Core_RAM_WE => MPI_Node_out(i).ram_we,
186--           Core_RAM_EN => MPI_Node_out(i).ram_en,
187--           --Core_RAM_ENB => MPI_Node_out(2).ram_en,
188--           Core_RAM_Address_Wr => MPI_Node_out(i).ram_address_wr,
189--           Core_RAM_Address_Rd => MPI_Node_out(i).ram_address_rd,
190--           Core_Hold_req => MPI_Node_out(i).hold_req,
191--           Core_Hold_Ack => MPI_Node_in(i).hold_ack
192);
193MPI_Node_in(i).reset<=reset;   
194MPI_Node_in(i).clk<=clkm;
195end generate S_Grp;
196dyn_mod: if dyn_allowed='1' generate
197D_Grp:for i in STATIC_HT+1 to NOC_SIZE generate
198D: PE   Generic map (DestId=>i-1,
199                                                use_dyn=>1)
200                        Port Map (
201                                Instruction => MPi_Node_in(i).Instruction,
202           Instruction_en => MPi_Node_in(i).Instruction_en,
203                          Core_PushOut => MPi_Node_out(i).PushOut,
204           clk =>clkm,
205           reset =>reset,
206                          CE => '0',
207           Core_RAM_Data_Out =>mux_ram(i).i.Data_out,
208           Core_RAM_Data_IN => mux_ram(i).o.data_in,
209           Core_RAM_WE => mux_ram(i).o.we,
210           Core_RAM_EN => mux_ram(i).o.enb,
211           Core_RAM_Address_Wr => mux_ram(i).o.addr_wr,
212           Core_RAM_Address_Rd => mux_ram(i).o.addr_rd,
213           Core_Hold_req => mux_hold_req(i),
214           Core_Hold_Ack => dmux_hold_ack(i)
215);
216MPI_Node_in(i).reset<=reset;   
217MPI_Node_in(i).clk<=clkm;
218end generate D_Grp;
219end generate dyn_mod;
220
221--lecture de la mémoire de communication de chaque tâche et envoie des données
222-- sur le port série
223Pcons_sync:process(clkm)
224begin
225if rising_edge(clkm) then
226if reset='1' then
227Et_Pconsole<=idle;
228else
229et_Pconsole<=next_et_Pconsole;
230
231end if;
232end if;
233end process;
234Pcons_next : process(et_Pconsole,rs_cmd)
235variable bus_free:std_logic:='0';
236begin
237case et_pconsole is
238when idle => if rs_cmd='1' then
239                next_et_pconsole<=get_bus;
240                end if;
241when get_bus => 
242bus_free:='0';
243for i in 1 to PROC loop
244        if MPI_Node_out(i).Hold_req='0' then
245                Pcons_sel(i)<='1';
246                bus_free:='1';
247        else
248                Pcons_sel(i)<='0';
249        end if;
250end loop;
251if bus_free='1' then
252        next_et_pconsole<=get_ht_mem;
253end if;
254when get_ht_mem => if rs_rw='1' then
255                                                                next_et_pconsole<=rd_ht_mem;
256                                                 else --if rs_rw='1' then
257                                                                next_et_pconsole<=wr_ht_mem;
258                                                 end if;
259when rd_ht_mem => if pcons_rd_comp='0' then
260                                                next_et_pconsole<=et_end;
261                                        end if;
262when wr_ht_mem=> if pcons_wr_comp='1' then
263                                        next_et_pconsole<=et_end;
264                                       
265                                        end if;
266when et_end =>
267        for i in 1 to PROC loop
268        Pcons_sel(i)<='0';
269        end loop;
270        if rs_cmd='0' then --atendre la fin de la cmd
271        next_et_pconsole<=idle;
272        end if;
273end case;
274end process;
275Pcons_val : process(et_Pconsole)
276begin
277pcons_rd_start<='0';
278pcons_wr_start<='0';
279rs_comp<='0';
280case et_pconsole is
281when idle =>
282when get_bus =>
283when get_ht_mem => 
284when rd_ht_mem => pcons_rd_start<='1';
285when wr_ht_mem=> pcons_wr_start<='1';
286when et_end=>rs_comp<='1';
287                pcons_wr_start<='0';
288end case;
289end process;
290--Multiplexeur de la console pour l'accès à la RAM de chaque HT.
291Ram_mux: process (clkm,MPI_Node_out,pcons_sel   )
292 begin 
293for i in 1 to PROC loop 
294 case Pcons_sel(i) is
295       
296
297        when '1' =>
298                        mux_ram(i).o.addr_wr<=pcons_ram.o.addr_wr;
299                        mux_ram(i).o.addr_rd<=pcons_ram.o.addr_rd ; 
300                        mux_ram(i).o.we<=pcons_ram.o.we;
301                        mux_ram(i).o.enb<=pcons_ram.o.enb;
302                        mux_ram(i).o.data_in<=pcons_ram.o.data_in;
303                        mux_hold_req(i)<=Pcons_Hold_req;
304        when others =>
305                        mux_ram(i).o.addr_wr<=MPI_Node_out(i).Ram_address_wr;
306                        mux_ram(i).o.addr_rd<=MPI_Node_out(i).Ram_address_rd ; 
307                        mux_ram(i).o.we<=MPI_Node_out(i).Ram_we;
308                        mux_ram(i).o.enb<=MPI_Node_out(i).Ram_en;
309                        mux_ram(i).o.data_in<=MPI_Node_out(i).Ram_data_in;
310                        mux_hold_req(i)<=MPI_Node_out(i).Hold_req;             
311end case ;
312end loop;
313end process ;
314--écriture dans la mémoire d'une tâche matérielle
315Inst_Fifo2Mem: Fifo2Mem PORT MAP(
316                clk =>clkm ,
317                reset =>reset ,
318                wr_start =>pcons_wr_start ,
319                fifo_data_out => rs_fifo_data_out,
320                fifo_data_available =>rs_fifo_data_available ,
321                datalen =>rs_plen ,
322                fifo_data_out_en =>rs_fifo_data_out_en ,
323                fifo_empty =>'0' ,
324                ram_busy => pcons_ram_busy, --not pcons_sel(pcons_ht) ,
325                ram_addr_start =>rs_addr_start ,
326                ram_addr =>pcons_ram.o.addr_wr,
327                ram_data_in =>pcons_ram.o.data_in ,
328                ram_wr =>pcons_ram.o.we ,
329                ram_en =>pcons_ram.o.enb ,
330                wr_comp =>pcons_wr_comp
331        );
332--démultiplexeurs de la console pour accès à la RAM de chaque Tâche matérielle.
333Ram_dmux : process(MPI_node_in,mux_ram,PCons_sel,pcons_ht)
334variable Tram_out:std_logic_vector(Word-1 downto 0):=(others=>'0');
335begin
336for i in 1 to PROC loop
337case PCons_sel(i) is
338
339when '1' =>     if pcons_ht=i then 
340                                                Pcons_hold_ack<=dmux_hold_ack(i);
341                                        end if;
342                                        --Pcons_ram.I.data_out<=mux_ram(i).i.data_out;
343                                        if i=pcons_ht then
344                                        Pcons_ram.I.data_out<=mux_ram(i).i.data_out;
345                                        else
346                                        TRam_out:=Tram_out or mux_ram(i).i.data_out;
347                                        end if;
348                                        MPI_Node_in(i).hold_ack<='0';
349                                        MPI_Node_in(i).Ram_data_out<=(others=>'-');
350when others => Pcons_hold_ack<='0';
351                                        --Pcons_ram.I.data_out<=(others=>'-');
352                                        TRam_out:=(others=>'-');
353                                        MPI_Node_in(i).hold_ack<=dmux_hold_ack(i);
354                                        MPI_Node_in(i).Ram_data_out<=mux_ram(i).i.data_out;                               
355end case;
356end loop;
357
358end process;
359END;
Note: See TracBrowser for help on using the repository browser.