source: PROJECT_CORE_MPI/MPI_HCL/TRUNK/CORE_MPI/image_pkg.vhd @ 100

Last change on this file since 100 was 100, checked in by rolagamo, 10 years ago
File size: 4.1 KB
Line 
1----------------------------------------------------------------------------
2-- Copyright (c) 1996, Ben Cohen.   All rights reserved.
3-- This model can be used in conjunction with the Kluwer Academic books
4-- "VHDL Coding Styles and Methodologies", ISBN: 0-7923-9598-0
5-- "VHDL Amswers to Frequently Asked Questions", ISBN 0-7923-9791-6
6-- Web page:   http://members.aol.com/vhdlcohen/vhdl
7-- email: vhdlcohen@aol.com
8--
9-- This source file for the image  package
10-- may be used and distributed without restriction provided
11-- that this copyright statement is not removed from the file
12-- and that any derivative work contains this copyright notice.
13-------------------------------------------------------------------------------
14library IEEE; 
15  use IEEE.Std_Logic_1164.all;
16  use IEEE.Std_Logic_TextIO.all; 
17  use IEEE.Std_Logic_Arith.all;
18
19library Std;
20  use STD.TextIO.all;
21
22package Image_Pkg is
23  function Image(In_Image : Time) return String;
24  function Image(In_Image : Bit) return String;
25  function Image(In_Image : Bit_Vector) return String;
26  function Image(In_Image : Integer) return String;
27  function Image(In_Image : Real) return String;
28  function Image(In_Image : Std_uLogic) return String;
29  function Image(In_Image : Std_uLogic_Vector) return String;
30  function Image(In_Image : Std_Logic_Vector) return String;
31  function Image(In_Image : Signed) return String;
32  function Image(In_Image : UnSigned) return String;
33
34end Image_Pkg;
35
36package body Image_Pkg is
37  function Image(In_Image : Time) return String is
38    variable L : Line;  -- access type
39    variable W : String(1 to 25) := (others => ' '); 
40       -- Long enough to hold a time string
41  begin
42    -- the WRITE procedure creates an object with "NEW".
43    -- L is passed as an output of the procedure.
44    Std.TextIO.WRITE(L, in_image);
45    -- Copy L.all onto W
46    W(L.all'range) := L.all;
47    Deallocate(L);
48    return W;
49  end Image;
50
51  function Image(In_Image : Bit) return String is
52    variable L : Line;  -- access type
53    variable W : String(1 to 3) := (others => ' '); 
54  begin
55    Std.TextIO.WRITE(L, in_image);
56    W(L.all'range) := L.all;
57    Deallocate(L);
58    return W;
59  end Image;
60
61  function Image(In_Image : Bit_Vector) return String is
62    variable L : Line;  -- access type
63    variable W : String(1 to In_Image'length) := (others => ' '); 
64  begin
65    Std.TextIO.WRITE(L, in_image);
66    W(L.all'range) := L.all;
67    Deallocate(L);
68    return W;
69  end Image;
70
71  function Image(In_Image : Integer) return String is
72    variable L : Line;  -- access type
73    variable W : String(1 to 32) := (others => ' '); 
74     -- Long enough to hold a time string
75  begin
76    Std.TextIO.WRITE(L, in_image);
77    W(L.all'range) := L.all;
78    Deallocate(L);
79    return W;
80  end Image;
81
82  function Image(In_Image : Real) return String is
83    variable L : Line;  -- access type
84    variable W : String(1 to 32) := (others => ' '); 
85      -- Long enough to hold a time string
86  begin
87    Std.TextIO.WRITE(L, in_image);
88    W(L.all'range) := L.all;
89    Deallocate(L);
90    return W;
91  end Image;
92
93  function Image(In_Image : Std_uLogic) return String is
94    variable L : Line;  -- access type
95    variable W : String(1 to 3) := (others => ' '); 
96  begin
97    IEEE.Std_Logic_Textio.WRITE(L, in_image);
98    W(L.all'range) := L.all;
99    Deallocate(L);
100    return W;
101  end Image;
102
103  function Image(In_Image : Std_uLogic_Vector) return String is
104    variable L : Line;  -- access type
105    variable W : String(1 to In_Image'length) := (others => ' '); 
106  begin
107    IEEE.Std_Logic_Textio.WRITE(L, in_image);
108    W(L.all'range) := L.all;
109    Deallocate(L);
110    return W;
111  end Image;
112
113  function Image(In_Image : Std_Logic_Vector) return String is
114    variable L : Line;  -- access type
115    variable W : String(1 to In_Image'length) := (others => ' '); 
116  begin
117     IEEE.Std_Logic_TextIO.WRITE(L, In_Image);
118     W(L.all'range) := L.all;
119     Deallocate(L);
120     return W;
121  end Image;
122
123  function Image(In_Image : Signed) return String is 
124  begin 
125    return Image(Std_Logic_Vector(In_Image));
126  end Image;
127
128  function Image(In_Image : UnSigned) return String is
129  begin 
130    return Image(Std_Logic_Vector(In_Image));
131  end Image;
132
133end Image_Pkg;
134
Note: See TracBrowser for help on using the repository browser.