source: PROJECT_CORE_MPI/MPI_HCL/BRANCHES/v2.1/Timer_Par/PE.vhd

Last change on this file was 159, checked in by rolagamo, 10 years ago
File size: 12.5 KB
RevLine 
[159]1----------------------------------------------------------------------------------
2-- Company:
3-- Engineer: GAMOM Roland Christian
4--
5-- Create Date:    21:20:54 07/16/2012
6-- Design Name:
7-- Module Name:    PE - Behavioral
8-- Project Name:
9-- Target Devices:
10-- Tool versions:
11-- Description: Ce module permet d'encapsuler une tâche matérielle
12-- et lui donne la possiblité de communiquer à l'aide des fonctions MPI-2 RMA
13-- Dependencies:
14--
15-- Revision:
16-- Revision 0.01 - File Created
17-- Additional Comments:
18--
19----------------------------------------------------------------------------------
20library IEEE;
21use IEEE.STD_LOGIC_1164.ALL;
22library NocLib ;
23library Std;
24--use IEEE.STD_LOGIC_ARITH.ALL;
25--use IEEE.STD_LOGIC_UNSIGNED.ALL;
26Library MPI_HCL;
27use NocLib.CoreTypes.all;
28use MPI_HCL.Packet_type.all;
29use MPI_HCL.MPI_RMA.all;
30
31-- synthesis translate_off
32use std.textio.all;
33-- synthesis translate_on
34use IEEE.NUMERIC_STD.ALL;
35
36
37entity PE is
38        Generic (DestId : natural:=0; --utiliser pour identifier la tâche
39                                Use_dyn : natural:=0); --détermine si le module est statique =0 ou reconfigurable =1
40    Port ( Instruction : out  STD_LOGIC_VECTOR (Word-1 downto 0);
41           Instruction_en : out  STD_LOGIC;
42                          Core_PushOut : in STD_LOGIC_VECTOR (Word-1 downto 0);
43           clk : in  STD_LOGIC;
44           reset : in  STD_LOGIC;
45                             CE : in STD_LOGIC; -- Active le  PE après sa synthèse
46                                PE_in : in STD_LOGIC_VECTOR (Word-1 downto 0); --port GPIO pour le PE
47                                PE_out : out STD_LOGIC_VECTOR (Word-1 downto 0); --port GPIO pour le PE
48           Core_RAM_Data_Out : out  STD_LOGIC_VECTOR (Word-1 downto 0);
49           Core_RAM_Data_Out2: out  STD_LOGIC_VECTOR (Word-1 downto 0);
50           Core_RAM_Data_In : in  STD_LOGIC_VECTOR (Word-1 downto 0);
51           Core_RAM_WE : in  STD_LOGIC;
52           Core_RAM_EN : in  STD_LOGIC;
53           --Core_RAM_ENB : in  STD_LOGIC;
54           Core_RAM_ADDRESS_WR : in  STD_LOGIC_VECTOR (ADRLEN-1 downto 0);
55           Core_RAM_ADDRESS_RD : in  STD_LOGIC_VECTOR (ADRLEN-1 downto 0);
56           Core_Hold_req : in  STD_LOGIC;
57                          ct_out : out  unsigned(7 downto 0);
58                          ht_state : out typ_mae;
59           Core_Hold_Ack : out  STD_LOGIC);
60end PE;
61
62architecture Behavioral of PE is
63COMPONENT RAM_v
64  generic (width : positive;size :positive);
65        Port ( clka, clkb : in std_logic;
66                          wea : in std_logic;
67                          ena, enb : in std_logic;
68                          addra, addrb : in std_logic_vector(size-1 downto 0); --cinq lignes d'adresse
69                          dia : in std_logic_vector(width-1 downto 0);
70                          dob : out std_logic_vector(width-1 downto 0));
71        END COMPONENT;
72COMPONENT memo8k8
73  PORT (
74    clka : IN STD_LOGIC;
75    ena : IN STD_LOGIC;
76    wea : IN STD_LOGIC_VECTOR(0 DOWNTO 0);
77    addra : IN STD_LOGIC_VECTOR(12 DOWNTO 0);
78    dina : IN STD_LOGIC_VECTOR(7 DOWNTO 0);
79    clkb : IN STD_LOGIC;
80    enb : IN STD_LOGIC;
81    addrb : IN STD_LOGIC_VECTOR(12 DOWNTO 0);
82    doutb : OUT STD_LOGIC_VECTOR(7 DOWNTO 0)
83  );
84END COMPONENT;
85COMPONENT HT_dyn is
86                generic (Task_Id : natural);
87    Port ( clk : in  STD_LOGIC;
88           reset : in  STD_LOGIC;
89                          en : in std_logic; -- active la tâche
90           Interf_i : in  core_i; --signaux pour l'interface I
91           Interf_o : out  core_o; --signaux pour l'interface IO
92           mem_i : in typ_dpram_i; -- signaux pour l'accès à la mémoire
93           mem_o : out typ_dpram_o; -- signaux pour l'accès à la mémoire
94                          ct_out : out unsigned(7 downto 0);
95                          ht_state : out typ_mae;
96                                PE_in : in STD_LOGIC_VECTOR (Word-1 downto 0); --port GPIO pour le PE
97                                PE_out : out STD_LOGIC_VECTOR (Word-1 downto 0) --port GPIO pour le PE
98                          );
99end COMPONENT HT_dyn;
100COMPONENT HT_stat is
101                generic (Task_Id : natural);
102    Port ( clk : in  STD_LOGIC;
103           reset : in  STD_LOGIC;
104                          en : in std_logic; -- active la tâche
105           Interf_i : in  core_i; --signaux pour l'interface I
106           Interf_o : out  core_o; --signaux pour l'interface IO
107           mem_i : in typ_dpram_i; -- signaux pour l'accès à la mémoire
108           mem_o : out typ_dpram_o; -- signaux pour l'accès à la mémoire
109                          ct_out :out unsigned(7 downto 0);
110                          ht_state : out typ_mae;
111                          PE_in : in STD_LOGIC_VECTOR (Word-1 downto 0); --port GPIO pour le PE
112                                PE_out : out STD_LOGIC_VECTOR (Word-1 downto 0) --port GPIO pour le PE
113                         
114                          );
115end COMPONENT HT_stat;
116
117COMPONENT Hold_FSM is
118       
119    Port ( Hold_Req : in  STD_LOGIC;
120           Ram_busy : in  STD_LOGIC;
121           Clk : in  STD_LOGIC;
122           Reset : in  STD_LOGIC;
123           Ramsel : out  STD_LOGIC;
124           Hold_Ack : out  STD_LOGIC);
125end COMPONENT Hold_FSM;
126--données du programme PE
127           --signaux pour l'interconnexionsignal datain :std_logic_vector(word-1 downto 0):= (others => '0');
128        signal ram_we ,ram_ena,ram_enb,ramsel_i: std_logic:='0';
129        signal pe_ram_we ,pe_ram_ena,pe_ram_enb: std_logic;
130        signal pe_instr_en,pe_hold_ack: std_logic:='0';
131        signal ram_do,ram_din:std_logic_vector(word-1 downto 0):= (others => '0');
132        signal pe_ram_do,pe_ram_din:std_logic_vector(word-1 downto 0):= (others => '0');
133        signal ram_addra,ram_addrb :std_logic_vector(ADRLEN-1 downto 0);
134        signal pe_ram_addra,pe_ram_addrb :std_logic_vector(ADRLEN-1 downto 0);
135        signal CRAM_DO : STD_LOGIC_VECTOR (Word-1 downto 0);
136        signal sram : typ_dpram;
137        signal clk_ht : std_logic;
138        signal MyGroup:mpi_group;
139        signal MyWin : mpi_win;
140        signal SrcAdr0,SrcAdr1,destAdr0,destAdr1,Datalen:std_logic_vector(word-1 downto 0);
141        --signal PE_out_i:std_logic_vector(Word-1 downto 0);
142        signal dpid,dpid_i : natural range 0 to 15:=DestId;
143        signal MyRank :std_logic_vector(3 downto 0);
144        signal Libr : Core_io;  --regroupe tous les signaux IO de la bibliothèque
145        signal Lib_Ready:std_logic; --indique que l'exécution de la fonction est terminée
146        signal Lib_instr_ack : std_logic; -- l'instruction est copiée dans le tampon FIFO
147        signal Lib_Init : std_logic; -- l'initialisation est terminée
148        signal Lib_Enable : std_logic:='0';
149        signal Ex1_run,Ex4_run : std_logic:='0'; --indique que ces modules sont en fin d'exécution
150        signal Hold_Ack : std_logic;
151        signal en_task : std_logic;
152        signal ht_reset :std_logic;
153        signal raz_en:std_logic;--signal pour l'activation de la RAZ RAM
154        signal m_count : natural:= 0;
155 --signaux pour la gestion de la MAE
156 type typ_Ht_ena is (ht_lock,ht_raz,ht_stop,ht_on);
157 type typ_mae is (start,Fillmem,NextFill,InitApp,GetRank,WInCreate,WinStart, putdata,getdata,WinCompleted,finalize,st_timeout);
158        type typ_Hld is (Ht_Lock,Core_Lock,Ht_free);
159signal dcount : natural range 0 to 255:=0; 
160signal wea : std_logic_vector (0 downto 0);
161signal count,count_i : natural range 0 to 15:=0;
162signal et_ht_ena : typ_ht_ena;
163
164                signal RunState : typ_mae;
165                signal Hld_state :typ_hld;
166                signal Ram_busy :std_logic:='0';
167begin
168Ram8_k8: RAM_v generic map(width=>word,size=>ADRLEN)
169        PORT MAP(
170                clka =>clk ,
171                clkb => clk ,
172                wea => ram_we,
173                ena => ram_ena,
174                enb => ram_enb,
175                addra => ram_addra,
176                addrb =>ram_addrb,
177                dia => ram_din,
178                dob => ram_do
179        );
180        --wea(0)<=ram_we;
181--      Ram8_k8 : memo8k8
182--  PORT MAP (
183--    clka => clk,
184--    ena => ram_ena,
185--    wea => wea,
186--    addra => ram_addra(12 downto 0),
187--    dina => ram_din,
188--    clkb => clk,
189--    enb => ram_enb,
190--    addrb => ram_addrb(12 downto 0),
191--    doutb => ram_do
192--  );
193 ts: if use_dyn=0  generate
194        HT_task:HT_stat generic map(Task_id =>DestId)
195        port map (
196        clk=>clk,
197        reset=>ht_reset,
198        en=>en_task,
199   Interf_i =>Libr.i,
200   Interf_o=>Libr.o,
201  mem_i =>sram.i,
202 
203   mem_o =>sram.o,     
204        ct_out=>ct_out,
205        pe_in=>pe_in,
206        pe_out=>pe_out,
207        ht_state=>ht_state);
208       
209        end generate;
210  td: if use_dyn=1 generate
211        HT_task:HT_dyn generic map(Task_id =>DestId)
212        port map (
213        clk=>clk,
214        reset=>ht_reset,
215        en=>en_task,
216   Interf_i =>Libr.i,
217   Interf_o=>Libr.o,
218  mem_i =>sram.i,
219   mem_o =>sram.o,     
220        ct_out=>ct_out,
221        pe_in=>pe_in,
222        pe_out=>pe_out,
223        ht_state=>ht_state);
224       
225        end generate;
226--================================================================
227        --MUX de la RAM
228                               
229Ram_mux: process (ramsel_i,pe_ram_addra,pe_ram_addrb,Core_ram_address_rd,Core_ram_address_wr,
230                                                Core_ram_en,Core_ram_we,Core_ram_data_in,pe_ram_ena,pe_ram_enb,Ram_do,
231                                                Pe_ram_din,Pe_ram_we    )
232 begin                         
233 case ramsel_i is
234       
235        when '1' =>
236                ram_addra <= Core_ram_address_wr ;
237                ram_addrb <= Core_ram_address_rd ;
238                ram_ena <= Core_ram_en;
239                ram_enb <= Core_ram_en;
240                ram_we<= Core_ram_we;
241                ram_din <= Core_ram_data_in;
242                pe_ram_do<=(others=>'U');
243                CRAM_DO<=ram_do;
244               
245        when others =>
246                ram_addra <=  pe_ram_addra;
247                ram_addrb <=  pe_ram_addrb;
248                ram_ena <= pe_ram_ena;
249                ram_enb <= pe_ram_enb;
250                ram_we<= pe_ram_we;
251                ram_din <=pe_ram_din;
252                CRAM_DO<=(others=>'0');
253                pe_ram_do<=ram_do;
254end case ;
255
256end process ;
257
258process(CRAM_DO)
259  begin
260CORE_RAM_DATA_OUT<=CRAM_DO; 
261end process;
262CORE_RAM_DATA_OUT2<=CRAM_DO;
263--Instruction_En<=PE_instr_EN; -- Libr.Instr_en; --********A changer **********
264--=== !!!!! attention la suppression de la ligne ci-dessous empêche ce
265-- composant de bien fonctionner !!! !!!!!!!!!!!!!!!!!!!!!!!
266--instruction<=std_logic_vector(to_unsigned(Core_upper_adr,8));
267
268dpid<=dpid_i;
269Lib_Instr_ack<=Core_Pushout(0); --l'instruction a été copié
270Lib_init<=Core_Pushout(4); -- Initialized
271Lib_Enable<=Core_Pushout(6);-- HT activée par la Librairie.
272Ex1_Run<=Core_Pushout(5);  -- fin de l'exécution de Ex1
273Ex4_Run<=Core_pushout(7); -- fin de l'exécution de Ex4 pour Spawn
274horloge_ht:process (reset,en_task,clk)
275begin
276if reset='1' then
277clk_ht<='0';
278count<=0;
279Ht_reset<='1';
280else
281if en_task='1' then
282  clk_ht<=clk;
283  if count=10 then --circuit de reset pour la  HT
284    ht_reset<='0';
285  else
286  if rising_edge(clk) then
287  count<=count+1;
288  end if;
289  ht_reset<='1';
290  end if;
291else
292  count<=0;
293  clk_ht<='0';
294  Ht_reset<='1';
295end if;
296end if;
297end process horloge_ht;
298
299Hold1: Hold_fsm port map (
300clk=>clk ,
301reset =>reset,
302Ram_Busy=>Ram_busy,
303Hold_Ack=>Hold_Ack,
304Hold_req =>Core_Hold_Req,
305RamSel => RamSel_i);
306Core_Hold_Ack<=Hold_Ack;
307
308--================RAM signals ======================                                   
309sram.I.data_out<=PE_ram_do;
310--pe_Ram_addra<=sram.O.addr_wr;
311--pe_Ram_addrb<=sram.O.addr_rd ;
312--PE_Ram_we<=sram.O.we;
313--PE_Ram_ena<=sram.O.ena;
314--PE_Ram_enb<=sram.O.enb;
315--PE_ram_din<=sram.O.data_in;
316--==========MPI HCL signals ============================
317--RAZ de la RAM de communication
318raz_ram: process(et_ht_ena,m_count,lib_enable,sram,reset,raz_en,
319en_task,Core_hold_req,RamSel_i,Core_pushout,Libr.O)
320--valeurs par défaut !
321begin
322pe_Ram_addra<=sram.O.addr_wr;
323pe_Ram_addrb<=sram.O.addr_rd ; 
324PE_Ram_we<=sram.O.we;
325PE_Ram_ena<=sram.O.ena;
326PE_Ram_enb<=sram.O.enb;
327PE_ram_din<=sram.O.data_in;
328
329Instruction<=Libr.O.Instruction;               
330Instruction_en<=Libr.O.Instr_en;       
331Libr.I.Instr_ack<=Core_pushout(0);
332Libr.I.InitOk<=Core_pushout(4);
333Libr.I.Spawned<=Lib_enable;
334Libr.I.Hold_Req<=Core_Hold_req;
335Libr.I.RamSel<=RamSel_i;       
336en_task<='0';
337raz_en<='0';
338--************************************
339case et_ht_ena is
340when ht_lock=>
341
342--si le HT n'est pas activé ces valeurs sont à 0 !
343 Instruction<=(others=>'0');                   
344        Ram_busy<='0';
345  PE_Instr_EN<='0'; 
346when ht_raz =>
347 
348pe_Ram_addra<=std_logic_vector(to_unsigned(m_count,ADRLEN));
349pe_Ram_addrb<=std_logic_vector(to_unsigned(m_count,ADRLEN)) ; 
350PE_Ram_we<='1';
351PE_Ram_ena<='1';
352PE_Ram_enb<='1';
353PE_ram_din<=(others=>'0');
354raz_en<='1';
355Libr.I.Instr_ack<='0';
356Libr.I.InitOk<='0';
357Libr.I.Spawned<=Lib_enable;
358Libr.I.Hold_Req<='1';
359Libr.I.RamSel<='1';     
360when ht_stop =>
361 en_task<='0';         
362Instruction_en<='0';   
363when ht_on=>
364en_task<= '1'; --l'activation d'une HT peut être directe ou commandée
365
366  Instruction<=Libr.O.Instruction;             
367Instruction_en<=Libr.O.Instr_en;       
368        Ram_busy<=Libr.O.membusy;
369PE_Instr_EN<=Libr.O.instr_en;
370pe_Ram_addra<=sram.O.addr_wr;
371pe_Ram_addrb<=sram.O.addr_rd ; 
372PE_Ram_we<=sram.O.we;
373PE_Ram_ena<=sram.O.ena;
374PE_Ram_enb<=sram.O.enb;
375PE_ram_din<=sram.O.data_in;
376
377assert not(Lib_enable='1')
378report "Spawn Activé"
379severity WARNING ;
380
381end case;
382
383end process;
384
385ht_ena_proc:process (clk,reset)
386begin
387if (clk'event and clk='1') then 
388case et_ht_ena is
389when ht_lock=>
390if CE='1' then
391  et_ht_ena<=ht_raz;
392elsif Lib_enable='1' then
393  et_ht_ena<=ht_raz;
394else 
395  et_ht_ena<=ht_lock;
396end if;
397
398m_count<=core_base_adr; --adresse de base du Core MPI-HCL
399when ht_raz=>
400  if m_count<core_base_adr+1023 then
401  m_count<=m_count+1;
402else
403  raz_en<='0';
404  m_count<=core_base_adr;
405  et_ht_ena<=ht_on;
406end if;
407When ht_stop =>
408    if reset='1' then
409        et_ht_ena<=ht_raz;
410    elsif  CE='1' or Lib_enable='1' then
411        et_ht_ena<=ht_on;
412  end if;
413when ht_on=>
414   if reset='1' then 
415     et_ht_ena<=ht_lock;
416  elsif  CE='0' and Lib_enable='0' then
417    et_ht_ena<=ht_stop;
418
419  end if;
420end case;
421end if;
422end process ht_ena_proc;
423--=======================================================================
424--MAE du PE
425--=======================================================================
426
427 
428end Behavioral;
429
Note: See TracBrowser for help on using the repository browser.