source: PROJECT_CORE_MPI/SWITCH_GEN/BRANCHES/v0.01/CoreTypes.vhd @ 36

Last change on this file since 36 was 36, checked in by rolagamo, 12 years ago

Ceci est la version stable pour les tests

File size: 9.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:= 8;
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 CORE_UPPER_ADR : natural range 0 to 255:=16;
18CONSTANT CORE_GET_ADR:natural:=CORE_BASE_ADR+526;
19CONSTANT CORE_PUT_ADR :natural:=CORE_BASE_ADR+516;
20CONSTANT core_INIT_ADR : natural:=CORE_BASE_ADR+512;
21CONSTANT CORE_WCREATE_ADR : natural := CORE_BASE_ADR+536;
22CONSTANT CORE_WCOMPL_ADR : natural := CORE_BASE_ADR+546;
23CONSTANT CORE_WPOST_ADR : natural := CORE_BASE_ADR+556;
24CONSTANT CORE_WWAIT_ADR : natural := CORE_BASE_ADR+566;
25CONSTANT CORE_Rank2port_BASE :NATURAL:=32;
26CONSTANT WIN0_ADR :natural :=4;
27CONSTANT WIN1_ADR :natural :=14;
28CONSTANT WIN2_ADR :natural :=24;
29CONSTANT WIN3_ADR :natural :=34;
30CONSTANT GETPORTID : std_logic_vector(3 downto 0):="0001";
31 
32  type Typ_PortIO is
33   array(natural range <>) of std_logic_vector( Word-1 downto 0);
34       
35        type memory is 
36        array (natural range <>) of std_logic_vector(word-1 downto 0);
37       
38type Core_io is
39        record
40                Instr_en :std_logic;  -- active une instruction MPI
41                Instr_ack :std_logic;-- signal la prise en compte de l'instruction
42                Ready   :std_logic;-- indique que la dernière fonction est terminée
43                InitOk :std_logic; -- l'initialisation est terminée
44                Hold_Req :std_logic;--Demande DMA
45                Hold_Ack :std_logic;-- Autorisation DMA
46                MemBusy :std_logic;-- active le refus de DMA (1 -> ignoré la requête DMA)
47                RamSel :std_logic;-- indique le statut de la RAM (0 ->dispo 1->occupé par Core_MPI)
48                IntState1 : natural range 0 to 255; --permet de stocker l'état des MAE interne dans les procédures
49                IntState2 : natural range 0 to 255;
50                Instruction :std_logic_vector (word-1 downto 0);
51                WinId :natural range  0 to 255; --stocke le dernier Id utilisé par WinCreate
52                IsMain : std_logic; -- indique si la librairie est principal
53                Rank : natural range 0 to 16; --donne le rang du processus courant
54end record;
55
56type typ_dpram is
57record
58                         
59           
60            clk_wr :  STD_LOGIC;
61            clk_rd :  STD_LOGIC;
62                we     :  STD_LOGIC;
63                ena    :  STD_LOGIC;
64                enb    :  STD_LOGIC;
65                addr_wr:  STD_LOGIC_VECTOR (ADRLEN-1 downto 0);
66                addr_rd :  STD_LOGIC_VECTOR (ADRLEN-1 downto 0);
67                data_in  :  STD_LOGIC_VECTOR (Word-1 downto 0);
68                data_out :  STD_LOGIC_VECTOR (Word-1 downto 0); 
69                         
70                         
71end record;       
72type Typ_MPIPort_in is
73record
74                          instruction :   STD_LOGIC_VECTOR (Word -1 downto 0);
75           instruction_en :  STD_LOGIC;
76                         
77
78                          packet_ack : std_logic;
79           ram_data_out :  STD_LOGIC_VECTOR (Word-1 downto 0);
80                         
81                          hold_ack       :  STD_Logic;  --autorisation par l'application
82                          clk :  STD_LOGIC;
83           reset :  STD_LOGIC;
84                         
85end record;
86type Typ_MPIPort_out is
87record           
88         
89                         
90           ram_we :  STD_LOGIC;
91                          ram_en :  STD_LOGIC;
92                          ram_data_in : STD_LOGIC_VECTOR (WORD-1 downto 0);
93           ram_address_rd :  STD_LOGIC_VECTOR (ADRLEN-1 downto 0);
94                          ram_address_wr :  STD_LOGIC_VECTOR (ADRLEN-1 downto 0);
95                          packet_received : STD_LOGIC;
96                          barrier_completed : STD_LOGIC;
97           instruction_fifo_full : STD_LOGIC;
98                          PushOut :  STD_LOGIC_VECTOR (WORD-1 downto 0);
99                           
100           hold_req       : STD_Logic;  --requete vers application
101end record;
102
103Type Ar_MPIPort_In is array (positive range <>) of Typ_MPIPort_in;
104Type Ar_MPIPort_out is array (positive range <>) of Typ_MPIPort_out;
105
106-- Declare constants
107
108--  constant <constant_name>            : time := <time_unit> ns;
109--  constant <constant_name>            : integer := <value>;
110--
111-- Declare functions and procedure
112Component  SWITCH_GEN is     
113 generic(number_of_ports : positive := 8);
114     port(
115                -- ports d'entree
116           Port_in : in typ_portIO(1 to number_of_ports) ;
117--                       
118                         
119                          -- port de sortie
120                          Port_out : out  typ_portIO(1 to number_of_ports);
121--                       
122                          -- signaux de controle
123                          cmd_in_en : in std_logic_vector(number_of_ports downto 1);
124                          data_in_en : in std_logic_vector(number_of_ports downto 1);
125                          data_out_en : in std_logic_vector(number_of_ports downto 1);
126                          fifo_in_full : out std_logic_vector(number_of_ports downto 1);
127                          fifo_in_empty : out std_logic_vector(number_of_ports downto 1);
128                          data_available : out std_logic_vector(number_of_ports downto 1);
129                          clk       : in   STD_LOGIC;
130                          reset     : in   STD_LOGIC);
131end component SWITCH_GEN;
132-- déclaration des fonctions utilisées
133 
134 FUNCTION all_ones(s1:std_logic_vector) return std_logic; 
135  --This function returns if the input vector has all ones and no zeros
136 FUNCTION all_zeros(s1:std_logic_vector) return std_logic; 
137  --This function returns if the input vector has all zeros and no ones
138 FUNCTION incr_vec(s1:std_logic_vector;en:std_logic) return std_logic_vector; 
139  --This function increments an std_logic_vector type by '1', without
140  --using any arithmatic
141
142  FUNCTION dcr_vec(s1:std_logic_vector;en:std_logic) return std_logic_vector; 
143  --This function decrements an std_logic_vector type by '1', without
144  --using any arithmatic
145  FUNCTION Rol_Vec(s1:std_logic_vector) return std_logic_vector;
146  --renvoie un std_logic_vector de taille ADRLEN
147  Function Stdlv (s1 : natural) return std_logic_vector;
148  --renvoie un std_logic_vector de taille width
149  Function Stdlv (s1 : natural;width:positive ) return std_logic_vector;
150end CoreTypes;
151
152
153Package body CoreTypes is
154
155
156FUNCTION incr_vec(s1:std_logic_vector;en:std_logic) return std_logic_vector is 
157                  --this function increments a std_logic_vector type by '1'
158        VARIABLE V : std_logic_vector(s1'high downto s1'low) ; 
159        VARIABLE tb : std_logic_vector(s1'high downto s1'low); 
160        BEGIN 
161        tb(s1'low) := en; 
162        V := s1; 
163        for i in (V'low + 1) to V'high loop 
164            tb(i) := V(i - 1) and tb(i -1); 
165        end loop; 
166        for i in V'low to V'high loop 
167            if(tb(i) = '1') then 
168                V(i) := not(V(i)); 
169            end if; 
170        end loop; 
171        return V; 
172        end incr_vec; -- end function
173
174FUNCTION  dcr_vec(s1:std_logic_vector;en:std_logic) return std_logic_vector is 
175                  --this function decrements a std_logic_vector type by '1'
176        VARIABLE V : std_logic_vector(s1'high downto s1'low) ; 
177        VARIABLE tb : std_logic_vector(s1'high downto s1'low); 
178        BEGIN 
179        tb(s1'low) := not(en); 
180        V := s1; 
181        for i in (V'low + 1) to V'high loop 
182            tb(i) := V(i - 1) or tb(i -1); 
183        end loop; 
184        for i in V'low to V'high loop 
185            if(tb(i) = '0') then 
186                V(i) := not(V(i)); 
187            end if; 
188        end loop; 
189        return V; 
190        end dcr_vec; -- end function
191FUNCTION all_ones(s1:std_logic_vector) return std_logic is 
192                  --this function tells if all bits of a vector are '1'
193                  --return value Z is '1', then vector has all 1 bits
194        --VARIABLE V : std_logic_vector(s1'high downto s1'low) ;
195        VARIABLE Z : std_logic; 
196        BEGIN 
197        Z := s1(s1'low); 
198        FOR i IN (s1'low+1) to s1'high LOOP 
199            Z := Z AND s1(i); 
200        END LOOP; 
201        RETURN Z; 
202        END all_ones; -- end function
203FUNCTION all_zeros(s1:std_logic_vector) return std_logic is 
204                  --this function tells if all bits of a vector are '0'
205                  --return value Z if '1', then vector has all 0 bits
206        --VARIABLE V : std_logic_vector(s1'high downto s1'low) ;
207        VARIABLE Z : std_logic; 
208        BEGIN 
209        Z := '0'; 
210        FOR i IN (s1'low) to s1'high LOOP 
211            Z := Z OR s1(i); 
212        END LOOP; 
213        RETURN not(Z); 
214        END all_zeros; -- end function
215                 
216FUNCTION Rol_Vec(s1:std_logic_vector) return std_logic_vector is
217--cette fonction fait roter un STD_logic d'un pas vers la gauche
218VARIABLE V : std_logic_vector(s1'high downto s1'low) ; 
219        VARIABLE lb : std_logic :=s1(s1'left);
220        BEGIN 
221     
222        for i in V'left  downto (V'right+1) loop 
223            V(i) := s1(i - 1) ; 
224        end loop; 
225        V(V'right):=lb;
226        return V; 
227        end Rol_vec;
228 Function Stdlv (s1 : natural ) return std_logic_vector is
229VARIABLE V : std_logic_vector(ADRLEN-1 downto 0);
230 begin
231        V:=std_logic_vector(to_unsigned(s1,ADRLEN));
232        return V;
233 end stdlv;
234 Function Stdlv (s1 : natural;width:positive ) return std_logic_vector is
235VARIABLE V : std_logic_vector(width-1 downto 0);
236 begin
237        V:=std_logic_vector(to_unsigned(s1,width));
238        return V;
239 end stdlv;
240end CoreTypes;
Note: See TracBrowser for help on using the repository browser.