source: PROJECT_CORE_MPI/SWITCH_GEN/TRUNK/CoreTypes.vhd @ 22

Last change on this file since 22 was 22, checked in by rolagamo, 12 years ago
File size: 8.6 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;
9
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;
148end CoreTypes;
149
150
151Package body CoreTypes is
152
153
154FUNCTION incr_vec(s1:std_logic_vector;en:std_logic) return std_logic_vector is 
155                  --this function increments a std_logic_vector type by '1'
156        VARIABLE V : std_logic_vector(s1'high downto s1'low) ; 
157        VARIABLE tb : std_logic_vector(s1'high downto s1'low); 
158        BEGIN 
159        tb(s1'low) := en; 
160        V := s1; 
161        for i in (V'low + 1) to V'high loop 
162            tb(i) := V(i - 1) and tb(i -1); 
163        end loop; 
164        for i in V'low to V'high loop 
165            if(tb(i) = '1') then 
166                V(i) := not(V(i)); 
167            end if; 
168        end loop; 
169        return V; 
170        end incr_vec; -- end function
171
172FUNCTION  dcr_vec(s1:std_logic_vector;en:std_logic) return std_logic_vector is 
173                  --this function decrements a std_logic_vector type by '1'
174        VARIABLE V : std_logic_vector(s1'high downto s1'low) ; 
175        VARIABLE tb : std_logic_vector(s1'high downto s1'low); 
176        BEGIN 
177        tb(s1'low) := not(en); 
178        V := s1; 
179        for i in (V'low + 1) to V'high loop 
180            tb(i) := V(i - 1) or tb(i -1); 
181        end loop; 
182        for i in V'low to V'high loop 
183            if(tb(i) = '0') then 
184                V(i) := not(V(i)); 
185            end if; 
186        end loop; 
187        return V; 
188        end dcr_vec; -- end function
189FUNCTION all_ones(s1:std_logic_vector) return std_logic is 
190                  --this function tells if all bits of a vector are '1'
191                  --return value Z is '1', then vector has all 1 bits
192        --VARIABLE V : std_logic_vector(s1'high downto s1'low) ;
193        VARIABLE Z : std_logic; 
194        BEGIN 
195        Z := s1(s1'low); 
196        FOR i IN (s1'low+1) to s1'high LOOP 
197            Z := Z AND s1(i); 
198        END LOOP; 
199        RETURN Z; 
200        END all_ones; -- end function
201FUNCTION all_zeros(s1:std_logic_vector) return std_logic is 
202                  --this function tells if all bits of a vector are '0'
203                  --return value Z if '1', then vector has all 0 bits
204        --VARIABLE V : std_logic_vector(s1'high downto s1'low) ;
205        VARIABLE Z : std_logic; 
206        BEGIN 
207        Z := '0'; 
208        FOR i IN (s1'low) to s1'high LOOP 
209            Z := Z OR s1(i); 
210        END LOOP; 
211        RETURN not(Z); 
212        END all_zeros; -- end function
213                 
214FUNCTION Rol_Vec(s1:std_logic_vector) return std_logic_vector is
215--cette fonction fait roter un STD_logic d'un pas vers la gauche
216VARIABLE V : std_logic_vector(s1'high downto s1'low) ; 
217        VARIABLE lb : std_logic :=s1(s1'left);
218        BEGIN 
219     
220        for i in V'left  downto (V'right+1) loop 
221            V(i) := s1(i - 1) ; 
222        end loop; 
223        V(V'right):=lb;
224        return V; 
225        end Rol_vec;
226 Function Stdlv (s1 : natural ) return std_logic_vector is
227VARIABLE V : std_logic_vector(ADRLEN-1 downto 0)
228 begin
229        V:=std_logic_vector(to_unsigned(s1,ADRLEN));
230        return V;
231 end stdlv;
232end CoreTypes;
Note: See TracBrowser for help on using the repository browser.