1 | ---------------------------------------------------------------------------------- |
---|
2 | -- Company: |
---|
3 | -- Engineer: GAMOM Roland Christian |
---|
4 | -- |
---|
5 | -- Create Date: 21:20:54 07/16/2012 |
---|
6 | -- Design Name: |
---|
7 | -- Module Name: PE - Behavioral |
---|
8 | -- Project Name: |
---|
9 | -- Target Devices: |
---|
10 | -- Tool versions: |
---|
11 | -- Description: Ce module permet d'encapsuler une tâche matérielle |
---|
12 | -- et lui donne la possiblité de communiquer à l'aide des fonctions MPI-2 RMA |
---|
13 | -- Dependencies: |
---|
14 | -- |
---|
15 | -- Revision: |
---|
16 | -- Revision 0.01 - File Created |
---|
17 | -- Additional Comments: |
---|
18 | -- |
---|
19 | ---------------------------------------------------------------------------------- |
---|
20 | library IEEE; |
---|
21 | use IEEE.STD_LOGIC_1164.ALL; |
---|
22 | library NocLib ; |
---|
23 | library Std; |
---|
24 | --use IEEE.STD_LOGIC_ARITH.ALL; |
---|
25 | --use IEEE.STD_LOGIC_UNSIGNED.ALL; |
---|
26 | Library MPI_HCL; |
---|
27 | use NocLib.CoreTypes.all; |
---|
28 | use MPI_HCL.Packet_type.all; |
---|
29 | use MPI_HCL.MPI_RMA.all; |
---|
30 | -- synthesis translate_off |
---|
31 | use std.textio.all; |
---|
32 | -- synthesis translate_on |
---|
33 | use IEEE.NUMERIC_STD.ALL; |
---|
34 | |
---|
35 | |
---|
36 | entity PE is |
---|
37 | Generic (DestId : natural:=0 ); |
---|
38 | Port ( Instruction : out STD_LOGIC_VECTOR (Word-1 downto 0); |
---|
39 | Instruction_en : out STD_LOGIC; |
---|
40 | Core_PushOut : in STD_LOGIC_VECTOR (Word-1 downto 0); |
---|
41 | clk : in STD_LOGIC; |
---|
42 | reset : in STD_LOGIC; |
---|
43 | CE : in STD_LOGIC; -- Active le PE après sa synthèse |
---|
44 | Core_RAM_Data_Out : out STD_LOGIC_VECTOR (Word-1 downto 0); |
---|
45 | Core_RAM_Data_In : in STD_LOGIC_VECTOR (Word-1 downto 0); |
---|
46 | Core_RAM_WE : in STD_LOGIC; |
---|
47 | Core_RAM_EN : in STD_LOGIC; |
---|
48 | --Core_RAM_ENB : in STD_LOGIC; |
---|
49 | Core_RAM_ADDRESS_WR : in STD_LOGIC_VECTOR (ADRLEN-1 downto 0); |
---|
50 | Core_RAM_ADDRESS_RD : in STD_LOGIC_VECTOR (ADRLEN-1 downto 0); |
---|
51 | Core_Hold_req : in STD_LOGIC; |
---|
52 | Core_Hold_Ack : out STD_LOGIC); |
---|
53 | end PE; |
---|
54 | |
---|
55 | architecture Behavioral of PE is |
---|
56 | COMPONENT RAM_v |
---|
57 | generic (width : positive;size :positive); |
---|
58 | PORT( |
---|
59 | clka : IN std_logic; |
---|
60 | clkb : IN std_logic; |
---|
61 | wea : IN std_logic; |
---|
62 | ena : IN std_logic; |
---|
63 | enb : IN std_logic; |
---|
64 | addra : IN std_logic_vector; |
---|
65 | addrb : IN std_logic_vector; |
---|
66 | dia : IN std_logic_vector; |
---|
67 | dob : OUT std_logic_vector |
---|
68 | ); |
---|
69 | END COMPONENT; |
---|
70 | COMPONENT mem8k8 |
---|
71 | PORT ( |
---|
72 | clka : IN STD_LOGIC; |
---|
73 | ena : IN STD_LOGIC; |
---|
74 | wea : IN STD_LOGIC_VECTOR(0 DOWNTO 0); |
---|
75 | addra : IN STD_LOGIC_VECTOR(12 DOWNTO 0); |
---|
76 | dina : IN STD_LOGIC_VECTOR(7 DOWNTO 0); |
---|
77 | clkb : IN STD_LOGIC; |
---|
78 | enb : IN STD_LOGIC; |
---|
79 | addrb : IN STD_LOGIC_VECTOR(12 DOWNTO 0); |
---|
80 | doutb : OUT STD_LOGIC_VECTOR(7 DOWNTO 0) |
---|
81 | ); |
---|
82 | END COMPONENT; |
---|
83 | COMPONENT HT_process is |
---|
84 | generic (Task_Id : natural); |
---|
85 | Port ( clk : in STD_LOGIC; |
---|
86 | reset : in STD_LOGIC; |
---|
87 | en : in std_logic; -- active la tâche |
---|
88 | Interf_i : in core_i; --signaux pour l'interface I |
---|
89 | Interf_o : out core_o; --signaux pour l'interface IO |
---|
90 | mem_i : in typ_dpram_i; -- signaux pour l'accès à la mémoire |
---|
91 | mem_o : out typ_dpram_o -- signaux pour l'accès à la mémoire |
---|
92 | ); |
---|
93 | end COMPONENT HT_process; |
---|
94 | |
---|
95 | COMPONENT Hold_FSM is |
---|
96 | |
---|
97 | Port ( Hold_Req : in STD_LOGIC; |
---|
98 | Ram_busy : in STD_LOGIC; |
---|
99 | Clk : in STD_LOGIC; |
---|
100 | Reset : in STD_LOGIC; |
---|
101 | Ramsel : out STD_LOGIC; |
---|
102 | Hold_Ack : out STD_LOGIC); |
---|
103 | end COMPONENT Hold_FSM; |
---|
104 | --données du programme PE |
---|
105 | --signaux pour l'interconnexionsignal datain :std_logic_vector(word-1 downto 0):= (others => '0'); |
---|
106 | signal ram_we ,ram_ena,ram_enb,ramsel_i: std_logic:='0'; |
---|
107 | signal pe_ram_we ,pe_ram_ena,pe_ram_enb: std_logic; |
---|
108 | signal pe_instr_en,pe_hold_ack: std_logic:='0'; |
---|
109 | signal ram_do,ram_din:std_logic_vector(word-1 downto 0):= (others => '0'); |
---|
110 | signal pe_ram_do,pe_ram_din:std_logic_vector(word-1 downto 0):= (others => '0'); |
---|
111 | signal ram_addra,ram_addrb :std_logic_vector(ADRLEN-1 downto 0); |
---|
112 | signal pe_ram_addra,pe_ram_addrb :std_logic_vector(ADRLEN-1 downto 0); |
---|
113 | signal sram : typ_dpram; |
---|
114 | signal clk_ht : std_logic; |
---|
115 | signal MyGroup:mpi_group; |
---|
116 | signal MyWin : mpi_win; |
---|
117 | signal SrcAdr0,SrcAdr1,destAdr0,destAdr1,Datalen:std_logic_vector(word-1 downto 0); |
---|
118 | signal dpid,dpid_i : natural range 0 to 15:=DestId; |
---|
119 | signal MyRank :std_logic_vector(3 downto 0); |
---|
120 | signal Libr : Core_io; --regroupe tous les signaux IO de la bibliothèque |
---|
121 | signal Lib_Ready:std_logic; --indique que l'exécution de la fonction est terminée |
---|
122 | signal Lib_instr_ack : std_logic; -- l'instruction est copiée dans le tampon FIFO |
---|
123 | signal Lib_Init : std_logic; -- l'initialisation est terminée |
---|
124 | signal Lib_Enable : std_logic:='0'; |
---|
125 | signal Ex1_run,Ex4_run : std_logic:='0'; --indique que ces modules sont en fin d'exécution |
---|
126 | signal Hold_Ack : std_logic; |
---|
127 | signal en_task : std_logic; |
---|
128 | signal ht_reset :std_logic; |
---|
129 | --signaux pour la gestion de la MAE |
---|
130 | type typ_mae is (start,Fillmem,NextFill,InitApp,GetRank,WInCreate,WinStart, putdata,getdata,WinCompleted,finalize,st_timeout); |
---|
131 | type typ_Hld is (Ht_Lock,Core_Lock,Ht_free); |
---|
132 | signal dcount : natural range 0 to 255:=0; |
---|
133 | signal wea : std_logic_vector (0 downto 0); |
---|
134 | signal count,count_i : natural range 0 to 15:=0; |
---|
135 | |
---|
136 | |
---|
137 | signal RunState : typ_mae; |
---|
138 | signal Hld_state :typ_hld; |
---|
139 | signal Ram_busy :std_logic:='0'; |
---|
140 | begin |
---|
141 | --Inst_RAM_v: RAM_v generic map(width=>word,size=>ADRLEN) |
---|
142 | -- PORT MAP( |
---|
143 | -- clka =>clk , |
---|
144 | -- clkb => clk , |
---|
145 | -- wea => ram_we, |
---|
146 | -- ena => ram_ena, |
---|
147 | -- enb => ram_enb, |
---|
148 | -- addra => ram_addra, |
---|
149 | -- addrb =>ram_addrb, |
---|
150 | -- dia => ram_din, |
---|
151 | -- dob => ram_do |
---|
152 | -- ); |
---|
153 | wea(0)<=ram_we; |
---|
154 | Ram8k8 : mem8k8 |
---|
155 | PORT MAP ( |
---|
156 | clka => clk, |
---|
157 | ena => ram_ena, |
---|
158 | wea => wea, |
---|
159 | addra => ram_addra(12 downto 0), |
---|
160 | dina => ram_din, |
---|
161 | clkb => clk, |
---|
162 | enb => ram_enb, |
---|
163 | addrb => ram_addrb(12 downto 0), |
---|
164 | doutb => ram_do |
---|
165 | ); |
---|
166 | HT_task:HT_process generic map(Task_id =>DestId) |
---|
167 | port map ( |
---|
168 | clk=>clk, |
---|
169 | reset=>ht_reset, |
---|
170 | en=>en_task, |
---|
171 | Interf_i =>Libr.i, |
---|
172 | Interf_o=>Libr.o, |
---|
173 | mem_i =>sram.i, |
---|
174 | mem_o =>sram.o ); |
---|
175 | |
---|
176 | --================================================================ |
---|
177 | --MUX de la RAM |
---|
178 | |
---|
179 | Ram_mux: process (clk,ramsel_i,pe_ram_addra,pe_ram_addrb,Core_ram_address_rd,Core_ram_address_wr, |
---|
180 | Core_ram_en,Core_ram_we,Core_ram_data_in,pe_ram_ena,pe_ram_enb,Ram_do, |
---|
181 | Pe_ram_din,Pe_ram_we ) |
---|
182 | begin |
---|
183 | case ramsel_i is |
---|
184 | |
---|
185 | when '1' => |
---|
186 | ram_addra <= Core_ram_address_wr ; |
---|
187 | ram_addrb <= Core_ram_address_rd ; |
---|
188 | ram_ena <= Core_ram_en; |
---|
189 | ram_enb <= Core_ram_en; |
---|
190 | ram_we<= Core_ram_we; |
---|
191 | ram_din <= Core_ram_data_in; |
---|
192 | pe_ram_do<=(others=>'U'); |
---|
193 | Core_ram_data_out<=ram_do; |
---|
194 | |
---|
195 | when others => |
---|
196 | ram_addra <= pe_ram_addra; |
---|
197 | ram_addrb <= pe_ram_addrb; |
---|
198 | ram_ena <= pe_ram_ena; |
---|
199 | ram_enb <= pe_ram_enb; |
---|
200 | ram_we<= pe_ram_we; |
---|
201 | ram_din <=pe_ram_din; |
---|
202 | Core_ram_data_out<=(others=>'U'); |
---|
203 | pe_ram_do<=ram_do; |
---|
204 | end case ; |
---|
205 | end process ; |
---|
206 | |
---|
207 | |
---|
208 | |
---|
209 | Instruction_En<=PE_instr_EN; -- Libr.Instr_en; --********A changer ********** |
---|
210 | --=== !!!!! attention la suppression de la ligne ci-dessous empêche ce |
---|
211 | -- composant de bien fonctionner !!! !!!!!!!!!!!!!!!!!!!!!!! |
---|
212 | --instruction<=std_logic_vector(to_unsigned(Core_upper_adr,8)); |
---|
213 | |
---|
214 | dpid<=dpid_i; |
---|
215 | en_task<= CE or Lib_enable; --l'activation d'une HT peut être directe ou commandée |
---|
216 | Lib_Instr_ack<=Core_Pushout(0); --l'instruction a été copié |
---|
217 | Lib_init<=Core_Pushout(4); -- Initialized |
---|
218 | Lib_Enable<=Core_Pushout(6);-- HT activée par la Librairie. |
---|
219 | Ex1_Run<=Core_Pushout(5); -- fin de l'exécution de Ex1 |
---|
220 | Ex4_Run<=Core_pushout(7); -- fin de l'exécution de Ex4 pour Spawn |
---|
221 | horloge_ht:process (reset,en_task,clk) |
---|
222 | begin |
---|
223 | if reset='1' then |
---|
224 | clk_ht<='0'; |
---|
225 | count<=0; |
---|
226 | Ht_reset<='1'; |
---|
227 | else |
---|
228 | if en_task='1' then |
---|
229 | clk_ht<=clk; |
---|
230 | if count=10 then --circuit de reset pour la HT |
---|
231 | ht_reset<='0'; |
---|
232 | else |
---|
233 | if rising_edge(clk) then |
---|
234 | count<=count+1; |
---|
235 | end if; |
---|
236 | ht_reset<='1'; |
---|
237 | end if; |
---|
238 | else |
---|
239 | count<=0; |
---|
240 | clk_ht<='0'; |
---|
241 | Ht_reset<='1'; |
---|
242 | end if; |
---|
243 | end if; |
---|
244 | end process horloge_ht; |
---|
245 | |
---|
246 | Hold1: Hold_fsm port map ( |
---|
247 | clk=>clk , |
---|
248 | reset =>reset, |
---|
249 | Ram_Busy=>Ram_busy, |
---|
250 | Hold_Ack=>Hold_Ack, |
---|
251 | Hold_req =>Core_Hold_Req, |
---|
252 | RamSel => RamSel_i); |
---|
253 | Core_Hold_Ack<=Hold_Ack; |
---|
254 | |
---|
255 | --================RAM signals ====================== |
---|
256 | sram.I.data_out<=PE_ram_do; |
---|
257 | pe_Ram_addra<=sram.O.addr_wr; |
---|
258 | pe_Ram_addrb<=sram.O.addr_rd ; |
---|
259 | PE_Ram_we<=sram.O.we; |
---|
260 | PE_Ram_ena<=sram.O.ena; |
---|
261 | PE_Ram_enb<=sram.O.enb; |
---|
262 | PE_ram_din<=sram.O.data_in; |
---|
263 | --==========MPI HCL signals ============================ |
---|
264 | |
---|
265 | affect:process (clk,en_task,Lib_enable,Core_hold_req,RamSel_i,Core_pushout,Libr.O) |
---|
266 | begin |
---|
267 | --if (clk'event and clk='1') then |
---|
268 | if en_task='1' then |
---|
269 | Instruction<=Libr.O.Instruction; |
---|
270 | Ram_busy<=Libr.O.membusy; |
---|
271 | PE_Instr_EN<=Libr.O.instr_en; |
---|
272 | else --si le HT n'est pas activé ces valeurs sont à 0 ! |
---|
273 | Instruction<=(others=>'0'); |
---|
274 | Ram_busy<='0'; |
---|
275 | PE_Instr_EN<='0'; |
---|
276 | end if; |
---|
277 | Libr.I.Instr_ack<=Core_pushout(0); |
---|
278 | Libr.I.InitOk<=Core_pushout(4); |
---|
279 | if Lib_enable='1' then |
---|
280 | Libr.I.Spawned<='1'; |
---|
281 | else |
---|
282 | Libr.I.Spawned<='0'; |
---|
283 | end if; |
---|
284 | Libr.I.Hold_Req<=Core_Hold_req; |
---|
285 | --Libr.I.Hold_Ack<=Hold_Ack; |
---|
286 | Libr.I.RamSel<=RamSel_i; |
---|
287 | --end if; |
---|
288 | assert not(Lib_enable='1') |
---|
289 | report "Spawn Activé" |
---|
290 | severity WARNING ; |
---|
291 | |
---|
292 | end process affect; |
---|
293 | --======================================================================= |
---|
294 | --MAE du PE |
---|
295 | --======================================================================= |
---|
296 | |
---|
297 | |
---|
298 | end Behavioral; |
---|
299 | |
---|