1 | -- Package File Template |
---|
2 | -- |
---|
3 | -- Purpose: This package defines supplemental types, subtypes, |
---|
4 | -- constants, and functions |
---|
5 | |
---|
6 | |
---|
7 | library IEEE; |
---|
8 | use IEEE.STD_LOGIC_1164.all; |
---|
9 | use ieee.numeric_std.all; |
---|
10 | use IEEE.STD_LOGIC_ARITH.ALL; |
---|
11 | use IEEE.STD_LOGIC_UNSIGNED.ALL; |
---|
12 | Library NocLib; |
---|
13 | use NocLib.CoreTypes.all; |
---|
14 | use work.PACKET_TYPE.all; |
---|
15 | |
---|
16 | package Mpi_Rma is |
---|
17 | procedure WritePtr(AdrVect:in std_logic_vector; count: inout natural;signal SysRam :out typ_dpram); |
---|
18 | procedure pMPI_INIT(NextCtx : inout natural;signal Interf:inout Core_io;signal clkin:std_logic;signal SysRam :inout typ_dpram); |
---|
19 | procedure pMPI_PUT(NextCtx : inout natural;signal Interf:inout Core_io;signal clkin:std_logic;signal SysRam :inout typ_dpram; |
---|
20 | Orig_Addr: std_logic_vector;Orig_Count : natural; Orig_DataType: natural; |
---|
21 | Target_Rank : natural; Target_disp : std_logic_vector; Target_Count : natural; |
---|
22 | Target_Datatype :natural; Win : natural); |
---|
23 | |
---|
24 | procedure pMPI_GET(NextCtx : inout natural;signal Interf:inout Core_io;signal clkin:std_logic;signal SysRam :inout typ_dpram; |
---|
25 | Orig_Addr: std_logic_vector;Orig_Count : natural; Orig_DataType: natural; |
---|
26 | Target_Rank : natural; Target_disp : std_logic_vector; Target_Count : natural; |
---|
27 | Target_Datatype :natural; Win : natural); |
---|
28 | procedure pMPI_Comm_Rank(NextCtx : inout natural;signal Interf:inout Core_io;signal SysRam :inout typ_dpram; COMM :in natural; signal Rank : out std_logic_vector ); |
---|
29 | |
---|
30 | procedure pMPI_Win_create(NextCtx : inout natural;signal Interf:inout Core_io;signal SysRam :inout typ_dpram; |
---|
31 | base :std_logic_vector; size : Mpi_Aint;disp_unit:natural; |
---|
32 | info:natural; comm:Mpi_Comm; Win: inout MPI_Win ); |
---|
33 | procedure pMPI_Win_start( NextCtx : inout natural;signal Interf:inout Core_io;signal SysRam :inout typ_dpram; pgroup:MPI_group;asser : natural; Win :MPI_Win); |
---|
34 | procedure pMPI_Win_wait( NextCtx : inout natural;signal Interf:inout Core_io;signal SysRam :inout typ_dpram; Win :MPI_Win); |
---|
35 | |
---|
36 | procedure pMPI_Comm_Spawn(NextCtx : inout natural;signal Interf:inout Core_io;signal SysRam :inout typ_dpram; |
---|
37 | command : natural; argv :natural; maxprocs : natural; info : natural; root : natural; comm : natural; |
---|
38 | signal intercomm :out natural; signal array_of_errcodes : out natural); |
---|
39 | -- declare functions and procedure |
---|
40 | procedure ReadMem( NextCtx : inout natural range 0 to 255;signal Interf:inout Core_io;signal SysRam :inout typ_dpram; |
---|
41 | AdrVect:in std_logic_vector; data: out std_logic_vector); |
---|
42 | procedure WriteMem(NextCtx : inout natural range 0 to 255;signal Interf:inout Core_io;signal SysRam :inout typ_dpram; |
---|
43 | AdrVect:in std_logic_vector; Data:in std_logic_vector); |
---|
44 | end MPI_Rma; |
---|
45 | |
---|
46 | |
---|
47 | package body MPI_Rma is |
---|
48 | ----int MPI_Put( |
---|
49 | -- void *origin_addr, |
---|
50 | -- int origin_count, |
---|
51 | -- MPI_Datatype origin_datatype, |
---|
52 | -- int target_rank, |
---|
53 | -- MPI_Aint target_disp, |
---|
54 | -- int target_count, |
---|
55 | -- MPI_Datatype target_datatype, |
---|
56 | -- MPI_Win win |
---|
57 | --); |
---|
58 | -- Example 1 |
---|
59 | procedure pMPI_PUT(NextCtx : inout natural;signal Interf:inout Core_io;signal clkin:std_logic;signal SysRam :inout typ_dpram; |
---|
60 | Orig_Addr: std_logic_vector;Orig_Count : natural; Orig_DataType: natural; |
---|
61 | Target_Rank : natural; Target_disp : std_logic_vector; Target_Count : natural; |
---|
62 | Target_Datatype :natural; Win : natural) is |
---|
63 | variable i,dcount : natural:=0; |
---|
64 | variable adresse :natural; |
---|
65 | variable addr1 :std_logic_vector(Orig_Addr'length-1 downto 0):=Orig_Addr; |
---|
66 | variable addr2 :std_logic_vector(Target_Disp'length-1 downto 0):=Target_Disp; |
---|
67 | variable put_adr : std_logic_vector (ADRLEN-1 downto 0); |
---|
68 | variable config_reg: std_logic_vector (Word-1 downto 0); |
---|
69 | constant LeftZero: std_logic_vector(2*Word-ADRLEN to 0):=(others=>'0'); |
---|
70 | begin |
---|
71 | put_adr:=Std_logic_vector(to_unsigned(Core_put_adr,ADRLEN)); |
---|
72 | |
---|
73 | addr1:=Orig_Addr; |
---|
74 | addr2:=Target_Disp; |
---|
75 | if NextCtx /=0 then --préserver la valeur de count entre les appels |
---|
76 | dcount:=NextCtx; |
---|
77 | end if; |
---|
78 | -- |
---|
79 | |
---|
80 | if rising_edge(clkin) then |
---|
81 | if dcount>=0 and dcount <=3 then |
---|
82 | if interf.I.ramsel='0' then |
---|
83 | Interf.O.membusy<='0'; |
---|
84 | SysRam.O.we<='1'; |
---|
85 | SysRam.O.ena<='1'; |
---|
86 | SysRam.O.enb<='0'; |
---|
87 | WritePtr (put_adr,dcount,SysRam); |
---|
88 | if dcount =4 then |
---|
89 | -- fin de l'écriture du pointeur en mémoire |
---|
90 | end if; |
---|
91 | end if; |
---|
92 | |
---|
93 | elsif dcount=4 then |
---|
94 | if interf.I.ramsel='0' then |
---|
95 | SysRam.O.we<='1'; |
---|
96 | SysRam.O.ena<='1'; |
---|
97 | SysRam.O.enb<='0'; |
---|
98 | Interf.O.membusy<='1'; |
---|
99 | adresse:=core_put_adr; |
---|
100 | SysRam.O.Data_in<=MPI_PUT & std_logic_vector(to_unsigned(Target_Rank,4)); --code fonction |
---|
101 | SysRam.O.Addr_wr<=Std_logic_vector(to_unsigned(adresse,ADRLEN)); |
---|
102 | dcount:=dcount+1; |
---|
103 | end if; |
---|
104 | elsif dcount=5 then |
---|
105 | if interf.I.ramsel='0' then |
---|
106 | adresse:=core_put_adr+1; |
---|
107 | SysRam.O.Data_in<=std_logic_vector(to_unsigned(Orig_Count,8)) ;--la longueur |
---|
108 | SysRam.O.Addr_wr<=Std_logic_vector(to_unsigned(adresse,ADRLEN)); |
---|
109 | dcount:=dcount+1; |
---|
110 | Interf.O.Instruction<=x"06"; -- nombre de mots de l'instruction |
---|
111 | end if; |
---|
112 | elsif dcount=6 then |
---|
113 | if interf.I.ramsel='0' then |
---|
114 | adresse:=core_put_adr+2; |
---|
115 | SysRam.O.Data_in<= Addr1(ADRLEN-1 downto Word) ; --source Haut |
---|
116 | SysRam.O.Addr_wr<=Std_logic_vector(to_unsigned(adresse,ADRLEN)); |
---|
117 | dcount:=dcount+1; |
---|
118 | end if; |
---|
119 | elsif dcount=7 then |
---|
120 | if interf.I.ramsel='0' then |
---|
121 | adresse:=core_put_adr+3; |
---|
122 | SysRam.O.Data_in<=Addr1(Word-1 downto 0); --source Bas |
---|
123 | SysRam.O.Addr_wr<=Std_logic_vector(to_unsigned(adresse,ADRLEN)); |
---|
124 | dcount:=dcount+1; |
---|
125 | end if; |
---|
126 | elsif dcount=8 then |
---|
127 | if interf.I.ramsel='0' then |
---|
128 | adresse:=core_put_adr+4; |
---|
129 | SysRam.O.Data_in<= Addr2(ADRLEN-1 downto Word) ; -- destination haut |
---|
130 | SysRam.O.Addr_wr<=Std_logic_vector(to_unsigned(adresse,ADRLEN)); |
---|
131 | dcount:=dcount+1; |
---|
132 | end if; |
---|
133 | elsif dcount=9 then |
---|
134 | if interf.I.ramsel='0' then |
---|
135 | adresse:=core_put_adr+5; |
---|
136 | SysRam.O.Data_in<=Addr2(Word-1 downto 0); -- destination bas |
---|
137 | SysRam.O.Addr_wr<=Std_logic_vector(to_unsigned(adresse,ADRLEN)); |
---|
138 | dcount:=dcount+1; |
---|
139 | end if; |
---|
140 | elsif dcount=10 then |
---|
141 | |
---|
142 | SysRam.O.we<='1'; |
---|
143 | SysRam.O.ena<='1'; |
---|
144 | SysRam.O.enb<='1'; |
---|
145 | if interf.I.ramsel='0' then |
---|
146 | adresse:=core_base_adr+1; |
---|
147 | SysRam.O.addr_rd<=std_logic_vector(to_unsigned(core_base_adr+1,ADRLEN)); |
---|
148 | SysRam.O.Addr_wr<=Std_logic_vector(to_unsigned(adresse,ADRLEN)); |
---|
149 | SysRam.O.Data_in<=x"01"; --instruction pulse enable via la mémoire; |
---|
150 | Interf.O.Instr_En<='1'; --active la prise en compte de l'instruction |
---|
151 | Interf.O.membusy<='0'; |
---|
152 | dcount:=dcount+1; |
---|
153 | end if; |
---|
154 | elsif dcount=11 then |
---|
155 | if Interf.I.Instr_ack='1' then -- le Core a reçu l'instruction ? |
---|
156 | Interf.O.Instr_En<='0'; --désactiver la prise en compte de l'instruction |
---|
157 | dcount:=dcount+1; |
---|
158 | config_reg:=SysRam.I.Data_out and x"f6"; |
---|
159 | SysRam.O.Data_in<=config_reg ; --ramener le IPulse à 0; |
---|
160 | else |
---|
161 | Interf.O.Instr_En<='1'; |
---|
162 | end if; |
---|
163 | adresse:=core_base_adr+1; |
---|
164 | SysRam.O.addr_rd<=std_logic_vector(to_unsigned(core_base_adr+1,ADRLEN)); |
---|
165 | SysRam.O.addr_wr<=Std_logic_vector(to_unsigned(adresse,ADRLEN)); |
---|
166 | --SysRam.O.Ram_busy<='0'; --?? |
---|
167 | SysRam.O.we<='0'; |
---|
168 | SysRam.O.ena<='0'; -- préparer la lecture du résultat du Put |
---|
169 | SysRam.O.enb<='1'; |
---|
170 | elsif dcount=12 then |
---|
171 | adresse:=core_base_adr+1; |
---|
172 | SysRam.O.we<='1'; |
---|
173 | SysRam.O.ena<='1'; -- préparer l'écriture du résultat du Put |
---|
174 | SysRam.O.enb<='1'; |
---|
175 | if interf.I.ramsel='0' then |
---|
176 | config_reg:=SysRam.I.Data_out and x"f6"; |
---|
177 | SysRam.O.Data_in<=config_reg ; --ramener le IPulse à 0; |
---|
178 | dcount:=dcount+1; |
---|
179 | Interf.O.membusy<='1'; |
---|
180 | end if; |
---|
181 | SysRam.O.addr_rd<=std_logic_vector(to_unsigned(core_base_adr+1,ADRLEN)); |
---|
182 | SysRam.O.Addr_wr<=Std_logic_vector(to_unsigned(adresse,ADRLEN)); |
---|
183 | elsif dcount=13 then |
---|
184 | SysRam.O.we<='1'; |
---|
185 | SysRam.O.ena<='1'; -- préparer l'écriture du résultat du Put |
---|
186 | SysRam.O.enb<='0'; |
---|
187 | config_reg:=SysRam.I.Data_out and x"f6"; |
---|
188 | SysRam.O.Data_in<=config_reg ; --ramener le IPulse à 0; |
---|
189 | dcount:=dcount+1; |
---|
190 | adresse:=core_base_adr+1; |
---|
191 | SysRam.O.Addr_wr<=Std_logic_vector(to_unsigned(adresse,ADRLEN)); |
---|
192 | elsif dcount=14 then |
---|
193 | SysRam.O.we<='0'; |
---|
194 | SysRam.O.ena<='0'; |
---|
195 | SysRam.O.enb<='1'; |
---|
196 | Interf.O.membusy<='0'; |
---|
197 | if interf.I.ramsel='0' then |
---|
198 | SysRam.O.addr_rd<=Std_logic_vector(to_unsigned(Core_put_adr+6,Adrlen)); |
---|
199 | if SysRam.I.Data_out(0)='1' then --fin du MPI PUT ici pour l'envoie ! |
---|
200 | dcount:=dcount+1; |
---|
201 | SysRam.O.addr_rd<=Std_logic_vector(to_unsigned(Core_put_adr+7,Adrlen)); |
---|
202 | Interf.S.Intstate2<=255; --timer pour la réception |
---|
203 | end if; |
---|
204 | end if; |
---|
205 | elsif dcount=15 then |
---|
206 | dcount:=dcount+1; -- ce cycle permet d'attendre la donnée en sortie après le changement d'adresse |
---|
207 | elsif dcount=16 then |
---|
208 | if interf.I.ramsel='0' then |
---|
209 | dcount:=dcount+1; -- ce cycle permet d'attendre la donnée en sortie après le changement d'adresse |
---|
210 | end if; |
---|
211 | elsif dcount=17 then |
---|
212 | SysRam.O.we<='0'; |
---|
213 | SysRam.O.ena<='0'; |
---|
214 | SysRam.O.enb<='1'; |
---|
215 | Interf.O.membusy<='0'; |
---|
216 | if interf.I.ramsel='0' then |
---|
217 | SysRam.O.addr_rd<=Std_logic_vector(to_unsigned(Core_put_adr+7,Adrlen)); |
---|
218 | if SysRam.I.Data_out(5)='1' then --Message du MPI PUT bien reçu ! |
---|
219 | dcount:=dcount+1; |
---|
220 | SysRam.O.addr_rd<=Std_logic_vector(to_unsigned(Core_put_adr+7,Adrlen)); |
---|
221 | elsif Interf.S.Intstate2>0 then |
---|
222 | Interf.S.Intstate2<=Interf.S.Intstate2-1; |
---|
223 | else |
---|
224 | -- dcount:=1;--recommencer l'envoi |
---|
225 | end if; |
---|
226 | end if; |
---|
227 | elsif dcount=18 then |
---|
228 | dcount:=0; --fin normale de la fonction |
---|
229 | Interf.O.membusy<='0'; |
---|
230 | end if; |
---|
231 | |
---|
232 | |
---|
233 | NExtCtx:=dcount; |
---|
234 | end if; |
---|
235 | end procedure; |
---|
236 | |
---|
237 | procedure pMPI_GET(NextCtx : inout natural;signal Interf:inout Core_io;signal clkin:std_logic;signal SysRam :inout typ_dpram; |
---|
238 | Orig_Addr: std_logic_vector;Orig_Count : natural; Orig_DataType: natural; |
---|
239 | Target_Rank : natural; Target_disp : std_logic_vector; Target_Count : natural; |
---|
240 | Target_Datatype :natural; Win : natural) is |
---|
241 | variable i,wcount,dcount : natural range 0 to 255:=0; |
---|
242 | variable adresse :natural; |
---|
243 | variable addr1 :std_logic_vector(Orig_Addr'length-1 downto 0):=Orig_Addr; |
---|
244 | variable addr2 :std_logic_vector(Target_Disp'length-1 downto 0):=Target_Disp; |
---|
245 | variable get_adr : std_logic_vector (ADRLEN-1 downto 0); |
---|
246 | variable config_reg,win_reg: std_logic_vector (Word-1 downto 0); |
---|
247 | constant LeftZero: std_logic_vector(2*Word-ADRLEN to 0):=(others=>'0'); |
---|
248 | begin |
---|
249 | get_adr:=Std_logic_vector(to_unsigned(Core_get_adr,ADRLEN)); |
---|
250 | |
---|
251 | addr1:=Orig_Addr; |
---|
252 | addr2:=Target_Disp; |
---|
253 | if NextCtx /=0 then --préserver la valeur de count entre les appels |
---|
254 | dcount:=NextCtx; |
---|
255 | end if; |
---|
256 | -- |
---|
257 | |
---|
258 | if rising_edge(clkin) then |
---|
259 | |
---|
260 | if dcount =0 then |
---|
261 | dcount:=dcount+1; |
---|
262 | elsif dcount>=1 and dcount <=3 then |
---|
263 | if interf.I.ramsel='0' then |
---|
264 | SysRam.O.we<='1'; |
---|
265 | SysRam.O.ena<='1'; |
---|
266 | SysRam.O.enb<='0'; |
---|
267 | wcount:=Interf.S.IntState1; |
---|
268 | WritePtr (get_adr,wcount,SysRam); |
---|
269 | Interf.S.IntState1<=wcount; |
---|
270 | Interf.O.membusy<='1'; |
---|
271 | if wcount =0 then |
---|
272 | dcount:=4; |
---|
273 | end if; |
---|
274 | end if; |
---|
275 | |
---|
276 | elsif dcount=4 then |
---|
277 | if interf.I.ramsel='0' then |
---|
278 | SysRam.O.we<='1'; |
---|
279 | SysRam.O.ena<='1'; |
---|
280 | SysRam.O.enb<='0'; |
---|
281 | |
---|
282 | adresse:=core_get_adr; |
---|
283 | SysRam.O.Data_in<=MPI_GET & std_logic_vector(to_unsigned(Target_Rank,4)); --code fonction |
---|
284 | SysRam.O.Addr_wr<=Std_logic_vector(to_unsigned(adresse,ADRLEN)); |
---|
285 | Interf.O.membusy<='1'; |
---|
286 | dcount:=dcount+1; |
---|
287 | end if; |
---|
288 | elsif dcount=5 then |
---|
289 | if interf.I.ramsel='0' then |
---|
290 | SysRam.O.we<='1'; |
---|
291 | SysRam.O.ena<='1'; |
---|
292 | adresse:=core_get_adr+1; |
---|
293 | SysRam.O.Data_in<=std_logic_vector(to_unsigned(Orig_Count,8)) ;--la longueur |
---|
294 | SysRam.O.Addr_wr<=Std_logic_vector(to_unsigned(adresse,ADRLEN)); |
---|
295 | interf.O.Instruction<=x"06"; --le nbre de mots de l'intstruction |
---|
296 | dcount:=dcount+1; |
---|
297 | end if; |
---|
298 | elsif dcount=6 then |
---|
299 | if interf.I.ramsel='0' then |
---|
300 | SysRam.O.we<='1'; |
---|
301 | SysRam.O.ena<='1'; |
---|
302 | adresse:=core_get_adr+2; |
---|
303 | SysRam.O.Data_in<= Addr1(ADRLEN-1 downto Word) ; --source Haut |
---|
304 | SysRam.O.Addr_wr<=Std_logic_vector(to_unsigned(adresse,ADRLEN)); |
---|
305 | |
---|
306 | dcount:=dcount+1; |
---|
307 | else |
---|
308 | dcount:=dcount-1; |
---|
309 | end if; |
---|
310 | elsif dcount=7 then |
---|
311 | if interf.I.ramsel='0' then |
---|
312 | SysRam.O.we<='1'; |
---|
313 | SysRam.O.ena<='1'; |
---|
314 | adresse:=core_get_adr+3; |
---|
315 | SysRam.O.Data_in<=Addr1(Word-1 downto 0); --source Bas |
---|
316 | SysRam.O.Addr_wr<=Std_logic_vector(to_unsigned(adresse,ADRLEN)); |
---|
317 | |
---|
318 | dcount:=dcount+1; |
---|
319 | else |
---|
320 | dcount:=dcount-1; |
---|
321 | end if; |
---|
322 | elsif dcount=8 then |
---|
323 | if interf.I.ramsel='0' then |
---|
324 | SysRam.O.we<='1'; |
---|
325 | SysRam.O.ena<='1'; |
---|
326 | adresse:=core_get_adr+4; |
---|
327 | SysRam.O.Data_in<= Addr2(ADRLEN-1 downto Word) ; -- destination haut |
---|
328 | SysRam.O.Addr_wr<=Std_logic_vector(to_unsigned(adresse,ADRLEN)); |
---|
329 | Interf.O.membusy<='1'; |
---|
330 | dcount:=dcount+1; |
---|
331 | else |
---|
332 | dcount:=dcount-1; |
---|
333 | end if; |
---|
334 | elsif dcount=9 then |
---|
335 | if interf.I.ramsel='0' then |
---|
336 | SysRam.O.we<='1'; |
---|
337 | SysRam.O.ena<='1'; |
---|
338 | adresse:=core_get_adr+5; |
---|
339 | SysRam.O.Data_in<=Addr2(Word-1 downto 0); -- destination bas |
---|
340 | SysRam.O.Addr_wr<=Std_logic_vector(to_unsigned(adresse,ADRLEN)); |
---|
341 | Interf.O.membusy<='0'; |
---|
342 | dcount:=dcount+1; |
---|
343 | end if; |
---|
344 | elsif dcount=10 then |
---|
345 | |
---|
346 | SysRam.O.we<='1'; |
---|
347 | SysRam.O.ena<='1'; |
---|
348 | SysRam.O.enb<='1'; |
---|
349 | adresse:=core_base_adr+1; |
---|
350 | SysRam.O.addr_rd<=std_logic_vector(to_unsigned(core_base_adr+1,ADRLEN)); |
---|
351 | SysRam.O.Addr_wr<=Std_logic_vector(to_unsigned(adresse,ADRLEN)); |
---|
352 | SysRam.O.Data_in<=x"01"; --instruction pulse enable via la mémoire; |
---|
353 | Interf.O.Instr_En<='1'; --active la prise en compte de l'instruction |
---|
354 | if interf.I.ramsel='0' then |
---|
355 | dcount:=dcount+1; |
---|
356 | end if; |
---|
357 | elsif dcount=11 then |
---|
358 | if Interf.I.Instr_ack='1' then -- le Core a reçu l'instruction ? |
---|
359 | Interf.O.Instr_En<='0'; --désactiver la prise en compte de l'instruction |
---|
360 | dcount:=dcount+1; |
---|
361 | config_reg:=SysRam.I.Data_out and x"f6"; |
---|
362 | SysRam.O.Data_in<=config_reg ; --ramener le IPulse à 0; |
---|
363 | end if; |
---|
364 | adresse:=core_base_adr+1; |
---|
365 | SysRam.O.addr_rd<=std_logic_vector(to_unsigned(core_base_adr+1,ADRLEN)); |
---|
366 | SysRam.O.addr_wr<=Std_logic_vector(to_unsigned(adresse,ADRLEN)); |
---|
367 | --SysRam.O.Ram_busy<='0'; --?? |
---|
368 | SysRam.O.we<='0'; |
---|
369 | SysRam.O.ena<='0'; -- préparer la lecture du résultat du get |
---|
370 | SysRam.O.enb<='1'; |
---|
371 | Interf.O.membusy<='0'; |
---|
372 | elsif dcount=12 then |
---|
373 | |
---|
374 | adresse:=core_base_adr+1; |
---|
375 | SysRam.O.we<='1'; |
---|
376 | SysRam.O.ena<='1'; -- préparer l'écriture du résultat du get |
---|
377 | SysRam.O.enb<='1'; |
---|
378 | if interf.I.ramsel='0' then |
---|
379 | config_reg:=SysRam.I.Data_out and x"f6"; |
---|
380 | SysRam.O.Data_in<=config_reg ; --ramener le IPulse à 0; |
---|
381 | dcount:=dcount+1; |
---|
382 | Interf.O.membusy<='1'; |
---|
383 | end if; |
---|
384 | SysRam.O.addr_rd<=std_logic_vector(to_unsigned(core_base_adr+1,ADRLEN)); |
---|
385 | SysRam.O.Addr_wr<=Std_logic_vector(to_unsigned(adresse,ADRLEN)); |
---|
386 | |
---|
387 | elsif dcount=13 then |
---|
388 | |
---|
389 | SysRam.O.we<='1'; |
---|
390 | SysRam.O.ena<='1'; -- préparer l'écriture du résultat du GET |
---|
391 | SysRam.O.enb<='0'; |
---|
392 | adresse:=core_base_adr+1; |
---|
393 | SysRam.O.Addr_wr<=Std_logic_vector(to_unsigned(adresse,ADRLEN)); |
---|
394 | if interf.I.ramsel='0' then |
---|
395 | config_reg:=SysRam.I.Data_out and x"f6"; |
---|
396 | SysRam.O.Data_in<=config_reg ; --ramener le IPulse à 0; |
---|
397 | dcount:=dcount+1; |
---|
398 | Interf.O.membusy<='0'; |
---|
399 | end if; |
---|
400 | elsif dcount=14 then |
---|
401 | SysRam.O.we<='0'; |
---|
402 | SysRam.O.ena<='0'; |
---|
403 | SysRam.O.enb<='1'; |
---|
404 | Interf.O.membusy<='0'; |
---|
405 | if interf.I.ramsel='0' then |
---|
406 | SysRam.O.addr_rd<=Std_logic_vector(to_unsigned(Core_get_adr+6,Adrlen)); |
---|
407 | if SysRam.I.Data_out(0)='1' then --fin du MPI get ici pour l'envoie ! |
---|
408 | dcount:=dcount+1; |
---|
409 | |
---|
410 | end if; |
---|
411 | end if; |
---|
412 | |
---|
413 | elsif dcount=15 then |
---|
414 | dcount:=0; --fin normale de la fonction |
---|
415 | Interf.O.membusy<='0'; |
---|
416 | end if; |
---|
417 | |
---|
418 | |
---|
419 | NExtCtx:=dcount; |
---|
420 | end if; |
---|
421 | end procedure; |
---|
422 | Procedure pMPI_Comm_group(NextCtx : inout natural;signal Interf:inout Core_io;signal SysRam : inout typ_dpram; COMM :in MPI_Comm; signal grp : out Mpi_group ) is |
---|
423 | Begin |
---|
424 | --cette procédure permet de récupérer le groupe qui est associé à un communicateur |
---|
425 | --dans notre cas c'est la récupération du groupe associé à COMM_WORLD |
---|
426 | end procedure; |
---|
427 | --int MPI_Group_incl(MPI_Group group, int n, int *ranks, |
---|
428 | -- MPI_Group *newgroup) |
---|
429 | Procedure pMPI_group_incl(NextCtx : inout natural;signal Interf:inout Core_io;signal SysRam : inout typ_dpram; |
---|
430 | GRP: Mpi_group; n:natural;ranks :natural; newgroup: out Mpi_group) is |
---|
431 | Begin |
---|
432 | -- cette procedure a pour algo de parcourir les rangs qui sont dans la mémoire pointée par ranks |
---|
433 | -- et d'activer l'un des bits de position de newgroup. |
---|
434 | -- |
---|
435 | -- |
---|
436 | end procedure; |
---|
437 | |
---|
438 | procedure pMPI_Comm_Rank(NextCtx : inout natural;signal Interf:inout Core_io;signal SysRam :inout typ_dpram; COMM :in natural; signal Rank : out std_logic_vector ) is |
---|
439 | variable adresse_rd : natural range 0 to 2**ADRLEN-1; |
---|
440 | |
---|
441 | begin |
---|
442 | |
---|
443 | if NextCtx =0 then |
---|
444 | SysRam.O.we<='0'; |
---|
445 | SysRam.O.ena<='0'; |
---|
446 | SysRam.O.enb<='1'; |
---|
447 | adresse_rd:=CORE_INIT_ADR+1; |
---|
448 | SysRam.O.Addr_rd<=Std_logic_vector(to_unsigned(adresse_rd,ADRLEN)); |
---|
449 | |
---|
450 | NextCtx:=1; |
---|
451 | |
---|
452 | elsif NextCtx=1 then |
---|
453 | SysRam.O.we<='0'; |
---|
454 | SysRam.O.ena<='0'; |
---|
455 | SysRam.O.enb<='1'; |
---|
456 | adresse_rd:=CORE_INIT_ADR+1; |
---|
457 | SysRam.O.Addr_rd<=Std_logic_vector(to_unsigned(adresse_rd,ADRLEN)); |
---|
458 | if interf.I.ramsel='0' then |
---|
459 | Rank<=SysRam.I.Data_out(3 downto 0); |
---|
460 | NextCtx:=2; |
---|
461 | Interf.O.membusy<='1'; |
---|
462 | end if; |
---|
463 | elsif NextCtx=2 then |
---|
464 | SysRam.O.we<='0'; |
---|
465 | SysRam.O.ena<='0'; |
---|
466 | SysRam.O.enb<='1'; |
---|
467 | adresse_rd:=CORE_INIT_ADR+1; |
---|
468 | SysRam.O.Addr_rd<=Std_logic_vector(to_unsigned(adresse_rd,ADRLEN)); |
---|
469 | if interf.I.ramsel='0' then |
---|
470 | Rank<=SysRam.I.Data_out(3 downto 0); |
---|
471 | NextCtx:=3; |
---|
472 | Interf.O.membusy<='1'; |
---|
473 | end if; |
---|
474 | elsif NextCtx=3 then |
---|
475 | SysRam.O.we<='0'; |
---|
476 | SysRam.O.ena<='0'; |
---|
477 | SysRam.O.enb<='1'; |
---|
478 | adresse_rd:=CORE_INIT_ADR+1; |
---|
479 | SysRam.O.Addr_rd<=Std_logic_vector(to_unsigned(adresse_rd,ADRLEN)); |
---|
480 | if interf.I.ramsel='0' then |
---|
481 | Rank<=SysRam.I.Data_out(3 downto 0); |
---|
482 | NextCtx:=4; |
---|
483 | Interf.O.membusy<='1'; |
---|
484 | end if; |
---|
485 | elsif NextCtx=4 then |
---|
486 | SysRam.O.we<='0'; |
---|
487 | SysRam.O.ena<='0'; |
---|
488 | SysRam.O.enb<='1'; |
---|
489 | adresse_rd:=CORE_INIT_ADR+1; |
---|
490 | SysRam.O.Addr_rd<=Std_logic_vector(to_unsigned(adresse_rd,ADRLEN)); |
---|
491 | if interf.I.ramsel='0' then |
---|
492 | Rank<=SysRam.I.Data_out(3 downto 0); |
---|
493 | NextCtx:=0; |
---|
494 | Interf.O.membusy<='0'; |
---|
495 | end if; |
---|
496 | end if; |
---|
497 | end procedure; |
---|
498 | |
---|
499 | --int MPI_Win_create( |
---|
500 | -- void *base, |
---|
501 | -- MPI_Aint size, |
---|
502 | -- int disp_unit, |
---|
503 | -- MPI_Info info, |
---|
504 | -- MPI_Comm comm, |
---|
505 | -- MPI_Win *win |
---|
506 | --); |
---|
507 | procedure pMPI_Win_create(NextCtx : inout natural ;signal Interf:inout Core_io;signal SysRam :inout typ_dpram; |
---|
508 | base :std_logic_vector; size : Mpi_Aint;disp_unit:natural; |
---|
509 | info:natural; comm:Mpi_Comm; Win: inout MPI_Win ) is |
---|
510 | -- parcours de la liste des fenêtres existantes à la recherche d'un emplacement libre |
---|
511 | -- si fenêtre libre trouvée, et |
---|
512 | -- mise à 1 du Bit WCreate du registre status |
---|
513 | type wtype is array (1 to 4 ) of natural range 0 to 255; |
---|
514 | variable AdrWin: std_logic_vector(ADRLEN-1 downto 0); |
---|
515 | variable adresse : std_logic_vector(ADRLEN-1 downto 0); |
---|
516 | variable clkin : std_logic:='1'; |
---|
517 | variable wcreate_adr : std_logic_vector(ADRLEN-1 downto 0):=std_logic_vector(to_unsigned(Core_wcreate_adr,ADRLEN)); |
---|
518 | variable w0 : std_logic_vector(Word-1 downto 0); |
---|
519 | variable adrnat : natural; |
---|
520 | variable sizewin : std_logic_vector(Word-1 downto 0); |
---|
521 | variable count : natural range 0 to 255; |
---|
522 | variable wdisp :wtype:=(4,14,24,34); --stocke l'adresse de la prochaine Win libre |
---|
523 | begin |
---|
524 | -- création d'une fenêtre il s'agit d'affecter l'objet Win et de retourner |
---|
525 | -- le pointeur qui permet de le décrire |
---|
526 | |
---|
527 | |
---|
528 | If NextCtx=0 then |
---|
529 | NExtCtx:=NextCtx+1; |
---|
530 | count:=0; |
---|
531 | Interf.O.membusy<='0'; |
---|
532 | Interf.S.IntState1<=count; |
---|
533 | elsif NextCtx>=1 and NextCtx <= 4 then |
---|
534 | count:=Interf.S.IntState1; |
---|
535 | AdrWin:=std_logic_vector(to_unsigned(Core_base_adr+Wdisp(NextCtx),16)); |
---|
536 | readmem(count,interf,sysRam,AdrWin,w0); |
---|
537 | if count=0 then |
---|
538 | if w0(0)/='1' then -- cette fenêtre est libre |
---|
539 | NextCtx:=6; --étape de la création de la fenêtre |
---|
540 | Win.addr:=base; --l'adresse de la fenêtre |
---|
541 | Win.id:=NextCtx; -- la référence provisoire de la fenêtre |
---|
542 | Win.size:=Size; -- la taille de la fenêtre |
---|
543 | |
---|
544 | else |
---|
545 | NextCtx:=NextCtx+1; |
---|
546 | end if; |
---|
547 | end if; |
---|
548 | Interf.S.IntState1<=count;--sauvegarde du statut de la sous-procédure |
---|
549 | |
---|
550 | elsif NextCtx=5 then |
---|
551 | -- Plus de fenêtre disponible erreur |
---|
552 | NextCtx:=1; -- boucle sans fin :) |
---|
553 | Win.id:=0; |
---|
554 | Win.addr:=x"0000"; |
---|
555 | elsif NextCtx=6 then |
---|
556 | --Affectation de l'objet Windows car une place est disponible |
---|
557 | count:=Interf.S.IntState1; |
---|
558 | AdrWin:=std_logic_vector(to_unsigned(Core_base_adr+Wdisp(Win.id),16)); |
---|
559 | Writemem(count,interf,SysRam,AdrWin,x"01"); --signal status pour created |
---|
560 | Interf.S.IntState1<=count; |
---|
561 | if count=0 then |
---|
562 | NextCtx:=NextCtx+1; |
---|
563 | end if; |
---|
564 | |
---|
565 | elsif NextCtx=8 then |
---|
566 | AdrWin:=std_logic_vector(to_unsigned(Core_base_adr+Wdisp(Win.id),16)); |
---|
567 | interf.S.winid<=interf.S.winid+1; |
---|
568 | count:=Interf.S.IntState1; |
---|
569 | Writemem(count,interf,SysRam,AdrWin+1,stdlv(interf.S.winid,8)); --win id de la fenêtre |
---|
570 | Interf.S.IntState1<=count; |
---|
571 | if count=0 then |
---|
572 | NextCtx:=NextCtx+1; |
---|
573 | end if; |
---|
574 | elsif NextCtx=9 then |
---|
575 | |
---|
576 | adrnat:=Core_base_adr+Wdisp(Win.id); |
---|
577 | |
---|
578 | AdrWin:=std_logic_vector(to_unsigned(Core_base_adr+Wdisp(Win.id),16)); |
---|
579 | count:=Interf.S.IntState1; |
---|
580 | |
---|
581 | |
---|
582 | Writemem(count,interf,SysRam,AdrWin+2,base(7 downto 0)); --adresse basse |
---|
583 | Interf.S.IntState1<=count; |
---|
584 | if count=0 then |
---|
585 | NextCtx:=NextCtx+1; |
---|
586 | end if; |
---|
587 | elsif NextCtx=10 then |
---|
588 | AdrWin:=std_logic_vector(to_unsigned(Core_base_adr+Wdisp(Win.id),16)); |
---|
589 | count:=Interf.S.IntState1; |
---|
590 | Writemem(count,interf,SysRam,AdrWin+3,base(15 downto 8)); --adresse haute |
---|
591 | Interf.S.IntState1<=count; |
---|
592 | if count=0 then |
---|
593 | NextCtx:=NextCtx+1; |
---|
594 | end if; |
---|
595 | elsif NextCtx=11 then |
---|
596 | AdrWin:=std_logic_vector(to_unsigned(Core_base_adr+Wdisp(Win.id),16)); |
---|
597 | sizewin:=std_logic_vector(to_unsigned(size,8)); |
---|
598 | count:=Interf.S.IntState1; |
---|
599 | Writemem(count,interf,SysRam,AdrWin+4,sizewin); -- taille de la fenêtre |
---|
600 | Interf.S.IntState1<=count; |
---|
601 | if count=0 then |
---|
602 | NextCtx:=NextCtx+1; |
---|
603 | end if; |
---|
604 | elsif NextCtx=12 then |
---|
605 | --cette étape consiste à envoyer le message WINCREATE Sur le réseau et à récupérer |
---|
606 | -- les informations donnant le numéro de la fenêtre |
---|
607 | W0:=MPI_WINCREATE & std_logic_vector(to_unsigned(0,4)); --code fonction |
---|
608 | count:=Interf.S.IntState1; |
---|
609 | Writemem(count,interf,SysRam,wcreate_adr,w0); |
---|
610 | Interf.S.IntState1<=count; |
---|
611 | if count=0 then |
---|
612 | NextCtx:=NextCtx+1; |
---|
613 | end if; |
---|
614 | |
---|
615 | elsif NextCtx=13 then |
---|
616 | w0:=std_logic_vector(to_unsigned(Win.Id,8)); -- id proposé pour la fenêtre en création |
---|
617 | count:=Interf.S.IntState1; |
---|
618 | Writemem(count,interf,SysRam,wcreate_adr+1,w0); |
---|
619 | Interf.S.IntState1<=count; |
---|
620 | if count=0 then |
---|
621 | NextCtx:=NextCtx+1; |
---|
622 | end if; |
---|
623 | elsif NextCtx=14 then |
---|
624 | SysRam.O.we<='1'; |
---|
625 | SysRam.O.ena<='1'; |
---|
626 | SysRam.O.enb<='0'; |
---|
627 | count:=Interf.S.IntState1; |
---|
628 | if interf.I.ramsel='0' then |
---|
629 | WritePtr (wcreate_adr,count,SysRam); --écriture du pointeur d'instruction |
---|
630 | Interf.S.IntState1<=count; |
---|
631 | if count=0 then |
---|
632 | NextCtx:=NextCtx+1; |
---|
633 | end if; |
---|
634 | end if; |
---|
635 | elsif NextCtx=15 then |
---|
636 | -- il faut mettre instruction_en à 1 |
---|
637 | SysRam.O.we<='0'; |
---|
638 | SysRam.O.ena<='0'; |
---|
639 | SysRam.O.enb<='1'; |
---|
640 | SysRam.O.we<='1'; |
---|
641 | SysRam.O.ena<='1'; |
---|
642 | SysRam.O.enb<='1'; |
---|
643 | adresse:=stdlv(core_base_adr+1); |
---|
644 | SysRam.O.addr_rd<=adresse; |
---|
645 | SysRam.O.Addr_wr<=adresse; |
---|
646 | SysRam.O.Data_in<=x"01"; --instruction pulse enable via la mémoire; |
---|
647 | Writemem(count,interf,SysRam,adresse,x"01"); |
---|
648 | Interf.S.IntState1<=count; |
---|
649 | if count=0 then |
---|
650 | NextCtx:=NextCtx+1; |
---|
651 | end if; |
---|
652 | Interf.O.Instr_En<='1'; |
---|
653 | adresse:=stdlv(core_base_adr); |
---|
654 | SysRam.O.Addr_rd<=adresse; |
---|
655 | NextCtx:=NextCtx+1; |
---|
656 | elsif NextCtx=16 then --acquittement de la copie des données dans le tampon de la lib |
---|
657 | if Interf.I.Instr_ack='1' then |
---|
658 | Interf.O.Instr_En<='0'; |
---|
659 | NextCtx:=NextCtx+1; |
---|
660 | end if; |
---|
661 | SysRam.O.we<='0'; |
---|
662 | SysRam.O.ena<='0'; |
---|
663 | SysRam.O.enb<='1'; |
---|
664 | elsif NextCtx=17 then |
---|
665 | -- lecture du résultat de l'instruction |
---|
666 | |
---|
667 | |
---|
668 | else |
---|
669 | |
---|
670 | end if; |
---|
671 | end procedure; |
---|
672 | --int MPI_Win_start( |
---|
673 | -- MPI_Group group, |
---|
674 | -- int assert, |
---|
675 | -- MPI_Win win |
---|
676 | --); |
---|
677 | procedure pMPI_Win_start( NextCtx : inout natural;signal Interf:inout Core_io;signal SysRam :inout typ_dpram; pgroup:MPI_group;asser : natural; Win :MPI_Win) is |
---|
678 | --cette fonction active les bits WStart pour chaque processus avec lequel |
---|
679 | -- la source veut communiquer et par la suite envoie un message de synchro sur le réseau à |
---|
680 | --chacune de ces cibles |
---|
681 | variable dcount : natural range 0 to 255:=0; |
---|
682 | variable cstatus : std_logic_vector(Word-1 downto 0); |
---|
683 | begin |
---|
684 | |
---|
685 | -- retour de l'adresse de de la fenêtre dans la structure Win |
---|
686 | -- initialisation des bits concernant |
---|
687 | |
---|
688 | if NextCtx =0 then |
---|
689 | NextCtx:=NextCtx+1; |
---|
690 | elsif NextCtx=1 then |
---|
691 | if interf.I.ramsel='0' then |
---|
692 | SysRam.O.we<='1'; |
---|
693 | SysRam.O.ena<='1'; |
---|
694 | SysRam.O.enb<='0'; |
---|
695 | SysRam.O.addr_wr<=Std_logic_vector(to_unsigned(core_base_adr+4,Adrlen)); |
---|
696 | SysRam.O.Data_in<=x"01"; --mise à 1 du bit WSTART et remise à zero de tous les autres Bits |
---|
697 | |
---|
698 | NextCtx:=NextCtx+1; |
---|
699 | Interf.O.membusy<='1'; |
---|
700 | |
---|
701 | end if; |
---|
702 | elsif NextCtx=2 then |
---|
703 | if interf.I.ramsel='0' then |
---|
704 | SysRam.O.we<='1'; |
---|
705 | SysRam.O.ena<='1'; |
---|
706 | SysRam.O.enb<='0'; |
---|
707 | SysRam.O.addr_wr<=Std_logic_vector(to_unsigned(core_base_adr+4,Adrlen)); |
---|
708 | SysRam.O.Data_in<=x"01"; |
---|
709 | NextCtx:=NextCtx+1; |
---|
710 | Interf.O.membusy<='0'; |
---|
711 | end if; |
---|
712 | elsif NextCtx=3 then |
---|
713 | NextCtx:=0; |
---|
714 | Interf.O.membusy<='0'; |
---|
715 | end if; |
---|
716 | |
---|
717 | |
---|
718 | end procedure; |
---|
719 | procedure pMPI_Win_complete( NextCtx : inout natural;signal Interf:inout Core_io;signal SysRam :inout typ_dpram; Win :MPI_Win) is |
---|
720 | begin |
---|
721 | |
---|
722 | end procedure; |
---|
723 | procedure pMPI_Win_post( NextCtx : inout natural;signal Interf:inout Core_io;signal SysRam :inout typ_dpram; pgroup:MPI_group;asser : natural; Win :MPI_Win) is |
---|
724 | --cette fonction active les bits WStart pour chaque processus avec lequel |
---|
725 | -- la source veut communiquer et par la suite envoie un message de synchro sur le réseau à |
---|
726 | --chacune de ces cibles |
---|
727 | begin |
---|
728 | |
---|
729 | end procedure; |
---|
730 | |
---|
731 | procedure pMPI_Win_wait( NextCtx : inout natural;signal Interf:inout Core_io;signal SysRam :inout typ_dpram; Win :MPI_Win) is |
---|
732 | --permet de synchroniser la fin des opérations sur une fenêtre |
---|
733 | variable dcount : natural range 0 to 255:=0; |
---|
734 | variable cstatus : std_logic_vector(Word-1 downto 0); |
---|
735 | |
---|
736 | begin |
---|
737 | |
---|
738 | |
---|
739 | |
---|
740 | if NextCtx =0 then |
---|
741 | NextCtx:=NextCtx+1; |
---|
742 | elsif NextCtx=1 then |
---|
743 | if interf.I.ramsel='0' then |
---|
744 | SysRam.O.we<='0'; |
---|
745 | SysRam.O.ena<='0'; |
---|
746 | SysRam.O.enb<='1'; |
---|
747 | SysRam.O.addr_rd<=Std_logic_vector(to_unsigned(core_base_adr+4,Adrlen)); |
---|
748 | if (SysRam.I.Data_out(5)='1' and SysRam.I.Data_out(4)='1') and SysRam.I.Data_out(2)='0' and SysRam.I.Data_out(1)='0' then |
---|
749 | NextCtx:=NextCtx+1; |
---|
750 | end if; |
---|
751 | end if; |
---|
752 | |
---|
753 | elsif NextCtx=2 then |
---|
754 | |
---|
755 | NextCtx:=0; |
---|
756 | end if; |
---|
757 | |
---|
758 | |
---|
759 | end procedure; |
---|
760 | |
---|
761 | |
---|
762 | Procedure pMPI_Finalize(NextCtx : inout natural;signal Interf:inout Core_io;signal SysRam :inout typ_dpram) is |
---|
763 | begin |
---|
764 | |
---|
765 | end procedure; |
---|
766 | |
---|
767 | procedure pMPI_Comm_Spawn(NextCtx : inout natural;signal Interf:inout Core_io;signal SysRam :inout typ_dpram; |
---|
768 | command : natural; argv :natural; maxprocs : natural; info : natural; root : natural; comm : natural; |
---|
769 | signal intercomm :out natural; signal array_of_errcodes : out natural) is |
---|
770 | |
---|
771 | variable i,dcount : natural:=0; |
---|
772 | variable adresse :natural; |
---|
773 | variable spawn_adr : std_logic_vector(adrlen-1 downto 0):=Std_logic_vector(to_unsigned(Core_spawn_adr,ADRLEN)); |
---|
774 | begin |
---|
775 | spawn_adr:=Std_logic_vector(to_unsigned(Core_spawn_adr,ADRLEN)); |
---|
776 | if NextCtx =0 then |
---|
777 | |
---|
778 | SysRam.O.we<='1'; |
---|
779 | SysRam.O.ena<='1'; |
---|
780 | SysRam.O.enb<='0'; |
---|
781 | NextCtx:=1; |
---|
782 | elsif NextCtx=1 then |
---|
783 | if interf.I.ramsel='0' then |
---|
784 | NextCtx:=2; |
---|
785 | adresse:=core_spawn_adr; |
---|
786 | SysRam.O.Data_in<=MPI_SPAWN & x"0" ; |
---|
787 | SysRam.O.Addr_wr<=Std_logic_vector(to_unsigned(adresse,ADRLEN)); |
---|
788 | Interf.O.membusy<='1'; |
---|
789 | Interf.O.Instr_En<='0'; |
---|
790 | Interf.S.IntState2<=1; -- préparation de la destination du spawn |
---|
791 | end if; |
---|
792 | elsif NextCtx=2 then |
---|
793 | SysRam.O.we<='1'; |
---|
794 | SysRam.O.ena<='1'; |
---|
795 | SysRam.O.enb<='0'; |
---|
796 | if interf.I.ramsel='0' then |
---|
797 | NextCtx:=NextCtx+1; |
---|
798 | Interf.O.membusy<='1'; |
---|
799 | adresse:=core_spawn_adr; |
---|
800 | if interf.I.ismain='1' then ---déclanche l'éxécution de la commande |
---|
801 | SysRam.O.Data_in<=MPI_spawn & x"0";--Std_logic_vector(to_unsigned(Interf.S.IntState2+2,4)) ; |
---|
802 | SysRam.O.Addr_wr<=Std_logic_vector(to_unsigned(adresse,ADRLEN)); |
---|
803 | |
---|
804 | else -- envoie d'une commande spawn à la main lib |
---|
805 | SysRam.O.Data_in<=MPI_spawn & x"0" ; |
---|
806 | SysRam.O.Addr_wr<=Std_logic_vector(to_unsigned(adresse,ADRLEN)); |
---|
807 | Interf.O.Instr_En<='0'; |
---|
808 | Interf.O.membusy<='1'; |
---|
809 | |
---|
810 | end if; |
---|
811 | end if; |
---|
812 | |
---|
813 | elsif NextCtx=3 then |
---|
814 | SysRam.O.we<='1'; |
---|
815 | SysRam.O.ena<='1'; |
---|
816 | SysRam.O.enb<='0'; |
---|
817 | adresse:=core_spawn_adr; |
---|
818 | SysRam.O.Addr_wr<=Std_logic_vector(to_unsigned(adresse,ADRLEN)); |
---|
819 | NextCtx:=NextCtx+1; |
---|
820 | elsif NextCtx=4 then |
---|
821 | if interf.I.ramsel='0' then |
---|
822 | adresse:=core_spawn_adr+1; |
---|
823 | SysRam.O.Data_in<=std_logic_vector(to_unsigned(4,8)) ;--la longueur |
---|
824 | SysRam.O.Addr_wr<=Std_logic_vector(to_unsigned(adresse,ADRLEN)); |
---|
825 | Interf.O.Instruction<=x"04"; |
---|
826 | NextCtx:=NextCtx+1; |
---|
827 | end if; |
---|
828 | elsif NextCtx=5 then |
---|
829 | if interf.I.ramsel='0' then |
---|
830 | adresse:=core_spawn_adr+2; |
---|
831 | SysRam.O.Data_in<=std_logic_vector(to_unsigned(maxprocs,8)) ;--le nombre de processus |
---|
832 | SysRam.O.Addr_wr<=Std_logic_vector(to_unsigned(adresse,ADRLEN)); |
---|
833 | NextCtx:=NextCtx+1; |
---|
834 | end if; |
---|
835 | elsif NextCtx=6 then |
---|
836 | if interf.I.ramsel='0' then |
---|
837 | adresse:=core_spawn_adr+3; |
---|
838 | SysRam.O.Addr_wr<=Std_logic_vector(to_unsigned(adresse,ADRLEN)); |
---|
839 | SysRam.O.Data_in<=SPAWN_LOAD & std_logic_vector(to_unsigned(maxprocs,4)) ;--l'instruction |
---|
840 | NextCtx:=NextCtx+1; |
---|
841 | |
---|
842 | end if; |
---|
843 | elsif NextCtx=7 then |
---|
844 | if interf.I.ramsel='0' then |
---|
845 | adresse:=core_spawn_adr+3; |
---|
846 | SysRam.O.Addr_wr<=Std_logic_vector(to_unsigned(adresse,ADRLEN)); |
---|
847 | SysRam.O.Data_in<=SPAWN_LOAD & std_logic_vector(to_unsigned(maxprocs,4)) ;--l'instruction |
---|
848 | NextCtx:=NextCtx+1; |
---|
849 | report "MPV SPAWN activé " & integer'image(interf.I.Rank); |
---|
850 | end if; |
---|
851 | elsif NextCtx=8 then |
---|
852 | SysRam.O.we<='1'; |
---|
853 | SysRam.O.ena<='1'; |
---|
854 | SysRam.O.enb<='0'; |
---|
855 | dcount:=Interf.S.IntState1; |
---|
856 | if interf.I.ramsel='0' then |
---|
857 | SysRam.O.Addr_rd<=Std_logic_vector(to_unsigned(Core_base_adr,ADRLEN)); |
---|
858 | WritePtr (spawn_adr,dcount,SysRam); |
---|
859 | Interf.O.Instr_En<='0'; |
---|
860 | Interf.O.membusy<='1'; |
---|
861 | Interf.S.IntState1<=dcount; |
---|
862 | if dcount =0 then |
---|
863 | NextCtx:=NextCtx+1; |
---|
864 | end if; |
---|
865 | end if; |
---|
866 | elsif NextCtx=9 then |
---|
867 | |
---|
868 | --fin de la fonction |
---|
869 | SysRam.O.we<='0'; |
---|
870 | SysRam.O.ena<='0'; |
---|
871 | SysRam.O.enb<='1'; |
---|
872 | dcount:=0; |
---|
873 | Interf.O.membusy<='0'; |
---|
874 | Interf.O.Instr_En<='1'; |
---|
875 | SysRam.O.Addr_rd<=Std_logic_vector(to_unsigned(Core_base_adr,AdrLen)); |
---|
876 | NextCtx:=NextCtx+1; |
---|
877 | elsif NextCtx=10 then --acquittement de la copie des données dans le tampon |
---|
878 | if Interf.I.Instr_ack='1' then |
---|
879 | Interf.O.Instr_En<='0'; |
---|
880 | NextCtx:=NextCtx+1; |
---|
881 | end if; |
---|
882 | SysRam.O.we<='0'; |
---|
883 | SysRam.O.ena<='0'; |
---|
884 | SysRam.O.enb<='1'; |
---|
885 | |
---|
886 | elsif NextCtx=11 then --lecture de la fin de l'initialisation |
---|
887 | SysRam.O.we<='0'; |
---|
888 | SysRam.O.ena<='0'; |
---|
889 | SysRam.O.enb<='1'; |
---|
890 | if interf.I.ramsel='0' then |
---|
891 | SysRam.O.addr_rd<=Std_logic_vector(to_unsigned(Core_base_adr,Adrlen)); |
---|
892 | if SysRam.I.Data_out(6)='1' then --spawned |
---|
893 | NextCtx:=NextCtx+1; |
---|
894 | intercomm<=1; |
---|
895 | end if; |
---|
896 | Interf.O.membusy<='0'; |
---|
897 | end if; |
---|
898 | elsif NextCtx =12 then |
---|
899 | Interf.O.Instr_En<='0'; |
---|
900 | Interf.O.membusy<='0'; |
---|
901 | SysRam.O.we<='0'; |
---|
902 | SysRam.O.ena<='0'; |
---|
903 | SysRam.O.enb<='0'; |
---|
904 | NextCtx:=0; |
---|
905 | --array_of_errcodes<=0; |
---|
906 | end if; |
---|
907 | array_of_errcodes<=NextCtx; |
---|
908 | end procedure; |
---|
909 | |
---|
910 | procedure pMPI_INIT(NextCtx : inout natural;signal Interf:inout Core_io;signal clkin:std_logic;signal SysRam :inout typ_dpram) is |
---|
911 | variable i,dcount,wcount : natural range 0 to 255:=0; |
---|
912 | variable adresse :natural; |
---|
913 | variable LRam : typ_dpRam; |
---|
914 | variable W0 :std_logic_vector(Word-1 downto 0); |
---|
915 | variable init_adr : std_logic_vector(adrlen-1 downto 0):=Std_logic_vector(to_unsigned(Core_init_adr,ADRLEN)); |
---|
916 | begin |
---|
917 | init_adr:=Std_logic_vector(to_unsigned(Core_init_adr,ADRLEN)); |
---|
918 | LRam:=SysRam; -- nécessaire pour le débogage |
---|
919 | if NextCtx =0 then |
---|
920 | |
---|
921 | SysRam.O.we<='1'; |
---|
922 | SysRam.O.ena<='1'; |
---|
923 | SysRam.O.enb<='0'; |
---|
924 | Interf.S.IntState1<=0; |
---|
925 | NextCtx:=1; |
---|
926 | adresse:=core_init_adr; |
---|
927 | SysRam.O.Addr_wr<=Std_logic_vector(to_unsigned(adresse,ADRLEN)); |
---|
928 | Interf.O.Instr_En<='0'; |
---|
929 | |
---|
930 | elsif NextCtx=1 then --écriture du ptr d'intruction |
---|
931 | SysRam.O.we<='1'; |
---|
932 | SysRam.O.ena<='1'; |
---|
933 | SysRam.O.enb<='0'; |
---|
934 | if interf.I.ramsel='0' then |
---|
935 | |
---|
936 | adresse:=core_init_adr; |
---|
937 | |
---|
938 | SysRam.O.Addr_wr<=Std_logic_vector(to_unsigned(adresse,ADRLEN)); |
---|
939 | Interf.O.Instr_En<='0'; |
---|
940 | Interf.O.membusy<='1'; |
---|
941 | |
---|
942 | wcount:=Interf.S.IntState1; |
---|
943 | WritePtr (Init_adr,wcount,SysRam); |
---|
944 | Interf.S.IntState1<=wcount; |
---|
945 | |
---|
946 | if wcount =4 then |
---|
947 | NextCtx:=2; |
---|
948 | Interf.S.IntState1<=0; |
---|
949 | adresse:=core_init_adr; |
---|
950 | SysRam.O.Addr_wr<=Std_logic_vector(to_unsigned(adresse,ADRLEN)); |
---|
951 | end if; |
---|
952 | end if; |
---|
953 | elsif NextCtx=2 then |
---|
954 | SysRam.O.we<='1'; |
---|
955 | SysRam.O.ena<='1'; |
---|
956 | SysRam.O.enb<='0'; |
---|
957 | adresse:=core_init_adr; |
---|
958 | SysRam.O.Data_in<=MPI_INIT & x"0" ; |
---|
959 | SysRam.O.Addr_wr<=Std_logic_vector(to_unsigned(adresse,ADRLEN)); |
---|
960 | NextCtx:=3; |
---|
961 | elsif NextCtx=3 then |
---|
962 | SysRam.O.we<='1'; |
---|
963 | SysRam.O.ena<='1'; |
---|
964 | SysRam.O.enb<='0'; |
---|
965 | adresse:=core_init_adr+1; |
---|
966 | SysRam.O.Data_in<= x"04" ; |
---|
967 | SysRam.O.Addr_wr<=Std_logic_vector(to_unsigned(adresse,ADRLEN)); |
---|
968 | NextCtx:=NextCtx+1; |
---|
969 | elsif NextCtx=4 then |
---|
970 | SysRam.O.we<='1'; |
---|
971 | SysRam.O.ena<='1'; |
---|
972 | SysRam.O.enb<='0'; |
---|
973 | adresse:=core_init_adr+2; |
---|
974 | Interf.O.Instruction<=x"04"; |
---|
975 | SysRam.O.Data_in<=x"00" ;--longueur de l'instruction |
---|
976 | SysRam.O.Addr_wr<=Std_logic_vector(to_unsigned(adresse,ADRLEN)); |
---|
977 | NextCtx:=5; |
---|
978 | elsif NextCtx=5 then |
---|
979 | SysRam.O.we<='1'; |
---|
980 | SysRam.O.ena<='1'; |
---|
981 | SysRam.O.enb<='0'; |
---|
982 | adresse:=core_init_adr+3; |
---|
983 | SysRam.O.Data_in<= x"00" ; |
---|
984 | SysRam.O.Addr_wr<=Std_logic_vector(to_unsigned(adresse,ADRLEN)); |
---|
985 | NextCtx:=6; |
---|
986 | elsif NextCtx=6 then |
---|
987 | SysRam.O.we<='1'; |
---|
988 | SysRam.O.ena<='1'; |
---|
989 | SysRam.O.enb<='0'; |
---|
990 | adresse:=core_init_adr+3; |
---|
991 | SysRam.O.Data_in<=x"00" ; |
---|
992 | SysRam.O.Addr_wr<=Std_logic_vector(to_unsigned(adresse,ADRLEN)); |
---|
993 | NextCtx:=7; |
---|
994 | |
---|
995 | elsif NextCtx=7 then --fin de la fonction |
---|
996 | SysRam.O.we<='0'; |
---|
997 | SysRam.O.ena<='0'; |
---|
998 | SysRam.O.enb<='1'; |
---|
999 | dcount:=0; |
---|
1000 | Interf.O.membusy<='0'; |
---|
1001 | Interf.O.Instruction(6)<=Interf.I.Spawned; --- préciser que la HT est dynamique |
---|
1002 | Interf.O.Instr_En<='1'; |
---|
1003 | SysRam.O.Addr_rd<=Std_logic_vector(to_unsigned(Core_base_adr,AdrLen)); |
---|
1004 | NextCtx:=8; |
---|
1005 | elsif NextCtx=8 then --acquittement de la copie des données dans le tampon |
---|
1006 | if Interf.I.Instr_ack='1' then |
---|
1007 | Interf.O.Instr_En<='0'; |
---|
1008 | NextCtx:=9; |
---|
1009 | end if; |
---|
1010 | SysRam.O.we<='0'; |
---|
1011 | SysRam.O.ena<='0'; |
---|
1012 | SysRam.O.enb<='1'; |
---|
1013 | |
---|
1014 | elsif NextCtx=9 then --lecture de la fin de l'initialisation |
---|
1015 | SysRam.O.we<='0'; |
---|
1016 | SysRam.O.ena<='0'; |
---|
1017 | SysRam.O.enb<='1'; |
---|
1018 | if interf.I.ramsel='0' then |
---|
1019 | SysRam.O.addr_rd<=Std_logic_vector(to_unsigned(Core_base_adr,Adrlen)); |
---|
1020 | if SysRam.I.Data_out(4)='1' then |
---|
1021 | NextCtx:=10; |
---|
1022 | Interf.S.IntState1<=0; -- initialisation du compteur d'état |
---|
1023 | end if; |
---|
1024 | Interf.O.membusy<='0'; |
---|
1025 | end if; |
---|
1026 | elsif NextCtx =10 then |
---|
1027 | dcount:=Interf.S.IntState1; --permet de sauvegarder l'état interne du compteur |
---|
1028 | readmem(dcount,interf,sysRam,init_Adr,w0); |
---|
1029 | Interf.S.IntState1<=dcount; |
---|
1030 | w0:=SysRam.I.Data_out; |
---|
1031 | if dcount=0 then |
---|
1032 | Interf.I.ismain<=all_zeros(SysRam.I.Data_out(3 downto 0));--Rank=0 -> MainLib |
---|
1033 | NextCtx:=NextCtx+1; |
---|
1034 | end if; |
---|
1035 | elsif NextCtx =11 then |
---|
1036 | Interf.O.Instr_En<='0'; |
---|
1037 | Interf.O.membusy<='0'; |
---|
1038 | SysRam.O.we<='0'; |
---|
1039 | SysRam.O.ena<='0'; |
---|
1040 | SysRam.O.enb<='0'; |
---|
1041 | NextCtx:=0; |
---|
1042 | end if; |
---|
1043 | |
---|
1044 | |
---|
1045 | end procedure; |
---|
1046 | |
---|
1047 | |
---|
1048 | procedure WriteMem(NextCtx : inout natural range 0 to 255;signal Interf:inout Core_io;signal SysRam :inout typ_dpram; |
---|
1049 | AdrVect:in std_logic_vector; Data:in std_logic_vector) is |
---|
1050 | --cette procédure permet d'écrire un mot dans la mémoire du PE(tâche matérielle) |
---|
1051 | --en ayant vérifié que le bus est bien disponible pour l'écriture |
---|
1052 | variable i,dcount : natural:=0; |
---|
1053 | variable adresse :natural; |
---|
1054 | variable AdrToSet :std_logic_vector(AdrVect'length-1 downto 0):=AdrVect; |
---|
1055 | |
---|
1056 | begin |
---|
1057 | if NextCtx /=0 then --préserver la valeur de count entre les appels |
---|
1058 | dcount:=NextCtx; |
---|
1059 | else |
---|
1060 | |
---|
1061 | |
---|
1062 | end if; |
---|
1063 | |
---|
1064 | |
---|
1065 | if dcount=0 then |
---|
1066 | if interf.I.ramsel='0' then |
---|
1067 | dcount :=dcount+1; |
---|
1068 | Interf.O.membusy<='1'; |
---|
1069 | end if; |
---|
1070 | SysRam.O.Data_in<=AdrToSet(Word-1 downto 0); |
---|
1071 | SysRam.O.Addr_wr<=adrToSet; |
---|
1072 | elsif dcount=1 then |
---|
1073 | if interf.I.ramsel='0' then |
---|
1074 | Interf.O.membusy<='1'; |
---|
1075 | dcount :=dcount+1; |
---|
1076 | end if; |
---|
1077 | SysRam.O.Data_in<=data; |
---|
1078 | SysRam.O.Addr_wr<=adrToSet; |
---|
1079 | elsif dcount=2 then |
---|
1080 | SysRam.O.Data_in<=data; |
---|
1081 | dcount :=dcount+1; |
---|
1082 | SysRam.O.Addr_wr<=AdrToSet; |
---|
1083 | elsif dcount=3 then |
---|
1084 | Interf.O.membusy<='1'; |
---|
1085 | dcount :=dcount+1; |
---|
1086 | SysRam.O.Addr_wr<=adrToSet; |
---|
1087 | SysRam.O.Data_in<=data; |
---|
1088 | elsif dcount=4 then -- ce cycle permet juste de vider le tampon d'écriture en RAM |
---|
1089 | dcount:=0; |
---|
1090 | Interf.O.membusy<='0'; |
---|
1091 | SysRam.O.Addr_wr<=AdrToSet; |
---|
1092 | end if; |
---|
1093 | |
---|
1094 | NextCtx:=dcount; |
---|
1095 | end procedure; |
---|
1096 | |
---|
1097 | -- écriture dans la mémoire |
---|
1098 | procedure ReadMem( NextCtx : inout natural range 0 to 255;signal Interf:inout Core_io;signal SysRam :inout typ_dpram; |
---|
1099 | AdrVect:in std_logic_vector; data: out std_logic_vector) is |
---|
1100 | --cette procédure permet d'écrire un mot dans la mémoire du PE(tâche matérielle) |
---|
1101 | --en ayant vérifié que le bus est bien disponible pour l'écriture |
---|
1102 | variable i,dcount : natural:=0; |
---|
1103 | variable adresse :natural; |
---|
1104 | variable AdrToSet :std_logic_vector(AdrVect'length-1 downto 0):=AdrVect; |
---|
1105 | |
---|
1106 | begin |
---|
1107 | if NextCtx /=0 then --préserver la valeur de count entre les appels |
---|
1108 | dcount:=NextCtx; |
---|
1109 | else |
---|
1110 | |
---|
1111 | |
---|
1112 | end if; |
---|
1113 | |
---|
1114 | if dcount=0 then |
---|
1115 | if interf.I.ramsel='0' then |
---|
1116 | dcount :=dcount+1; |
---|
1117 | Interf.O.membusy<='1'; |
---|
1118 | end if; |
---|
1119 | |
---|
1120 | SysRam.O.Addr_rd<=adrToSet; |
---|
1121 | elsif dcount=1 then |
---|
1122 | data:=SysRam.I.Data_out; |
---|
1123 | dcount :=dcount+1; |
---|
1124 | SysRam.O.Addr_rd<=adrToSet; |
---|
1125 | elsif dcount=2 then |
---|
1126 | data:=SysRam.I.Data_out; |
---|
1127 | dcount :=dcount+1; |
---|
1128 | SysRam.O.Addr_rd<=adrToSet; |
---|
1129 | elsif dcount=3 then |
---|
1130 | if interf.I.ramsel='0' then |
---|
1131 | dcount :=dcount+1; |
---|
1132 | SysRam.O.Addr_rd<=adrToSet; |
---|
1133 | data:=SysRam.I.Data_out; |
---|
1134 | Interf.O.membusy<='0'; |
---|
1135 | end if; |
---|
1136 | elsif dcount=4 then -- ce cycle permet juste de vider le tampon d'écriture en RAM |
---|
1137 | dcount:=0; |
---|
1138 | Interf.O.membusy<='0'; |
---|
1139 | data:=SysRam.I.Data_out; |
---|
1140 | end if; |
---|
1141 | data:=SysRam.I.Data_out; |
---|
1142 | NextCtx:=dcount; |
---|
1143 | end procedure; |
---|
1144 | |
---|
1145 | |
---|
1146 | |
---|
1147 | |
---|
1148 | |
---|
1149 | |
---|
1150 | |
---|
1151 | |
---|
1152 | |
---|
1153 | |
---|
1154 | |
---|
1155 | |
---|
1156 | |
---|
1157 | |
---|
1158 | |
---|
1159 | |
---|
1160 | |
---|
1161 | procedure WritePtr(AdrVect:in std_logic_vector; count: inout natural;signal SysRam :out typ_dpram) is |
---|
1162 | --cette procédure permet d'écrire dans la mémoire du PE(tâche matérielle) |
---|
1163 | --les données de l'appel de la procédure |
---|
1164 | variable i,dcount : natural:=0; |
---|
1165 | variable adresse :natural; |
---|
1166 | variable AdrToSet :std_logic_vector(AdrVect'length-1 downto 0):=AdrVect; |
---|
1167 | begin |
---|
1168 | if count /=0 then --préserver la valeur de count entre les appels |
---|
1169 | dcount:=count; |
---|
1170 | else |
---|
1171 | |
---|
1172 | |
---|
1173 | end if; |
---|
1174 | adresse:=Core_base_adr+2; |
---|
1175 | |
---|
1176 | if dcount=0 then |
---|
1177 | SysRam.O.Data_in<=AdrToSet(Word-1 downto 0); |
---|
1178 | dcount :=dcount+1; |
---|
1179 | SysRam.O.Addr_wr<=Std_logic_vector(to_unsigned(adresse,ADRLEN)); |
---|
1180 | elsif dcount=1 then |
---|
1181 | SysRam.O.Data_in<=AdrToSet(Word-1 downto 0); |
---|
1182 | dcount :=dcount+1; |
---|
1183 | SysRam.O.Addr_wr<=Std_logic_vector(to_unsigned(adresse,ADRLEN)); |
---|
1184 | elsif dcount=2 then |
---|
1185 | SysRam.O.Data_in<=AdrToSet(ADRLEN-1 downto Word); |
---|
1186 | dcount :=dcount+1; |
---|
1187 | SysRam.O.Addr_wr<=Std_logic_vector(to_unsigned(adresse+1,ADRLEN)); |
---|
1188 | elsif dcount=3 then |
---|
1189 | dcount :=dcount+1; |
---|
1190 | SysRam.O.Addr_wr<=Std_logic_vector(to_unsigned(adresse+1,ADRLEN)); |
---|
1191 | SysRam.O.Data_in<=AdrToSet(ADRLEN-1 downto Word); |
---|
1192 | elsif dcount=4 then -- ce cycle permet juste de vider le tampon d'écriture en RAM |
---|
1193 | dcount:=0; |
---|
1194 | SysRam.O.Addr_wr<=Std_logic_vector(to_unsigned(adresse+1,ADRLEN)); |
---|
1195 | end if; |
---|
1196 | |
---|
1197 | count:=dcount; |
---|
1198 | end procedure; |
---|
1199 | end MPI_Rma; |
---|