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