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