source: PROJECT_CORE_MPI/MPI_HCL/BRANCHES/v2.0/NOC/CoreTypes.vhd @ 153

Last change on this file since 153 was 139, checked in by rolagamo, 10 years ago

Ceci est la version 16 bits de la plateforme ainsi que la version hierarchique du NoCNoC

File size: 13.0 KB
Line 
1  --    Package File Template
2--
3--      Purpose: This package defines supplemental types, subtypes,
4--               constants, and components
5
6
7library IEEE;
8use IEEE.STD_LOGIC_1164.all;
9use IEEE.numeric_std.all;
10package CoreTypes is
11CONSTANT Word :POSITIVE:= 16;
12CONSTANT ADRLEN:POSITIVE:=16;
13CONSTANT LZFILL :std_logic_vector(2*Word-ADRLEN to 0):=(others=>'0');--indique le nombre de zero à utiliser pour completer le bus de données lorsque la longueur restante du bus d'adresse est inférueure à la largeur du bus de données
14CONSTANT IADR0 : NATURAL :=2; --Adresse basse de l'instruction
15CONSTANT IADR1 : natural :=3;
16CONSTANT CORE_BASE_ADR :natural range 0 to 65535:=4096;
17CONSTANT WIN_BASE_ADR :natural range 0 to 65535:=CORE_BASE_ADR+4;
18CONSTANT CORE_UPPER_ADR : natural range 0 to 255:=16;
19CONSTANT CORE_GET_ADR:natural:=CORE_BASE_ADR+526;
20CONSTANT CORE_PUT_ADR :natural:=CORE_BASE_ADR+516;
21CONSTANT core_INIT_ADR : natural:=CORE_BASE_ADR+512;
22CONSTANT CORE_WCREATE_ADR : natural := CORE_BASE_ADR+536;
23CONSTANT CORE_WCOMPL_ADR : natural := CORE_BASE_ADR+546;
24CONSTANT CORE_WPOST_ADR : natural := CORE_BASE_ADR+556;
25CONSTANT CORE_WWAIT_ADR : natural := CORE_BASE_ADR+566;
26CONSTANT CORE_WSYNC_ADR : natural := CORE_BASE_ADR+576;
27CONSTANT CORE_SPAWN_ADR : natural := CORE_BASE_ADR+586;
28CONSTANT CORE_Rank2port_BASE :NATURAL:=52;
29CONSTANT CORE_RANK_ADR : NATURAL:=CORE_BASE_ADR+CORE_Rank2Port_Base;
30CONSTANT WIN0_ADR :natural :=CORE_BASE_ADR+4;
31CONSTANT WIN1_ADR :natural :=CORE_BASE_ADR+20;
32CONSTANT WIN2_ADR :natural :=CORE_BASE_ADR+36;
33CONSTANT WIN3_ADR :natural :=CORE_BASE_ADR+52;
34CONSTANT GETPORTID : std_logic_vector(3 downto 0):="0001";
35 
36  type Typ_PortIO is
37   array(natural range <>) of std_logic_vector( Word-1 downto 0);
38       
39        type Typ_PortIO8 is
40   array(natural range <>) of std_logic_vector( 7 downto 0);
41        type memory is 
42        array (natural range <>) of std_logic_vector(word-1 downto 0);
43
44type Core_i is
45        record
46                Instr_ack :std_logic;-- signal la prise en compte de l'instruction
47                Ready   :std_logic;-- indique que la dernière fonction est terminée
48                InitOk :std_logic; -- l'initialisation est terminée
49                Hold_Req :std_logic;--Demande DMA
50                RamSel :std_logic;-- indique le statut de la RAM (0 ->dispo 1->occupé par Core_MPI)
51                IsMain : std_logic; -- indique si la librairie est principal
52                Rank : natural range 0 to 15; --donne le rang du processus courant
53                Spawned: std_logic; --indique que ce module a été activé par la bibliothèque
54end record;     
55type Core_o is
56        record
57                Instr_en :std_logic;  -- active une instruction MPI
58                Hold_Ack :std_logic;-- Autorisation DMA
59                MemBusy :std_logic;-- active le refus de DMA (1 -> ignoré la requête DMA de MPI HCL)
60                Instruction :std_logic_vector (word-1 downto 0); -- fonction Mpi à exécuter     
61end record;
62type core_s is
63record
64    Rank : natural range 0 to 15; --donne le rang du processus courant
65                IntState1 : natural range 0 to 255; --permet de stocker l'état des MAE interne dans les procédures
66                IntState2 : natural range 0 to 255;
67                WinId :natural range  0 to 255; --stocke le dernier Id utilisé par WinCreate
68                GPost : std_logic_vector(15 downto 0); --etat de la fenêtre active
69                GStart : std_logic_vector(15 downto 0);
70                tmem : memory(0 to 3); --petite mémoire tampon pour stocker les variables statiques des MVPs
71end record;
72type core_io is
73record
74                I:core_i; --les entrées
75                O:core_o; --les sorties
76                S:core_s; --les signaux temporaires
77end record;
78
79type Core_io_old is
80        record
81                Instr_en :std_logic;  -- active une instruction MPI
82                Instr_ack :std_logic;-- signal la prise en compte de l'instruction
83                Ready   :std_logic;-- indique que la dernière fonction est terminée
84                InitOk :std_logic; -- l'initialisation est terminée
85                Hold_Req :std_logic;--Demande DMA
86                Hold_Ack :std_logic;-- Autorisation DMA
87                MemBusy :std_logic;-- active le refus de DMA (1 -> ignoré la requête DMA)
88                RamSel :std_logic;-- indique le statut de la RAM (0 ->dispo 1->occupé par Core_MPI)
89                IntState1 : natural range 0 to 255; --permet de stocker l'état des MAE interne dans les procédures
90                IntState2 : natural range 0 to 255;
91                Instruction :std_logic_vector (word-1 downto 0);
92                WinId :natural range  0 to 255; --stocke le dernier Id utilisé par WinCreate
93                IsMain : std_logic; -- indique si la librairie est principal
94                Rank : natural range 0 to 15; --donne le rang du processus courant
95                Spawned: std_logic; --indique que ce module a été activé par la bibliothèque
96end record;
97
98type typ_dpram_i is
99record
100                data_out :  STD_LOGIC_VECTOR (Word-1 downto 0); 
101                                                 
102end record;       
103type typ_dpram_o is
104record
105           clk_wr :  STD_LOGIC;
106           clk_rd :  STD_LOGIC;
107                we     :  STD_LOGIC;
108                ena    :  STD_LOGIC;
109                enb    :  STD_LOGIC;
110                addr_wr:  STD_LOGIC_VECTOR (ADRLEN-1 downto 0);
111                addr_rd :  STD_LOGIC_VECTOR (ADRLEN-1 downto 0);
112                data_in  :  STD_LOGIC_VECTOR (Word-1 downto 0); 
113end record;     
114type typ_dpram is
115record
116O : typ_dpram_o;
117I : typ_dpram_I;
118end record;   
119type Typ_MPIPort_in is
120record
121                          instruction :   STD_LOGIC_VECTOR (Word -1 downto 0);
122           instruction_en :  STD_LOGIC;
123                         
124
125                          packet_ack : std_logic;
126           ram_data_out :  STD_LOGIC_VECTOR (Word-1 downto 0);
127                         
128                          hold_ack       :  STD_Logic;  --autorisation par l'application
129                          clk :  STD_LOGIC;
130           reset :  STD_LOGIC;
131                         
132end record;
133type Typ_MPIPort_out is
134record           
135         
136                         
137           ram_we :  STD_LOGIC;
138                          ram_en :  STD_LOGIC;
139                          ram_data_in : STD_LOGIC_VECTOR (WORD-1 downto 0);
140           ram_address_rd :  STD_LOGIC_VECTOR (ADRLEN-1 downto 0);
141                          ram_address_wr :  STD_LOGIC_VECTOR (ADRLEN-1 downto 0);
142                          packet_received : STD_LOGIC;
143                          barrier_completed : STD_LOGIC;
144           instruction_fifo_full : STD_LOGIC;
145                          PushOut :  STD_LOGIC_VECTOR (WORD-1 downto 0);
146                           
147           hold_req       : STD_Logic;  --requete vers application
148end record;
149
150Type Ar_MPIPort_In is array (positive range <>) of Typ_MPIPort_in;
151Type Ar_MPIPort_out is array (positive range <>) of Typ_MPIPort_out;
152
153-- Declare constants
154
155--  constant <constant_name>            : time := <time_unit> ns;
156--  constant <constant_name>            : integer := <value>;
157--
158-- Declare functions and procedure
159Component  SWITCH_GEN is     
160 generic(number_of_ports : positive := 8);
161     port(
162                -- ports d'entree
163           Port_in : in typ_portIO(1 to number_of_ports) ;
164--                       
165                         
166                          -- port de sortie
167                          Port_out : out  typ_portIO(1 to number_of_ports);
168--                       
169                          -- signaux de controle
170                          cmd_in_en : in std_logic_vector(number_of_ports downto 1);
171                          data_in_en : in std_logic_vector(number_of_ports downto 1);
172                          data_out_en : in std_logic_vector(number_of_ports downto 1);
173                          fifo_in_full : out std_logic_vector(number_of_ports downto 1);
174                          fifo_in_empty : out std_logic_vector(number_of_ports downto 1);
175                          data_available : out std_logic_vector(number_of_ports downto 1);
176                          clk       : in   STD_LOGIC;
177                          reset     : in   STD_LOGIC);
178end component SWITCH_GEN;
179-- déclaration des fonctions utilisées
180 function wor (din : std_logic_vector) return std_logic;
181subtype resolved_or is wor std_logic;
182
183 FUNCTION all_ones(s1:std_logic_vector) return std_logic; 
184  --This function returns if the input vector has all ones and no zeros
185 FUNCTION all_zeros(s1:std_logic_vector) return std_logic; 
186  --This function returns if the input vector has all zeros and no ones
187 FUNCTION incr_vec(s1:std_logic_vector;en:std_logic) return std_logic_vector; 
188  --This function increments an std_logic_vector type by '1', without
189  --using any arithmatic
190
191  FUNCTION dcr_vec(s1:std_logic_vector;en:std_logic) return std_logic_vector; 
192  --This function decrements an std_logic_vector type by '1', without
193  --using any arithmatic
194  FUNCTION Rol_Vec(s1:std_logic_vector) return std_logic_vector;
195  --renvoie un std_logic_vector de taille ADRLEN
196  Function Stdlv (s1 : natural) return std_logic_vector;
197  --renvoie un std_logic_vector de taille width
198  Function Stdlv (s1 : natural;width:positive ) return std_logic_vector;
199  function image(L: bit_vector) return String;
200  function image(L: bit) return String;
201   function image(L: std_logic_vector) return String;
202  function image(L: std_logic) return String;
203--  function HexImage(L: unsigned) return String;
204--  function HexImage(L: signed) return String;
205--  function HexImage(L: std_ulogic_vector) return String;
206--  function HexImage(L: std_logic_vector) return String;
207--  function HexImage(L: bit_vector) return String;
208end CoreTypes;
209
210
211Package body CoreTypes is
212
213
214FUNCTION incr_vec(s1:std_logic_vector;en:std_logic) return std_logic_vector is 
215                  --this function increments a std_logic_vector type by '1'
216        VARIABLE V : std_logic_vector(s1'high downto s1'low) ; 
217        VARIABLE tb : std_logic_vector(s1'high downto s1'low); 
218        BEGIN 
219        tb(s1'low) := en; 
220        V := s1; 
221        for i in (V'low + 1) to V'high loop 
222            tb(i) := V(i - 1) and tb(i -1); 
223        end loop; 
224        for i in V'low to V'high loop 
225            if(tb(i) = '1') then 
226                V(i) := not(V(i)); 
227            end if; 
228        end loop; 
229        return V; 
230        end incr_vec; -- end function
231
232FUNCTION  dcr_vec(s1:std_logic_vector;en:std_logic) return std_logic_vector is 
233                  --this function decrements a std_logic_vector type by '1'
234        VARIABLE V : std_logic_vector(s1'high downto s1'low) ; 
235        VARIABLE tb : std_logic_vector(s1'high downto s1'low); 
236        BEGIN 
237        tb(s1'low) := not(en); 
238        V := s1; 
239        for i in (V'low + 1) to V'high loop 
240            tb(i) := V(i - 1) or tb(i -1); 
241        end loop; 
242        for i in V'low to V'high loop 
243            if(tb(i) = '0') then 
244                V(i) := not(V(i)); 
245            end if; 
246        end loop; 
247        return V; 
248        end dcr_vec; -- end function
249FUNCTION all_ones(s1:std_logic_vector) return std_logic is 
250                  --this function tells if all bits of a vector are '1'
251                  --return value Z is '1', then vector has all 1 bits
252        --VARIABLE V : std_logic_vector(s1'high downto s1'low) ;
253        VARIABLE Z : std_logic; 
254        BEGIN 
255        Z := s1(s1'low); 
256        FOR i IN (s1'low+1) to s1'high LOOP 
257            Z := Z AND s1(i); 
258        END LOOP; 
259        RETURN Z; 
260        END all_ones; -- end function
261FUNCTION all_zeros(s1:std_logic_vector) return std_logic is 
262                  --this function tells if all bits of a vector are '0'
263                  --return value Z if '1', then vector has all 0 bits
264        --VARIABLE V : std_logic_vector(s1'high downto s1'low) ;
265        VARIABLE Z : std_logic; 
266        BEGIN 
267        Z := '0'; 
268        FOR i IN (s1'low) to s1'high LOOP 
269            Z := Z OR s1(i); 
270        END LOOP; 
271        RETURN not(Z); 
272        END all_zeros; -- end function
273                 
274FUNCTION Rol_Vec(s1:std_logic_vector) return std_logic_vector is
275--cette fonction fait roter un STD_logic d'un pas vers la gauche
276VARIABLE V : std_logic_vector(s1'high downto s1'low) ; 
277        VARIABLE lb : std_logic :=s1(s1'left);
278        BEGIN 
279     
280        for i in V'left  downto (V'right+1) loop 
281            V(i) := s1(i - 1) ; 
282        end loop; 
283        V(V'right):=lb;
284        return V; 
285        end Rol_vec;
286 Function Stdlv (s1 : natural ) return std_logic_vector is
287VARIABLE V : std_logic_vector(ADRLEN-1 downto 0);
288 begin
289        V:=std_logic_vector(to_unsigned(s1,ADRLEN));
290        return V;
291 end stdlv;
292 Function Stdlv (s1 : natural;width:positive ) return std_logic_vector is
293VARIABLE V : std_logic_vector(width-1 downto 0);
294 begin
295        V:=std_logic_vector(to_unsigned(s1,width));
296        return V;
297 end stdlv;
298 
299 -- Start of heximage functions
300--function HexImage(L: bit_vector) return String is
301--begin
302--return(HexImage(imge(L)));
303--end function HexImage;
304--
305--function HexImage(L: std_ulogic_vector) return String is
306--begin
307--return(HexImage(image(to_x01(L))));
308--end function HexImage;
309
310--function HexImage(L: std_logic_vector) return String is
311--begin
312--return(HexImage(imge(to_x01(L))));
313--end function HexImage;
314--
315--function HexImage(L: signed) return String is
316--begin
317--return(HexImage(imge(L)));
318--end function HexImage;
319--
320--function HexImage(L: unsigned) return String is
321--begin
322--return(HexImage(image(L)));
323--end function HexImage;
324-- End of heximage functions
325-- Start of an example image function
326function image(L: bit) return String is
327variable bit_image: String(1 to 1) := bit'image(L);
328begin
329return(bit_image(1 to 1));
330end function image;
331
332
333function image(L: std_logic) return String is
334variable bit_image: String(1 to 3) := std_logic'image(L);
335begin
336return(bit_image(2 to 2));
337end function image;
338
339function image(L: bit_vector) return String is
340variable Lx: bit_vector(1 to L'length);
341variable RetVal: String(1 to L'length);
342begin
343Lx := L;
344for i in Lx'range loop
345RetVal(i to i) := image(Lx(i));
346end loop;
347return(RetVal);
348end function image;
349
350
351function image(L: std_logic_vector) return String is
352variable Lx: std_logic_vector(1 to L'length);
353variable RetVal: String(1 to L'length);
354begin
355Lx := L;
356for i in Lx'range loop
357RetVal(i to i) := image(Lx(i));
358end loop;
359return(RetVal);
360end function image;
361function wor (din : std_logic_vector) return std_logic is
362begin
363for i in din'range loop
364if (din(i)='1') then
365return din(i);
366end if;
367end loop;
368return '0';
369end function wor;
370
371end CoreTypes;
Note: See TracBrowser for help on using the repository browser.