1 |
8 |
eejlny |
-------------------------------------------------------------------------------
|
2 |
|
|
--
|
3 |
|
|
-- Copyright (c) 1994 by AT&T. All rights reserved.
|
4 |
|
|
--
|
5 |
|
|
-- This source file may be used and distributed without restriction
|
6 |
|
|
-- provided that this copyright statement is not removed from the file
|
7 |
|
|
-- and that any derivative work contains this copyright notice.
|
8 |
|
|
--
|
9 |
|
|
-- Package name: BIT_UTILS
|
10 |
|
|
-- File name : bit_utils.vhdl
|
11 |
|
|
--
|
12 |
|
|
-- Updates:
|
13 |
|
|
|
14 |
|
|
--D sccsid @(#)bit_utils.vhdl 1.2 daisy(C) 2/13/95 /files1/SCCS.model/bvhdl/vhdl_packages/dzx/src/s.bit_utils.vhdl
|
15 |
|
|
-------------------------------------------------------------------------------
|
16 |
|
|
|
17 |
|
|
package Bit_Utils is
|
18 |
|
|
|
19 |
|
|
---------------------------------------------------------------------
|
20 |
|
|
-- rising, falling clock edge and clock level detection functions: --
|
21 |
|
|
---------------------------------------------------------------------
|
22 |
|
|
function Rising_Edge (signal clock_name : Bit) return Boolean;
|
23 |
|
|
function Falling_Edge (signal clock_name : Bit) return Boolean;
|
24 |
|
|
function High_Level (signal clock_name : Bit) return Boolean;
|
25 |
|
|
function Low_Level (signal clock_name : Bit) return Boolean;
|
26 |
|
|
|
27 |
|
|
--------------------------
|
28 |
|
|
-- conversions routines --
|
29 |
|
|
--------------------------
|
30 |
|
|
|
31 |
|
|
function To_Bit (b: Boolean) return Bit;
|
32 |
|
|
function To_Char (l : Bit) return Character;
|
33 |
|
|
function To_String (v : Bit_Vector) return String;
|
34 |
|
|
|
35 |
|
|
----------------------------------
|
36 |
|
|
-- Boolean reduction functions: --
|
37 |
|
|
----------------------------------
|
38 |
|
|
function And_Bits (v: Bit_Vector) return Bit;
|
39 |
|
|
function Nand_Bits (v: Bit_Vector) return Bit;
|
40 |
|
|
function Or_Bits (v: Bit_Vector) return Bit;
|
41 |
|
|
function Nor_Bits (v: Bit_Vector) return Bit;
|
42 |
|
|
function Xor_Bits (v: Bit_Vector) return Bit;
|
43 |
|
|
function Xnor_Bits (v: Bit_Vector) return Bit;
|
44 |
|
|
|
45 |
|
|
-- preset / clear procedure:
|
46 |
|
|
procedure Preset_Clear (signal FF: out Bit_Vector; Pc_Value: Bit_Vector);
|
47 |
|
|
procedure Preset_Clear (signal FF: out Bit; Pc_Value: Bit);
|
48 |
|
|
|
49 |
|
|
|
50 |
|
|
attribute BUILT_IN: BOOLEAN; --D
|
51 |
|
|
attribute BUILT_IN of Rising_Edge: function is TRUE; --D
|
52 |
|
|
attribute BUILT_IN of Falling_Edge: function is TRUE; --D
|
53 |
|
|
attribute BUILT_IN of High_Level: function is TRUE; --D
|
54 |
|
|
attribute BUILT_IN of LOw_Level: function is TRUE; --D
|
55 |
|
|
attribute BUILT_IN of To_Bit : function is TRUE; --D
|
56 |
|
|
attribute BUILT_IN of To_Char : function is TRUE; --D
|
57 |
|
|
attribute BUILT_IN of To_String : function is TRUE; --D
|
58 |
|
|
attribute BUILT_IN of And_Bits: function is TRUE; --D
|
59 |
|
|
attribute BUILT_IN of Nand_Bits: function is TRUE; --D
|
60 |
|
|
attribute BUILT_IN of Or_Bits: function is TRUE; --D
|
61 |
|
|
attribute BUILT_IN of Nor_Bits: function is TRUE; --D
|
62 |
|
|
attribute BUILT_IN of Xor_Bits: function is TRUE; --D
|
63 |
|
|
attribute BUILT_IN of Xnor_Bits: function is TRUE; --D
|
64 |
|
|
attribute BUILT_IN of Preset_Clear: procedure is TRUE; --D
|
65 |
|
|
|
66 |
|
|
end Bit_Utils;
|
67 |
|
|
|
68 |
|
|
--D sccsid @(#)bit_utils-body.vhdl 1.2 daisy(C) 2/13/95 /files1/SCCS.model/bvhdl/vhdl_packages/dzx/src/s.bit_utils-body.vhdl
|
69 |
|
|
-------------------------------------------------------------------------------
|
70 |
|
|
-- File: Bit_Utils
|
71 |
|
|
--
|
72 |
|
|
-------------------------------------------------------------------------------
|
73 |
|
|
|
74 |
|
|
package body Bit_Utils is
|
75 |
|
|
-- contains the subprogram definitions for subprograms declared above.
|
76 |
|
|
|
77 |
|
|
---------------------------------------------------------------------
|
78 |
|
|
-- rising, falling clock edge and clock level detection functions: --
|
79 |
|
|
---------------------------------------------------------------------
|
80 |
|
|
|
81 |
|
|
function Rising_Edge (signal clock_name: Bit) return Boolean is
|
82 |
|
|
begin
|
83 |
|
|
return (clock_name = '1') and (clock_name'event);
|
84 |
|
|
end Rising_Edge;
|
85 |
|
|
|
86 |
|
|
function Falling_Edge (signal clock_name: Bit) return Boolean is
|
87 |
|
|
begin
|
88 |
|
|
return (clock_name = '0') and (clock_name'event);
|
89 |
|
|
end Falling_Edge;
|
90 |
|
|
|
91 |
|
|
function High_Level (signal clock_name: Bit) return Boolean is
|
92 |
|
|
begin
|
93 |
|
|
return (clock_name = '1');
|
94 |
|
|
end High_Level;
|
95 |
|
|
|
96 |
|
|
function Low_Level (signal clock_name: Bit) return Boolean is
|
97 |
|
|
begin
|
98 |
|
|
return (clock_name = '0');
|
99 |
|
|
end Low_Level;
|
100 |
|
|
|
101 |
|
|
-------------------------
|
102 |
|
|
-- Conversion routines --
|
103 |
|
|
-------------------------
|
104 |
|
|
|
105 |
|
|
function To_Bit (b: Boolean) return Bit is
|
106 |
|
|
begin
|
107 |
|
|
case b is
|
108 |
|
|
when FALSE => return '0';
|
109 |
|
|
when TRUE => return '1';
|
110 |
|
|
end case;
|
111 |
|
|
end To_Bit;
|
112 |
|
|
|
113 |
|
|
function To_Char (l: Bit) return Character is
|
114 |
|
|
begin
|
115 |
|
|
case l is
|
116 |
|
|
when '0' => return '0';
|
117 |
|
|
when '1' => return '1';
|
118 |
|
|
end case;
|
119 |
|
|
end To_Char;
|
120 |
|
|
|
121 |
|
|
function To_String (v: Bit_Vector) return String is
|
122 |
|
|
variable ret: String (v'range);
|
123 |
|
|
begin
|
124 |
|
|
for j in ret'range loop
|
125 |
|
|
ret(j) := To_Char(v(j));
|
126 |
|
|
end loop;
|
127 |
|
|
|
128 |
|
|
return ret;
|
129 |
|
|
end To_String;
|
130 |
|
|
|
131 |
|
|
|
132 |
|
|
-----------------------------------
|
133 |
|
|
-- Boolean reduction functions: --
|
134 |
|
|
-----------------------------------
|
135 |
|
|
function And_Bits (v: Bit_Vector) return Bit is
|
136 |
|
|
variable ret: Bit :='1';
|
137 |
|
|
begin
|
138 |
|
|
for j in v'range loop
|
139 |
|
|
ret := ret and v(j);
|
140 |
|
|
end loop;
|
141 |
|
|
|
142 |
|
|
return ret;
|
143 |
|
|
end And_Bits;
|
144 |
|
|
|
145 |
|
|
function Nand_Bits (v: Bit_Vector) return Bit is
|
146 |
|
|
begin
|
147 |
|
|
return (not And_Bits(v));
|
148 |
|
|
end Nand_Bits;
|
149 |
|
|
|
150 |
|
|
function Or_Bits (v: Bit_Vector) return Bit is
|
151 |
|
|
variable ret: Bit := '0';
|
152 |
|
|
begin
|
153 |
|
|
for j in v'range loop
|
154 |
|
|
ret := ret or v(j);
|
155 |
|
|
end loop;
|
156 |
|
|
|
157 |
|
|
return ret;
|
158 |
|
|
end Or_Bits;
|
159 |
|
|
|
160 |
|
|
function Nor_Bits (v: Bit_Vector) return Bit is
|
161 |
|
|
begin
|
162 |
|
|
return (not Or_Bits(v));
|
163 |
|
|
end Nor_Bits;
|
164 |
|
|
|
165 |
|
|
function Xor_Bits (v: Bit_Vector) return Bit is
|
166 |
|
|
variable ret: Bit := '0';
|
167 |
|
|
begin
|
168 |
|
|
for j in v'range loop
|
169 |
|
|
ret := ret xor v(j);
|
170 |
|
|
end loop;
|
171 |
|
|
|
172 |
|
|
return ret;
|
173 |
|
|
end Xor_Bits;
|
174 |
|
|
|
175 |
|
|
function Xnor_Bits (v: Bit_Vector) return Bit is
|
176 |
|
|
begin
|
177 |
|
|
return (not Xor_Bits (v));
|
178 |
|
|
end Xnor_Bits;
|
179 |
|
|
|
180 |
|
|
-- preset / clear procedure:
|
181 |
|
|
procedure PRESET_CLEAR (signal FF: out BIT_VECTOR; PC_VALUE: BIT_VECTOR) is
|
182 |
|
|
begin
|
183 |
|
|
FF <= PC_VALUE;
|
184 |
|
|
end;
|
185 |
|
|
|
186 |
|
|
procedure PRESET_CLEAR (signal FF: out BIT; PC_VALUE: BIT) is
|
187 |
|
|
begin
|
188 |
|
|
FF <= PC_VALUE;
|
189 |
|
|
end;
|
190 |
|
|
|
191 |
|
|
end Bit_Utils;
|
192 |
|
|
|