[22] | 1 | -- Package File Template |
---|
| 2 | -- |
---|
| 3 | -- Purpose: This package defines supplemental types, subtypes, |
---|
| 4 | -- constants, and components |
---|
| 5 | |
---|
| 6 | |
---|
| 7 | library IEEE; |
---|
| 8 | use IEEE.STD_LOGIC_1164.all; |
---|
[36] | 9 | use IEEE.numeric_std.all; |
---|
[22] | 10 | package CoreTypes is |
---|
| 11 | CONSTANT Word :POSITIVE:= 8; |
---|
| 12 | CONSTANT ADRLEN:POSITIVE:=16; |
---|
| 13 | CONSTANT 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 |
---|
| 14 | CONSTANT IADR0 : NATURAL :=2; --Adresse basse de l'instruction |
---|
| 15 | CONSTANT IADR1 : natural :=3; |
---|
| 16 | CONSTANT CORE_BASE_ADR :natural range 0 to 65535:=4096; |
---|
| 17 | CONSTANT CORE_UPPER_ADR : natural range 0 to 255:=16; |
---|
| 18 | CONSTANT CORE_GET_ADR:natural:=CORE_BASE_ADR+526; |
---|
| 19 | CONSTANT CORE_PUT_ADR :natural:=CORE_BASE_ADR+516; |
---|
| 20 | CONSTANT core_INIT_ADR : natural:=CORE_BASE_ADR+512; |
---|
| 21 | CONSTANT CORE_WCREATE_ADR : natural := CORE_BASE_ADR+536; |
---|
| 22 | CONSTANT CORE_WCOMPL_ADR : natural := CORE_BASE_ADR+546; |
---|
| 23 | CONSTANT CORE_WPOST_ADR : natural := CORE_BASE_ADR+556; |
---|
| 24 | CONSTANT CORE_WWAIT_ADR : natural := CORE_BASE_ADR+566; |
---|
| 25 | CONSTANT CORE_Rank2port_BASE :NATURAL:=32; |
---|
| 26 | CONSTANT WIN0_ADR :natural :=4; |
---|
| 27 | CONSTANT WIN1_ADR :natural :=14; |
---|
| 28 | CONSTANT WIN2_ADR :natural :=24; |
---|
| 29 | CONSTANT WIN3_ADR :natural :=34; |
---|
| 30 | CONSTANT 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 | |
---|
| 38 | type 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 |
---|
| 54 | end record; |
---|
| 55 | |
---|
| 56 | type typ_dpram is |
---|
| 57 | record |
---|
| 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 | |
---|
| 71 | end record; |
---|
| 72 | type Typ_MPIPort_in is |
---|
| 73 | record |
---|
| 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 | |
---|
| 85 | end record; |
---|
| 86 | type Typ_MPIPort_out is |
---|
| 87 | record |
---|
| 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 |
---|
| 101 | end record; |
---|
| 102 | |
---|
| 103 | Type Ar_MPIPort_In is array (positive range <>) of Typ_MPIPort_in; |
---|
| 104 | Type 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 |
---|
| 112 | Component 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); |
---|
| 131 | end 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 |
---|
[36] | 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; |
---|
[40] | 150 | function image(L: bit_vector) return String; |
---|
| 151 | function image(L: bit) return String; |
---|
| 152 | function image(L: std_logic_vector) return String; |
---|
| 153 | function image(L: std_logic) return String; |
---|
| 154 | -- function HexImage(L: unsigned) return String; |
---|
| 155 | -- function HexImage(L: signed) return String; |
---|
| 156 | -- function HexImage(L: std_ulogic_vector) return String; |
---|
| 157 | -- function HexImage(L: std_logic_vector) return String; |
---|
| 158 | -- function HexImage(L: bit_vector) return String; |
---|
[22] | 159 | end CoreTypes; |
---|
| 160 | |
---|
| 161 | |
---|
| 162 | Package body CoreTypes is |
---|
| 163 | |
---|
| 164 | |
---|
| 165 | FUNCTION incr_vec(s1:std_logic_vector;en:std_logic) return std_logic_vector is |
---|
| 166 | --this function increments a std_logic_vector type by '1' |
---|
| 167 | VARIABLE V : std_logic_vector(s1'high downto s1'low) ; |
---|
| 168 | VARIABLE tb : std_logic_vector(s1'high downto s1'low); |
---|
| 169 | BEGIN |
---|
| 170 | tb(s1'low) := en; |
---|
| 171 | V := s1; |
---|
| 172 | for i in (V'low + 1) to V'high loop |
---|
| 173 | tb(i) := V(i - 1) and tb(i -1); |
---|
| 174 | end loop; |
---|
| 175 | for i in V'low to V'high loop |
---|
| 176 | if(tb(i) = '1') then |
---|
| 177 | V(i) := not(V(i)); |
---|
| 178 | end if; |
---|
| 179 | end loop; |
---|
| 180 | return V; |
---|
| 181 | end incr_vec; -- end function |
---|
| 182 | |
---|
| 183 | FUNCTION dcr_vec(s1:std_logic_vector;en:std_logic) return std_logic_vector is |
---|
| 184 | --this function decrements a std_logic_vector type by '1' |
---|
| 185 | VARIABLE V : std_logic_vector(s1'high downto s1'low) ; |
---|
| 186 | VARIABLE tb : std_logic_vector(s1'high downto s1'low); |
---|
| 187 | BEGIN |
---|
| 188 | tb(s1'low) := not(en); |
---|
| 189 | V := s1; |
---|
| 190 | for i in (V'low + 1) to V'high loop |
---|
| 191 | tb(i) := V(i - 1) or tb(i -1); |
---|
| 192 | end loop; |
---|
| 193 | for i in V'low to V'high loop |
---|
| 194 | if(tb(i) = '0') then |
---|
| 195 | V(i) := not(V(i)); |
---|
| 196 | end if; |
---|
| 197 | end loop; |
---|
| 198 | return V; |
---|
| 199 | end dcr_vec; -- end function |
---|
| 200 | FUNCTION all_ones(s1:std_logic_vector) return std_logic is |
---|
| 201 | --this function tells if all bits of a vector are '1' |
---|
| 202 | --return value Z is '1', then vector has all 1 bits |
---|
| 203 | --VARIABLE V : std_logic_vector(s1'high downto s1'low) ; |
---|
| 204 | VARIABLE Z : std_logic; |
---|
| 205 | BEGIN |
---|
| 206 | Z := s1(s1'low); |
---|
| 207 | FOR i IN (s1'low+1) to s1'high LOOP |
---|
| 208 | Z := Z AND s1(i); |
---|
| 209 | END LOOP; |
---|
| 210 | RETURN Z; |
---|
| 211 | END all_ones; -- end function |
---|
| 212 | FUNCTION all_zeros(s1:std_logic_vector) return std_logic is |
---|
| 213 | --this function tells if all bits of a vector are '0' |
---|
| 214 | --return value Z if '1', then vector has all 0 bits |
---|
| 215 | --VARIABLE V : std_logic_vector(s1'high downto s1'low) ; |
---|
| 216 | VARIABLE Z : std_logic; |
---|
| 217 | BEGIN |
---|
| 218 | Z := '0'; |
---|
| 219 | FOR i IN (s1'low) to s1'high LOOP |
---|
| 220 | Z := Z OR s1(i); |
---|
| 221 | END LOOP; |
---|
| 222 | RETURN not(Z); |
---|
| 223 | END all_zeros; -- end function |
---|
| 224 | |
---|
| 225 | FUNCTION Rol_Vec(s1:std_logic_vector) return std_logic_vector is |
---|
| 226 | --cette fonction fait roter un STD_logic d'un pas vers la gauche |
---|
| 227 | VARIABLE V : std_logic_vector(s1'high downto s1'low) ; |
---|
| 228 | VARIABLE lb : std_logic :=s1(s1'left); |
---|
| 229 | BEGIN |
---|
| 230 | |
---|
| 231 | for i in V'left downto (V'right+1) loop |
---|
| 232 | V(i) := s1(i - 1) ; |
---|
| 233 | end loop; |
---|
| 234 | V(V'right):=lb; |
---|
| 235 | return V; |
---|
| 236 | end Rol_vec; |
---|
| 237 | Function Stdlv (s1 : natural ) return std_logic_vector is |
---|
[36] | 238 | VARIABLE V : std_logic_vector(ADRLEN-1 downto 0); |
---|
[22] | 239 | begin |
---|
| 240 | V:=std_logic_vector(to_unsigned(s1,ADRLEN)); |
---|
| 241 | return V; |
---|
| 242 | end stdlv; |
---|
[36] | 243 | Function Stdlv (s1 : natural;width:positive ) return std_logic_vector is |
---|
| 244 | VARIABLE V : std_logic_vector(width-1 downto 0); |
---|
| 245 | begin |
---|
| 246 | V:=std_logic_vector(to_unsigned(s1,width)); |
---|
| 247 | return V; |
---|
| 248 | end stdlv; |
---|
[40] | 249 | |
---|
| 250 | -- Start of heximage functions |
---|
| 251 | --function HexImage(L: bit_vector) return String is |
---|
| 252 | --begin |
---|
| 253 | --return(HexImage(imge(L))); |
---|
| 254 | --end function HexImage; |
---|
| 255 | -- |
---|
| 256 | --function HexImage(L: std_ulogic_vector) return String is |
---|
| 257 | --begin |
---|
| 258 | --return(HexImage(image(to_x01(L)))); |
---|
| 259 | --end function HexImage; |
---|
| 260 | |
---|
| 261 | --function HexImage(L: std_logic_vector) return String is |
---|
| 262 | --begin |
---|
| 263 | --return(HexImage(imge(to_x01(L)))); |
---|
| 264 | --end function HexImage; |
---|
| 265 | -- |
---|
| 266 | --function HexImage(L: signed) return String is |
---|
| 267 | --begin |
---|
| 268 | --return(HexImage(imge(L))); |
---|
| 269 | --end function HexImage; |
---|
| 270 | -- |
---|
| 271 | --function HexImage(L: unsigned) return String is |
---|
| 272 | --begin |
---|
| 273 | --return(HexImage(image(L))); |
---|
| 274 | --end function HexImage; |
---|
| 275 | -- End of heximage functions |
---|
| 276 | -- Start of an example image function |
---|
| 277 | function image(L: bit) return String is |
---|
[42] | 278 | variable bit_image: String(1 to 1) := bit'image(L); |
---|
[40] | 279 | begin |
---|
[42] | 280 | return(bit_image(1 to 1)); |
---|
[40] | 281 | end function image; |
---|
| 282 | |
---|
| 283 | |
---|
| 284 | function image(L: std_logic) return String is |
---|
[42] | 285 | variable bit_image: String(1 to 1) := std_logic'image(L); |
---|
[40] | 286 | begin |
---|
[42] | 287 | return(bit_image(1 to 1)); |
---|
[40] | 288 | end function image; |
---|
| 289 | |
---|
| 290 | function image(L: bit_vector) return String is |
---|
| 291 | variable Lx: bit_vector(1 to L'length); |
---|
| 292 | variable RetVal: String(1 to L'length); |
---|
| 293 | begin |
---|
| 294 | Lx := L; |
---|
| 295 | for i in Lx'range loop |
---|
| 296 | RetVal(i to i) := image(Lx(i)); |
---|
| 297 | end loop; |
---|
| 298 | return(RetVal); |
---|
| 299 | end function image; |
---|
| 300 | |
---|
| 301 | |
---|
| 302 | function image(L: std_logic_vector) return String is |
---|
| 303 | variable Lx: std_logic_vector(1 to L'length); |
---|
| 304 | variable RetVal: String(1 to L'length); |
---|
| 305 | begin |
---|
| 306 | Lx := L; |
---|
| 307 | for i in Lx'range loop |
---|
| 308 | RetVal(i to i) := image(Lx(i)); |
---|
| 309 | end loop; |
---|
| 310 | return(RetVal); |
---|
| 311 | end function image; |
---|
[22] | 312 | end CoreTypes; |
---|