1 |
2 |
pela |
----------------------------------------------------------------------
|
2 |
|
|
---- ----
|
3 |
|
|
---- PlTbUtils Types Package ----
|
4 |
|
|
---- ----
|
5 |
|
|
---- This file is part of the PlTbUtils project ----
|
6 |
|
|
---- http://opencores.org/project,pltbutils ----
|
7 |
|
|
---- ----
|
8 |
|
|
---- Description: ----
|
9 |
|
|
---- PlTbUtils is a collection of functions, procedures and ----
|
10 |
|
|
---- components for easily creating stimuli and checking response ----
|
11 |
|
|
---- in automatic self-checking testbenches. ----
|
12 |
|
|
---- ----
|
13 |
|
|
---- This file defines types used by PlTbUtils, mainly protected ----
|
14 |
|
|
---- types. ----
|
15 |
|
|
---- ----
|
16 |
|
|
---- ----
|
17 |
|
|
---- To Do: ----
|
18 |
|
|
---- - ----
|
19 |
|
|
---- ----
|
20 |
|
|
---- Author(s): ----
|
21 |
|
|
---- - Per Larsson, pela@opencores.org ----
|
22 |
|
|
---- ----
|
23 |
|
|
----------------------------------------------------------------------
|
24 |
|
|
---- ----
|
25 |
|
|
---- Copyright (C) 2009 Authors and OPENCORES.ORG ----
|
26 |
|
|
---- ----
|
27 |
|
|
---- This source file may be used and distributed without ----
|
28 |
|
|
---- restriction provided that this copyright statement is not ----
|
29 |
|
|
---- removed from the file and that any derivative work contains ----
|
30 |
|
|
---- the original copyright notice and the associated disclaimer. ----
|
31 |
|
|
---- ----
|
32 |
|
|
---- This source file is free software; you can redistribute it ----
|
33 |
|
|
---- and/or modify it under the terms of the GNU Lesser General ----
|
34 |
|
|
---- Public License as published by the Free Software Foundation; ----
|
35 |
|
|
---- either version 2.1 of the License, or (at your option) any ----
|
36 |
|
|
---- later version. ----
|
37 |
|
|
---- ----
|
38 |
|
|
---- This source is distributed in the hope that it will be ----
|
39 |
|
|
---- useful, but WITHOUT ANY WARRANTY; without even the implied ----
|
40 |
|
|
---- warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR ----
|
41 |
|
|
---- PURPOSE. See the GNU Lesser General Public License for more ----
|
42 |
|
|
---- details. ----
|
43 |
|
|
---- ----
|
44 |
|
|
---- You should have received a copy of the GNU Lesser General ----
|
45 |
|
|
---- Public License along with this source; if not, download it ----
|
46 |
|
|
---- from http://www.opencores.org/lgpl.shtml ----
|
47 |
|
|
---- ----
|
48 |
|
|
----------------------------------------------------------------------
|
49 |
|
|
library ieee;
|
50 |
|
|
use ieee.std_logic_1164.all;
|
51 |
|
|
|
52 |
|
|
package pltbutils_type_pkg is
|
53 |
|
|
|
54 |
|
|
constant C_PLTBUTILS_SC_STRLEN : integer := 80;
|
55 |
|
|
|
56 |
|
|
type pltbutils_p_integer_t is protected
|
57 |
|
|
procedure clr;
|
58 |
|
|
procedure inc;
|
59 |
|
|
procedure dec;
|
60 |
|
|
procedure set(x : integer);
|
61 |
|
|
impure function value return integer;
|
62 |
|
|
end protected pltbutils_p_integer_t;
|
63 |
|
|
|
64 |
|
|
type pltbutils_p_std_logic_t is protected
|
65 |
|
|
procedure clr;
|
66 |
|
|
procedure set(x : std_logic);
|
67 |
|
|
impure function value return std_logic;
|
68 |
|
|
end protected pltbutils_p_std_logic_t;
|
69 |
|
|
|
70 |
|
|
type pltbutils_p_string_t is protected
|
71 |
|
|
procedure clr;
|
72 |
|
|
procedure set(s : string);
|
73 |
|
|
impure function value return string;
|
74 |
|
|
end protected pltbutils_p_string_t;
|
75 |
|
|
|
76 |
|
|
end package pltbutils_type_pkg;
|
77 |
|
|
|
78 |
|
|
package body pltbutils_type_pkg is
|
79 |
|
|
----------------------------------------------------------------------------
|
80 |
|
|
type pltbutils_p_integer_t is protected body
|
81 |
|
|
variable val : integer := 0;
|
82 |
|
|
|
83 |
|
|
procedure clr is
|
84 |
|
|
begin
|
85 |
|
|
val := 0;
|
86 |
|
|
end procedure clr;
|
87 |
|
|
|
88 |
|
|
procedure inc is
|
89 |
|
|
begin
|
90 |
|
|
val := val + 1;
|
91 |
|
|
end procedure inc;
|
92 |
|
|
|
93 |
|
|
procedure dec is
|
94 |
|
|
begin
|
95 |
|
|
val := val - 1;
|
96 |
|
|
end procedure dec;
|
97 |
|
|
|
98 |
|
|
procedure set(x : integer) is
|
99 |
|
|
begin
|
100 |
|
|
val := x;
|
101 |
|
|
end procedure set;
|
102 |
|
|
|
103 |
|
|
impure function value return integer is
|
104 |
|
|
begin
|
105 |
|
|
return val;
|
106 |
|
|
end function value;
|
107 |
|
|
end protected body pltbutils_p_integer_t;
|
108 |
|
|
----------------------------------------------------------------------------
|
109 |
|
|
type pltbutils_p_std_logic_t is protected body
|
110 |
|
|
variable val : std_logic := '0';
|
111 |
|
|
|
112 |
|
|
procedure clr is
|
113 |
|
|
begin
|
114 |
|
|
val := '0';
|
115 |
|
|
end procedure clr;
|
116 |
|
|
|
117 |
|
|
procedure set(x : std_logic) is
|
118 |
|
|
begin
|
119 |
|
|
val := x;
|
120 |
|
|
end procedure set;
|
121 |
|
|
|
122 |
|
|
impure function value return std_logic is
|
123 |
|
|
begin
|
124 |
|
|
return val;
|
125 |
|
|
end function value;
|
126 |
|
|
end protected body pltbutils_p_std_logic_t;
|
127 |
|
|
----------------------------------------------------------------------------
|
128 |
|
|
type pltbutils_p_string_t is protected body
|
129 |
|
|
variable str : string(1 to C_PLTBUTILS_SC_STRLEN) := (others => '0');
|
130 |
|
|
|
131 |
|
|
procedure clr is
|
132 |
|
|
begin
|
133 |
|
|
str := (others => ' ');
|
134 |
|
|
end procedure clr;
|
135 |
|
|
|
136 |
|
|
procedure set(s : string) is
|
137 |
|
|
variable j : positive := s'low;
|
138 |
|
|
begin
|
139 |
|
|
for i in str'range loop
|
140 |
|
|
if j <= s'high then
|
141 |
|
|
str(i) := s(j);
|
142 |
|
|
else
|
143 |
|
|
str(i) := ' ';
|
144 |
|
|
end if;
|
145 |
|
|
j := j + 1;
|
146 |
|
|
end loop;
|
147 |
|
|
end procedure set;
|
148 |
|
|
|
149 |
|
|
impure function value return string is
|
150 |
|
|
begin
|
151 |
|
|
return str;
|
152 |
|
|
end function value;
|
153 |
|
|
end protected body pltbutils_p_string_t;
|
154 |
|
|
----------------------------------------------------------------------------
|
155 |
|
|
end package body pltbutils_type_pkg;
|