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

Subversion Repositories openfpu64

[/] [openfpu64/] [trunk/] [eis_helpers.vhd] - Blame information for rev 5

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 5 bro
-------------------------------------------------------------------------------
2
-- Title      : Helpers
3
-- Project    : openFPU64
4
-------------------------------------------------------------------------------
5
-- File       : eis_helpers.vhd
6
-- Author     : Prof. Dr. Gundolf Kiefer <gundolf.kiefer@hs-augsburg.de>
7
-- Company    : University of Applied Sciences, Augsburg
8
-- Last update: 2010-04-22
9
-- Platform   : 
10
-- Standard   : VHDL'87
11
-------------------------------------------------------------------------------
12
-- Description: This package contains neat some helper functions that ease
13
--              printing out std_logic, std_logic_vector, unsigned and integer
14
--              values. This package is especially handy for Testbenches.
15
-------------------------------------------------------------------------------
16
-- Copyright (c) 2010 
17
-------------------------------------------------------------------------------
18
-- License   : GPL v3 -- see gpl.txt
19
-------------------------------------------------------------------------------
20
 
21
library IEEE;
22
use IEEE.std_logic_1164.all;
23
use IEEE.numeric_std.all;
24
 
25
library STD;
26
use STD.textio.all;
27
 
28
 
29
 
30
package helpers is
31
  function to_character (val : in std_logic) return character;
32
  function to_string (val : in std_logic_vector) return string;
33
  function to_string (val: in unsigned) return string;
34
  function to_string (val: in integer) return string;
35
end helpers;
36
 
37
 
38
package body helpers is
39
 
40
  -- Testbench helpers...
41
  function to_character (val : in std_logic) return character is
42
  begin
43
    case val is
44
      when '0' => return '0';
45
      when '1' => return '1';
46
      when 'U' => return 'u';
47
      when 'Z' => return 'z';
48
      when others => return 'x';
49
    end case;
50
  end to_character;
51
 
52
  function to_string (val : in std_logic_vector) return string is
53
    variable str: string (1 to val'length);
54
    alias val_norm : std_logic_vector (1 to val'length) is val;
55
    variable n: integer;
56
  begin
57
    for i in str'range loop
58
      str(i) := to_character(val_norm(i));
59
    end loop;
60
    return str;
61
  end to_string;
62
 
63
  function to_string (val: in unsigned) return string is
64
  begin
65
    return to_string (std_logic_vector (val));
66
  end to_string;
67
 
68
  function to_string (val: in integer) return string is
69
    variable retLine: line;
70
  begin
71
    write (retLine, val);
72
    return retLine(1 to retLine'length);
73
  end to_string;
74
 
75
 
76
end helpers;

powered by: WebSVN 2.1.0

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