1 |
5 |
gerhardhoh |
----------------------------------------------------------------------------------
|
2 |
|
|
-- Company: RIIC
|
3 |
|
|
-- Engineer: Gerhard Hohner Mat.nr.: 7555111
|
4 |
|
|
--
|
5 |
|
|
-- Create Date: 01/07/2004
|
6 |
|
|
-- Design Name: Diplomarbeit
|
7 |
|
|
-- Module Name: MYCPU - Rtl
|
8 |
|
|
-- Project Name: 32 bit FORTH processor
|
9 |
|
|
-- Target Devices: Spartan 3
|
10 |
|
|
-- Tool versions: ISE 8.2
|
11 |
|
|
-- Description: contains declarations valid for every source
|
12 |
|
|
-- Dependencies: none
|
13 |
|
|
--
|
14 |
|
|
-- Revision:
|
15 |
|
|
-- Revision 0.01 - File Created
|
16 |
|
|
-- Additional Comments:
|
17 |
|
|
--
|
18 |
|
|
----------------------------------------------------------------------------------
|
19 |
|
|
library IEEE;
|
20 |
|
|
use IEEE.std_logic_1164.all;
|
21 |
|
|
--use IEEE.numeric_std.all;
|
22 |
|
|
use IEEE.std_logic_arith.all;
|
23 |
|
|
|
24 |
|
|
---------------------------------------------------------------------------------------------------
|
25 |
|
|
package Global is
|
26 |
|
|
function To_Integer(Arg : in std_ulogic_vector) return integer;
|
27 |
|
|
function To_Integer(Arg : in std_ulogic) return integer;
|
28 |
|
|
function TO_UNSIGNED (ARG, SIZE: natural) return UNSIGNED;
|
29 |
|
|
|
30 |
|
|
subtype RAMrange is natural range 25 downto 0; -- 64MB as example MUST BE REDEFINED !!!
|
31 |
|
|
|
32 |
|
|
|
33 |
|
|
end Global;
|
34 |
|
|
|
35 |
|
|
|
36 |
|
|
---------------------------------------------------------------------------------------------------
|
37 |
|
|
---------------------------------------------------------------------------------------------------
|
38 |
|
|
package body Global is
|
39 |
|
|
function To_Integer(Arg : in std_ulogic) return integer is
|
40 |
|
|
begin
|
41 |
|
|
return CONV_INTEGER(Arg);
|
42 |
|
|
end;
|
43 |
|
|
|
44 |
|
|
|
45 |
|
|
---------------------------------------------------------------------------------------------------
|
46 |
|
|
function To_Integer(Arg : in std_ulogic_vector) return integer is
|
47 |
|
|
begin
|
48 |
|
|
return CONV_INTEGER(unsigned(Arg));
|
49 |
|
|
end;
|
50 |
|
|
|
51 |
|
|
---------------------------------------------------------------------------------------------------
|
52 |
|
|
function TO_UNSIGNED (ARG, SIZE: natural) return UNSIGNED is
|
53 |
|
|
variable RESULT: UNSIGNED(SIZE-1 downto 0);
|
54 |
|
|
variable I_VAL: NATURAL := ARG;
|
55 |
|
|
begin
|
56 |
|
|
for I in 0 to RESULT'LEFT loop
|
57 |
|
|
if (I_VAL mod 2) = 0 then
|
58 |
|
|
RESULT(I) := '0';
|
59 |
|
|
else RESULT(I) := '1';
|
60 |
|
|
end if;
|
61 |
|
|
I_VAL := I_VAL/2;
|
62 |
|
|
end loop;
|
63 |
|
|
return RESULT;
|
64 |
|
|
end TO_UNSIGNED;
|
65 |
|
|
|
66 |
|
|
end Global;
|
67 |
|
|
|
68 |
|
|
---------------------------------------------------------------------------------------------------
|
69 |
|
|
---------------------------------------------------------------------------------------------------
|