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