[76] | 1 | entity HT_process is |
---|
| 2 | generic (Task_id : natural:=0); |
---|
| 3 | Port ( clk : in STD_LOGIC; |
---|
| 4 | reset : in STD_LOGIC; |
---|
| 5 | en : in std_logic; -- active la tâche |
---|
| 6 | Interf_i : in core_i; --signaux pour l'interface IO |
---|
| 7 | Interf_o : out core_o; --signaux pour l'interface IO |
---|
| 8 | mem_o : out typ_dpram_o; -- signaux pour l'accès à la mémoire |
---|
| 9 | mem_i : in typ_dpram_i -- signaux pour l'accès à la mémoire |
---|
| 10 | ); |
---|
| 11 | end HT_process; |
---|
| 12 | |
---|
| 13 | architecture Behavioral of HT_process is |
---|
| 14 | |
---|
| 15 | type typ_mae is (start,Fillmem,NextFill,InitApp,GetRank,WInCreate,WinPost,WinStart, |
---|
| 16 | putdata,getdata,WinWait,WinCompleted,MpiSpawn,finalize,st_timeout); |
---|
| 17 | signal sram : typ_dpram; |
---|
| 18 | signal MyGroup:mpi_group; |
---|
| 19 | signal MyWin : mpi_win; |
---|
| 20 | signal MyRank :std_logic_vector(3 downto 0); |
---|
| 21 | signal intercomm,array_of_errcodes : natural; |
---|
| 22 | signal Libr : Core_io; --regroupe tous les signaux IO de la bibliothèque |
---|
| 23 | signal RunState : typ_mae; |
---|
| 24 | |
---|
| 25 | begin |
---|
| 26 | |
---|
| 27 | --MAE du PE |
---|
| 28 | --======================================================================= |
---|
| 29 | -- Interf<=Libr; |
---|
| 30 | |
---|
| 31 | |
---|
| 32 | pPutGet:process(clk,reset,en) |
---|
| 33 | |
---|
| 34 | |
---|
| 35 | variable destrank : natural range 0 to 15; |
---|
| 36 | variable timeout,ct,dlen,dcount : natural range 0 to 255; |
---|
| 37 | variable SrcAdr,DestAdr : std_logic_vector(ADRLEN-1 downto 0); |
---|
| 38 | variable mywin : Mpi_win; |
---|
| 39 | variable command , argv , maxprocs , info , root : natural:=0; --variable pour le spawn |
---|
| 40 | variable adresse,adresse_rd :natural range 0 to 65536; |
---|
| 41 | |
---|
| 42 | begin |
---|
| 43 | |
---|
| 44 | if (clk'event and clk='1') and en='1' then |
---|
| 45 | |
---|
| 46 | |
---|
| 47 | if reset='1' then |
---|
| 48 | --set the default signals values |
---|
| 49 | |
---|
| 50 | Libr.O.MemBusy<='0'; |
---|
| 51 | Libr.O.Instr_En<='0'; |
---|
| 52 | sram.O.we<='0'; |
---|
| 53 | sram.O.ena<='0'; |
---|
| 54 | sram.O.enb<='0'; |
---|
| 55 | RunState<=start; --jump to the first state of the FSM |
---|
| 56 | else |
---|
| 57 | --========================================================== |
---|
| 58 | --affectation des entrées sorties mémoires |
---|
| 59 | --These signals binding must remain unchanged for proper functionning of the template ! |
---|
| 60 | sram.i.data_out<=mem_I.data_out; |
---|
| 61 | mem_o.addr_wr<=sram.O.addr_wr; |
---|
| 62 | mem_o.addr_rd<=sram.O.addr_rd ; |
---|
| 63 | mem_o.we<=sram.O.we; |
---|
| 64 | mem_o.ena<=sram.O.ena; |
---|
| 65 | mem_o.enb<=sram.O.enb; |
---|
| 66 | mem_o.data_in<=sram.O.data_in; |
---|
| 67 | --affectation des entrées sorties MPI_HCL |
---|
| 68 | Interf_o.Instr_EN<=Libr.O.instr_en; |
---|
| 69 | Interf_o.Membusy<=Libr.O.MemBusy; |
---|
| 70 | Interf_o.Instruction<=Libr.O.Instruction; |
---|
| 71 | Libr.i.Instr_ack<=Interf_i.Instr_ack; |
---|
| 72 | Libr.i.InitOk<=Interf_i.InitOk; |
---|
| 73 | Libr.i.Hold_Req<=Interf_i.Hold_req; |
---|
| 74 | Libr.i.RamSel<=Interf_i.RamSel; |
---|
| 75 | --============================================================ |
---|
| 76 | |
---|
| 77 | case RunState is |
---|
| 78 | when start => |
---|
| 79 | adresse:=10;dcount:=0; |
---|
| 80 | RunState<=Fillmem; |
---|
| 81 | when Fillmem => --this state demonstrate a simple example task that writes data in the communication RAM |
---|
| 82 | sram.O.we<='1'; --enables writting |
---|
| 83 | sram.O.ena<='1'; |
---|
| 84 | sram.O.enb<='0'; --disable reading on port B |
---|
| 85 | if Libr.I.Ramsel='0' then --test if the RAM is free |
---|
| 86 | sram.O.addr_wr<=std_logic_vector(to_unsigned(adresse,ADRLEN)); |
---|
| 87 | sram.O.data_in<=std_logic_vector(to_unsigned(dcount,8)); -- x"0f"; |
---|
| 88 | Libr.O.MemBusy<='1'; --prevent the MPI-HCL to gain control on the RAM |
---|
| 89 | dcount:=dcount+1; |
---|
| 90 | |
---|
| 91 | if dcount=250 then |
---|
| 92 | RunState<=InitApp; |
---|
| 93 | Libr.O.MemBusy<='0'; --release the RAM access |
---|
| 94 | else |
---|
| 95 | adresse:=adresse+1; |
---|
| 96 | RunState<=Fillmem; |
---|
| 97 | end if; |
---|
| 98 | else -- attente de la libéraion de la mémoire /waiting for Ram to be free |
---|
| 99 | timeout:=timeout+1; |
---|
| 100 | if timeout=200 then |
---|
| 101 | report "The RAM is been busy for too long!!!"; |
---|
| 102 | timeout:=0; |
---|
| 103 | end if; |
---|
| 104 | |
---|
| 105 | end if; |
---|
| 106 | |
---|
| 107 | when InitApp => |
---|
| 108 | dlen:=15; |
---|
| 109 | |
---|
| 110 | pMPI_Init(ct,Libr,Clk,SRam); |
---|
| 111 | |
---|
| 112 | if ct=0 then |
---|
| 113 | RunState<=GetRank; |
---|
| 114 | end if; |
---|
| 115 | |
---|
| 116 | when GetRank => |
---|
| 117 | |
---|
| 118 | pMPI_Comm_rank(ct,Libr,sram,MPI_COMM_WORLD,MyRank); |
---|
| 119 | |
---|
| 120 | if ct=0 then |
---|
| 121 | RunState<=WinCreate; |
---|
| 122 | |
---|
| 123 | end if; |
---|
| 124 | |
---|
| 125 | when Wincreate => --ici nous personalisons les HT en fonction de leur rang |
---|
| 126 | --we use this state to fix HT parameters in regard of thier rank |
---|
| 127 | case MyRank is |
---|
| 128 | when x"0"=> |
---|
| 129 | Mygroup.grp<=x"0000";-- No rank in this group ==> No Win_Post |
---|
| 130 | MyGroup.nb<=2; |
---|
| 131 | destRank:=1; |
---|
| 132 | when x"1" => |
---|
| 133 | Mygroup.grp<=x"000A";-- rank 1 and 3 in this group |
---|
| 134 | destRank:=0; -- not use by this HT instance |
---|
| 135 | DestAdr:=X"043F"; |
---|
| 136 | when x"2" => |
---|
| 137 | Mygroup.grp<=x"0000";-- no rank in this group |
---|
| 138 | destRank:=1; |
---|
| 139 | DestAdr:=X"044F"; |
---|
| 140 | when x"3" => |
---|
| 141 | Mygroup.grp<=x"0004";-- rank 2 in this group |
---|
| 142 | destRank:=0; -- not use by this HT instance |
---|
| 143 | DestAdr:=X"045F"; |
---|
| 144 | when others => |
---|
| 145 | Mygroup.grp<=x"0000"; |
---|
| 146 | destRank:=0; |
---|
| 147 | end case; |
---|
| 148 | RunState<=WinPost; |
---|
| 149 | when WinPost => |
---|
| 150 | |
---|
| 151 | pMPI_Win_Post(ct,Libr,sram,MyGroup,0,MyWin); |
---|
| 152 | if ct=0 then |
---|
| 153 | RunState<=WinStart; |
---|
| 154 | |
---|
| 155 | end if; |
---|
| 156 | |
---|
| 157 | when WinStart => |
---|
| 158 | pMPI_Win_start(ct,Libr,sram,MyGroup,0,MyWin); |
---|
| 159 | |
---|
| 160 | if ct=0 then |
---|
| 161 | RunState<=PutData; |
---|
| 162 | end if; |
---|
| 163 | when putdata => --construire le packet pour le Put |
---|
| 164 | |
---|
| 165 | SrcAdr:=X"000A"; |
---|
| 166 | pMPI_put(ct,Libr,Clk,Sram,SrcAdr,Dlen,MPI_int,destrank,DestAdr,Dlen,Mpi_int,Default_win); |
---|
| 167 | if ct=0 then |
---|
| 168 | RunState<=GetData; |
---|
| 169 | end if; |
---|
| 170 | |
---|
| 171 | |
---|
| 172 | when getdata => |
---|
| 173 | SrcAdr:=X"006D"; |
---|
| 174 | destrank:=3; |
---|
| 175 | if unsigned(MyRank) = 2 then |
---|
| 176 | pMPI_GET(ct,Libr,Clk,Sram,SrcAdr,Dlen,MPI_int,destrank,DestAdr,Dlen,Mpi_int,Default_win); |
---|
| 177 | end if; |
---|
| 178 | |
---|
| 179 | if ct=0 then |
---|
| 180 | |
---|
| 181 | RunState<=wincompleted; |
---|
| 182 | |
---|
| 183 | end if; |
---|
| 184 | |
---|
| 185 | when WinCompleted => |
---|
| 186 | |
---|
| 187 | pMPI_Win_Complete(ct,Libr,sram,MyWin ); |
---|
| 188 | if ct=0 then |
---|
| 189 | RunState<=WinWait; |
---|
| 190 | |
---|
| 191 | end if; |
---|
| 192 | when WinWait => |
---|
| 193 | |
---|
| 194 | pMPI_Win_wait(ct,Libr,sram,MyWin ); |
---|
| 195 | |
---|
| 196 | if ct=0 then |
---|
| 197 | RunState<=Finalize; |
---|
| 198 | end if; |
---|
| 199 | |
---|
| 200 | when finalize => |
---|
| 201 | |
---|
| 202 | if ct=0 then |
---|
| 203 | RunState<=start; |
---|
| 204 | |
---|
| 205 | end if; |
---|
| 206 | when others => |
---|
| 207 | RunState<=start; |
---|
| 208 | end case; |
---|
| 209 | |
---|
| 210 | end if; |
---|
| 211 | end if; |
---|
| 212 | |
---|
| 213 | end process pPutGet; |
---|
| 214 | |
---|
| 215 | end Behavioral; |
---|