Browse Source

Replace OSVVM directory by git submodule

T. Meissner 1 year ago
parent
commit
2ee7c4d131

+ 3
- 0
.gitmodules View File

@@ -0,0 +1,3 @@
1
+[submodule "lib/OSVVM"]
2
+	path = lib/OSVVM
3
+	url = https://github.com/OSVVM/OSVVM.git

+ 0
- 3247
OSVVM/AlertLogPkg.vhd
File diff suppressed because it is too large
View File


+ 0
- 78
OSVVM/Artistic License 2.0.md View File

@@ -1,78 +0,0 @@
1
-This is a local copy of the Artistic License 2.0.  
2
-The original can be obtained here: [http://www.perlfoundation.org/artistic_license_2_0](http://www.perlfoundation.org/artistic_license_2_0)
3
-
4
---------------------------------------------------------------------------------
5
-
6
-# Artistic License 2.0
7
-
8
-**Copyright © 2000-2006, The Perl Foundation.**
9
-
10
-Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed.
11
-
12
-### Preamble
13
-
14
-This license establishes the terms under which a given free software Package may be copied, modified, distributed, and/or redistributed. The intent is that the Copyright Holder maintains some artistic control over the development of that Package while still keeping the Package available as open source and free software.
15
-You are always permitted to make arrangements wholly outside of this license directly with the Copyright Holder of a given Package. If the terms of this license do not permit the full use that you propose to make of the Package, you should contact the Copyright Holder and seek a different licensing arrangement.
16
-
17
-### Definitions
18
-
19
-*"Copyright Holder"* means the individual(s) or organization(s) named in the copyright notice for the entire Package.  
20
-*"Contributor"* means any party that has contributed code or other material to the Package, in accordance with the Copyright Holder's procedures.  
21
-*"You"* and *"your"* means any person who would like to copy, distribute, or modify the Package.  
22
-*"Package"* means the collection of files distributed by the Copyright Holder, and derivatives of that collection and/or of those files. A given Package may consist of either the Standard Version, or a Modified Version.  
23
-*"Distribute"* means providing a copy of the Package or making it accessible to anyone else, or in the case of a company or organization, to others outside of your company or organization.  
24
-*"Distributor Fee"* means any fee that you charge for Distributing this Package or providing support for this Package to another party. It does not mean licensing fees.  
25
-*"Standard Version"* refers to the Package if it has not been modified, or has been modified only in ways explicitly requested by the Copyright Holder.  
26
-*"Modified Version"* means the Package, if it has been changed, and such changes were not explicitly requested by the Copyright Holder.  
27
-*"Original License"* means this Artistic License as Distributed with the Standard Version of the Package, in its current version or as it may be modified by The Perl Foundation in the future.  
28
-*"Source"* form means the source code, documentation source, and configuration files for the Package.  
29
-*"Compiled"* form means the compiled bytecode, object code, binary, or any other form resulting from mechanical transformation or translation of the Source form.  
30
-
31
-### Permission for Use and Modification Without Distribution
32
-
33
-(1) You are permitted to use the Standard Version and create and use Modified Versions for any purpose without restriction, provided that you do not Distribute the Modified Version.
34
-
35
-### Permissions for Redistribution of the Standard Version
36
-
37
-(2) You may Distribute verbatim copies of the Source form of the Standard Version of this Package in any medium without restriction, either gratis or for a Distributor Fee, provided that you duplicate all of the original copyright notices and associated disclaimers. At your discretion, such verbatim copies may or may not include a Compiled form of the Package.
38
-
39
-(3) You may apply any bug fixes, portability changes, and other modifications made available from the Copyright Holder. The resulting Package will still be considered the Standard Version, and as such will be subject to the Original License.
40
-
41
-### Distribution of Modified Versions of the Package as Source
42
-
43
-(4) You may Distribute your Modified Version as Source (either gratis or for a Distributor Fee, and with or without a Compiled form of the Modified Version) provided that you clearly document how it differs from the Standard Version, including, but not limited to, documenting any non-standard features, executables, or modules, and provided that you do at least ONE of the following:
44
-
45
- - (a) make the Modified Version available to the Copyright Holder of the Standard Version, under the Original License, so that the Copyright Holder may include your modifications in the Standard Version.
46
- - (b) ensure that installation of your Modified Version does not prevent the user installing or running the Standard Version. In addition, the Modified Version must bear a name that is different from the name of the Standard Version.
47
- - (c) allow anyone who receives a copy of the Modified Version to make the Source form of the Modified Version available to others under
48
-    - (i) the Original License or
49
-    - (ii) a license that permits the licensee to freely copy, modify and redistribute the Modified Version using the same licensing terms that apply to the copy that the licensee received, and requires that the Source form of the Modified Version, and of any works derived from it, be made freely available in that license fees are prohibited but Distributor Fees are allowed.
50
-
51
-Distribution of Compiled Forms of the Standard Version or Modified Versions without the Source
52
-
53
-(5) You may Distribute Compiled forms of the Standard Version without the Source, provided that you include complete instructions on how to get the Source of the Standard Version. Such instructions must be valid at the time of your distribution. If these instructions, at any time while you are carrying out such distribution, become invalid, you must provide new instructions on demand or cease further distribution. If you provide valid instructions or cease distribution within thirty days after you become aware that the instructions are invalid, then you do not forfeit any of your rights under this license.
54
-
55
-(6) You may Distribute a Modified Version in Compiled form without the Source, provided that you comply with Section 4 with respect to the Source of the Modified Version.
56
-
57
-### Aggregating or Linking the Package
58
-
59
-(7) You may aggregate the Package (either the Standard Version or Modified Version) with other packages and Distribute the resulting aggregation provided that you do not charge a licensing fee for the Package. Distributor Fees are permitted, and licensing fees for other components in the aggregation are permitted. The terms of this license apply to the use and Distribution of the Standard or Modified Versions as included in the aggregation.
60
-
61
-(8) You are permitted to link Modified and Standard Versions with other works, to embed the Package in a larger work of your own, or to build stand-alone binary or bytecode versions of applications that include the Package, and Distribute the result without restriction, provided the result does not expose a direct interface to the Package.
62
-
63
-### Items That are Not Considered Part of a Modified Version
64
-
65
-(9) Works (including, but not limited to, modules and scripts) that merely extend or make use of the Package, do not, by themselves, cause the Package to be a Modified Version. In addition, such works are not considered parts of the Package itself, and are not subject to the terms of this license.
66
-
67
-### General Provisions
68
-
69
-(10) Any use, modification, and distribution of the Standard or Modified Versions is governed by this Artistic License. By using, modifying or distributing the Package, you accept this license. Do not use, modify, or distribute the Package, if you do not accept this license.
70
-
71
-(11) If your Modified Version has been derived from a Modified Version made by someone other than you, you are nevertheless required to ensure that your Modified Version complies with the requirements of this license.
72
-
73
-(12) This license does not grant you the right to use any trademark, service mark, tradename, or logo of the Copyright Holder.
74
-
75
-(13) This license includes the non-exclusive, worldwide, free-of-charge patent license to make, have made, use, offer to sell, sell, import and otherwise transfer the Package with respect to any patent claims licensable by the Copyright Holder that are necessarily infringed by the Package. If you institute patent litigation (including a cross-claim or counterclaim) against any party alleging that the Package constitutes direct or contributory patent infringement, then this Artistic License to you shall terminate on the date that such litigation is filed.
76
-
77
-(14) Disclaimer of Warranty:  
78
-**THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES. THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY YOUR LOCAL LAW. UNLESS REQUIRED BY LAW, NO COPYRIGHT HOLDER OR CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE OF THE PACKAGE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.**

+ 0
- 4906
OSVVM/CoveragePkg.vhd
File diff suppressed because it is too large
View File


+ 0
- 629
OSVVM/MemoryPkg.vhd View File

@@ -1,672 +0,0 @@
1
---
2
---
3
---
4
---
5
---
6
---
7
---
8
---
9
-use std.textio.all ;
10
-library IEEE ; 
11
-  use IEEE.std_logic_1164.all ; 
12
-  use IEEE.numeric_std.all ; 
13
-  use IEEE.numeric_std_unsigned.all ; 
14
-  use IEEE.math_real.all ;
15
-  
16
-use work.TextUtilPkg.all ;
17
-use work.TranscriptPkg.all ;  
18
-use work.AlertLogPkg.all ;
19
-
20
-package MemoryPkg is
21
-  type MemoryPType is protected 
22
-    ------------------------------------------------------------
23
-    procedure MemInit ( AddrWidth, DataWidth  : in  integer ) ;
24
-    
25
-    ------------------------------------------------------------
26
-    procedure MemWrite ( Addr, Data  : in  std_logic_vector ) ; 
27
-
28
-    ------------------------------------------------------------
29
-    procedure MemRead (  
30
-      Addr  : in  std_logic_vector ;
31
-      Data  : out std_logic_vector 
32
-    ) ; 
33
-    impure function MemRead ( Addr  : std_logic_vector ) return std_logic_vector ; 
34
-
35
-    ------------------------------------------------------------
36
-    procedure MemErase ; 
37
-    procedure deallocate ; 
38
-    
39
-    ------------------------------------------------------------
40
-    procedure SetAlertLogID (A : AlertLogIDType) ;
41
-    procedure SetAlertLogID (Name : string ; ParentID : AlertLogIDType := ALERTLOG_BASE_ID ; CreateHierarchy : Boolean := TRUE) ;    
42
-    impure function GetAlertLogID return AlertLogIDType ;
43
-    
44
-    ------------------------------------------------------------
45
-    procedure FileReadH (    -- Hexadecimal File Read 
46
-      FileName     : string ; 
47
-      StartAddr    : std_logic_vector ; 
48
-      EndAddr      : std_logic_vector
49
-    ) ;
50
-    procedure FileReadH (FileName : string ;  StartAddr : std_logic_vector) ;
51
-    procedure FileReadH (FileName : string) ; 
52
-
53
-    ------------------------------------------------------------
54
-    procedure FileReadB (    -- Binary File Read 
55
-      FileName     : string ; 
56
-      StartAddr    : std_logic_vector ; 
57
-      EndAddr      : std_logic_vector
58
-    ) ;
59
-    procedure FileReadB (FileName : string ;  StartAddr : std_logic_vector) ;
60
-    procedure FileReadB (FileName : string) ; 
61
-
62
-    ------------------------------------------------------------
63
-    procedure FileWriteH (    -- Hexadecimal File Write 
64
-      FileName     : string ; 
65
-      StartAddr    : std_logic_vector ; 
66
-      EndAddr      : std_logic_vector
67
-    ) ;
68
-    procedure FileWriteH (FileName : string ;  StartAddr : std_logic_vector) ;
69
-    procedure FileWriteH (FileName : string) ; 
70
-
71
-    ------------------------------------------------------------
72
-    procedure FileWriteB (    -- Binary File Write 
73
-      FileName     : string ; 
74
-      StartAddr    : std_logic_vector ; 
75
-      EndAddr      : std_logic_vector
76
-    ) ;
77
-    procedure FileWriteB (FileName : string ;  StartAddr : std_logic_vector) ;
78
-    procedure FileWriteB (FileName : string) ; 
79
-
80
-  end protected MemoryPType ;
81
-
82
-end MemoryPkg ;
83
-
84
-package body MemoryPkg is 
85
-  constant BLOCK_WIDTH : integer := 10 ; 
86
-
87
-  type MemoryPType is protected body
88
-
89
-    type MemBlockType    is array (integer range <>) of integer ;
90
-    type MemBlockPtrType is access MemBlockType ;
91
-    type MemArrayType    is array (integer range <>) of MemBlockPtrType ;
92
-    type ArrayPtrVarType is access MemArrayType ; 
93
-
94
-    variable ArrayPtrVar     : ArrayPtrVarType := NULL ; 
95
-    variable AddrWidthVar    : integer := -1 ;  -- set by MemInit - merges addr length and initialized checks.
96
-    variable DataWidthVar    : natural := 1 ;   -- set by MemInit
97
-    variable BlockkWidthVar  : natural := 0 ;   -- set by MemInit
98
-    
99
-    variable AlertLogIDVar : AlertLogIDType := OSVVM_ALERTLOG_ID ;
100
-    
101
-    type FileFormatType is (BINARY, HEX) ; 
102
-    
103
-    ------------------------------------------------------------
104
-    procedure MemInit ( AddrWidth, DataWidth  : In  integer ) is
105
-    ------------------------------------------------------------
106
-    begin
107
-      if AddrWidth <= 0 then 
108
-        Alert(AlertLogIDVar, "MemoryPType.MemInit.  AddrWidth = " & to_string(AddrWidth) & " must be > 0.", FAILURE) ; 
109
-        return ; 
110
-      end if ; 
111
-      if DataWidth <= 0 then 
112
-        Alert(AlertLogIDVar, "MemoryPType.MemInit.  DataWidth = " & to_string(DataWidth) & " must be > 0.", FAILURE) ; 
113
-        return ; 
114
-      end if ; 
115
-
116
-      AddrWidthVar   := AddrWidth ; 
117
-      DataWidthVar   := DataWidth ; 
118
-      BlockkWidthVar := minimum(BLOCK_WIDTH, AddrWidth) ;
119
-      ArrayPtrVar    := new MemArrayType(0 to 2**(AddrWidth-BlockkWidthVar)-1) ;  
120
-    end procedure MemInit ;
121
-    
122
-    ------------------------------------------------------------
123
-    procedure MemWrite (  Addr, Data  : in  std_logic_vector ) is 
124
-    ------------------------------------------------------------
125
-      variable BlockAddr, WordAddr  : integer ;
126
-      alias aAddr : std_logic_vector (Addr'length-1 downto 0) is Addr ; 
127
-    begin
128
-    
129
-      -- Check Bounds of Address and if memory is initialized
130
-      if Addr'length /= AddrWidthVar then
131
-        if (ArrayPtrVar = NULL) then 
132
-          Alert(AlertLogIDVar, "MemoryPType.MemWrite:  Memory not initialized, Write Ignored.", FAILURE) ; 
133
-        else
134
-          Alert(AlertLogIDVar, "MemoryPType.MemWrite:  Addr'length: " & to_string(Addr'length) & " /= Memory Address Width: " & to_string(AddrWidthVar), FAILURE) ; 
135
-        end if ; 
136
-        return ; 
137
-      end if ; 
138
-      
139
-      -- Check Bounds on Data
140
-      if Data'length /= DataWidthVar then
141
-        Alert(AlertLogIDVar, "MemoryPType.MemWrite:  Data'length: " & to_string(Data'length) & " /= Memory Data Width: " & to_string(DataWidthVar), FAILURE) ; 
142
-        return ; 
143
-      end if ; 
144
-
145
-      if is_X( Addr ) then
146
-        Alert(AlertLogIDVar, "MemoryPType.MemWrite:  Address X, Write Ignored.") ; 
147
-        return ;
148
-      end if ; 
149
-
150
-      -- Slice out upper address to form block address
151
-      if aAddr'high >= BlockkWidthVar then
152
-        BlockAddr := to_integer(aAddr(aAddr'high downto BlockkWidthVar)) ;
153
-      else
154
-        BlockAddr  := 0 ; 
155
-      end if ; 
156
-
157
-      -- If empty, allocate a memory block
158
-      if (ArrayPtrVar(BlockAddr) = NULL) then 
159
-          ArrayPtrVar(BlockAddr) := new MemBlockType(0 to 2**BlockkWidthVar-1) ;
160
-      end if ; 
161
-
162
-      -- Address of a word within a block
163
-      WordAddr  := to_integer(aAddr(BlockkWidthVar -1 downto 0)) ;
164
-
165
-      -- Write to BlockAddr, WordAddr
166
-      if (Is_X(Data)) then 
167
-        ArrayPtrVar(BlockAddr)(WordAddr) := -1 ;
168
-      else
169
-        ArrayPtrVar(BlockAddr)(WordAddr) := to_integer( Data ) ;
170
-      end if ;
171
-    end procedure MemWrite ; 
172
-
173
-    ------------------------------------------------------------
174
-    procedure MemRead (  
175
-    ------------------------------------------------------------
176
-      Addr  : In   std_logic_vector ;
177
-      Data  : Out  std_logic_vector 
178
-    ) is
179
-      variable BlockAddr, WordAddr  : integer ;
180
-      alias aAddr : std_logic_vector (Addr'length-1 downto 0) is Addr ; 
181
-    begin
182
-      -- Check Bounds of Address and if memory is initialized
183
-      if Addr'length /= AddrWidthVar then
184
-        if (ArrayPtrVar = NULL) then 
185
-          Alert(AlertLogIDVar, "MemoryPType.MemRead:  Memory not initialized. Returning U", FAILURE) ; 
186
-        else
187
-          Alert(AlertLogIDVar, "MemoryPType.MemRead:  Addr'length: " & to_string(Addr'length) & " /= Memory Address Width: " & to_string(AddrWidthVar), FAILURE) ; 
188
-        end if ; 
189
-        Data := (Data'range => 'U') ; 
190
-        return ; 
191
-      end if ; 
192
-      
193
-      -- Check Bounds on Data
194
-      if Data'length /= DataWidthVar then
195
-        Alert(AlertLogIDVar, "MemoryPType.MemRead:  Data'length: " & to_string(Data'length) & " /= Memory Data Width: " & to_string(DataWidthVar), FAILURE) ; 
196
-        Data := (Data'range => 'U') ; 
197
-        return ; 
198
-      end if ; 
199
-
200
-      -- If Addr X, data = X
201
-      if is_X( aAddr ) then
202
-        Data := (Data'range => 'X') ; 
203
-        return ; 
204
-      end if ; 
205
-
206
-      -- Slice out upper address to form block address
207
-      if aAddr'high >= BlockkWidthVar then
208
-        BlockAddr := to_integer(aAddr(aAddr'high downto BlockkWidthVar)) ;
209
-      else
210
-        BlockAddr  := 0 ; 
211
-      end if ; 
212
-      
213
-      -- Empty Block, return all U
214
-      if (ArrayPtrVar(BlockAddr) = NULL) then 
215
-        Data := (Data'range => 'U') ; 
216
-        return ; 
217
-      end if ; 
218
-
219
-      -- Address of a word within a block
220
-      WordAddr := to_integer(aAddr(BlockkWidthVar -1 downto 0)) ;
221
-
222
-      if ArrayPtrVar(BlockAddr)(WordAddr) >= 0 then 
223
-        -- Get the Word from the Array
224
-        Data := to_slv(ArrayPtrVar(BlockAddr)(WordAddr), Data'length) ;
225
-
226
-      elsif ArrayPtrVar(BlockAddr)(WordAddr) = -1 then 
227
-       -- X in Word, return all X
228
-        Data := (Data'range => 'X') ;
229
-
230
-      else 
231
-       -- Location Uninitialized, return all X
232
-        Data := (Data'range => 'U') ;
233
-
234
-      end if ;
235
-    end procedure MemRead ; 
236
-
237
-    ------------------------------------------------------------
238
-    impure function MemRead ( Addr  : std_logic_vector ) return std_logic_vector is
239
-    ------------------------------------------------------------
240
-      variable BlockAddr, WordAddr  : integer ;
241
-      alias    aAddr : std_logic_vector (Addr'length-1 downto 0) is Addr ; 
242
-      variable Data  : std_logic_vector(DataWidthVar-1 downto 0) ; 
243
-    begin
244
-      MemRead(Addr, Data) ; 
245
-      return Data ; 
246
-    end function MemRead ; 
247
-
248
-    ------------------------------------------------------------
249
-    procedure MemErase is 
250
-    -- Deallocate the memory, but not the array of pointers
251
-    ------------------------------------------------------------
252
-    begin
253
-      for BlockAddr in ArrayPtrVar'range loop 
254
-        if (ArrayPtrVar(BlockAddr) /= NULL) then 
255
-          deallocate (ArrayPtrVar(BlockAddr)) ; 
256
-        end if ; 
257
-      end loop ; 
258
-    end procedure ; 
259
-    
260
-    ------------------------------------------------------------
261
-    procedure deallocate is 
262
-    -- Deallocate all allocated memory
263
-    ------------------------------------------------------------
264
-    begin
265
-      MemErase ; 
266
-      deallocate(ArrayPtrVar) ; 
267
-      AddrWidthVar   := -1 ;
268
-      DataWidthVar   := 1 ;
269
-      BlockkWidthVar  := 0 ;
270
-    end procedure ; 
271
-
272
-    ------------------------------------------------------------
273
-    procedure SetAlertLogID (A : AlertLogIDType) is
274
-    ------------------------------------------------------------
275
-    begin
276
-      AlertLogIDVar := A ;
277
-    end procedure SetAlertLogID ;
278
-
279
-    ------------------------------------------------------------
280
-    procedure SetAlertLogID(Name : string ; ParentID : AlertLogIDType := ALERTLOG_BASE_ID ; CreateHierarchy : Boolean := TRUE) is
281
-    ------------------------------------------------------------
282
-    begin
283
-      AlertLogIDVar := GetAlertLogID(Name, ParentID, CreateHierarchy) ;
284
-    end procedure SetAlertLogID ;
285
-    
286
-    ------------------------------------------------------------
287
-    impure function GetAlertLogID return AlertLogIDType is
288
-    ------------------------------------------------------------
289
-    begin
290
-      return AlertLogIDVar ; 
291
-    end function GetAlertLogID ;
292
-    
293
-    ------------------------------------------------------------
294
-    -- PT Local
295
-    procedure FileReadX (
296
-    -- Hexadecimal or Binary File Read 
297
-    ------------------------------------------------------------
298
-      FileName     : string ;
299
-      DataFormat   : FileFormatType ; 
300
-      StartAddr    : std_logic_vector ; 
301
-      EndAddr      : std_logic_vector
302
-    ) is
303
-      -- Format:  
304
-      --  @hh..h     -- Address in hex
305
-      --  hhh_XX_ZZ  -- data values in hex - space delimited 
306
-      --  "--" or "//" -- comments
307
-     file MemFile : text open READ_MODE is FileName ;
308
-
309
-      variable Addr             : std_logic_vector(AddrWidthVar - 1 downto 0) ;
310
-      variable SmallAddr        : std_logic_vector(AddrWidthVar - 1 downto 0) ;
311
-      variable BigAddr          : std_logic_vector(AddrWidthVar - 1 downto 0) ;
312
-      variable Data             : std_logic_vector(DataWidthVar - 1 downto 0) ;
313
-      variable LineNum          : natural ; 
314
-      variable ItemNum          : natural ; 
315
-      variable AddrInc          : std_logic_vector(AddrWidthVar - 1 downto 0) ; 
316
-      variable buf              : line ;
317
-      variable ReadValid        : boolean ;
318
-      variable Empty            : boolean ; 
319
-      variable MultiLineComment : boolean ; 
320
-      variable NextChar         : character ; 
321
-      variable StrLen           : integer ; 
322
-    begin
323
-      MultiLineComment := FALSE ; 
324
-      if StartAddr'length /= AddrWidthVar and EndAddr'length /= AddrWidthVar then
325
-        if (ArrayPtrVar = NULL) then 
326
-          Alert(AlertLogIDVar, "MemoryPType.FileReadX:  Memory not initialized, FileRead Ignored.", FAILURE) ; 
327
-        else
328
-          Alert(AlertLogIDVar, "MemoryPType.FileReadX:  Addr'length: " & to_string(Addr'length) & " /= Memory Address Width: " & to_string(AddrWidthVar), FAILURE) ; 
329
-        end if ; 
330
-        return ; 
331
-      end if ; 
332
-
333
-      Addr    := StartAddr ; 
334
-      LineNum := 0 ; 
335
-      
336
-      if StartAddr <= EndAddr then 
337
-        SmallAddr := StartAddr ; 
338
-        BigAddr   := EndAddr ; 
339
-        AddrInc   := (AddrWidthVar -1 downto 0 => '0') + 1 ;  
340
-      else
341
-        SmallAddr := EndAddr ; 
342
-        BigAddr   := StartAddr ; 
343
-        AddrInc   := (others => '1') ;  -- -1
344
-      end if; 
345
-      
346
-      ReadLineLoop : while not EndFile(MemFile) loop
347
-        ReadLine(MemFile, buf) ;
348
-        LineNum := LineNum + 1 ; 
349
-        ItemNum := 0 ; 
350
-        
351
-        ItemLoop : loop 
352
-          EmptyOrCommentLine(buf, Empty, MultiLineComment) ; 
353
-          exit ItemLoop when Empty ; 
354
-          ItemNum := ItemNum + 1 ; 
355
-          NextChar := buf.all(buf'left) ;
356
-          
357
-          if (NextChar = '@') then 
358
-          -- Get Address
359
-            read(buf, NextChar) ; 
360
-            ReadHexToken(buf, Addr, StrLen) ; 
361
-            exit ReadLineLoop when AlertIf(AlertLogIDVar, StrLen = 0, "MemoryPType.FileReadX: Address length 0 on line: " & to_string(LineNum), FAILURE) ;
362
-            exit ItemLoop when AlertIf(AlertLogIDVar, Addr < SmallAddr, 
363
-                                           "MemoryPType.FileReadX: Address in file: " & to_hstring(Addr) & 
364
-                                           " < StartAddr: " & to_hstring(StartAddr) & " on line: " & to_string(LineNum)) ; 
365
-            exit ItemLoop when AlertIf(AlertLogIDVar, Addr > BigAddr, 
366
-                                           "MemoryPType.FileReadX: Address in file: " & to_hstring(Addr) & 
367
-                                           " > EndAddr: " & to_hstring(BigAddr) & " on line: " & to_string(LineNum)) ; 
368
-          
369
-          elsif DataFormat = HEX and ishex(NextChar) then 
370
-          -- Get Hex Data
371
-            ReadHexToken(buf, data, StrLen) ;
372
-            exit ReadLineLoop when AlertIfNot(AlertLogIDVar, StrLen > 0, 
373
-              "MemoryPType.FileReadH: Error while reading data on line: " & to_string(LineNum) &
374
-              "  Item number: " & to_string(ItemNum), FAILURE) ;
375
-            log("MemoryPType.FileReadX:  MemWrite(Addr => " & to_hstring(Addr) & ", Data => " & to_hstring(Data) & ")", DEBUG) ; 
376
-            MemWrite(Addr, data) ; 
377
-            Addr := Addr + AddrInc ; 
378
-            
379
-          elsif DataFormat = BINARY and isstd_logic(NextChar) then 
380
-          -- Get Binary Data
381
-            -- read(buf, data, ReadValid) ;
382
-            ReadBinaryToken(buf, data, StrLen) ;
383
-            -- exit ReadLineLoop when AlertIfNot(AlertLogIDVar, ReadValid, 
384
-            exit ReadLineLoop when AlertIfNot(AlertLogIDVar, StrLen > 0, 
385
-              "MemoryPType.FileReadB: Error while reading data on line: " & to_string(LineNum) &
386
-              "  Item number: " & to_string(ItemNum), FAILURE) ;
387
-            log("MemoryPType.FileReadX:  MemWrite(Addr => " & to_hstring(Addr) & ", Data => " & to_string(Data) & ")", DEBUG) ; 
388
-            MemWrite(Addr, data) ; 
389
-            Addr := Addr + AddrInc ; 
390
-          
391
-          else
392
-          -- Invalid Text, Issue Warning and skip it
393
-            Alert(AlertLogIDVar,  
394
-              "MemoryPType.FileReadX: Invalid text on line: " & to_string(LineNum) &
395
-              "  Item: " & to_string(ItemNum) & ".  Skipping text: " & buf.all) ;
396
-            exit ItemLoop ; 
397
-          end if ; 
398
-          
399
-        end loop ItemLoop ; 
400
-      end loop ReadLineLoop ; 
401
-      
402
-      file_close(MemFile) ; 
403
-    end FileReadX ;
404
-    
405
-    ------------------------------------------------------------
406
-    procedure FileReadH (
407
-    -- Hexadecimal File Read 
408
-    ------------------------------------------------------------
409
-      FileName     : string ; 
410
-      StartAddr    : std_logic_vector ; 
411
-      EndAddr      : std_logic_vector
412
-    ) is
413
-    begin
414
-      FileReadX(FileName, HEX, StartAddr, EndAddr) ; 
415
-    end FileReadH ;
416
-    
417
-    ------------------------------------------------------------
418
-    procedure FileReadH (FileName : string ;  StartAddr : std_logic_vector) is
419
-    -- Hexadecimal File Read 
420
-    ------------------------------------------------------------
421
-      constant EndAddr : std_logic_vector(AddrWidthVar - 1 downto 0) := (others => '1') ;
422
-    begin
423
-      FileReadX(FileName, HEX, StartAddr, EndAddr) ; 
424
-    end FileReadH ;
425
-
426
-    ------------------------------------------------------------
427
-    procedure FileReadH (FileName : string) is 
428
-    -- Hexadecimal File Read 
429
-    ------------------------------------------------------------
430
-      constant StartAddr : std_logic_vector(AddrWidthVar - 1 downto 0) := (others => '0') ;
431
-      constant EndAddr   : std_logic_vector(AddrWidthVar - 1 downto 0) := (others => '1') ;
432
-    begin
433
-      FileReadX(FileName, HEX, StartAddr, EndAddr) ; 
434
-    end FileReadH ;    
435
-    
436
-     ------------------------------------------------------------
437
-    procedure FileReadB (
438
-    -- Binary File Read 
439
-    ------------------------------------------------------------
440
-      FileName     : string ; 
441
-      StartAddr    : std_logic_vector ; 
442
-      EndAddr      : std_logic_vector
443
-    ) is
444
-    begin
445
-      FileReadX(FileName, BINARY, StartAddr, EndAddr) ; 
446
-    end FileReadB ;
447
-    
448
-    ------------------------------------------------------------
449
-    procedure FileReadB (FileName : string ;  StartAddr : std_logic_vector) is
450
-    -- Binary File Read 
451
-    ------------------------------------------------------------
452
-      constant EndAddr : std_logic_vector(AddrWidthVar - 1 downto 0) := (others => '1') ;
453
-    begin
454
-      FileReadX(FileName, BINARY, StartAddr, EndAddr) ; 
455
-    end FileReadB ;
456
-
457
-    ------------------------------------------------------------
458
-    procedure FileReadB (FileName : string) is 
459
-    -- Binary File Read 
460
-    ------------------------------------------------------------
461
-      constant StartAddr : std_logic_vector(AddrWidthVar - 1 downto 0) := (others => '0') ;
462
-      constant EndAddr   : std_logic_vector(AddrWidthVar - 1 downto 0) := (others => '1') ;
463
-    begin
464
-      FileReadX(FileName, BINARY, StartAddr, EndAddr) ; 
465
-    end FileReadB ;    
466
-
467
-    ------------------------------------------------------------
468
-    -- PT Local
469
-    procedure FileWriteX (
470
-    -- Hexadecimal or Binary File Write 
471
-    ------------------------------------------------------------
472
-      FileName     : string ; 
473
-      DataFormat   : FileFormatType ; 
474
-      StartAddr    : std_logic_vector ; 
475
-      EndAddr      : std_logic_vector
476
-    ) is
477
-      -- Format:  
478
-      --  @hh..h     -- Address in hex
479
-      --  hhhhh      -- data one per line in either hex or binary as specified 
480
-      file MemFile : text open WRITE_MODE is FileName ;
481
-      alias normStartAddr     : std_logic_vector(StartAddr'length-1 downto 0) is StartAddr ; 
482
-      alias normEndAddr       : std_logic_vector(EndAddr'length-1 downto 0) is EndAddr ; 
483
-      variable StartBlockAddr : natural ;
484
-      variable EndBlockAddr   : natural ;
485
-      variable StartWordAddr  : natural ; 
486
-      variable EndWordAddr    : natural ; 
487
-      variable Data           : std_logic_vector(DataWidthVar - 1 downto 0) ;
488
-      variable FoundData      : boolean ; 
489
-      variable buf            : line ;
490
-    begin
491
-      if StartAddr'length /= AddrWidthVar and EndAddr'length /= AddrWidthVar then
492
-      -- Check StartAddr and EndAddr Widths and Memory not initialized
493
-        if (ArrayPtrVar = NULL) then 
494
-          Alert(AlertLogIDVar, "MemoryPType.FileWriteX:  Memory not initialized, FileRead Ignored.", FAILURE) ; 
495
-        else
496
-          AlertIf(AlertLogIDVar, StartAddr'length /= AddrWidthVar, "MemoryPType.FileWriteX:  StartAddr'length: " 
497
-                               & to_string(StartAddr'length) & 
498
-                               " /= Memory Address Width: " & to_string(AddrWidthVar), FAILURE) ; 
499
-          AlertIf(AlertLogIDVar, EndAddr'length /= AddrWidthVar, "MemoryPType.FileWriteX:  EndAddr'length: " 
500
-                               & to_string(EndAddr'length) & 
501
-                               " /= Memory Address Width: " & to_string(AddrWidthVar), FAILURE) ; 
502
-        end if ; 
503
-        return ; 
504
-      end if ; 
505
-
506
-      if StartAddr > EndAddr then 
507
-      -- Only support ascending addresses
508
-        Alert(AlertLogIDVar, "MemoryPType.FileWriteX:  StartAddr: " & to_hstring(StartAddr) & 
509
-                             " > EndAddr: " & to_hstring(EndAddr), FAILURE) ;
510
-        return ; 
511
-      end if ; 
512
-            
513
-      -- Slice out upper address to form block address
514
-      if AddrWidthVar >= BlockkWidthVar then
515
-        StartBlockAddr := to_integer(normStartAddr(AddrWidthVar-1 downto BlockkWidthVar)) ;
516
-        EndBlockAddr   := to_integer(  normEndAddr(AddrWidthVar-1 downto BlockkWidthVar)) ;
517
-      else
518
-        StartBlockAddr  := 0 ; 
519
-        EndBlockAddr  := 0 ; 
520
-      end if ; 
521
-            
522
-      BlockAddrLoop : for BlockAddr in StartBlockAddr to EndBlockAddr loop 
523
-        next BlockAddrLoop when ArrayPtrVar(BlockAddr) = NULL ;  
524
-        if BlockAddr = StartBlockAddr then 
525
-          StartWordAddr := to_integer(normStartAddr(BlockkWidthVar-1 downto 0)) ; 
526
-        else
527
-          StartWordAddr := 0 ;
528
-        end if ; 
529
-        if BlockAddr = EndBlockAddr then 
530
-          EndWordAddr := to_integer(normEndAddr(BlockkWidthVar-1 downto 0)) ; 
531
-        else 
532
-          EndWordAddr := 2**BlockkWidthVar-1 ;
533
-        end if ; 
534
-        FoundData := FALSE ; 
535
-        WordAddrLoop : for WordAddr in StartWordAddr to EndWordAddr loop 
536
-          if (ArrayPtrVar(BlockAddr)(WordAddr) < 0) then 
537
-            -- X in Word, return all X
538
-            Data := (Data'range => 'X') ;
539
-            FoundData := FALSE ;
540
-          else 
541
-            -- Get the Word from the Array
542
-            Data := to_slv(ArrayPtrVar(BlockAddr)(WordAddr), Data'length) ;
543
-            if not FoundData then
544
-              -- Write Address
545
-              write(buf, '@') ; 
546
-              hwrite(buf, to_slv(BlockAddr, AddrWidthVar-BlockkWidthVar) & to_slv(WordAddr, BlockkWidthVar)) ; 
547
-              writeline(MemFile, buf) ; 
548
-            end if ; 
549
-            FoundData := TRUE ; 
550
-          end if ;
551
-          if FoundData then  -- Write Data
552
-            if DataFormat = HEX then
553
-              hwrite(buf, Data) ; 
554
-              writeline(MemFile, buf) ; 
555
-            else
556
-              write(buf, Data) ; 
557
-              writeline(MemFile, buf) ; 
558
-            end if; 
559
-          end if ;                
560
-        end loop WordAddrLoop ; 
561
-      end loop BlockAddrLoop ;       
562
-      file_close(MemFile) ; 
563
-    end FileWriteX ;
564
-    
565
-    ------------------------------------------------------------
566
-    procedure FileWriteH (
567
-    -- Hexadecimal File Write 
568
-    ------------------------------------------------------------
569
-      FileName     : string ; 
570
-      StartAddr    : std_logic_vector ; 
571
-      EndAddr      : std_logic_vector
572
-    ) is
573
-    begin
574
-      FileWriteX(FileName, HEX, StartAddr, EndAddr) ; 
575
-    end FileWriteH ;
576
-    
577
-    ------------------------------------------------------------
578
-    procedure FileWriteH (FileName : string ;  StartAddr : std_logic_vector) is
579
-    -- Hexadecimal File Write 
580
-    ------------------------------------------------------------
581
-      constant EndAddr : std_logic_vector(AddrWidthVar - 1 downto 0) := (others => '1') ;
582
-    begin
583
-      FileWriteX(FileName, HEX, StartAddr, EndAddr) ; 
584
-    end FileWriteH ;
585
-
586
-    ------------------------------------------------------------
587
-    procedure FileWriteH (FileName : string) is 
588
-    -- Hexadecimal File Write 
589
-    ------------------------------------------------------------
590
-      constant StartAddr : std_logic_vector(AddrWidthVar - 1 downto 0) := (others => '0') ;
591
-      constant EndAddr   : std_logic_vector(AddrWidthVar - 1 downto 0) := (others => '1') ;
592
-    begin
593
-      FileWriteX(FileName, HEX, StartAddr, EndAddr) ; 
594
-    end FileWriteH ;    
595
-    
596
-     ------------------------------------------------------------
597
-    procedure FileWriteB (
598
-    -- Binary File Write 
599
-    ------------------------------------------------------------
600
-      FileName     : string ; 
601
-      StartAddr    : std_logic_vector ; 
602
-      EndAddr      : std_logic_vector
603
-    ) is
604
-    begin
605
-      FileWriteX(FileName, BINARY, StartAddr, EndAddr) ; 
606
-    end FileWriteB ;
607
-    
608
-    ------------------------------------------------------------
609
-    procedure FileWriteB (FileName : string ;  StartAddr : std_logic_vector) is
610
-    -- Binary File Write 
611
-    ------------------------------------------------------------
612
-      constant EndAddr : std_logic_vector(AddrWidthVar - 1 downto 0) := (others => '1') ;
613
-    begin
614
-      FileWriteX(FileName, BINARY, StartAddr, EndAddr) ; 
615
-    end FileWriteB ;
616
-
617
-    ------------------------------------------------------------
618
-    procedure FileWriteB (FileName : string) is 
619
-    -- Binary File Write 
620
-    ------------------------------------------------------------
621
-      constant StartAddr : std_logic_vector(AddrWidthVar - 1 downto 0) := (others => '0') ;
622
-      constant EndAddr   : std_logic_vector(AddrWidthVar - 1 downto 0) := (others => '1') ;
623
-    begin
624
-      FileWriteX(FileName, BINARY, StartAddr, EndAddr) ; 
625
-    end FileWriteB ;    
626
-    
627
-  end protected body MemoryPType ;
628
- 
629
-end MemoryPkg ;

+ 0
- 130
OSVVM/MessagePkg.vhd View File

@@ -1,165 +0,0 @@
1
---
2
---
3
---
4
---
5
---
6
---
7
---
8
---
9
---
10
---
11
---
12
---
13
---
14
---
15
-use work.OsvvmGlobalPkg.all ; 
16
-use work.AlertLogPkg.all ; 
17
-
18
-library ieee ;
19
-use ieee.std_logic_1164.all ;
20
-use ieee.numeric_std.all ;
21
-use ieee.math_real.all ;
22
-use std.textio.all ;
23
-
24
-package MessagePkg is
25
-
26
-  type MessagePType is protected
27
-
28
-    procedure Set (MessageIn : String) ;
29
-    impure function Get (ItemNumber : integer) return string ; 
30
-    impure function GetCount return integer ; 
31
-    impure function IsSet return boolean ; 
32
-    procedure Clear ; -- clear message
33
-    procedure Deallocate ; -- clear message
34
-        
35
-  end protected MessagePType ;
36
-  
37
-end package MessagePkg ;
38
-
39
---- ///////////////////////////////////////////////////////////////////////////
40
---- ///////////////////////////////////////////////////////////////////////////
41
---- ///////////////////////////////////////////////////////////////////////////
42
-
43
-package body MessagePkg is
44
-
45
-  -- Local Data Structure Types
46
-  type LineArrayType is array (natural range <>) of line ; 
47
-  type LineArrayPtrType is access LineArrayType ;
48
-
49
-  type MessagePType is protected body
50
-  
51
-    variable MessageCount : integer := 0 ; 
52
-    constant INITIAL_ITEM_COUNT : integer := 16 ; 
53
-    variable MaxMessageCount : integer := 0 ; 
54
-    variable MessagePtr : LineArrayPtrType ; 
55
-
56
-    ------------------------------------------------------------
57
-    procedure Set (MessageIn : String) is
58
-    ------------------------------------------------------------
59
-      variable NamePtr : line ;
60
-      variable OldMaxMessageCount : integer ;
61
-      variable OldMessagePtr : LineArrayPtrType ; 
62
-    begin
63
-      MessageCount := MessageCount + 1 ; 
64
-      if MessageCount > MaxMessageCount then
65
-        OldMaxMessageCount := MaxMessageCount ; 
66
-        MaxMessageCount := MaxMessageCount + INITIAL_ITEM_COUNT ; 
67
-        OldMessagePtr := MessagePtr ;
68
-        MessagePtr := new LineArrayType(1 to MaxMessageCount) ; 
69
-        for i in 1 to OldMaxMessageCount loop
70
-          MessagePtr(i) := OldMessagePtr(i) ; 
71
-        end loop ;
72
-        Deallocate( OldMessagePtr ) ;
73
-      end if ; 
74
-      MessagePtr(MessageCount) := new string'(MessageIn) ;
75
-    end procedure Set ; 
76
-
77
-    ------------------------------------------------------------
78
-    impure function Get (ItemNumber : integer) return string is
79
-    ------------------------------------------------------------
80
-    begin
81
-      if MessageCount > 0 then 
82
-        if ItemNumber >= 1 and ItemNumber <= MessageCount then 
83
-          return MessagePtr(ItemNumber).all ; 
84
-        else
85
-          Alert(OSVVM_ALERTLOG_ID, "%% MessagePkg.Get input value out of range", FAILURE) ; 
86
-          return "" ; -- error if this happens 
87
-        end if ; 
88
-      else 
89
-        Alert(OSVVM_ALERTLOG_ID, "%% MessagePkg.Get message is not set", FAILURE) ; 
90
-        return "" ; -- error if this happens 
91
-      end if ;
92
-    end function Get ; 
93
-
94
-    ------------------------------------------------------------
95
-    impure function GetCount return integer is 
96
-    ------------------------------------------------------------
97
-    begin
98
-      return MessageCount ; 
99
-    end function GetCount ; 
100
-
101
-    ------------------------------------------------------------
102
-    impure function IsSet return boolean is 
103
-    ------------------------------------------------------------
104
-    begin
105
-      return MessageCount > 0 ; 
106
-    end function IsSet ;      
107
-
108
-    ------------------------------------------------------------
109
-    procedure Deallocate is  -- clear message
110
-    ------------------------------------------------------------
111
-      variable CurPtr : LineArrayPtrType ;
112
-    begin
113
-      for i in 1 to MessageCount loop 
114
-        deallocate( MessagePtr(i) ) ; 
115
-      end loop ; 
116
-      MessageCount := 0 ; 
117
-      MaxMessageCount := 0 ; 
118
-      deallocate( MessagePtr ) ; 
119
-    end procedure Deallocate ;
120
-
121
-    ------------------------------------------------------------
122
-    procedure Clear is  -- clear 
123
-    ------------------------------------------------------------
124
-    begin
125
-      Deallocate ;
126
-    end procedure Clear ;
127
-
128
-  end protected body MessagePType ;
129
-  
130
-end package body MessagePkg ;

+ 0
- 93
OSVVM/NamePkg.vhd View File

@@ -1,129 +0,0 @@
1
---
2
---
3
---
4
---
5
---
6
---
7
---
8
---
9
---
10
---
11
---
12
---
13
---
14
---
15
-
16
-use std.textio.all ;
17
-
18
-package NamePkg is
19
-
20
-  type NamePType is protected
21
-    procedure Set (NameIn : String) ;
22
-    impure function Get (DefaultName : string := "") return string ;
23
-    impure function GetOpt return string ;
24
-    impure function IsSet return boolean ; 
25
-    procedure Clear ; -- clear name
26
-    procedure Deallocate ; -- effectively alias to clear name
27
-  end protected NamePType ;
28
-
29
-end package NamePkg ;
30
-
31
---- ///////////////////////////////////////////////////////////////////////////
32
---- ///////////////////////////////////////////////////////////////////////////
33
---- ///////////////////////////////////////////////////////////////////////////
34
-
35
-package body NamePkg is
36
-  type NamePType is protected body
37
-  
38
-    variable NamePtr   : line ;
39
-
40
-    ------------------------------------------------------------
41
-    procedure Set (NameIn : String) is
42
-    ------------------------------------------------------------
43
-    begin
44
-      deallocate(NamePtr) ;
45
-      NamePtr := new string'(NameIn) ;
46
-    end procedure Set ;
47
-
48
-    ------------------------------------------------------------
49
-    impure function Get (DefaultName : string := "") return string is
50
-    ------------------------------------------------------------
51
-    begin
52
-      if NamePtr = NULL then 
53
-        return DefaultName ; 
54
-      else
55
-        return NamePtr.all ; 
56
-      end if ; 
57
-    end function Get ;
58
-
59
-    ------------------------------------------------------------
60
-    impure function GetOpt return string is
61
-    ------------------------------------------------------------
62
-    begin
63
-      if NamePtr = NULL then 
64
-        return NUL & "" ; 
65
-      else
66
-        return NamePtr.all ; 
67
-      end if ; 
68
-    end function GetOpt ;
69
-
70
-    ------------------------------------------------------------
71
-    impure function IsSet return boolean is 
72
-    ------------------------------------------------------------
73
-    begin
74
-      return NamePtr /= NULL ; 
75
-    end function IsSet ;      
76
-    
77
-    ------------------------------------------------------------
78
-    procedure Clear is  -- clear name
79
-    ------------------------------------------------------------
80
-    begin
81
-      deallocate(NamePtr) ;
82
-    end procedure Clear ;
83
-    
84
-    ------------------------------------------------------------
85
-    procedure Deallocate is  -- clear name
86
-    ------------------------------------------------------------
87
-    begin
88
-      Clear ; 
89
-    end procedure Deallocate ;
90
-
91
-  end protected body NamePType ;
92
-
93
-end package body NamePkg ;

+ 0
- 31
OSVVM/OsvvmContext.vhd View File

@@ -1,63 +0,0 @@
1
---
2
---
3
---
4
---
5
---
6
---
7
---
8
---
9
---
10
---
11
---
12
---
13
---
14
---
15
-
16
-context OsvvmContext is
17
-    library OSVVM ;  
18
-
19
-    use OSVVM.NamePkg.all ;
20
-    use OSVVM.TranscriptPkg.all ; 
21
-    use OSVVM.TextUtilPkg.all ; 
22
-    use OSVVM.OsvvmGlobalPkg.all ;
23
-    use OSVVM.AlertLogPkg.all ; 
24
-    use OSVVM.RandomPkg.all ;
25
-    use OSVVM.CoveragePkg.all ;
26
-    use OSVVM.MemoryPkg.all ;
27
-    use OSVVM.ResolutionPkg.all ;
28
-    use OSVVM.TbUtilPkg.all ;
29
-
30
-end context OsvvmContext ; 
31
-

+ 0
- 319
OSVVM/OsvvmGlobalPkg.vhd View File

@@ -1,350 +0,0 @@
1
---
2
---
3
---
4
---
5
---
6
---
7
---
8
---
9
---
10
---
11
---
12
---
13
---
14
---
15
-
16
-library ieee ;
17
-use std.textio.all ;
18
-
19
-use work.NamePkg.all ; 
20
-
21
-package OsvvmGlobalPkg is
22
-  -- FILE IO Global File Identifier -- Open using AlertLogPkg.TranscriptOpen
23
-
24
-  -- Shared Options Type used in OSVVM
25
-  type OsvvmOptionsType is (OPT_INIT_PARM_DETECT, OPT_USE_DEFAULT, DISABLED, FALSE, ENABLED, TRUE) ;
26
-  function IsEnabled (A : OsvvmOptionsType) return boolean ;  -- Requires that TRUE is last and ENABLED is 2nd to last
27
-  function to_OsvvmOptionsType (A : boolean) return OsvvmOptionsType ;
28
-
29
-  -- Defaults for String values
30
-  constant OSVVM_DEFAULT_ALERT_PREFIX     : string := "%% Alert" ;
31
-  constant OSVVM_DEFAULT_LOG_PREFIX       : string := "%% Log  " ;
32
-  constant OSVVM_DEFAULT_WRITE_PREFIX     : string := "%% " ;
33
-  constant OSVVM_DEFAULT_DONE_NAME        : string := "DONE" ;
34
-  constant OSVVM_DEFAULT_PASS_NAME        : string := "PASSED" ;
35
-  constant OSVVM_DEFAULT_FAIL_NAME        : string := "FAILED" ;
36
-  constant OSVVM_STRING_INIT_PARM_DETECT  : string := NUL & NUL & NUL ; 
37
-  constant OSVVM_STRING_USE_DEFAULT       : string := NUL & "" ; 
38
-
39
-  -- Coverage Settings
40
-  constant OSVVM_DEFAULT_WRITE_PASS_FAIL   : OsvvmOptionsType := FALSE ;
41
-  constant OSVVM_DEFAULT_WRITE_BIN_INFO    : OsvvmOptionsType := TRUE ;
42
-  constant OSVVM_DEFAULT_WRITE_COUNT       : OsvvmOptionsType := TRUE ;
43
-  constant OSVVM_DEFAULT_WRITE_ANY_ILLEGAL : OsvvmOptionsType := FALSE ;
44
-
45
-  ------------------------------------------------------------
46
-  procedure SetOsvvmGlobalOptions (
47
-  ------------------------------------------------------------
48
-    WritePassFail   : OsvvmOptionsType := OPT_INIT_PARM_DETECT ;
49
-    WriteBinInfo    : OsvvmOptionsType := OPT_INIT_PARM_DETECT ;
50
-    WriteCount      : OsvvmOptionsType := OPT_INIT_PARM_DETECT ;
51
-    WriteAnyIllegal : OsvvmOptionsType := OPT_INIT_PARM_DETECT ;
52
-    WritePrefix     : string := OSVVM_STRING_INIT_PARM_DETECT ;
53
-    DoneName        : string := OSVVM_STRING_INIT_PARM_DETECT ;
54
-    PassName        : string := OSVVM_STRING_INIT_PARM_DETECT ;
55
-    FailName        : string := OSVVM_STRING_INIT_PARM_DETECT
56
-  ) ;
57
-  
58
-  ------------------------------------------------------------
59
-  -- Accessor Functions
60
-  function ResolveOsvvmOption(A, B, C : OsvvmOptionsType) return OsvvmOptionsType ; 
61
-  function ResolveOsvvmOption(A, B, C, D : OsvvmOptionsType) return OsvvmOptionsType ; 
62
-  function IsOsvvmStringSet (A : string) return boolean ;
63
-  function ResolveOsvvmOption(A, B : string) return string ; 
64
-  function ResolveOsvvmOption(A, B, C : string) return string ; 
65
-  function ResolveOsvvmOption(A, B, C, D : string) return string ; 
66
-  
67
-  impure function ResolveOsvvmWritePrefix(A : String)  return string ; 
68
-  impure function ResolveOsvvmWritePrefix(A, B : String)  return string ; 
69
-  impure function ResolveOsvvmDoneName(A : String)  return string ; 
70
-  impure function ResolveOsvvmDoneName(A, B : String)  return string ; 
71
-  impure function ResolveOsvvmPassName(A : String)  return string ; 
72
-  impure function ResolveOsvvmPassName(A, B : String)  return string ; 
73
-  impure function ResolveOsvvmFailName(A : String)  return string ; 
74
-  impure function ResolveOsvvmFailName(A, B : String)  return string ; 
75
-
76
-  impure function ResolveCovWritePassFail(A, B : OsvvmOptionsType) return OsvvmOptionsType ;  -- Cov
77
-  impure function ResolveCovWriteBinInfo(A, B : OsvvmOptionsType) return OsvvmOptionsType ; -- Cov
78
-  impure function ResolveCovWriteCount(A, B : OsvvmOptionsType) return OsvvmOptionsType ; -- Cov
79
-  impure function ResolveCovWriteAnyIllegal(A, B : OsvvmOptionsType) return OsvvmOptionsType ;  -- Cov
80
-  
81
-  procedure OsvvmDeallocate ;
82
-  
83
-  type OptionsPType is protected 
84
-    procedure Set (A: OsvvmOptionsType) ; 
85
-    impure function get return OsvvmOptionsType ;
86
-  end protected OptionsPType ;
87
-end OsvvmGlobalPkg ;
88
-
89
---- ///////////////////////////////////////////////////////////////////////////
90
---- ///////////////////////////////////////////////////////////////////////////
91
---- ///////////////////////////////////////////////////////////////////////////
92
-
93
-package body OsvvmGlobalPkg is
94
-  type OptionsPType is protected body
95
-    variable GlobalVar : OsvvmOptionsType ; 
96
-    procedure Set (A : OsvvmOptionsType) is
97
-    begin
98
-       GlobalVar := A ; 
99
-    end procedure Set ; 
100
-    impure function get return OsvvmOptionsType is
101
-    begin
102
-      return GlobalVar ; 
103
-    end function get ; 
104
-  end protected body OptionsPType ; 
105
-  
106
-  shared variable WritePrefixVar     : NamePType ;
107
-  shared variable DoneNameVar        : NamePType ;
108
-  shared variable PassNameVar        : NamePType ;
109
-  shared variable FailNameVar        : NamePType ;
110
-  shared variable WritePassFailVar   : OptionsPType ; -- := FALSE ;
111
-  shared variable WriteBinInfoVar    : OptionsPType ; -- := TRUE ;
112
-  shared variable WriteCountVar      : OptionsPType ; -- := TRUE ;
113
-  shared variable WriteAnyIllegalVar : OptionsPType ; -- := FALSE ;
114
-
115
-  function IsEnabled (A : OsvvmOptionsType) return boolean is
116
-  begin
117
-    return A >= ENABLED ; 
118
-  end function IsEnabled ; 
119
-  
120
-  function to_OsvvmOptionsType (A : boolean) return OsvvmOptionsType is
121
-  begin
122
-    if A then 
123
-      return TRUE ; 
124
-    else 
125
-      return FALSE ;
126
-    end if ; 
127
-  end function to_OsvvmOptionsType ; 
128
-  
129
-
130
-  ------------------------------------------------------------
131
-  procedure SetOsvvmGlobalOptions (
132
-  ------------------------------------------------------------
133
-    WritePassFail   : OsvvmOptionsType := OPT_INIT_PARM_DETECT ;
134
-    WriteBinInfo    : OsvvmOptionsType := OPT_INIT_PARM_DETECT ;
135
-    WriteCount      : OsvvmOptionsType := OPT_INIT_PARM_DETECT ;
136
-    WriteAnyIllegal : OsvvmOptionsType := OPT_INIT_PARM_DETECT ;
137
-    WritePrefix     : string := OSVVM_STRING_INIT_PARM_DETECT ;
138
-    DoneName        : string := OSVVM_STRING_INIT_PARM_DETECT ;
139
-    PassName        : string := OSVVM_STRING_INIT_PARM_DETECT ;
140
-    FailName        : string := OSVVM_STRING_INIT_PARM_DETECT
141
-  ) is
142
-  begin
143
-    if WritePassFail /= OPT_INIT_PARM_DETECT then
144
-      WritePassFailVar.Set(WritePassFail) ;
145
-    end if ;
146
-    if WriteBinInfo /= OPT_INIT_PARM_DETECT then
147
-      WriteBinInfoVar.Set(WriteBinInfo) ;
148
-    end if ;
149
-    if WriteCount /= OPT_INIT_PARM_DETECT then
150
-      WriteCountVar.Set(WriteCount) ;
151
-    end if ;
152
-    if WriteAnyIllegal /= OPT_INIT_PARM_DETECT then
153
-      WriteAnyIllegalVar.Set(WriteAnyIllegal) ;
154
-    end if ;
155
-    if WritePrefix /= OSVVM_STRING_INIT_PARM_DETECT then
156
-      WritePrefixVar.Set(WritePrefix) ; 
157
-    end if ;
158
-    if DoneName /= OSVVM_STRING_INIT_PARM_DETECT then
159
-      DoneNameVar.Set(DoneName) ; 
160
-    end if ;
161
-    if PassName /= OSVVM_STRING_INIT_PARM_DETECT then
162
-      PassNameVar.Set(PassName) ; 
163
-    end if ;
164
-    if FailName /= OSVVM_STRING_INIT_PARM_DETECT then
165
-      FailNameVar.Set(FailName) ; 
166
-    end if ;
167
-  end procedure SetOsvvmGlobalOptions ;  
168
-
169
-  ------------------------------------------------------------
170
-  -- Accessor Functions
171
-  -- Local Function
172
-  function IsOsvvmOptionSet (A : OsvvmOptionsType) return boolean is
173
-  begin
174
-    return A > OPT_USE_DEFAULT ; 
175
-  end function IsOsvvmOptionSet ;
176
-
177
-  function ResolveOsvvmOption(A, B, C : OsvvmOptionsType) return OsvvmOptionsType is
178
-  begin
179
-    if IsOsvvmOptionSet(A) then
180
-      return A ;
181
-    elsif IsOsvvmOptionSet(B) then
182
-      return B ;
183
-    else
184
-      return C ;
185
-    end if ;
186
-  end function ResolveOsvvmOption ;
187
- 
188
-  function ResolveOsvvmOption(A, B, C, D : OsvvmOptionsType) return OsvvmOptionsType is
189
-  begin
190
-    if IsOsvvmOptionSet(A) then
191
-      return A ;
192
-    elsif IsOsvvmOptionSet(B) then
193
-      return B ;
194
-    elsif IsOsvvmOptionSet(C) then
195
-      return C ;
196
-    else
197
-      return D ;
198
-    end if ;
199
-  end function ResolveOsvvmOption ;
200
-  
201
-  -- Local Function
202
-  function IsOsvvmStringSet (A : string) return boolean is
203
-  begin
204
-    if A'length = 0 then   -- Null strings permitted
205
-      return TRUE ;     
206
-    else 
207
-      return A(A'left) /= NUL ;
208
-    end if; 
209
-  end function IsOsvvmStringSet ;
210
-  
211
-  function ResolveOsvvmOption(A, B : string) return string is
212
-  begin
213
-    if IsOsvvmStringSet(A) then
214
-      return A ;
215
-    else
216
-      return B ;
217
-    end if ;
218
-  end function ResolveOsvvmOption ; 
219
-  
220
-  function ResolveOsvvmOption(A, B, C : string) return string is
221
-  begin
222
-    if IsOsvvmStringSet(A) then
223
-      return A ;
224
-    elsif IsOsvvmStringSet(B) then
225
-      return B ;
226
-    else
227
-      return C ;
228
-    end if ;
229
-  end function ResolveOsvvmOption ; 
230
-  
231
-  function ResolveOsvvmOption(A, B, C, D : string) return string is
232
-  begin
233
-    if IsOsvvmStringSet(A) then
234
-      return A ;
235
-    elsif IsOsvvmStringSet(B) then
236
-      return B ;
237
-    elsif IsOsvvmStringSet(C) then
238
-      return C ;
239
-    else
240
-      return D ;
241
-    end if ;
242
-  end function ResolveOsvvmOption ;
243
-  
244
-
245
-  impure function ResolveOsvvmWritePrefix(A : String)  return string is
246
-  begin
247
-    return ResolveOsvvmOption(A, WritePrefixVar.GetOpt, OSVVM_DEFAULT_WRITE_PREFIX) ;
248
-  end function ResolveOsvvmWritePrefix ; 
249
-  
250
-  impure function ResolveOsvvmWritePrefix(A, B : String)  return string is
251
-  begin
252
-    return ResolveOsvvmOption(A, B, WritePrefixVar.GetOpt, OSVVM_DEFAULT_WRITE_PREFIX) ;
253
-  end function ResolveOsvvmWritePrefix ; 
254
-  
255
-  impure function ResolveOsvvmDoneName(A : String)  return string is
256
-  begin
257
-    return ResolveOsvvmOption(A, DoneNameVar.GetOpt, OSVVM_DEFAULT_DONE_NAME) ;
258
-  end function ResolveOsvvmDoneName ; 
259
-  
260
-  impure function ResolveOsvvmDoneName(A, B : String)  return string is
261
-  begin
262
-    return ResolveOsvvmOption(A, DoneNameVar.GetOpt, OSVVM_DEFAULT_DONE_NAME) ;
263
-  end function ResolveOsvvmDoneName ; 
264
-  
265
-  impure function ResolveOsvvmPassName(A : String)  return string is
266
-  begin
267
-    return ResolveOsvvmOption(A, PassNameVar.GetOpt, OSVVM_DEFAULT_PASS_NAME) ;
268
-  end function ResolveOsvvmPassName ; 
269
-  
270
-  impure function ResolveOsvvmPassName(A, B : String)  return string is
271
-  begin
272
-    return ResolveOsvvmOption(A, B, PassNameVar.GetOpt, OSVVM_DEFAULT_PASS_NAME) ;
273
-  end function ResolveOsvvmPassName ; 
274
-  
275
-  impure function ResolveOsvvmFailName(A : String)  return string is
276
-  begin
277
-    return ResolveOsvvmOption(A, FailNameVar.GetOpt, OSVVM_DEFAULT_FAIL_NAME) ;
278
-  end function ResolveOsvvmFailName ;  
279
- 
280
-  impure function ResolveOsvvmFailName(A, B : String)  return string is
281
-  begin
282
-    return ResolveOsvvmOption(A, B, FailNameVar.GetOpt, OSVVM_DEFAULT_FAIL_NAME) ;
283
-  end function ResolveOsvvmFailName ;  
284
-
285
-  impure function ResolveCovWritePassFail(A, B : OsvvmOptionsType) return OsvvmOptionsType is
286
-  begin
287
-    return ResolveOsvvmOption(A, B, WritePassFailVar.Get, OSVVM_DEFAULT_WRITE_PASS_FAIL) ;
288
-  end function ResolveCovWritePassFail ;  -- Cov
289
-  
290
-  impure function ResolveCovWriteBinInfo(A, B : OsvvmOptionsType) return OsvvmOptionsType is
291
-  begin
292
-    return ResolveOsvvmOption(A, B, WriteBinInfoVar.Get, OSVVM_DEFAULT_WRITE_BIN_INFO) ;
293
-  end function ResolveCovWriteBinInfo ;  -- Cov
294
-
295
-  impure function ResolveCovWriteCount(A, B : OsvvmOptionsType) return OsvvmOptionsType is
296
-  begin
297
-    return ResolveOsvvmOption(A, B, WriteCountVar.Get, OSVVM_DEFAULT_WRITE_COUNT) ;
298
-  end function ResolveCovWriteCount ;  -- Cov
299
-
300
-  impure function ResolveCovWriteAnyIllegal(A, B : OsvvmOptionsType) return OsvvmOptionsType is
301
-  begin
302
-    return ResolveOsvvmOption(A, B, WriteAnyIllegalVar.Get, OSVVM_DEFAULT_WRITE_ANY_ILLEGAL) ;
303
-  end function ResolveCovWriteAnyIllegal ;  -- Cov
304
-  
305
-  procedure OsvvmDeallocate is
306
-  begin
307
-    -- Free up space used by NamePType within OsvvmGlobalPkg
308
-    WritePrefixVar.Deallocate ;
309
-    DoneNameVar.Deallocate ;
310
-    PassNameVar.Deallocate ;
311
-    FailNameVar.Deallocate ;
312
-    WritePassFailVar.Set(FALSE) ; -- := FALSE ;
313
-    WriteBinInfoVar.Set(TRUE ) ; -- := TRUE  ;
314
-    WriteCountVar.Set(TRUE ) ; -- := TRUE  ;
315
-    WriteAnyIllegalVar.Set(FALSE) ; -- := FALSE ;
316
-
317
-  end procedure OsvvmDeallocate ; 
318
-   
319
-end package body OsvvmGlobalPkg ;

+ 0
- 183
OSVVM/RandomBasePkg.vhd View File

@@ -1,234 +0,0 @@
1
---
2
---
3
---
4
---
5
---
6
---
7
---
8
---
9
---
10
---
11
---
12
---
13
---
14
---
15
---
16
-
17
-library ieee ;
18
-use ieee.math_real.all ;
19
-use std.textio.all ;
20
-
21
-use work.OsvvmGlobalPkg.all ; 
22
-use work.AlertLogPkg.all ; 
23
-
24
-
25
-
26
-package RandomBasePkg is
27
-
28
-  -- RandomSeedType and Uniform can be replaced by any procedure that
29
-  -- produces a uniform distribution with 0 <= Value < 1  or  0 < Value < 1
30
-  -- and maintains the same call interface
31
-  type RandomSeedType is array (1 to 2) of integer ;
32
-  procedure Uniform (Result : out real ;  Seed : inout RandomSeedType) ;
33
-
34
-  -- Translate from integer_vector, integer, or string to RandomSeedType
35
-  -- Required by RandomPkg.InitSeed
36
-  -- GenRandSeed makes sure all values are in a valid range
37
-  impure function  GenRandSeed(IV : integer_vector) return RandomSeedType ;
38
-  impure function  GenRandSeed(I : integer) return RandomSeedType ;
39
-  impure function  GenRandSeed(S : string) return RandomSeedType ;
40
-  
41
-  -- IO for RandomSeedType.  If use subtype, then create aliases here
42
-  -- in a similar fashion VHDL-2008 std_logic_textio.
43
-  -- Not required by RandomPkg
44
-  function  to_string(A : RandomSeedType) return string ;
45
-  procedure write(variable L: inout line ; A : RandomSeedType ) ;
46
-  procedure read (variable L: inout line ; A : out RandomSeedType ; good : out boolean ) ;
47
-  procedure read (variable L: inout line ; A : out RandomSeedType ) ;
48
-
49
-end RandomBasePkg ;
50
-
51
---- ///////////////////////////////////////////////////////////////////////////
52
---- ///////////////////////////////////////////////////////////////////////////
53
---- ///////////////////////////////////////////////////////////////////////////
54
-
55
-package body RandomBasePkg is
56
-
57
-  -----------------------------------------------------------------
58
-  -- Uniform
59
-  --   Generate a random number with a Uniform distribution
60
-  --   Required by RandomPkg.  All randomization is derived from here.
61
-  --   Value produced must be either: 
62
-  --     0 <= Value < 1  or  0 < Value < 1
63
-  --
64
-  --   Current version uses ieee.math_real.Uniform
65
-  --   This abstraction allows higher precision version 
66
-  --   of a uniform distribution to be used provided
67
-  --
68
-  procedure Uniform (
69
-    Result : out   real ;
70
-    Seed   : inout RandomSeedType 
71
-  ) is
72
-  begin
73
-    ieee.math_real.Uniform (Seed(Seed'left), Seed(Seed'right), Result) ;
74
-  end procedure Uniform ;
75
-
76
-
77
-  -----------------------------------------------------------------
78
-  --  GenRandSeed
79
-  --    Convert integer_vector to RandomSeedType
80
-  --    Uniform requires two seed values of the form:
81
-  --        1 <= SEED1 <= 2147483562; 1 <= SEED2 <= 2147483398
82
-  --
83
-  --    if 2 seed values are passed to GenRandSeed and they are 
84
-  --    in the above range, then they must remain unmodified.
85
-  --
86
-  impure function GenRandSeed(IV : integer_vector) return RandomSeedType is
87
-    alias iIV : integer_vector(1 to IV'length) is IV ;
88
-    variable Seed1 : integer ;
89
-    variable Seed2 : integer ;
90
-    constant SEED1_MAX : integer := 2147483562 ;
91
-    constant SEED2_MAX : integer := 2147483398 ;
92
-  begin
93
-    if iIV'Length <= 0 then  -- no seed
94
-      Alert(OSVVM_ALERTLOG_ID, "RandomBasePkg.GenRandSeed received NULL integer_vector", FAILURE) ; 
95
-      return (3, 17) ;  -- if continue seed = (3, 17)
96
-
97
-    elsif iIV'Length = 1 then  -- one seed value
98
-      -- inefficient handling, but condition is unlikely
99
-      return GenRandSeed(iIV(1)) ;  -- generate a seed
100
-
101
-    else  -- only use the left two values
102
-      -- 1 <= SEED1 <= 2147483562
103
-      -- mod returns 0 to MAX-1, the -1 adjusts legal values, +1 adjusts them back
104
-      Seed1 := ((iIV(1)-1) mod SEED1_MAX) + 1 ;
105
-     -- 1 <= SEED2 <= 2147483398
106
-      Seed2 := ((iIV(2)-1) mod SEED2_MAX) + 1 ;
107
-      return (Seed1, Seed2) ;
108
-    end if ;
109
-  end function GenRandSeed ;
110
-
111
-
112
-  -----------------------------------------------------------------
113
-  --  GenRandSeed
114
-  --    transform a single integer into the internal seed
115
-  --
116
-  impure function GenRandSeed(I : integer) return RandomSeedType is
117
-    variable result : integer_vector(1 to 2) ;
118
-  begin
119
-    result(1) := I ;
120
-    result(2) := I/3 + 1 ;
121
-    return GenRandSeed(result) ; -- make value ranges legal
122
-  end function GenRandSeed ;
123
-
124
-
125
-  -----------------------------------------------------------------
126
-  --  GenRandSeed
127
-  --    transform a string value into the internal seed
128
-  --    usage:  RV.GenRandSeed(RV'instance_path));
129
-  --
130
-  impure function GenRandSeed(S : string) return RandomSeedType is
131
-    constant LEN : integer := S'length ;
132
-    constant HALF_LEN : integer := LEN/2 ;
133
-    alias revS : string(LEN downto 1) is S ;
134
-    variable result : integer_vector(1 to 2) ;
135
-    variable temp : integer := 0 ;
136
-  begin
137
-    for i in 1 to HALF_LEN loop
138
-      temp := (temp + character'pos(revS(i))) mod (integer'right - 2**8) ;
139
-    end loop ;
140
-    result(1) := temp ;
141
-    for i in HALF_LEN + 1 to LEN loop
142
-      temp := (temp + character'pos(revS(i))) mod (integer'right - 2**8) ;
143
-    end loop ;
144
-    result(2) := temp ;
145
-    return GenRandSeed(result) ;  -- make value ranges legal
146
-  end function GenRandSeed ;
147
-
148
-
149
-  -----------------------------------------------------------------
150
-  function to_string(A : RandomSeedType) return string is
151
-  begin
152
-    return to_string(A(A'left)) & " " & to_string(A(A'right)) ;
153
-  end function to_string ;
154
-
155
-
156
-  -----------------------------------------------------------------
157
-  procedure write(variable L: inout line ; A : RandomSeedType ) is
158
-  begin
159
-    write(L, to_string(A)) ;
160
-  end procedure ;
161
-
162
-
163
-  -----------------------------------------------------------------
164
-  procedure read(variable L: inout line ; A : out RandomSeedType ; good : out boolean ) is
165
-    variable iReadValid : boolean ;
166
-  begin
167
-    for i in A'range loop
168
-      read(L, A(i), iReadValid) ;
169
-      exit when not iReadValid ;
170
-    end loop ;
171
-    good := iReadValid ;
172
-  end procedure read ;
173
-
174
-
175
-  -----------------------------------------------------------------
176
-  procedure read(variable L: inout line ; A : out RandomSeedType ) is
177
-    variable ReadValid : boolean ;
178
-  begin
179
-      read(L, A, ReadValid) ;
180
-      AlertIfNot(ReadValid, OSVVM_ALERTLOG_ID, "RandomBasePkg.read[line, RandomSeedType] failed", FAILURE) ;  
181
-  end procedure read ;
182
-  
183
-end RandomBasePkg ;

+ 0
- 1584
OSVVM/RandomPkg.vhd
File diff suppressed because it is too large
View File


+ 0
- 347
OSVVM/ResolutionPkg.vhd View File

@@ -1,392 +0,0 @@
1
---
2
---
3
---
4
---
5
---
6
---
7
---
8
---
9
-
10
-library ieee ; 
11
-use ieee.std_logic_1164.all ; 
12
-use ieee.numeric_std.all ; 
13
-
14
-library osvvm ; 
15
-use osvvm.AlertLogPkg.all ; 
16
-
17
-package ResolutionPkg is 
18
-  constant MULTIPLE_DRIVER_SEVERITY : severity_level := ERROR ; 
19
-
20
---
21
---
22
---
23
-
24
-  -- resolved_max
25
-  --   return maximum value.  
26
-  --   No initializations required on ports, default of type'left is ok
27
-  function resolved_max ( s : std_ulogic_vector) return std_ulogic ; 
28
-  subtype  std_logic_max is resolved_max std_ulogic ; 
29
-  subtype  std_logic_vector_max is (resolved_max) std_ulogic_vector ;
30
-  type     std_logic_vector_max_c is array (natural range <>) of std_logic_max ; -- for non VHDL-2008  
31
-
32
-  subtype  unsigned_max is (resolved_max) unresolved_unsigned ; 
33
-  type     unsigned_max_c is array (natural range <>) of std_logic_max ; -- for non VHDL-2008  
34
-  subtype  signed_max   is (resolved_max) unresolved_signed ;
35
-  type     signed_max_c is array (natural range <>) of std_logic_max ; -- for non VHDL-2008  
36
-
37
-  function resolved_max ( s : bit_vector) return bit ;               
38
-  subtype  bit_max is resolved_max bit ; 
39
-  subtype  bit_vector_max is (resolved_max) bit_vector ; 
40
-  type     bit_vector_max_c is array (natural range <>) of bit_max ; -- for non VHDL-2008  
41
-
42
-  function resolved_max ( s : integer_vector ) return integer ;      
43
-  subtype  integer_max is resolved_max integer ; 
44
-  subtype  integer_vector_max is (resolved_max) integer_vector ; 
45
-  type     integer_vector_max_c is array (natural range <>) of integer_max ; -- for non VHDL-2008  
46
-
47
-  function resolved_max ( s : time_vector ) return time ;            
48
-  subtype  time_max is resolved_max time ; 
49
-  subtype  time_vector_max is (resolved_max) time_vector ; 
50
-  type     time_vector_max_c is array (natural range <>) of time_max ; -- for non VHDL-2008  
51
-
52
-  function resolved_max ( s : real_vector ) return real ;            
53
-  subtype  real_max is resolved_max real ; 
54
-  subtype  real_vector_max is (resolved_max) real_vector ; 
55
-  type     real_vector_max_c is array (natural range <>) of real_max ; -- for non VHDL-2008  
56
-
57
-  function resolved_max ( s : string) return character ;             
58
-  subtype  character_max is resolved_max character ; 
59
-  subtype  string_max is (resolved_max) string ; 
60
-  type     string_max_c is array (positive range <>) of character_max ; -- for non VHDL-2008  
61
-
62
-  function resolved_max ( s : boolean_vector) return boolean ;       
63
-  subtype  boolean_max is resolved_max boolean ; 
64
-  subtype  boolean_vector_max is (resolved_max) boolean_vector ; 
65
-  type     boolean_vector_max_c is array (natural range <>) of boolean_max ; -- for non VHDL-2008  
66
-
67
-  
68
-  -- return sum of values that /= type'left
69
-  -- No initializations required on ports, default of type'left is ok
70
-  function resolved_sum ( s : integer_vector ) return integer ;      
71
-  subtype  integer_sum is resolved_sum integer ; 
72
-  subtype  integer_vector_sum is (resolved_sum) integer_vector ; 
73
-  type     integer_vector_sum_c is array (natural range <>) of integer_sum ; -- for non VHDL-2008  
74
-
75
-  function resolved_sum ( s : time_vector ) return time ;            
76
-  subtype  time_sum is resolved_sum time ; 
77
-  subtype  time_vector_sum is (resolved_sum) time_vector ; 
78
-  type     time_vector_sum_c is array (natural range <>) of time_sum ; -- for non VHDL-2008  
79
-
80
-  function resolved_sum ( s : real_vector ) return real ;            
81
-  subtype  real_sum is resolved_sum real ; 
82
-  subtype  real_vector_sum is (resolved_sum) real_vector ; 
83
-  type     real_vector_sum_c is array (natural range <>) of real_sum ; -- for non VHDL-2008  
84
-
85
-  
86
-  -- resolved_weak
87
-  -- Special just for std_ulogic
88
-  -- No initializations required on ports, default of type'left is ok
89
-  function resolved_weak (s : std_ulogic_vector) return std_ulogic ;  -- no init, type'left
90
-  subtype  std_logic_weak is resolved_weak std_ulogic ; 
91
-  subtype  std_logic_vector_weak is (resolved_weak) std_ulogic_vector ;  
92
-
93
-
94
-  -- legacy stuff
95
-  -- requires ports to be initialized to 0 in the appropriate type.  
96
-  function resolved ( s : integer_vector ) return integer ;     
97
-  subtype  resolved_integer is resolved integer ;
98
-
99
-  function resolved ( s : time_vector ) return time ; 
100
-  subtype  resolved_time is resolved time ;
101
-
102
-  function resolved ( s : real_vector ) return real ; 
103
-  subtype  resolved_real is resolved real ;
104
-  
105
-  function resolved (s : string) return character ;      -- same as resolved_max
106
-  subtype  resolved_character is resolved character ;
107
-  -- subtype  resolved_string is (resolved) string ;  -- subtype will replace type later 
108
-  type resolved_string is array (positive range <>) of resolved_character;  -- will change to subtype -- assert but no init
109
-
110
-  function resolved ( s : boolean_vector) return boolean ;  --same as resolved_max  
111
-  subtype  resolved_boolean is resolved boolean ;
112
-
113
-end package ResolutionPkg ;
114
-package body ResolutionPkg is 
115
-
116
-  -- resolved_max
117
-  -- return maximum value.  Assert FAILURE if more than 1 /= type'left
118
-  -- No initializations required on ports, default of type'left is ok
119
-
120
-  -- Optimized version is just the following:  
121
-  --  ------------------------------------------------------------
122
-  --  function resolved_max ( s : <array_type> ) return <element_type> is 
123
-  --  ------------------------------------------------------------
124
-  --  begin
125
-  --    return maximum(s) ;  
126
-  --  end function resolved_max ; 
127
-
128
-  ------------------------------------------------------------
129
-  function resolved_max (s : std_ulogic_vector) return std_ulogic is 
130
-  ------------------------------------------------------------ 
131
-  begin
132
-    return maximum(s) ; 
133
-  end function resolved_max ; 
134
-
135
-  ------------------------------------------------------------
136
-  function resolved_max ( s : bit_vector ) return bit is 
137
-  ------------------------------------------------------------ 
138
-  begin
139
-    return maximum(s) ; 
140
-  end function resolved_max ; 
141
-
142
-  ------------------------------------------------------------
143
-  function resolved_max ( s : integer_vector ) return integer is 
144
-  ------------------------------------------------------------ 
145
-  begin
146
-    return maximum(s) ; 
147
-  end function resolved_max ; 
148
-  
149
-  ------------------------------------------------------------
150
-  function resolved_max ( s : time_vector ) return time is 
151
-  ------------------------------------------------------------
152
-  begin
153
-    return maximum(s) ; 
154
-  end function resolved_max ; 
155
-
156
-  ------------------------------------------------------------
157
-  function resolved_max ( s : real_vector ) return real is 
158
-  ------------------------------------------------------------
159
-  begin
160
-    return maximum(s) ; 
161
-  end function resolved_max ; 
162
-  
163
-  ------------------------------------------------------------
164
-  function resolved_max ( s : string ) return character is 
165
-  ------------------------------------------------------------
166
-  begin
167
-    return maximum(s) ; 
168
-  end function resolved_max ; 
169
-
170
-  ------------------------------------------------------------
171
-  function resolved_max ( s : boolean_vector) return boolean is
172
-  ------------------------------------------------------------
173
-  begin
174
-    return maximum(s) ; 
175
-  end function resolved_max ; 
176
-
177
-  
178
-  -- resolved_sum - appropriate for numeric types
179
-  -- return sum of values that /= type'left
180
-  -- No initializations required on ports, default of type'left is ok
181
-  ------------------------------------------------------------
182
-  function resolved_sum ( s : integer_vector ) return integer is 
183
-  ------------------------------------------------------------
184
-    variable result : integer := 0 ; 
185
-  begin
186
-    for i in s'RANGE loop
187
-      if s(i) /= integer'left then 
188
-        result := s(i) + result;
189
-      end if ;
190
-    end loop ;
191
-    return result ; 
192
-  end function resolved_sum ; 
193
-  
194
-  ------------------------------------------------------------
195
-  function resolved_sum ( s : time_vector ) return time is 
196
-  ------------------------------------------------------------
197
-    variable result : time := 0 sec ; 
198
-  begin
199
-    for i in s'RANGE loop
200
-      if s(i) /= time'left then 
201
-        result := s(i) + result;
202
-      end if ;
203
-    end loop ;
204
-    return result ; 
205
-  end function resolved_sum ; 
206
-
207
-  ------------------------------------------------------------
208
-  function resolved_sum ( s : real_vector ) return real is 
209
-  ------------------------------------------------------------
210
-    variable result : real := 0.0 ; 
211
-  begin
212
-    for i in s'RANGE loop
213
-      if s(i) /= real'left then 
214
-        result := s(i) + result;
215
-      end if ;
216
-    end loop ;
217
-    return result ; 
218
-  end function resolved_sum ; 
219
-  
220
-  
221
-  -- resolved_weak
222
-  -- Special just for std_ulogic
223
-  -- No initializations required on ports, default of type'left is ok
224
-  type stdlogic_table is array(STD_ULOGIC, STD_ULOGIC) of STD_ULOGIC;
225
-
226
-  constant weak_resolution_table : stdlogic_table := (
227
-    --  Resolution order:  Z < U < W < X < - < L < H < 0 < 1
228
-    --      ---------------------------------------------------------
229
-    --      |  U    X    0    1    Z    W    L    H    -        |   |  
230
-    --      ---------------------------------------------------------
231
-             ('U', 'X', '0', '1', 'U', 'W', 'L', 'H', '-'),  -- | U |
232
-             ('X', 'X', '0', '1', 'X', 'X', 'L', 'H', '-'),  -- | X |
233
-             ('0', '0', '0', '1', '0', '0', '0', '0', '0'),  -- | 0 |
234
-             ('1', '1', '1', '1', '1', '1', '1', '1', '1'),  -- | 1 |
235
-             ('U', 'X', '0', '1', 'Z', 'W', 'L', 'H', '-'),  -- | Z |
236
-             ('W', 'X', '0', '1', 'W', 'W', 'L', 'H', '-'),  -- | W |
237
-             ('L', 'L', '0', '1', 'L', 'L', 'L', 'H', 'L'),  -- | L |
238
-             ('H', 'H', '0', '1', 'H', 'H', 'W', 'H', 'H'),  -- | H |
239
-             ('-', '-', '0', '1', '-', '-', 'L', 'H', '-')   -- | - |
240
-             );
241
-             
242
-  ------------------------------------------------------------
243
-  function resolved_weak (s : std_ulogic_vector) return std_ulogic is
244
-  ------------------------------------------------------------
245
-    variable result : std_ulogic := 'Z' ; 
246
-  begin
247
-    for i in s'RANGE loop
248
-      result := weak_resolution_table(result, s(i)) ; 
249
-    end loop ;
250
-    return result ; 
251
-  end function resolved_weak ; 
252
-
253
-  
254
-  -- legacy stuff.
255
-  -- requires ports to be initialized to 0 in the appropriate type.  
256
-  
257
-  ------------------------------------------------------------
258
-  function resolved ( s : integer_vector ) return integer is 
259
-  -- requires interface to be initialized to 0
260
-  ------------------------------------------------------------
261
-    variable result : integer := 0 ; 
262
-    variable failed : boolean := FALSE ; 
263
-  begin
264
-    for i in s'RANGE loop
265
-      if s(i) /= 0 then 
266
-        failed := failed or (result /= 0) ;
267
-        result := maximum(s(i),result);
268
-      end if ;
269
-    end loop ;
270
-    assert not failed report "ResolutionPkg.resolved: multiple drivers on integer" severity MULTIPLE_DRIVER_SEVERITY ; 
271
-    -- AlertIf(OSVVM_ALERTLOG_ID, failed, "ResolutionPkg.resolved: multiple drivers on integer") ; 
272
-    return result ; 
273
-  end function resolved ; 
274
-
275
-  ------------------------------------------------------------
276
-  function resolved ( s : time_vector ) return time is 
277
-  -- requires interface to be initialized to 0 ns
278
-  ------------------------------------------------------------
279
-    variable result : time := 0 ns ; 
280
-    variable failed : boolean := FALSE ; 
281
-  begin
282
-    for i in s'RANGE loop
283
-      if s(i) > 0 ns then 
284
-        failed := failed or (result /= 0 ns) ;
285
-        result := maximum(s(i),result);
286
-      end if ;
287
-    end loop ;
288
-    assert not failed report "ResolutionPkg.resolved: multiple drivers on time" severity MULTIPLE_DRIVER_SEVERITY ; 
289
-    -- AlertIf(OSVVM_ALERTLOG_ID, failed, "ResolutionPkg.resolved: multiple drivers on time") ; 
290
-    return result ; 
291
-  end function resolved ; 
292
-
293
-  ------------------------------------------------------------
294
-  function resolved ( s : real_vector ) return real is 
295
-  -- requires interface to be initialized to 0.0
296
-  ------------------------------------------------------------
297
-    variable result : real := 0.0 ; 
298
-    variable failed : boolean := FALSE ; 
299
-  begin
300
-    for i in s'RANGE loop
301
-      if s(i) /= 0.0 then 
302
-        failed := failed or (result /= 0.0) ;
303
-        result := maximum(s(i),result);
304
-      end if ;
305
-    end loop ;
306
-    assert not failed report "ResolutionPkg.resolved: multiple drivers on real" severity MULTIPLE_DRIVER_SEVERITY ; 
307
-    -- AlertIf(OSVVM_ALERTLOG_ID, failed, "ResolutionPkg.resolved: multiple drivers on real") ; 
308
-    return result ; 
309
-  end function resolved ; 
310
-
311
-  ------------------------------------------------------------
312
-  function resolved (s : string) return character is  
313
-  -- same as resolved_max
314
-  ------------------------------------------------------------
315
-    variable result : character := NUL ; 
316
-    variable failed : boolean := FALSE ; 
317
-  begin
318
-    for i in s'RANGE loop
319
-      if s(i) /= NUL then 
320
-        failed := failed or (result /= NUL) ;
321
-        result := maximum(result, s(i)) ; 
322
-      end if ; 
323
-    end loop ;
324
-    assert not failed report "ResolutionPkg.resolved: multiple drivers on character" severity MULTIPLE_DRIVER_SEVERITY ; 
325
-    -- AlertIf(OSVVM_ALERTLOG_ID, failed, "ResolutionPkg.resolved: multiple drivers on character") ; 
326
-    return result ; 
327
-  end function resolved ; 
328
-
329
-  ------------------------------------------------------------
330
-  function resolved ( s : boolean_vector) return boolean is
331
-  -- same as resolved_max
332
-  ------------------------------------------------------------
333
-    variable result : boolean := FALSE ; 
334
-    variable failed : boolean := FALSE ; 
335
-  begin
336
-    for i in s'RANGE loop
337
-      if s(i) then 
338
-        failed := failed or result ; 
339
-        result := TRUE ;
340
-      end if ; 
341
-    end loop ;
342
-    assert not failed report "ResolutionPkg.resolved: multiple drivers on boolean" severity MULTIPLE_DRIVER_SEVERITY ; 
343
-    -- AlertIf(OSVVM_ALERTLOG_ID, failed, "ResolutionPkg.resolved: multiple drivers on boolean") ; 
344
-    return result ; 
345
-  end function resolved ; 
346
-
347
-end package body ResolutionPkg ;

+ 0
- 1470
OSVVM/ScoreboardGenericPkg.vhd
File diff suppressed because it is too large
View File


+ 0
- 31
OSVVM/ScoreboardPkg_int.vhd View File

@@ -1,65 +0,0 @@
1
---
2
---
3
---
4
---
5
---
6
---
7
---
8
---
9
---
10
---
11
---
12
---
13
---
14
---
15
---
16
-
17
-use std.textio.all ;
18
-
19
-library ieee ;
20
-  use ieee.std_logic_1164.all ;
21
-  use ieee.numeric_std.all ;
22
-
23
-
24
-package ScoreBoardPkg_int is new work.ScoreboardGenericPkg
25
-  generic map (
26
-    ExpectedType        => integer,  
27
-    ActualType          => integer,  
28
-    Match               => "=",  
29
-    expected_to_string  => to_string,  
30
-    actual_to_string    => to_string    
31
-  ) ;  

+ 0
- 31
OSVVM/ScoreboardPkg_slv.vhd View File

@@ -1,65 +0,0 @@
1
---
2
---
3
---
4
---
5
---
6
---
7
---
8
---
9
---
10
---
11
---
12
---
13
---
14
---
15
---
16
-
17
-use std.textio.all ;
18
-
19
-library ieee ;
20
-  use ieee.std_logic_1164.all ;
21
-  use ieee.numeric_std.all ;
22
-
23
-
24
-package ScoreBoardPkg_slv is new work.ScoreboardGenericPkg
25
-  generic map (
26
-    ExpectedType        => std_logic_vector,  
27
-    ActualType          => std_logic_vector,  
28
-    Match               => std_match,  -- "=", [std_logic_vector, std_logic_vector return boolean]
29
-    expected_to_string  => to_hstring, --      [std_logic_vector return string] 
30
-    actual_to_string    => to_hstring  --      [std_logic_vector return string]  
31
-  ) ;  

+ 0
- 367
OSVVM/SortListPkg_int.vhd View File

@@ -1,417 +0,0 @@
1
---
2
---
3
---
4
---
5
---
6
---
7
---
8
---
9
---
10
---
11
---
12
---
13
---
14
-
15
-use work.OsvvmGlobalPkg.all ; 
16
-use work.AlertLogPkg.all ; 
17
-use std.textio.all ;
18
-
19
-library ieee ;
20
-use ieee.std_logic_1164.all ;
21
-use ieee.numeric_std.all ;
22
-use ieee.std_logic_textio.all ;
23
-
24
-
25
-
26
-package SortListPkg_int is
27
-  -- with VHDL-2008, convert package to generic package
28
-  -- convert subtypes ElementType and ArrayofElementType to generics
29
-  -- package SortListGenericPkg is
30
-  subtype ElementType is integer ;
31
-  subtype ArrayofElementType is integer_vector ;
32
-
33
-  impure function inside (constant E : ElementType; constant A : in ArrayofElementType) return boolean ;
34
-  impure function sort (constant A : in ArrayofElementType) return ArrayofElementType ;
35
-  impure function revsort (constant A : in ArrayofElementType) return ArrayofElementType ;
36
-
37
-  type SortListPType is protected
38
-    procedure add ( constant A : in ElementType ; constant AllowDuplicate : Boolean := FALSE ) ;
39
-    procedure add ( constant A : in ArrayofElementType ) ;
40
-    procedure add ( constant A : in ArrayofElementType ; Min, Max : ElementType ) ;
41
-    procedure add ( variable A : inout SortListPType ) ;
42
-    -- Count items in list
43
-    impure function  count return integer ;
44
-    impure function  find_index ( constant A : ElementType) return integer ;
45
-    impure function inside (constant A : ElementType) return boolean ;
46
-    procedure insert ( constant A : in ElementType; constant index : in integer := 1 ) ;
47
-    impure function get ( constant index : in integer := 1 ) return ElementType ;
48
-    procedure erase  ;
49
-    impure function Empty return boolean ;
50
-    procedure print ;
51
-
52
-    procedure remove ( constant A : in ElementType ) ;
53
-    procedure remove ( constant A : in ArrayofElementType ) ;
54
-    procedure remove ( variable A : inout SortListPType ) ;
55
-
56
-    impure function to_array (constant EraseList : boolean := FALSE) return ArrayofElementType ;
57
-    impure function to_rev_array (constant EraseList : boolean := FALSE) return ArrayofElementType ;
58
-  end protected SortListPType ;
59
-
60
-end SortListPkg_int ;
61
-
62
---- ///////////////////////////////////////////////////////////////////////////
63
---- ///////////////////////////////////////////////////////////////////////////
64
---- ///////////////////////////////////////////////////////////////////////////
65
-
66
-package body SortListPkg_int is
67
-
68
-  impure function inside (constant E : ElementType; constant A : in ArrayofElementType) return boolean is
69
-  begin
70
-    for i in A'range loop
71
-      if E = A(i) then
72
-        return TRUE ;
73
-      end if ;
74
-    end loop ;
75
-    return FALSE ;
76
-  end function inside ;
77
-  
78
-  type SortListPType is protected body
79
-    type ListType ;
80
-    type ListPointerType is access ListType ;
81
-    type ListType is record
82
-      A           : ElementType ;
83
-      -- item_num    : integer ;
84
-      NextPtr     : ListPointerType ;
85
-      -- PrevPtr     : ListPointerType ;
86
-    end record ;
87
-    variable HeadPointer : ListPointerType := NULL ;
88
-    -- variable TailPointer : ListPointerType := NULL ;
89
-
90
-    procedure add ( constant A : in ElementType ; constant AllowDuplicate : Boolean := FALSE ) is
91
-      variable CurPtr, tempPtr : ListPointerType ;
92
-    begin
93
-      if HeadPointer = NULL then
94
-        HeadPointer  := new ListType'(A, NULL) ;
95
-      elsif A = HeadPointer.A then -- ignore duplicates
96
-        if AllowDuplicate then
97
-          tempPtr := HeadPointer ;
98
-          HeadPointer   := new ListType'(A, tempPtr) ;
99
-        end if ; 
100
-      elsif A < HeadPointer.A  then
101
-        tempPtr := HeadPointer ;
102
-        HeadPointer   := new ListType'(A, tempPtr) ;
103
-      else
104
-        CurPtr := HeadPointer ;
105
-        AddLoop : loop
106
-          exit AddLoop when CurPtr.NextPtr = NULL ;
107
-          exit AddLoop when A < CurPtr.NextPtr.A  ;
108
-          if A = CurPtr.NextPtr.A then 
109
-            if not AllowDuplicate then 
110
-              return ;  -- return without insert
111
-            end if; 
112
-          end if ; 
113
-          CurPtr := CurPtr.NextPtr ;
114
-        end loop AddLoop ;
115
-        tempPtr := CurPtr.NextPtr ;
116
-        CurPtr.NextPtr := new ListType'(A, tempPtr) ;
117
-      end if ;
118
-    end procedure add ;
119
-    
120
-    procedure add ( constant A : in ArrayofElementType ) is
121
-    begin
122
-      for i in A'range loop
123
-        add(A(i)) ;
124
-      end loop ;
125
-    end procedure add ;
126
-
127
-    procedure add ( constant A : in ArrayofElementType ; Min, Max : ElementType ) is
128
-    begin
129
-      for i in A'range loop
130
-        if A(i) >= Min and A(i) <= Max then
131
-          add(A(i)) ;
132
-        end if ;
133
-      end loop ;
134
-    end procedure add ;
135
-
136
-    procedure add ( variable A : inout SortListPType ) is
137
-    begin
138
-      for i in 1 to A.Count loop
139
-        add(A.Get(i)) ;
140
-      end loop ;
141
-    end procedure add ;
142
-
143
-    -- Count items in list
144
-    impure function count return integer is
145
-      variable result : positive := 1 ;
146
-      variable CurPtr : ListPointerType ;
147
-    begin
148
-      if HeadPointer = NULL then
149
-        return 0 ;
150
-      else
151
-        CurPtr := HeadPointer ;
152
-        loop
153
-          exit when CurPtr.NextPtr = NULL ;
154
-          result := result + 1 ;
155
-          CurPtr := CurPtr.NextPtr ;
156
-        end loop ;
157
-        return result ;
158
-      end if ;
159
-    end function count ;
160
-
161
-    impure function find_index (constant A : ElementType) return integer is
162
-      variable result : positive := 2 ;
163
-      variable CurPtr : ListPointerType ;
164
-    begin
165
-      if HeadPointer = NULL then
166
-        return 0 ;
167
-      elsif A <= HeadPointer.A then
168
-        return 1 ;
169
-      else
170
-        CurPtr := HeadPointer ;
171
-        loop
172
-          exit when CurPtr.NextPtr = NULL ;
173
-          exit when A <= CurPtr.NextPtr.A ;
174
-          result := result + 1 ;
175
-          CurPtr := CurPtr.NextPtr ;
176
-        end loop ;
177
-        return result ;
178
-      end if ;
179
-    end function find_index ;
180
-
181
-    impure function inside (constant A : ElementType) return boolean is
182
-      variable CurPtr : ListPointerType ;
183
-    begin
184
-      if HeadPointer = NULL then
185
-        return FALSE ;
186
-      end if ;
187
-      if A = HeadPointer.A then
188
-        return TRUE ;
189
-      else
190
-        CurPtr := HeadPointer ;
191
-        loop
192
-          exit when CurPtr.NextPtr = NULL ;
193
-          exit when A < CurPtr.NextPtr.A  ;
194
-          if A = CurPtr.NextPtr.A then
195
-            return TRUE ;  -- exit
196
-          end if;
197
-          CurPtr := CurPtr.NextPtr ;
198
-        end loop ;
199
-      end if ;
200
-      return FALSE ;
201
-    end function inside ;
202
-
203
-
204
-    procedure insert( constant A : in ElementType; constant index : in integer := 1 ) is
205
-      variable CurPtr, tempPtr : ListPointerType ;
206
-    begin
207
-      if index <= 1 then
208
-        tempPtr := HeadPointer ;
209
-        HeadPointer   := new ListType'(A, tempPtr) ;
210
-      else
211
-        CurPtr := HeadPointer ;
212
-        for i in 3 to index loop
213
-          exit when CurPtr.NextPtr = NULL ; -- end of list
214
-          CurPtr := CurPtr.NextPtr ;
215
-        end loop ;
216
-        tempPtr := CurPtr.NextPtr ;
217
-        CurPtr.NextPtr := new ListType'(A, tempPtr) ;
218
-      end if;
219
-    end procedure insert ;
220
-
221
-    impure function get ( constant index : in integer := 1 ) return ElementType is
222
-      variable CurPtr : ListPointerType ;
223
-    begin
224
-      if index > Count then
225
-        Alert(OSVVM_ALERTLOG_ID, "SortLIstPkg_int.get index out of range", FAILURE) ;
226
-        return ElementType'left ;
227
-      elsif HeadPointer = NULL then
228
-        return ElementType'left ;
229
-      elsif index <= 1 then
230
-        return HeadPointer.A ;
231
-      else
232
-        CurPtr := HeadPointer ;
233
-        for i in 2 to index loop
234
-          CurPtr := CurPtr.NextPtr ;
235
-        end loop ;
236
-        return CurPtr.A ;
237
-      end if;
238
-    end function get ;
239
-
240
-
241
-    procedure erase (variable CurPtr : inout ListPointerType ) is
242
-    begin
243
-      if CurPtr.NextPtr /= NULL then
244
-        erase (CurPtr.NextPtr) ;
245
-      end if ;
246
-      deallocate (CurPtr) ;
247
-    end procedure erase ;
248
-
249
-    procedure erase is
250
-    begin
251
-      if HeadPointer /= NULL then
252
-        erase(HeadPointer) ;
253
-        -- deallocate (HeadPointer) ;
254
-        HeadPointer := NULL ;
255
-      end if;
256
-    end procedure erase ;
257
-
258
-    impure function Empty return boolean is
259
-    begin
260
-      return HeadPointer = NULL ;
261
-    end Empty ;
262
-
263
-    procedure print is
264
-      variable buf : line ;
265
-      variable CurPtr : ListPointerType ;
266
-    begin
267
-      if HeadPointer = NULL then
268
-        write (buf, string'("( )")) ;
269
-      else
270
-        CurPtr := HeadPointer ;
271
-        write (buf, string'("(")) ;
272
-        loop
273
-          write (buf, CurPtr.A) ;
274
-          exit when CurPtr.NextPtr = NULL ;
275
-          write (buf, string'(", ")) ;
276
-          CurPtr := CurPtr.NextPtr ;
277
-        end loop ;
278
-        write (buf, string'(")")) ;
279
-      end if ;
280
-      writeline(OUTPUT, buf) ;
281
-    end procedure print ;
282
-
283
-    procedure remove ( constant A : in ElementType ) is
284
-      variable CurPtr, tempPtr : ListPointerType ;
285
-    begin
286
-      if HeadPointer = NULL then
287
-        return ;
288
-      elsif A = HeadPointer.A then
289
-        tempPtr := HeadPointer ;
290
-        HeadPointer := HeadPointer.NextPtr ;
291
-        deallocate (tempPtr) ;
292
-      else
293
-        CurPtr := HeadPointer ;
294
-        loop
295
-          exit when CurPtr.NextPtr = NULL ;
296
-          if A = CurPtr.NextPtr.A then
297
-            tempPtr := CurPtr.NextPtr ;
298
-            CurPtr.NextPtr := CurPtr.NextPtr.NextPtr ;
299
-            deallocate (tempPtr) ;
300
-            exit ;
301
-          end if ;
302
-          exit when A < CurPtr.NextPtr.A ;
303
-          CurPtr := CurPtr.NextPtr ;
304
-        end loop ;
305
-      end if ;
306
-    end procedure remove ;
307
-
308
-    procedure remove ( constant A : in ArrayofElementType ) is
309
-    begin
310
-      for i in A'range loop
311
-        remove(A(i)) ;
312
-      end loop ;
313
-    end procedure remove ;
314
-
315
-    procedure remove ( variable A : inout SortListPType ) is
316
-    begin
317
-      for i in 1 to A.Count loop
318
-        remove(A.Get(i)) ;
319
-      end loop ;
320
-    end procedure remove ;
321
-
322
-    impure function to_array (constant EraseList : boolean := FALSE) return ArrayofElementType is
323
-      variable result : ArrayofElementType(1 to Count) ;
324
-    begin
325
-      for i in 1 to Count loop
326
-        result(i) := Get(i) ;
327
-      end loop ;
328
-      if EraseList then
329
-        erase ;
330
-      end if ;
331
-      return result ;
332
-    end function to_array ;
333
-
334
-    impure function to_rev_array (constant EraseList : boolean := FALSE) return ArrayofElementType is
335
-      variable result : ArrayofElementType(Count downto 1) ;
336
-    begin
337
-      for i in 1 to Count loop
338
-        result(i) := Get(i) ;
339
-      end loop ;
340
-      if EraseList then
341
-        erase ;
342
-      end if ;
343
-      return result ;
344
-    end function to_rev_array ;
345
-
346
-    end protected body SortListPType ;
347
- 
348
- 
349
-  impure function sort (constant A : in ArrayofElementType) return ArrayofElementType is
350
-    variable Result : SortListPType ;
351
-  begin
352
-    for i in A'range loop 
353
-      Result.Add(A(i), TRUE) ;
354
-    end loop ;
355
-    return Result.to_array(EraseList => TRUE)  ; 
356
-  end function sort ;
357
-
358
-  impure function revsort (constant A : in ArrayofElementType) return ArrayofElementType is
359
-    variable Result : SortListPType ;
360
-  begin
361
-    for i in A'range loop 
362
-      Result.Add(A(i), TRUE) ;
363
-    end loop ;
364
-    return Result.to_rev_array(EraseList => TRUE)  ; 
365
-  end function revsort ;
366
-end SortListPkg_int ;
367
-

+ 0
- 812
OSVVM/TbUtilPkg.vhd View File

@@ -1,851 +0,0 @@
1
---
2
---
3
---
4
---
5
---
6
---
7
---
8
---
9
-library ieee ;
10
-  use ieee.std_logic_1164.all ;
11
-  
12
-library osvvm ; 
13
-  use osvvm.AlertLogPkg.all ;
14
-  use osvvm.TranscriptPkg.all ; 
15
-
16
-package TbUtilPkg is
17
-
18
-  constant CLK_ACTIVE : std_logic := '1' ; 
19
-
20
-  constant t_sim_resolution : time := std.env.resolution_limit ;  -- VHDL-2008
21
-  -- constant t_sim_resolution : time := 1 ns ;  -- for non VHDL-2008 simulators
22
-
23
-  ------------------------------------------------------------
24
-  -- ZeroOneHot, OneHot
25
-  --   OneHot:      return true if exactly one value is 1
26
-  --   ZeroOneHot:  return false when more than one value is a 1
27
-  ------------------------------------------------------------
28
-  function OneHot ( constant A : in std_logic_vector ) return boolean ;  
29
-  function ZeroOneHot ( constant A : in std_logic_vector ) return boolean ;  
30
-
31
-
32
-  ------------------------------------------------------------
33
-  -- RequestTransaction
34
-  --   Transaction initiation side of handshaking
35
-  --   Pairs with WaitForTransaction or one of its variations
36
-  ------------------------------------------------------------
37
-  procedure RequestTransaction (
38
-    signal Rdy  : Out std_logic ;
39
-    signal Ack  : In  std_logic 
40
-  ) ;
41
-  
42
-  ------------------------------------------------------------
43
-  -- WaitForTransaction
44
-  --   Model side of handshaking
45
-  --   Pairs with RequestTransaction 
46
-  ------------------------------------------------------------
47
-  procedure WaitForTransaction (
48
-    signal Clk  : In  std_logic ;
49
-    signal Rdy  : In  std_logic ;
50
-    signal Ack  : Out std_logic 
51
-  ) ;
52
-
53
-  -- Variation for model that stops waiting when TimeOut is asserted
54
-  -- Intended for models that need to switch between instruction streams
55
-  -- such as a CPU when interrupt is pending
56
-  procedure WaitForTransaction (
57
-    signal   Clk       : In  std_logic ;
58
-    signal   Rdy       : In  std_logic ;
59
-    signal   Ack       : Out std_logic ;
60
-    signal   TimeOut   : In  std_logic ;
61
-    constant Polarity  : In  std_logic := '1' 
62
-  ) ;
63
-
64
-  -- Set Ack to Model starting value
65
-  procedure StartTransaction  ( signal Ack : Out std_logic ) ; 
66
-  -- Set Ack to Model finishing value
67
-  procedure FinishTransaction ( signal Ack : Out std_logic ) ; 
68
-  -- If a transaction is pending, return true
69
-  function TransactionPending ( signal Rdy : In  std_logic ) return boolean ;
70
-
71
-  -- Variation for clockless models
72
-  procedure WaitForTransaction ( 
73
-    signal Rdy : In  std_logic ; 
74
-    signal Ack : Out std_logic 
75
-  ) ;
76
-
77
-
78
-  ------------------------------------------------------------
79
-  -- Toggle, WaitForToggle
80
-  --   Used for communicating between processes
81
-  ------------------------------------------------------------
82
-  procedure Toggle (
83
-    signal Sig        : InOut std_logic ;
84
-    constant DelayVal : time  
85
-  ) ;
86
-  procedure Toggle ( signal Sig : InOut std_logic ) ;
87
-  procedure ToggleHS ( signal Sig : InOut std_logic ) ;
88
-  function  IsToggle ( signal Sig : In std_logic ) return boolean ; 
89
-  procedure WaitForToggle ( signal Sig : In std_logic ) ;
90
-  
91
-  -- Bit type versions
92
-  procedure Toggle ( signal Sig : InOut bit ; constant DelayVal : time ) ;
93
-  procedure Toggle ( signal Sig : InOut bit ) ;
94
-  procedure ToggleHS ( signal Sig : InOut bit ) ;
95
-  function  IsToggle ( signal Sig : In bit ) return boolean ; 
96
-  procedure WaitForToggle ( signal Sig : In bit ) ;
97
-
98
-
99
-  ------------------------------------------------------------
100
-  -- WaitForBarrier
101
-  --   Barrier Synchronization
102
-  --   Multiple processes call it, it finishes when all have called it
103
-  ------------------------------------------------------------
104
-  procedure WaitForBarrier ( signal Sig : InOut std_logic ) ;
105
-  procedure WaitForBarrier ( signal Sig : InOut std_logic ; signal TimeOut : std_logic ; constant Polarity : in std_logic := '1') ;
106
-  procedure WaitForBarrier ( signal Sig : InOut std_logic ; constant TimeOut : time ) ;
107
-  -- resolved_barrier : summing resolution used in conjunction with integer based barriers
108
-  function resolved_barrier ( s : integer_vector ) return integer ; 
109
-  subtype  integer_barrier is resolved_barrier integer ; 
110
-  -- Usage of integer barriers requires resolved_barrier. Initialization to 1 recommended, but not required
111
-  --   signal barrier1 : resolved_barrier integer := 1 ;     -- using the resolution function
112
-  --   signal barrier2 : integer_barrier := 1 ;              -- using the subtype that already applies the resolution function
113
-  procedure WaitForBarrier ( signal Sig : InOut integer ) ;  
114
-  procedure WaitForBarrier ( signal Sig : InOut integer ; signal TimeOut : std_logic ; constant Polarity : in std_logic := '1') ;
115
-  procedure WaitForBarrier ( signal Sig : InOut integer ; constant TimeOut : time ) ;
116
-  -- Using separate signals
117
-  procedure WaitForBarrier2 ( signal SyncOut : out std_logic ; signal SyncIn : in  std_logic ) ;
118
-  procedure WaitForBarrier2 ( signal SyncOut : out std_logic ; signal SyncInV : in  std_logic_vector ) ;
119
-
120
-  
121
-  ------------------------------------------------------------
122
-  -- WaitForClock
123
-  --   Sync to Clock - after a delay, after a number of clocks
124
-  ------------------------------------------------------------
125
-  procedure WaitForClock ( signal Clk : in std_logic ;  constant Delay : in time ) ; 
126
-  procedure WaitForClock ( signal Clk : in std_logic ;  constant NumberOfClocks : in integer := 1) ; 
127
-  procedure WaitForClock ( signal Clk : in std_logic ;  signal Enable : in boolean ) ; 
128
-  procedure WaitForClock ( signal Clk : in std_logic ;  signal Enable : in std_logic ; constant Polarity : std_logic := '1' ) ;
129
-
130
-
131
-  ------------------------------------------------------------
132
-  -- WaitForLevel
133
-  --   Find a signal at a level
134
-  ------------------------------------------------------------
135
-  procedure WaitForLevel ( signal A : in boolean ) ;
136
-  procedure WaitForLevel ( signal A : in std_logic ; Polarity : std_logic := '1' ) ; 
137
-
138
-  ------------------------------------------------------------
139
-  -- CreateClock,  CreateReset
140
-  --   Note these do not exit
141
-  ------------------------------------------------------------
142
-  procedure CreateClock ( 
143
-    signal   Clk        : inout std_logic ; 
144
-    constant Period     : time ; 
145
-    constant DutyCycle  : real := 0.5 
146
-  )  ; 
147
-  
148
-  procedure CheckClockPeriod ( 
149
-    constant AlertLogID : AlertLogIDType ; 
150
-    signal   Clk        : in  std_logic ; 
151
-    constant Period     : time ;
152
-    constant ClkName    : string := "Clock" ;
153
-    constant HowMany    : integer := 5
154
-  ) ; 
155
-  
156
-  procedure CheckClockPeriod ( 
157
-    signal   Clk        : in  std_logic ; 
158
-    constant Period     : time ;
159
-    constant ClkName    : string := "Clock" ;
160
-    constant HowMany    : integer := 5
161
-  ) ; 
162
-
163
-  procedure CreateReset ( 
164
-    signal   Reset       : out std_logic ; 
165
-    constant ResetActive : in  std_logic ; 
166
-    signal   Clk         : in  std_logic ; 
167
-    constant Period      :     time ; 
168
-    constant tpd         :     time 
169
-  ) ;
170
-  
171
-  procedure LogReset ( 
172
-    constant AlertLogID  : AlertLogIDType ; 
173
-    signal   Reset       : in  std_logic ; 
174
-    constant ResetActive : in  std_logic ;
175
-    constant ResetName   : in  string := "Reset" ;
176
-    constant LogLevel    : in  LogType := ALWAYS
177
-  ) ;
178
-
179
-  procedure LogReset ( 
180
-    signal   Reset       : in  std_logic ; 
181
-    constant ResetActive : in  std_logic ;
182
-    constant ResetName   : in  string := "Reset" ;
183
-    constant LogLevel    : in  LogType := ALWAYS
184
-  ) ;
185
-  
186
-  ------------------------------------------------------------
187
-  --  Deprecated subprogram names
188
-  --    Maintaining backward compatibility using aliases
189
-  ------------------------------------------------------------
190
-  -- History of RequestTransaction / WaitForTransaction
191
-  alias RequestAction is RequestTransaction [std_logic, std_logic] ;
192
-  alias WaitForRequest is WaitForTransaction [std_logic, std_logic, std_logic] ;
193
-  -- History of WaitForToggle
194
-  alias WaitOnToggle is WaitForToggle [std_logic] ;
195
-  -- History of WaitForBarrier 
196
-  alias WayPointBlock is WaitForBarrier [std_logic] ;
197
-  alias SyncTo is WaitForBarrier2[std_logic, std_logic] ;
198
-  alias SyncTo is WaitForBarrier2[std_logic, std_logic_vector] ;
199
-  -- Backward compatible name  
200
-  alias SyncToClk is WaitForClock [std_logic, time] ;
201
-
202
-  ------------------------------------------------------------
203
-  -- Deprecated
204
-  -- subsumed by WaitForTransaction with Ack and TimeOut.
205
-  -- TimeOut works exactly like IntReq
206
-  ------------------------------------------------------------
207
-  procedure WaitForTransactionOrIrq (
208
-    signal Clk     : In  std_logic ;
209
-    signal Rdy     : In  std_logic ;
210
-    signal IntReq  : In  std_logic 
211
-  ) ;
212
-
213
-  ------------------------------------------------------------
214
-  -- Deprecated
215
-  -- WaitForAck, StrobeAck
216
-  --   Replaced by WaitForToggle and Toggle
217
-  ------------------------------------------------------------
218
-  procedure WaitForAck ( signal Ack : In  std_logic ) ;
219
-  procedure StrobeAck  ( signal Ack : Out std_logic ) ;
220
-  
221
-end TbUtilPkg ;
222
-
223
-package body TbUtilPkg is 
224
-
225
-  ------------------------------------------------------------
226
-  -- ZeroOneHot, OneHot
227
-  --   OneHot:      return true if exactly one value is 1
228
-  --   ZeroOneHot:  return false when more than one value is a 1
229
-  ------------------------------------------------------------
230
-  function OneHot ( constant A : in std_logic_vector ) return boolean is
231
-    variable found_one : boolean := FALSE ;
232
-  begin
233
-    for i in A'range loop 
234
-      if A(i) = '1' or A(i) = 'H' then 
235
-        if found_one then 
236
-          return FALSE ; 
237
-        end if ; 
238
-        found_one := TRUE ;
239
-      end if ; 
240
-    end loop ;
241
-    return found_one ; -- found a one
242
-  end function OneHot ; 
243
-  
244
-  function ZeroOneHot ( constant A : in std_logic_vector ) return boolean is  
245
-    variable found_one : boolean := FALSE ;
246
-  begin
247
-    for i in A'range loop 
248
-      if A(i) = '1' or A(i) = 'H' then 
249
-        if found_one then 
250
-          return FALSE ; 
251
-        end if ; 
252
-        found_one := TRUE ;
253
-      end if ; 
254
-    end loop ;
255
-    return TRUE ;  -- all zero or found a one
256
-  end function ZeroOneHot ; 
257
-
258
-
259
-  ------------------------------------------------------------
260
-  -- RequestTransaction
261
-  --   Transaction initiation side of handshaking
262
-  --   Pairs with WaitForTransaction or one of its variations
263
-  ------------------------------------------------------------
264
-  procedure RequestTransaction (
265
-    signal Rdy  : Out std_logic ;
266
-    signal Ack  : In  std_logic 
267
-  ) is
268
-  begin
269
-    -- Record contains new transaction
270
-    Rdy        <= '1' ;
271
-    -- Find Ack low = '0' 
272
-    wait until Ack = '0' ;
273
-    -- Prepare for Next Transaction
274
-    Rdy        <= '0' ;
275
-    -- Transaction Done
276
-    wait until Ack = '1' ;        
277
-  end procedure ;
278
-
279
-
280
-  ------------------------------------------------------------
281
-  -- WaitForTransaction
282
-  --   Model side of handshaking
283
-  --   Pairs with RequestTransaction 
284
-  ------------------------------------------------------------
285
-  procedure WaitForTransaction (
286
-    signal Clk  : In  std_logic ;
287
-    signal Rdy  : In  std_logic ;
288
-    signal Ack  : Out std_logic 
289
-  ) is
290
-    variable AckTime : time ; 
291
-  begin
292
-    -- End of Previous Cycle.  Signal Done
293
-    Ack        <= '1' ;               --  #6
294
-    AckTime    := NOW ; 
295
-    -- Find Start of Transaction
296
-    if Rdy /= '1' then                --   #2
297
-      wait until Rdy = '1' ; 
298
-    else
299
-      wait for 0 ns ; -- allow Ack to update
300
-    end if ; 
301
-    -- align to clock if needed (not back-to-back transactions)
302
-    if NOW /= AckTime then 
303
-      wait until Clk = CLK_ACTIVE ;
304
-    end if ; 
305
-    -- Model active and owns the record
306
-    Ack        <= '0' ;               --  #3
307
-  end procedure ;
308
-
309
-  -- Variation for model that stops waiting when TimeOut is asserted
310
-  -- Intended for models that need to switch between instruction streams
311
-  -- such as a CPU when interrupt is pending
312
-  procedure WaitForTransaction (
313
-    signal   Clk       : In  std_logic ;
314
-    signal   Rdy       : In  std_logic ;
315
-    signal   Ack       : Out std_logic ;
316
-    signal   TimeOut   : In  std_logic ;
317
-    constant Polarity  : In std_logic := '1' 
318
-  ) is
319
-    variable AckTime : time ; 
320
-    variable FoundRdy : boolean ; 
321
-  begin
322
-    -- End of Previous Cycle.  Signal Done
323
-    Ack        <= '1' ;               --  #6
324
-    AckTime    := NOW ; 
325
-    -- Find Ready or Time out
326
-    if (Rdy /= '1' and TimeOut /= Polarity) then 
327
-      wait until Rdy = '1' or TimeOut = Polarity ; 
328
-    else
329
-      wait for 0 ns ; -- allow Ack to update
330
-    end if ; 
331
-    FoundRdy := Rdy = '1' ; 
332
-    -- align to clock if Rdy or TimeOut does not happen within delta cycles from Ack
333
-    if NOW /= AckTime then 
334
-      wait until Clk = CLK_ACTIVE ;
335
-    end if ; 
336
-    if FoundRdy then 
337
-      -- Model active and owns the record
338
-      Ack        <= '0' ;             --  #3
339
-    end if ;
340
-  end procedure ;
341
-  
342
-  -- Set Ack to Model starting value
343
-  -- Pairs with WaitForTransactionOrIrq above
344
-  procedure StartTransaction  ( signal Ack : Out std_logic ) is
345
-  begin
346
-    Ack        <= '0' ;
347
-  end procedure ; 
348
-
349
-  -- Set Ack to Model finishing value
350
-  -- Pairs with WaitForTransactionOrIrq above
351
-  procedure FinishTransaction ( signal Ack : Out std_logic ) is
352
-  begin
353
-    -- End of Cycle
354
-    Ack        <= '1' ;
355
-  end procedure ; 
356
-
357
-  -- If a transaction is pending, return true
358
-  --   Used to detect presence of transaction stream, 
359
-  --   such as an interrupt handler
360
-  function TransactionPending (
361
-    signal Rdy     : In  std_logic 
362
-  ) return boolean is
363
-  begin
364
-    return Rdy = '1' ; 
365
-  end function ;
366
-
367
-  -- Variation for clockless models
368
-  procedure WaitForTransaction (
369
-    signal Rdy  : In  std_logic ;
370
-    signal Ack  : Out std_logic 
371
-  ) is
372
-    variable AckTime : time ; 
373
-  begin
374
-    -- End of Previous Cycle.  Signal Done
375
-    Ack        <= '1' ;               --  #6
376
-    -- Find Start of Transaction
377
-    if Rdy /= '1' then                --   #2
378
-      wait until Rdy = '1' ; 
379
-    else
380
-      wait for 0 ns ; -- allow Ack to update
381
-    end if ; 
382
-    -- Model active and owns the record
383
-    Ack        <= '0' ;               --  #3
384
-  end procedure ;
385
-
386
-
387
-  ------------------------------------------------------------
388
-  -- Toggle, WaitForToggle
389
-  --   Used for communicating b