OpenCores
URL https://opencores.org/ocsvn/diogenes/diogenes/trunk

Subversion Repositories diogenes

[/] [diogenes/] [trunk/] [vhdl/] [types.vhd] - Blame information for rev 236

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 154 fellnhofer
--      Package File Template
2
--
3
--      Purpose: This package defines supplemental types, subtypes, 
4
--               constants, and functions 
5
 
6
 
7
library IEEE;
8
use IEEE.STD_LOGIC_1164.all;
9
 
10
package types is
11
 
12
        subtype slv_36 is std_logic_VECTOR(35 downto 0);
13
        subtype slv_32 is std_logic_VECTOR(31 downto 0);
14
        subtype slv_16 is std_logic_VECTOR(15 downto 0);
15
        subtype slv_8 is std_logic_VECTOR(7 downto 0);
16
        subtype slv_4 is std_logic_VECTOR(3 downto 0);
17
 
18
        type slv_32_array is array (integer range <>) of slv_32;
19
 
20
-- Declare constants
21
--      constant op_add : bit_8 := X"00";
22
--      constant op_sub : bit_8 := X"01";
23
 
24
-- Declare functions and procedure
25
        function bits_to_natural (lv : in std_logic_vector) return natural;
26
 
27
end types;
28
 
29
 
30
package body types is
31
 
32
        function bits_to_natural (lv : in std_logic_vector) return natural is
33
                variable result : natural := 0;
34
                variable bits : bit_vector(lv'range);
35
                begin
36
 
37
                        bits := To_bitvector(lv);
38
                        for index in bits'range loop
39
                                        result := result * 2 + bit'pos(bits(index));
40
                        end loop;
41
                        return result;
42
                end bits_to_natural;
43
 
44
end types;

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.