source: PROJECT_CORE_MPI/MPI_HCL/BRANCHES/v2.1/Timer_Par/MultiMPITest.vhd @ 158

Last change on this file since 158 was 158, checked in by rolagamo, 10 years ago
File size: 34.8 KB
Line 
1--------------------------------------------------------------------------------
2-- Company:
3-- Engineer: GAMOM Roland Christian
4--
5-- Create Date:   16:44:13 08/01/2012
6-- Design Name:   
7-- Module Name:   C:/Core MPI/CORE_MPI/MultiMPITest.vhd
8-- Project Name:  MPI_CORE_COMPONENTS
9-- Target Device: 
10-- Tool versions: 
11-- Description:   
12--
13-- Template d'untilisation de MPI - HCL
14--
15-- Dependencies:
16--
17-- Revision:
18-- Revision 0.01 - File Created
19-- Additional Comments:
20--
21--
22--
23--------------------------------------------------------------------------------
24LIBRARY ieee;
25USE ieee.std_logic_1164.ALL;
26 
27library NocLib ;
28
29use NocLib.CoreTypes.all;
30LIbrary MPI_HCL;
31use MPI_HCL.Packet_type.all;
32use work.Hcl_Arch_conf.all;
33USE ieee.numeric_std.ALL;
34 Library UNISIM;
35use UNISIM.vcomponents.all;
36ENTITY Mpi_template IS
37--rem simulation translate_off
38port (clk100MHz : in std_logic;
39rstn : in std_logic;
40sw : in std_logic_vector(15 downto 0); --bouton bascule
41Led : out std_logic_vector(15 downto 0);
42--rem simulation translate_on
43RsRX      : in  STD_LOGIC;
44RsTX     : out STD_LOGIC);
45END MPi_template;
46 
47ARCHITECTURE behavior OF MPI_Template IS 
48 
49    -- Composant pour le diviseur d'horloge
50 component CLKDIV
51port
52 (-- Clock in ports
53  SysCLK100           : in     std_logic;
54  -- Clock out ports
55  CLK100          : out    std_logic;
56  CLK50          : out    std_logic;
57  CLK25          : out    std_logic;
58  -- Status and control signals
59  RST             : in     std_logic;
60  LOCKED            : out    std_logic
61 );
62end component;
63---------------------------------------------------------------------
64  --
65  --  ICON component declaration
66  --
67  ---------------------------------------------------------------------
68
69  component chipscope_icon
70    port (
71      CONTROL0  : inout std_logic_vector(35 downto 0)
72   
73      );
74  end component;
75
76   ---------------------------------------------------------------------
77  --
78  --  VIO component declaration 
79  --
80  ---------------------------------------------------------------------
81
82  component chipscope_vio
83    port (
84      CONTROL   : inout std_logic_vector(35 downto 0);
85      CLK       :  in  std_logic;
86      SYNC_IN   :  in  std_logic_vector(7 downto 0)
87      );
88  end component;
89
90  ---------------------------------------------------------------------
91  --
92  --  ILA component declaration
93  --
94  ---------------------------------------------------------------------
95
96  component chipscope_ila
97    port (
98      CONTROL   : inout std_logic_vector(35 downto 0);
99      CLK       :  in  std_logic;
100      TRIG0     :  in std_logic_vector(7 downto 0);
101      TRIG1     :  in std_logic_vector(7 downto 0);
102      TRIG2     :  in std_logic_vector(7 downto 0);
103      TRIG3     :  in std_logic_vector(7 downto 0);
104      TRIG4     :  in std_logic_vector(7 downto 0);
105      TRIG5     :  in std_logic_vector(7 downto 0);
106      TRIG6     :  in std_logic_vector(7 downto 0);
107      TRIG7     :  in std_logic_vector(7 downto 0);
108      TRIG_OUT  :  out std_logic
109      );
110  end component;
111    COMPONENT MPI_NOC
112         generic (NPROC: natural:=2);
113    PORT(
114         MPI_Node_in : IN   Ar_MPIPort_in(1 to NPROC);
115         MPI_Node_Out : OUT   Ar_MPIPort_out(1 to NPROC)
116        );
117    END COMPONENT;
118         component proto_send is
119generic (sizemem : natural := 64);
120 port (
121 clk,reset : in std_logic;
122 fifo_in_empty,fifo_in_full : in std_logic; --signaux pour le fifo d'entrée
123 fifo_out_empty,fifo_out_full : in std_logic; --signaux pour le fifo de sortie
124 fifo_out_wr_en : out std_logic:='0'; --écriture autorisée dans la fifo de sortie
125 fifo_in_rd_en : out std_logic:='0'; --lecture autorisée dans la fifo d'entrée
126 fifo_in_data_out : in std_logic_vector(Word-1 downto 0);
127 fifo_out_data_in : out std_logic_vector(Word-1 downto 0);
128 packet_len : in std_logic_vector(Word-1 downto 0); --la longueur du paquet
129 copy_mode : in std_logic; --Fifo_to_mem ou Fifo_to_fifo
130 snd_start : in std_logic; --début de la réception
131 snd_ack :in std_logic;   -- acquittement de la réception
132 snd_comp : out std_logic; -- fin de la réception
133 mem :in memory(0 to sizemem-1)); --données à copier vers le fifo
134 end component proto_send;
135Component Fifo2mem is
136Port ( clk : in  STD_LOGIC;
137           reset : in  STD_LOGIC;
138                          wr_start : in STD_LOGIC;
139           fifo_data_out : in  STD_LOGIC_VECTOR (Word-1 downto 0);
140           fifo_data_available : in  STD_LOGIC;
141                          datalen :   STD_LOGIC_VECTOR (Word-1 downto 0);
142           fifo_data_out_en : out  STD_LOGIC;
143           fifo_empty : in  STD_LOGIC;
144                          ram_busy : in  STD_LOGIC;
145           ram_addr_start : in  STD_LOGIC_VECTOR (ADRLEN-1 downto 0);
146                          ram_addr : out  STD_LOGIC_VECTOR (ADRLEN-1 downto 0);
147           ram_data_in : out  STD_LOGIC_VECTOR (Word-1 downto 0);
148           ram_wr : out  STD_LOGIC;
149           ram_en : out  STD_LOGIC;
150                          wr_comp :out STD_LOGIC);
151end component fifo2mem;
152
153COMPONENT mem2fifo_a is --copy from memory to fifo
154 port (
155 clk,reset : in std_logic;
156 copy_mode : in std_logic; --Fifo_to_mem ou Fifo_to_fifo
157 snd_start : in std_logic; --début de la réception
158 snd_ack :in std_logic;   -- acquittement de la réception
159 datalen : in std_logic_vector(Word-1 downto 0); --la longueur du paquet
160 ram_busy : in  STD_LOGIC;
161 ram_addr_start :in std_logic_vector(ADRLEN-1 downto 0); --addresse de début du bloc de donnée à copier
162 fifo_out_empty,fifo_out_full : in std_logic; --signaux pour le fifo de sortie
163 fifo_out_wr_en : out std_logic:='0'; --écriture autorisée dans la fifo de sortie
164 ram_in_rd_en : out std_logic:='0'; --lecture autorisée dans la fifo d'entrée
165 ram_in_data_out : in std_logic_vector(Word-1 downto 0);
166 ram_in_addr_rd :out std_logic_vector(ADRLEN-1 downto 0); --addresse de la donnée à copier
167 fifo_out_data_in : out std_logic_vector(Word-1 downto 0);
168 snd_comp : out std_logic); -- fin de la réception
169
170END COMPONENT mem2fifo_a;
171
172COMPONENT UART_TX_CTRL generic (ComRate : natural:=217);
173        PORT(
174                SEND : IN std_logic;
175                DATA : IN std_logic_vector(7 downto 0);
176                CLK : IN std_logic;         
177                READY : OUT std_logic;
178                UART_TX : OUT std_logic
179                );
180        END COMPONENT;
181component com_icap is
182  generic ( hexmode : boolean := true; -- false is for faster binary mode, but will not work on all machines/boards
183            ComRate : integer := 217); -- ComRate = f_CLK / Boud_rate (e.g., 25 MHz/115200 Boud = 217)
184  port (CLK         : in  std_logic;
185        Rx          : in  std_logic;
186        Tx          : out std_logic;
187                  RxErr:         out std_logic;
188        debug0:     out std_logic_vector(19 downto 0);
189        debug1:     out std_logic_vector(19 downto 0);
190        debug2:     out std_logic_vector(19 downto 0);
191                  bs_load_start : in std_logic; --début de réception bitstream
192                  bs_load_comp :out std_logic; --fin de réception
193                  bs_load_ack :in std_logic; --acquitement bistream
194                  bs_load_data : out std_logic_vector(31 downto 0);
195                   rxWord   : out std_logic_vector(7 downto 0); -- mot reçu
196                        RxRdy     : out std_logic; --données reçues
197        ComActive   : out std_logic;
198        WriteStrobe : out std_logic;
199        ReceiveLED  : out std_logic);
200end component com_icap;
201 Component PE
202  generic(destid : natural;
203                                use_dyn:natural);
204  Port ( Instruction : out  STD_LOGIC_VECTOR (Word-1 downto 0);
205           Instruction_en : out  STD_LOGIC;
206                          Core_PushOut : in STD_LOGIC_VECTOR (Word-1 downto 0);
207           clk : in  STD_LOGIC;
208           reset : in  STD_LOGIC;
209                             CE : in  STD_LOGIC;
210                             ct_out : out unsigned(7 downto 0);
211                                  PE_in : in STD_LOGIC_VECTOR (Word-1 downto 0);
212                                  PE_out : out STD_LOGIC_VECTOR (Word-1 downto 0);
213           Core_RAM_Data_Out : out  STD_LOGIC_VECTOR (Word-1 downto 0);
214           Core_RAM_Data_Out2: out  STD_LOGIC_VECTOR (Word-1 downto 0);
215           Core_RAM_Data_In : in  STD_LOGIC_VECTOR (Word-1 downto 0);
216           Core_RAM_WE : in  STD_LOGIC;
217           Core_RAM_EN : in  STD_LOGIC;
218           --Core_RAM_ENB : in  STD_LOGIC;
219           Core_RAM_ADDRESS_WR : in  STD_LOGIC_VECTOR (ADRLEN-1 downto 0);
220           Core_RAM_ADDRESS_RD : in  STD_LOGIC_VECTOR (ADRLEN-1 downto 0);
221           Core_Hold_req : in  STD_LOGIC;
222           Core_Hold_Ack : out  STD_LOGIC);
223end Component; 
224 component FIFO_256_FWFT
225        port (
226        clk: IN std_logic;
227        din: IN std_logic_VECTOR(Word-1 downto 0);
228        rd_en: IN std_logic;
229        srst: IN std_logic;
230        wr_en: IN std_logic;
231        dout: OUT std_logic_VECTOR(Word-1 downto 0);
232        empty: OUT std_logic;
233        full: OUT std_logic);
234end component;
235        constant clk_period : time := 15 ns;
236   constant PROC : positive :=NOC_SIZE; --4
237
238--===================signaux pour l'horloge ==============================
239signal CLK100,CLK50,CLK25,reset,locked : std_logic := '0';
240signal CLK200,Clkm,RST : std_logic := '0';
241--========================================================================
242
243 --signaux pour la gestion de la MAE
244 type typ_rs_send is (snd_wait,snd_read,snd_sendBit,snd_lf,snd_cr);
245type typ_mem is array (natural range <>) of std_logic_vector(Word-1 downto 0);
246type typ_tab is array (natural range <>) of unsigned(7 downto 0);
247--groupe de signaux utilisé pour communiquer avec l'extérieur de la plateforme
248type arDpRam is array (natural range <>) of typ_dpRam;
249type typ_Pconsole is(idle,get_bus,get_ht_mem,rd_ht_mem,wr_ht_mem,
250Write_cmd,Cmd_To_fifo,et_end);
251signal et_send :typ_rs_send;
252signal et_Pconsole,Next_et_Pconsole : typ_pconsole;
253signal Pcons_ram :typ_dpram; --signaux pour accès à la ram par la console
254signal pcons_hold_req,pcons_hold_ack: std_logic;--pour accès à la Ram du HT
255signal pcons_cmd : natural range 0 to 15; -- la  commande qui est sollicitée depuis le clavier
256signal pcons_wr_comp,pcons_wr_start : std_logic;--pour contrôler l'écriture dans la Ram du HT
257signal pcons_fifo_wr:std_logic;--contrôle l'écriture des données dans le FIFO de sortie
258signal pcons_rd_comp,pcons_rd_start,pcons_rd_ack :std_logic;
259signal pcons_ram_busy : std_logic:='0';
260signal pcons_data:std_logic_vector(Word-1 downto 0); --une données fournie par la console aux HTs
261signal pcons_ht : natural range 0 to 15:=0;--le numéro du HT qui est sollicité
262signal mux_hold_req,dmux_hold_ack: std_logic_vector(1 to PROC); --multiplexer les signaux d'accès RAM HT entre Core_MPI et console
263signal dmux_instruction : typ_mem(1 to PROC);
264signal dmux_instruction_en : std_logic_vector(1 to PROC);
265signal mux_ram,mux_ram_s,mux_ram_d : Ar_DpRam(1 to PROC); --signaux pour récupérer les données de la RAM
266signal pcons_sel,pcons_sel_i:std_logic_vector(1 to PROC):=(others=>'0');--état de la sélection du MUX entre Console et Core MPI
267signal pcons_fin_rd_en:std_logic;
268signal wr_ok,rd_ok:std_logic:='0';
269signal presence : std_logic_vector(1 to 4); --signale les modules actifs
270signal ct_tab : typ_tab(1 to 4); --etat des sorties des MAE
271--signal PE_out : std_logic_vector(Word-1 downto 0);
272signal Sys_in : typ_mem(1 to PROC);
273signal Sys_Out : typ_mem(1 to PROC);
274--
275--signaux pour le module de communication RS232C
276signal rs_cmd,rs_rw,rs_comp:std_logic;
277signal rs_addr_start:std_logic_vector(adrlen-1 downto 0);
278signal rs_plen :std_logic_vector(word-1 downto 0);
279signal rs_fifo_in_data_out_en:std_logic;
280signal rs_fifo_in_data_available : std_logic;
281signal rs_fifo_in_data_out :std_logic_vector(word-1 downto 0);
282signal rs_fifo_out_data_out_en:std_logic;
283signal rsin_fifo_data_available : std_logic;
284signal rs_fifo_out_data_out :std_logic_vector(word-1 downto 0);
285signal rs_fifo_out_empty:std_logic;
286--
287signal dcount : natural range 0 to 255:=0; --permet de compter le packet de données envoyées
288signal count,count_i : natural range 0 to 15:=0;
289
290signal MPI_Node_in : Ar_MPIPort_in(1 to PROC) ;
291signal MPI_Node_Out : Ar_MPIPort_out(1 to PROC);
292--=========================================================
293--signaux pour la communication série
294        constant period  : time := 68 ns ;
295        constant   BITperiod :  time := 8680 ns ; -- 115.200 ; -- 115.200
296        signal COM_RX : std_logic := '0';
297        signal COM_TX : std_logic := '0';
298        signal  RSData :std_logic_vector (7 downto 0):=x"00";
299        signal Data_to_send :memory(0 to 8000);
300        signal n : natural:=0; 
301        --
302type UART_STATE_TYPE is (RST_REG, LD_INIT_STR, SEND_CHAR, RDY_LOW, WAIT_RDY, WAIT_BTN, LD_BTN_STR);
303type CHAR_ARRAY is array (integer range<>) of std_logic_vector(7 downto 0);
304constant MAX_STR_LEN : integer := 27;
305
306signal counter : std_logic_vector(25 downto 0) := (others => '0');
307signal rxWord : std_logic_vector(7 downto 0);
308signal ComCommand : std_logic_vector(7 downto 0);
309signal comWriteStrobe :std_logic;
310signal ComActive, NotComActive : std_logic;
311signal RxRdy : std_logic;
312signal Local_COM_RX : std_logic;
313signal Local_COM_TX : std_logic;
314signal uartState : UART_STATE_TYPE := RST_REG;
315--UART_TX_CTRL control signals
316signal uartRdy : std_logic;
317signal uartSend : std_logic := '0';
318signal uartData : std_logic_vector (7 downto 0):= "00000000";
319signal uartTX : std_logic;
320--signale une erreur en cas de mauvaise réception
321signal Recv_Err_led : std_logic:='0';
322--===============================================================+
323--signaux pour les fifo d'entrée et de sortie
324
325signal rsin_fifo_rd_en:std_logic;--(ADRLEN-1 downto 0);
326signal rsin_fifo_wr_en : std_logic;
327signal rsin_fifo_empty : std_logic;
328signal rsin_fifo_full : std_logic;
329signal rsin_fifo_dout : std_logic_vector(WORD-1 downto 0);
330signal rsin_fifo_din : std_logic_vector(WORD-1 downto 0);
331signal rsout_fifo_rd_en:std_logic;--(ADRLEN-1 downto 0);
332signal rsout_fifo_wr_en : std_logic;
333signal rsout_fifo_empty : std_logic;
334signal rsout_fifo_full : std_logic;
335signal rsout_fifo_dout : std_logic_vector(WORD-1 downto 0);
336signal rsout_fifo_din : std_logic_vector(WORD-1 downto 0);
337--===============================================================
338  signal trigout        : std_logic;
339  signal syncin : std_logic_vector(7 downto 0);
340  signal control_0             : std_logic_vector (35 downto 0);
341  signal control_1      : std_logic_vector(35 downto 0);
342  -----------------------------------------------------------------------
343  --  Constant Declaration
344  -----------------------------------------------------------------------
345  constant C_NUM_OF_TRIGPORTS   : integer := 8;
346  constant C_TRIG0_SIZE         : integer       := 8;
347  constant C_TRIG1_SIZE         : integer       := 8;
348  constant C_TRIG2_SIZE         : integer       := 8;
349  constant C_TRIG3_SIZE         : integer       := 8;
350  constant C_TRIG4_SIZE         : integer       := 8;
351  constant C_TRIG5_SIZE         : integer       := 8;
352  constant C_TRIG6_SIZE         : integer       := 8;
353  constant C_TRIG7_SIZE         : integer       := 8;
354--===============================================================
355  signal trig_0 : std_logic_vector(C_TRIG0_SIZE-1 downto 0);
356  signal trig_1 : std_logic_vector(C_TRIG1_SIZE-1 downto 0);
357  signal trig_2 : std_logic_vector(C_TRIG2_SIZE-1 downto 0);
358  signal trig_3 : std_logic_vector(C_TRIG3_SIZE-1 downto 0);
359  signal trig_4 : std_logic_vector(C_TRIG4_SIZE-1 downto 0);
360  signal trig_5 : std_logic_vector(C_TRIG5_SIZE-1 downto 0);
361  signal trig_6 : std_logic_vector(C_TRIG6_SIZE-1 downto 0);
362  signal trig_7 : std_logic_vector(C_TRIG7_SIZE-1 downto 0);
363
364---===============================================================
365--signaux pour le port ICAP
366        signal swap_reg : std_logic_vector(31 downto 0) := (others=>'0');
367        type RegStateType is (getHigh, getNib1,getNib2,getLow);
368        signal RegState : RegStateType;
369        signal IcapCLK_trigger, IcapCLK_trigger_reg, IcapCLK : std_logic;
370        signal Icapi, IcapO : std_logic_vector(31 downto 0);
371        signal IcapBUSY : std_logic;
372        signal IcapCE : std_logic;
373        Signal RdWrB : std_logic:='0'; --contrôle la lecture ou l'écriture du port ICAP
374        signal icap_COM_RX,icap_COM_TX:std_logic; --conversion serie/ICAP
375        -- Signaux pour le port Série qui reçoit le fichier *.Bit
376        signal debug0: std_logic_vector(19 downto 0);
377signal debug1: std_logic_vector(19 downto 0);
378signal debug2: std_logic_vector(19 downto 0);
379signal receiveLed :std_logic; --led qui clignote au rithme des réceptions.
380signal bs_load_start :  std_logic; --début de réception bitstream
381signal bs_load_comp : std_logic; --fin de réception
382signal bs_load_ack : std_logic; --acquitement bistream
383signal bs_load_data:  std_logic_vector(31 downto 0);
384--signal rxWord   :  std_logic_vector(7 downto 0); -- mot reçu
385--signal RxRdy     :  std_logic;
386--=================================================================
387 
388BEGIN
389SysMPI: MPI_NOC GENERIC MAP (NPROC=>NOC_SIZE)
390                PORT MAP (
391          MPI_Node_in => MPI_Node_in,
392          MPI_Node_Out => MPI_Node_Out
393        );
394--
395---port ICAP série ====================================================================
396instcomicap:com_icap            -- instantiate the UART receiving the configuration data
397  generic map(
398    hexmode => false,  -- false is for faster binary mode, but will not work on all PCs
399    ComRate => 108)   -- ComRate = f_CLK / Boud_rate (e.g., 25 MHz/115200 Boud = 217)
400                           -- 1302 @ 19200 Boud 108 @ 230400/25 MHz
401  port map (
402    clk            => CLK25,
403    rx             => icap_COM_RX,
404    tx             => icap_COM_TX,
405         rxerr                  => Recv_Err_led,
406         rxRdy                  => RxRdy,
407         --rxWord                       => RxWord,
408         debug0         => debug0,
409         debug1         => debug1,
410         debug2         => debug2,
411    RxWord       => rxWord,
412         bs_load_data           => bs_load_data,
413    comactive      => ComActive,
414    writestrobe    => ComWritestrobe,
415    bs_load_start  => bs_load_start,
416         bs_load_comp   =>bs_load_comp,
417         bs_load_ack    =>bs_load_ack,
418    receiveled     => receiveled  );
419         
420--========================================================
421
422res_Led_sw:process (MPi_Node_out,sw,bs_load_start,CLK25,uartTX,rsRX,
423pcons_sel,receiveLed,presence)
424variable p:natural range 0 to 255:=1;
425begin
426p:=to_integer(unsigned(sw)); --récupérer les switchs pour définir les entrées
427if p>0 then
428Led(7 downto 0)<=MPi_Node_out(1).PushOut;
429else
430 Led(7 downto 0)<=MPi_Node_out(2).PushOut;
431end if;
432led(8)<=sw(4);
433led(9)<=CLK25;
434led(10)<=uartTx;
435led(11)<=rsRX;
436led(12)<=ReceiveLed;
437led(13)<=pcons_sel(1);
438led(14)<=bs_load_start;
439led(8)<=presence(1);
440led(9)<=presence(2);
441led(15)<=presence(3);
442end process;
443--===========================================================
444--diviseur d'horloge
445process(CLK100Mhz)
446begin
447  if CLK100Mhz'event AND CLK100Mhz='1' then
448    counter <= std_logic_vector(unsigned(counter) + 1);
449  end if;
450end process;
451inst_CLKDIV : CLKDIV
452  port map
453   (-- Clock in ports
454    SysCLK100 => CLK100Mhz,
455    -- Clock out ports
456    CLK100 => CLK100,
457    CLK50 => CLK50,
458    CLK25 => CLK25,
459    -- Status and control signals
460    RST  => Rst,
461    LOCKED => LOCKED);
462--CLKm<=counter(0);--horloge à 50 MHz
463CLKm<=CLK50;--counter(0);--horloge à 50 MHz
464--CLK25<=counter(1); --CLK10 est une horloge à 100 MHZ sur NEXSYS 4!
465reset<= not locked; --inversion de l'état de reset pour les composant du montage
466RST<= not rstn;
467--===========================================================
468
469--===========================================================
470S_Grp:for i in 1 to STATIC_HT generate
471S: PE   Generic map (DestId=>i-1,
472                                                         use_dyn=>0)
473                        Port Map (
474                                Instruction => dmux_instruction(i),
475           Instruction_en =>dmux_instruction_en(i),
476                          Core_PushOut => MPi_Node_out(i).PushOut,
477           clk =>clkm,
478           reset =>reset,
479                          CE => '1',
480                          ct_out=>ct_tab(i),
481                          PE_Out=>Sys_out(i),
482                          PE_In=>sys_In(i),
483                                Core_RAM_Data_Out =>mux_ram_d(i).i.Data_out,
484                                Core_RAM_Data_Out2=>mux_ram_s(i).i.Data_out,
485           Core_RAM_Data_IN => mux_ram(i).o.data_in,
486           Core_RAM_WE => mux_ram(i).o.we,
487           Core_RAM_EN => mux_ram(i).o.enb,
488           Core_RAM_Address_Wr => mux_ram(i).o.addr_wr,
489           Core_RAM_Address_Rd => mux_ram(i).o.addr_rd,
490           Core_Hold_req => mux_hold_req(i),
491           Core_Hold_Ack => dmux_hold_ack(i)                     
492
493);
494
495end generate S_Grp;
496dyn_mod: if dyn_allowed='1' generate
497D_Grp:for i in STATIC_HT+1 to NOC_SIZE generate
498D: PE   Generic map (DestId=>i-1,
499                                                use_dyn=>1)
500                        Port Map (
501                                Instruction => dmux_instruction(i),--MPi_Node_in(i).Instruction,
502           Instruction_en =>dmux_instruction_en(i),-- MPi_Node_in(i).Instruction_en,
503                          Core_PushOut => MPi_Node_out(i).PushOut,
504           clk =>clkm,
505           reset =>reset,
506                          CE => '0',
507                          ct_out=>ct_tab(i),
508                          PE_Out=>Sys_out(i),
509                          PE_In=>sys_In(i),
510           Core_RAM_Data_Out2 =>mux_ram_s(i).i.Data_out,
511           Core_RAM_Data_Out =>mux_ram_d(i).i.Data_out,
512           Core_RAM_Data_IN => mux_ram(i).o.data_in,
513           Core_RAM_WE => mux_ram(i).o.we,
514           Core_RAM_EN => mux_ram(i).o.enb,
515           Core_RAM_Address_Wr => mux_ram(i).o.addr_wr,
516           Core_RAM_Address_Rd => mux_ram(i).o.addr_rd,
517           Core_Hold_req => mux_hold_req(i),
518           Core_Hold_Ack => dmux_hold_ack(i)
519);
520
521end generate D_Grp;
522end generate dyn_mod;
523
524trig_0(3 downto 0)<= x"0";
525trig_0(7)<=MPi_Node_out(1).PushOut(0);
526trig_0(6)<=MPi_Node_out(2).PushOut(0);
527trig_0(5)<=MPi_Node_out(3).PushOut(0);
528trig_0(4)<=MPi_Node_out(4).PushOut(0);
529trig_1<=dmux_instruction(1);
530trig_2<=dmux_instruction(2);
531trig_3<=dmux_instruction(3);
532trig_4<=dmux_instruction(4);
533trig_5<=std_logic_vector(ct_tab(1));
534trig_6<=std_logic_vector(ct_tab(2));
535trig_7<=std_logic_vector(ct_tab(3));
536
537--(7 => '0', 6 downto 5 => '1',others => '0')
538--affect_process
539affec_pres:process(ct_tab)
540begin
541  for i in 1 to 4 loop
542presence(i)<=ct_tab(i)(7);
543end loop;
544end process;
545affec_PE:process(sw)
546begin
547for i in 1 to 4 loop
548sys_in(i)<=(0=>sw(i+7),others=>'1');
549end loop;
550end process;
551 --instantiation du FIFO_256 pour le port série
552 RS_INPUT_FIFO : FIFO_256_FWFT
553                port map (
554                        clk => clkm,
555                        din => rsin_fifo_din,
556                        rd_en => rsin_fifo_rd_en,
557                        srst => reset,
558                        wr_en => rsin_fifo_wr_en,
559                        dout => rsin_fifo_dout,
560                        empty => rsin_fifo_empty,
561                        full => rsin_fifo_full);
562         RS_OutPut_FIFO : FIFO_256_FWFT
563                port map (
564                        clk => clkm,
565                        din => rsout_fifo_din,
566                        rd_en => rsout_fifo_rd_en,
567                        srst => reset,
568                        wr_en => rsout_fifo_wr_en,
569                        dout => rsout_fifo_dout,
570                        empty => rsout_fifo_empty,
571                        full => rsout_fifo_full);
572
573-------------------------------------------------------------------
574  --
575  --  ICON Pro core instance
576  --
577  -------------------------------------------------------------------
578  -- Icon core with two control ports is instantiated to connect to ILA and VIO cores.
579  ICON_inst : chipscope_icon 
580    port map(
581      CONTROL0 => control_0 -- INOUT BUS [35:0]
582
583      );
584                       
585--VIO_inst : chipscope_vio
586--    port map (
587--      CONTROL => control_1,   -- INOUT BUS (35:0)
588--      CLK     => clk50,       -- IN
589--      SYNC_IN =>MPi_Node_out(1).PushOut       -- IN (7:0)
590--      );
591
592ILA_inst : chipscope_ila
593    port map (
594      CONTROL   => control_0,   -- INOUT BUS (35:0)
595      CLK       => clk50,       -- IN
596      TRIG0     => trig_0,      -- IN BUS (7:0)
597      TRIG1     => trig_1,      -- IN BUS (7:0)
598      TRIG2     => trig_2,      -- IN BUS (7:0)
599      TRIG3     => trig_3,      -- IN BUS (7:0)
600      TRIG4     => trig_4,      -- IN BUS (7:0)
601      TRIG5     => trig_5,      -- IN BUS (7:0)
602      TRIG6     => trig_6,      -- IN BUS (7:0)
603      TRIG7     => trig_7,      -- IN BUS (7:0)
604      TRIG_OUT  => trigout      -- OUT
605      );
606
607
608rsin_fifo_data_available<= not rsin_fifo_empty;
609-- Merge two bytes or four bytes if ICAPE2 from the UART to one 16/32 bit word for the Spartan-6 ICAP/ARTIX-7 ICAPE2
610-- Note that we have to permute the bits within each byte...
611inversion_byte:process(bs_load_data)
612begin
613           for i in 0 to 7 loop --inversion des bits octet par octet
614             for j in 0 to 3 loop
615               swap_reg(j*8+i)<= bs_load_data(j*8+7-i);
616               end loop;
617              end loop;
618end process;
619
620--- controle de la reconfiguration du FPGA
621process(CLKM)
622begin
623  if rising_edge(clkm) then
624         if ComWritestrobe='1' then
625           IcapCLK_trigger <= '1';
626         else
627           IcapCLK_trigger <= '0';
628         end if;
629         IcapCLK_trigger_reg <= IcapCLK_trigger;
630  end if; 
631end process;
632--Component used to send a byte of data over a UART line.
633Inst_UART_TX_CTRL: UART_TX_CTRL generic map(ComRate => 217)
634port map(
635                SEND => uartSend,
636                DATA => uartData,
637                CLK => CLKm,
638                READY => uartRdy,
639                UART_TX => uartTX
640        );
641        rsTX<=UartTX;
642-- connect ICAP signals
643--icap_signal:process (Et_Icap,bs_load_data,writestrobe,
644--bs_load_start,bs_load_comp)
645--begin
646-- 
647--  case et_icap is
648--  when icap_idle =>
649--    IcapCE <= '1';
650--    RDWRB<='1';
651--       IcapI <= bs_load_data;
652--      when icap_writting =>
653--       IcapCE <= '1';
654--    RDWRB<='1';
655--       IcapI <= bs_load_data;
656--      when icap_idle =>
657      IcapCLK<=clkm;--IcapCLK_trigger_reg
658          IcapCE <= not comWritestrobe;--Not(bs_load_start);
659    RDWRB<='0';
660         IcapI <= swap_reg;
661--      end case;
662 -- ICAPE2: Internal Configuration Access Port
663   --         Artix-7 ID=X3631093 Voir UG470 pour les autres devices
664   -- Xilinx HDL Language Template, version 14.7
665               
666   ICAPE2_inst : ICAPE2
667   generic map (
668      DEVICE_ID => X"03631093",     -- Specifies the pre-programmed Device ID value to be used for simulation
669                                   -- purposes.
670      ICAP_WIDTH => "X32",         -- Specifies the input and output data width.
671      SIM_CFG_FILE_NAME => "None"  -- Specifies the Raw Bitstream (RBT) file to be parsed by the simulation
672                                   -- model.
673   )
674   port map (
675      O => IcapO,         -- 32-bit output: Configuration data output bus
676      CLK => IcapCLK,     -- 1-bit input: Clock Input
677      CSIB => IcapCE,   -- 1-bit input: Active-Low ICAP Enable
678      I => IcapI,         -- 32-bit input: Configuration data input bus
679      RDWRB => RDWRB  -- 1-bit input: Read/Write Select input
680   );
681
682   -- End of ICAPE2_inst instantiation
683
684
685--******************************************
686--** Gestion des switchs et de la réception des données
687--********************************************
688process(clkm,sw,rsRX,bs_load_comp)
689begin
690if rising_edge(clkm) then
691if sw(0)='1' then
692        rs_cmd<='1';
693else
694        rs_cmd<='0';
695end if;
696
697if sw(1)='1' then
698        rs_rw<='1';
699else
700        rs_rw<='0';
701       
702end if;
703
704--if sw(2)='1' or sw(3)='1' then
705--pcons_ht<=to_integer(unsigned(sw(3 downto 2))+1); --choix du HT à contrôler
706--else
707pcons_ht<=1; --choix du HT à contrôler
708--end if;
709if sw(3)='1' then
710  icap_COM_RX<=rsRX;
711  bs_load_start<='1';
712  bs_load_ack<=bs_load_comp;
713else
714  icap_COM_RX<='1';
715  bs_load_start<='0';
716  bs_load_ack<='0';
717end if;
718pcons_cmd<=to_integer(unsigned(sw(7 downto 4)));
719end if;
720end process;
721--************************************************************
722--MAE de lecture de la mémoire de communication de chaque tâche et envoie des données
723-- sur le port série
724Pcons_sync:process(clkm)
725begin
726if rising_edge(clkm) then
727if reset='1' then
728Et_Pconsole<=idle;
729pcons_sel<=(others=>'0');
730else
731et_Pconsole<=next_et_Pconsole;
732pcons_sel<=pcons_sel_i;
733end if;
734end if;
735end process;
736--*********************************************************
737Pcons_next : process(et_Pconsole,pcons_rd_comp,pcons_wr_comp,dmux_hold_ack,rs_cmd,
738rs_rw,rsin_fifo_empty,pcons_ht,MPI_Node_out,pcons_cmd,pcons_sel)
739
740variable bus_free:std_logic:='0';
741begin
742next_et_pconsole<=et_Pconsole; --valeur par défaut
743pcons_sel_i<=pcons_sel;
744wr_ok<='0';
745rd_ok<='0';
746case et_pconsole is
747when idle => if rs_cmd='1' then
748                next_et_pconsole<=get_bus;
749                end if;
750                pcons_sel_i<=(others=>'0');
751when get_bus => 
752bus_free:='0';
753for i in 1 to PROC loop
754        if pcons_ht=i then
755        if MPI_Node_out(i).Hold_req='0' then
756                Pcons_sel_i(i)<='1';
757                bus_free:='1';
758        else
759                Pcons_sel_i(i)<='0';
760        end if;
761        else
762                Pcons_sel_i(i)<='0';
763        end if;
764end loop;
765if bus_free='1' then
766        next_et_pconsole<=get_ht_mem;
767end if;
768when get_ht_mem => if dmux_hold_ack(pcons_ht)='1' then 
769                                                        if pcons_cmd>0 then 
770                                                        next_et_pconsole<=Cmd_to_fifo;
771                                                        else
772                                                        if rs_rw='1' then
773                                                                                        next_et_pconsole<=rd_ht_mem;
774                                                                         else --if rs_rw='1' then
775                                                                                        next_et_pconsole<=wr_ht_mem;
776                                                                         end if;
777                                                 end if;
778                                                 end if;
779when cmd_to_fifo=> if rsin_fifo_empty='1' then
780                                                        wr_ok<='1';
781                                                        next_et_pconsole<=Write_cmd;
782                                                        else
783                                                         rd_ok<='1'; --vider le fifo
784                                                end if;
785when Write_cmd => --écrire la commande dans la mémoire du HT
786                                                                        if pcons_wr_comp='1' then
787                                                                        if rs_rw='1' then
788                                                                                        next_et_pconsole<=rd_ht_mem;
789                                                                         else --if rs_rw='1' then
790                                                                                        next_et_pconsole<=wr_ht_mem;
791                                                                         end if;
792                                                                         end if;
793when rd_ht_mem => if pcons_rd_comp='1' then
794                                               
795                                                next_et_pconsole<=et_end;
796                                        end if;
797when wr_ht_mem=> if pcons_wr_comp='1' then
798                                        next_et_pconsole<=et_end;
799                                       
800                                        end if;
801when et_end =>
802        for i in 1 to PROC loop
803        Pcons_sel_i(i)<='0';
804        end loop;
805        if rs_cmd='0' then --atendre la fin de la cmd
806        next_et_pconsole<=idle;
807        end if;
808end case;
809end process;
810--*************************************************
811Pcons_val : process(et_Pconsole,pcons_cmd,pcons_rd_comp,wr_ok,rd_ok,
812rxRdy,rxWord,pcons_fin_rd_en)
813begin
814pcons_rd_start<='0';
815pcons_rd_ack<='0';
816pcons_wr_start<='0';
817Pcons_Hold_req<='0';
818rs_comp<='0';
819rs_addr_start<=x"0100";
820rs_plen<=x"FA"; --taille des données à copier (250)
821rsin_fifo_wr_en<=RxRdy;
822rsin_fifo_din<=RxWord;
823rsin_fifo_rd_en<=pcons_fin_rd_en;
824case et_pconsole is
825when idle =>
826when get_bus =>
827when get_ht_mem => Pcons_Hold_req<='1';
828WHEN Write_cmd=>rs_addr_start<=x"0004"; --adresse dans la mémoire pour les commandes
829rs_plen<=x"01"; --un seul octet
830pcons_wr_start<='1';
831Pcons_Hold_req<='1';
832when Cmd_to_fifo =>
833rsin_fifo_wr_en<=wr_ok;
834rsin_fifo_rd_en<=rd_ok;
835rsin_fifo_din<=std_logic_vector(to_unsigned(pcons_cmd,WoRD));
836Pcons_Hold_req<='1';
837when rd_ht_mem => pcons_rd_start<='1';
838  Pcons_Hold_req<='1';
839 if pcons_cmd=1 then
840  rs_addr_start<=x"1000";
841elsif pcons_cmd=2 then
842rs_addr_start<=x"1200";
843elsif pcons_cmd=3 then
844rs_addr_start<=x"0104";
845elsif pcons_cmd=4 then
846rs_addr_start<=x"0004";
847elsif pcons_cmd=5 then
848  rs_addr_start<=x"0440";
849end if;
850pcons_rd_ack<=pcons_rd_comp;
851when wr_ht_mem=> pcons_wr_start<='1';
852  Pcons_Hold_req<='1';
853rs_addr_start<=x"0100";
854when et_end=>rs_comp<='1';
855                pcons_wr_start<='0';
856                Pcons_Hold_req<='0';
857end case;
858end process;
859--Multiplexeur de la console pour l'accès à la RAM de chaque HT.
860Ram_mux: process (MPI_Node_out,pcons_sel,pcons_ram.o,
861pcons_rd_start,pcons_wr_start,pcons_hold_req    )
862 begin 
863for i in 1 to PROC loop 
864 case Pcons_sel(i) is
865       
866
867        when '1' =>
868                        mux_ram(i).o.addr_wr<=pcons_ram.o.addr_wr;
869                        mux_ram(i).o.addr_rd<=pcons_ram.o.addr_rd ; 
870                        mux_ram(i).o.we<=pcons_ram.o.we;
871                        if pcons_rd_start='1' then
872                        mux_ram(i).o.enb<=pcons_ram.o.enb;
873                        elsif pcons_wr_start='1' then
874                          mux_ram(i).o.enb<=pcons_ram.o.ena;
875                        else
876                          mux_ram(i).o.enb<='0';
877                         end if;
878                        mux_ram(i).o.data_in<=pcons_ram.o.data_in;
879                        mux_hold_req(i)<=Pcons_Hold_req;
880        when others =>
881                        mux_ram(i).o.addr_wr<=MPI_Node_out(i).Ram_address_wr;
882                        mux_ram(i).o.addr_rd<=MPI_Node_out(i).Ram_address_rd ; 
883                        mux_ram(i).o.we<=MPI_Node_out(i).Ram_we;
884                        mux_ram(i).o.enb<=MPI_Node_out(i).Ram_en;
885                        mux_ram(i).o.data_in<=MPI_Node_out(i).Ram_data_in;
886                        mux_hold_req(i)<=MPI_Node_out(i).Hold_req;             
887end case ;
888end loop;
889end process ;
890--écriture dans la mémoire d'une tâche matérielle
891Inst_Fifo2Mem: Fifo2Mem PORT MAP(
892                clk =>clkm ,
893                reset =>reset ,
894                wr_start =>pcons_wr_start ,
895                fifo_data_out => rsin_fifo_dout,
896                fifo_data_available =>rsin_fifo_data_available,
897                datalen =>rs_plen ,
898                fifo_data_out_en =>pcons_fin_rd_en,--rsin_fifo_rd_en ,
899                fifo_empty =>'0' ,
900                ram_busy => pcons_ram_busy, --not pcons_sel(pcons_ht) ,
901                ram_addr_start =>rs_addr_start ,
902                ram_addr =>pcons_ram.o.addr_wr,
903                ram_data_in =>pcons_ram.o.data_in ,
904                ram_wr =>pcons_ram.o.we ,
905                ram_en =>pcons_ram.o.ena,
906                wr_comp =>pcons_wr_comp
907        );
908-- Lecture des données dans la RAM d'une tâche
909--ce process lit les données de la RAM et les charge dans le FIFO
910 --copy from memory to fifo
911Inst_Mem2fifo: entity mpi_hcl.Mem2fifo_a PORT MAP(
912                clk =>clkm ,
913                reset =>reset ,
914 copy_mode =>'0', 
915 snd_start=>pcons_rd_start, --début de la lecture
916 snd_ack =>pcons_rd_ack,   -- acquittement de la lecture
917 datalen => rs_plen, --la longueur du paquet
918 ram_busy => pcons_ram_busy,
919 ram_addr_start => rs_addr_start, --addresse de début du bloc de donnée à copier
920 fifo_out_empty=> rsout_fifo_empty,
921 fifo_out_full => rsout_fifo_full,   --signaux pour le fifo de sortie
922 fifo_out_wr_en => rsout_fifo_wr_en,  --écriture autorisée dans la fifo de sortie
923 ram_in_rd_en => pcons_ram.o.enb, --lecture autorisée dans la fifo d'entrée
924 ram_in_data_out=> pcons_ram.i.data_out,
925 ram_in_addr_rd => pcons_ram.O.addr_rd, --addresse de la donnée à copier
926 fifo_out_data_in => rsout_fifo_din,
927 snd_comp => pcons_rd_comp    -- fin de la lecture
928 );
929
930
931--démultiplexeurs de la console pour accès à la RAM de chaque Tâche matérielle.
932Ram_dmux : process(mux_ram_d,dmux_hold_ack,PCons_sel,pcons_ht,clkm,reset,
933dmux_instruction,dmux_instruction_en)
934variable Tram_out:std_logic_vector(Word-1 downto 0):=(others=>'0');
935begin
936for i in 1 to PROC loop
937case PCons_sel(i) is
938
939when '1' =>     if pcons_ht=i then 
940                                                Pcons_hold_ack<=dmux_hold_ack(i);
941                                        end if;
942                                        --Pcons_ram.I.data_out<=mux_ram(i).i.data_out;
943                                        if pcons_ht=i then
944                                        Pcons_ram.I.data_out<=mux_ram_d(i).i.data_out;
945                                        else
946                                        TRam_out:=Tram_out or mux_ram_d(i).i.data_out;
947                                        Pcons_ram.I.data_out<=Pcons_ram.I.data_out;
948                                        end if;
949                                        MPI_Node_in(i).hold_ack<='0';
950                                        MPI_Node_in(i).Ram_data_out<=(others=>'-');
951when others => Pcons_hold_ack<='0';
952                                        --Pcons_ram.I.data_out<=(others=>'-');
953                                        TRam_out:=(others=>'-');
954                                        MPI_Node_in(i).hold_ack<=dmux_hold_ack(i);
955                                        MPI_Node_in(i).Ram_data_out<=mux_ram_d(i).i.data_out;                             
956end case;
957MPI_Node_in(i).reset<=reset;   
958MPI_Node_in(i).clk<=clkm;
959MPI_Node_in(i).instruction<=dmux_instruction(i);
960MPI_Node_in(i).instruction_en<=dmux_instruction_en(i);
961end loop;
962
963end process;
964
965sendrs232c_proc: process(clkm,reset,rsout_fifo_empty,rsout_fifo_dout,
966uartrdy)
967variable nib:natural range 0 to 1:=0;
968variable rs_crlf : natural range 0 to 3:=0; --compte les derniers mots
969   begin               
970     
971     if rising_edge(clkm) then
972          rsout_fifo_rd_en<='0';
973          uartSend<='0';
974          --UartData<=rsout_fifo_dout or x"AA";
975          if reset='1' then 
976                et_send<=snd_wait;
977                --rs_crlf:=0;
978          else
979                case et_send is
980               
981                        when snd_wait => --attente
982                          --rs_crlf:=0;
983                          if rsout_fifo_empty='0' then
984                                et_send<=snd_read;
985                                --rs_crlf:=2; --deux caractères à envoyer
986                                end if;
987                               
988--                      when snd_read =>  --lecture du mot
989--                              if unsigned(rsout_fifo_dout)>31 then
990--                                UartData<=rsout_fifo_dout ;
991--                               else --rendre les codes observables en ASCII
992--                                UartData<=rsout_fifo_dout or x"20";
993--                              end if;
994--                             
995--                             
996--                              rsout_fifo_rd_en<='1';
997--                              et_send<=snd_sendBit;
998                               
999                        when snd_sendbit=> --envoie du mot
1000                         
1001                                UartSend<='1';
1002                                if Uartrdy='1' and rsout_fifo_empty='0' then
1003                                        et_send<=snd_read;
1004                                elsif UartRdy='1' then
1005                                        et_send<=snd_Cr; --fin de l'envoi
1006                                end if;
1007                        when snd_read =>
1008                        if Nib=0 then --envoi du code ascii en mode hexa décimal texte (Intel Hex)
1009                                UartData<=Hex_to_ascii(rsout_fifo_dout(7 downto 4));
1010                                nib:=1;
1011                                rsout_fifo_rd_en<='0';
1012                                et_send<=snd_sendBit;
1013                        else
1014                                UartData<=Hex_to_ascii(rsout_fifo_dout(3 downto 0));
1015                                nib:=0;
1016                                rsout_fifo_rd_en<='1';
1017                                et_send<=snd_sendBit;
1018                        end if;
1019                        et_send<=snd_sendbit;
1020                        When snd_Cr =>UartSend<='1';
1021                                if UartRdy='1' then
1022                                        et_send<=snd_lf;
1023                                end if;
1024                                UartData<=x"0D";
1025                        When snd_Lf =>UartSend<='1';
1026                        if UartRdy='1' then
1027                                        et_send<=snd_wait;
1028                                end if;
1029                        UartData<=x"0A";
1030                        when others =>
1031
1032                end case;
1033        end if;
1034        end if;
1035end process;
1036-------------------------------------------------------------------
1037  --
1038  --  If Trigout port is selected
1039  --
1040  -------------------------------------------------------------------
1041  -- Trigger output logic triggers external test equipment and other logic.
1042  -- In this example, TRIG_OUT is used to view shift operation on VIO core.
1043  process (clk50)
1044  begin
1045    if (clk50'event and clk50='1') then
1046      if(trigout = '1') then
1047        syncin <= trig_0;
1048      end if;
1049    end if;
1050  end process;
1051
1052END;
Note: See TracBrowser for help on using the repository browser.