Browse Source

Replace OSVVM directory by git submodule

AHBL_BFM
T. Meissner 7 years ago
parent
commit
2ee7c4d131
23 changed files with 5 additions and 15878 deletions
  1. +3
    -0
      .gitmodules
  2. +0
    -3311
      OSVVM/AlertLogPkg.vhd
  3. +0
    -78
      OSVVM/Artistic License 2.0.md
  4. +0
    -5044
      OSVVM/CoveragePkg.vhd
  5. +0
    -672
      OSVVM/MemoryPkg.vhd
  6. +0
    -165
      OSVVM/MessagePkg.vhd
  7. +0
    -129
      OSVVM/NamePkg.vhd
  8. +0
    -63
      OSVVM/OsvvmContext.vhd
  9. +0
    -350
      OSVVM/OsvvmGlobalPkg.vhd
  10. +0
    -234
      OSVVM/RandomBasePkg.vhd
  11. +0
    -1647
      OSVVM/RandomPkg.vhd
  12. +0
    -392
      OSVVM/ResolutionPkg.vhd
  13. +0
    -1575
      OSVVM/ScoreboardGenericPkg.vhd
  14. +0
    -65
      OSVVM/ScoreboardPkg_int.vhd
  15. +0
    -65
      OSVVM/ScoreboardPkg_slv.vhd
  16. +0
    -417
      OSVVM/SortListPkg_int.vhd
  17. +0
    -851
      OSVVM/TbUtilPkg.vhd
  18. +0
    -407
      OSVVM/TextUtilPkg.vhd
  19. +0
    -200
      OSVVM/TranscriptPkg.vhd
  20. +0
    -120
      OSVVM/VendorCovApiPkg.vhd
  21. +0
    -92
      OSVVM/VendorCovApiPkg_Aldec.vhd
  22. +1
    -0
      lib/OSVVM
  23. +1
    -1
      test/Makefile

+ 3
- 0
.gitmodules View File

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

+ 0
- 3311
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 @@
This is a local copy of the Artistic License 2.0.
The original can be obtained here: [http://www.perlfoundation.org/artistic_license_2_0](http://www.perlfoundation.org/artistic_license_2_0)
--------------------------------------------------------------------------------
# Artistic License 2.0
**Copyright © 2000-2006, The Perl Foundation.**
Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed.
### Preamble
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.
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.
### Definitions
*"Copyright Holder"* means the individual(s) or organization(s) named in the copyright notice for the entire Package.
*"Contributor"* means any party that has contributed code or other material to the Package, in accordance with the Copyright Holder's procedures.
*"You"* and *"your"* means any person who would like to copy, distribute, or modify the Package.
*"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.
*"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.
*"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.
*"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.
*"Modified Version"* means the Package, if it has been changed, and such changes were not explicitly requested by the Copyright Holder.
*"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.
*"Source"* form means the source code, documentation source, and configuration files for the Package.
*"Compiled"* form means the compiled bytecode, object code, binary, or any other form resulting from mechanical transformation or translation of the Source form.
### Permission for Use and Modification Without Distribution
(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.
### Permissions for Redistribution of the Standard Version
(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.
(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.
### Distribution of Modified Versions of the Package as Source
(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:
- (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.
- (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.
- (c) allow anyone who receives a copy of the Modified Version to make the Source form of the Modified Version available to others under
- (i) the Original License or
- (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.
Distribution of Compiled Forms of the Standard Version or Modified Versions without the Source
(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.
(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.
### Aggregating or Linking the Package
(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.
(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.
### Items That are Not Considered Part of a Modified Version
(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.
### General Provisions
(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.
(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.
(12) This license does not grant you the right to use any trademark, service mark, tradename, or logo of the Copyright Holder.
(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.
(14) Disclaimer of Warranty:
**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
- 5044
OSVVM/CoveragePkg.vhd
File diff suppressed because it is too large
View File


+ 0
- 672
OSVVM/MemoryPkg.vhd View File

@ -1,672 +0,0 @@
--
-- File Name: MemoryPkg.vhd
-- Design Unit Name: MemoryPkg
-- Revision: STANDARD VERSION
--
-- Maintainer: Jim Lewis email: jim@synthworks.com
-- Contributor(s):
-- Jim Lewis email: jim@synthworks.com
--
-- Description
-- Package defines a protected type, MemoryPType, and methods
-- for efficiently implementing memory data structures
--
-- Developed for:
-- SynthWorks Design Inc.
-- VHDL Training Classes
-- 11898 SW 128th Ave. Tigard, Or 97223
-- http://www.SynthWorks.com
--
-- Revision History:
-- Date Version Description
-- 05/2005: 0.1 Initial revision
-- 06/2015: 2015.06 Updated for Alerts, ...
-- Numerous revisions for VHDL Testbenches and Verification
-- 01/2016: 2016.01 Update for buf.all(buf'left)
-- 11/2016: 2016.11 Refinement to MemRead to return value, X (if X), U (if not initialized)
--
--
-- Copyright (c) 2005 - 2016 by SynthWorks Design Inc. All rights reserved.
--
-- Verbatim copies of this source file may be used and
-- distributed without restriction.
--
-- This source file is free software; you can redistribute it
-- and/or modify it under the terms of the ARTISTIC License
-- as published by The Perl Foundation; either version 2.0 of
-- the License, or (at your option) any later version.
--
-- This source is distributed in the hope that it will be
-- useful, but WITHOUT ANY WARRANTY; without even the implied
-- warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
-- PURPOSE. See the Artistic License for details.
--
-- You should have received a copy of the license with this source.
-- If not download it from,
-- http://www.perlfoundation.org/artistic_license_2_0
--
use std.textio.all ;
library IEEE ;
use IEEE.std_logic_1164.all ;
use IEEE.numeric_std.all ;
use IEEE.numeric_std_unsigned.all ;
use IEEE.math_real.all ;
use work.TextUtilPkg.all ;
use work.TranscriptPkg.all ;
use work.AlertLogPkg.all ;
package MemoryPkg is
type MemoryPType is protected
------------------------------------------------------------
procedure MemInit ( AddrWidth, DataWidth : in integer ) ;
------------------------------------------------------------
procedure MemWrite ( Addr, Data : in std_logic_vector ) ;
------------------------------------------------------------
procedure MemRead (
Addr : in std_logic_vector ;
Data : out std_logic_vector
) ;
impure function MemRead ( Addr : std_logic_vector ) return std_logic_vector ;
------------------------------------------------------------
procedure MemErase ;
procedure deallocate ;
------------------------------------------------------------
procedure SetAlertLogID (A : AlertLogIDType) ;
procedure SetAlertLogID (Name : string ; ParentID : AlertLogIDType := ALERTLOG_BASE_ID ; CreateHierarchy : Boolean := TRUE) ;
impure function GetAlertLogID return AlertLogIDType ;
------------------------------------------------------------
procedure FileReadH ( -- Hexadecimal File Read
FileName : string ;
StartAddr : std_logic_vector ;
EndAddr : std_logic_vector
) ;
procedure FileReadH (FileName : string ; StartAddr : std_logic_vector) ;
procedure FileReadH (FileName : string) ;
------------------------------------------------------------
procedure FileReadB ( -- Binary File Read
FileName : string ;
StartAddr : std_logic_vector ;
EndAddr : std_logic_vector
) ;
procedure FileReadB (FileName : string ; StartAddr : std_logic_vector) ;
procedure FileReadB (FileName : string) ;
------------------------------------------------------------
procedure FileWriteH ( -- Hexadecimal File Write
FileName : string ;
StartAddr : std_logic_vector ;
EndAddr : std_logic_vector
) ;
procedure FileWriteH (FileName : string ; StartAddr : std_logic_vector) ;
procedure FileWriteH (FileName : string) ;
------------------------------------------------------------
procedure FileWriteB ( -- Binary File Write
FileName : string ;
StartAddr : std_logic_vector ;
EndAddr : std_logic_vector
) ;
procedure FileWriteB (FileName : string ; StartAddr : std_logic_vector) ;
procedure FileWriteB (FileName : string) ;
end protected MemoryPType ;
end MemoryPkg ;
package body MemoryPkg is
constant BLOCK_WIDTH : integer := 10 ;
type MemoryPType is protected body
type MemBlockType is array (integer range <>) of integer ;
type MemBlockPtrType is access MemBlockType ;
type MemArrayType is array (integer range <>) of MemBlockPtrType ;
type ArrayPtrVarType is access MemArrayType ;
variable ArrayPtrVar : ArrayPtrVarType := NULL ;
variable AddrWidthVar : integer := -1 ; -- set by MemInit - merges addr length and initialized checks.
variable DataWidthVar : natural := 1 ; -- set by MemInit
variable BlockkWidthVar : natural := 0 ; -- set by MemInit
variable AlertLogIDVar : AlertLogIDType := OSVVM_ALERTLOG_ID ;
type FileFormatType is (BINARY, HEX) ;
------------------------------------------------------------
procedure MemInit ( AddrWidth, DataWidth : In integer ) is
------------------------------------------------------------
begin
if AddrWidth <= 0 then
Alert(AlertLogIDVar, "MemoryPType.MemInit. AddrWidth = " & to_string(AddrWidth) & " must be > 0.", FAILURE) ;
return ;
end if ;
if DataWidth <= 0 then
Alert(AlertLogIDVar, "MemoryPType.MemInit. DataWidth = " & to_string(DataWidth) & " must be > 0.", FAILURE) ;
return ;
end if ;
AddrWidthVar := AddrWidth ;
DataWidthVar := DataWidth ;
BlockkWidthVar := minimum(BLOCK_WIDTH, AddrWidth) ;
ArrayPtrVar := new MemArrayType(0 to 2**(AddrWidth-BlockkWidthVar)-1) ;
end procedure MemInit ;
------------------------------------------------------------
procedure MemWrite ( Addr, Data : in std_logic_vector ) is
------------------------------------------------------------
variable BlockAddr, WordAddr : integer ;
alias aAddr : std_logic_vector (Addr'length-1 downto 0) is Addr ;
begin
-- Check Bounds of Address and if memory is initialized
if Addr'length /= AddrWidthVar then
if (ArrayPtrVar = NULL) then
Alert(AlertLogIDVar, "MemoryPType.MemWrite: Memory not initialized, Write Ignored.", FAILURE) ;
else
Alert(AlertLogIDVar, "MemoryPType.MemWrite: Addr'length: " & to_string(Addr'length) & " /= Memory Address Width: " & to_string(AddrWidthVar), FAILURE) ;
end if ;
return ;
end if ;
-- Check Bounds on Data
if Data'length /= DataWidthVar then
Alert(AlertLogIDVar, "MemoryPType.MemWrite: Data'length: " & to_string(Data'length) & " /= Memory Data Width: " & to_string(DataWidthVar), FAILURE) ;
return ;
end if ;
if is_X( Addr ) then
Alert(AlertLogIDVar, "MemoryPType.MemWrite: Address X, Write Ignored.") ;
return ;
end if ;
-- Slice out upper address to form block address
if aAddr'high >= BlockkWidthVar then
BlockAddr := to_integer(aAddr(aAddr'high downto BlockkWidthVar)) ;
else
BlockAddr := 0 ;
end if ;
-- If empty, allocate a memory block
if (ArrayPtrVar(BlockAddr) = NULL) then
ArrayPtrVar(BlockAddr) := new MemBlockType(0 to 2**BlockkWidthVar-1) ;
end if ;
-- Address of a word within a block
WordAddr := to_integer(aAddr(BlockkWidthVar -1 downto 0)) ;
-- Write to BlockAddr, WordAddr
if (Is_X(Data)) then
ArrayPtrVar(BlockAddr)(WordAddr) := -1 ;
else
ArrayPtrVar(BlockAddr)(WordAddr) := to_integer( Data ) ;
end if ;
end procedure MemWrite ;
------------------------------------------------------------
procedure MemRead (
------------------------------------------------------------
Addr : In std_logic_vector ;
Data : Out std_logic_vector
) is
variable BlockAddr, WordAddr : integer ;
alias aAddr : std_logic_vector (Addr'length-1 downto 0) is Addr ;
begin
-- Check Bounds of Address and if memory is initialized
if Addr'length /= AddrWidthVar then
if (ArrayPtrVar = NULL) then
Alert(AlertLogIDVar, "MemoryPType.MemRead: Memory not initialized. Returning U", FAILURE) ;
else
Alert(AlertLogIDVar, "MemoryPType.MemRead: Addr'length: " & to_string(Addr'length) & " /= Memory Address Width: " & to_string(AddrWidthVar), FAILURE) ;
end if ;
Data := (Data'range => 'U') ;
return ;
end if ;
-- Check Bounds on Data
if Data'length /= DataWidthVar then
Alert(AlertLogIDVar, "MemoryPType.MemRead: Data'length: " & to_string(Data'length) & " /= Memory Data Width: " & to_string(DataWidthVar), FAILURE) ;
Data := (Data'range => 'U') ;
return ;
end if ;
-- If Addr X, data = X
if is_X( aAddr ) then
Data := (Data'range => 'X') ;
return ;
end if ;
-- Slice out upper address to form block address
if aAddr'high >= BlockkWidthVar then
BlockAddr := to_integer(aAddr(aAddr'high downto BlockkWidthVar)) ;
else
BlockAddr := 0 ;
end if ;
-- Empty Block, return all U
if (ArrayPtrVar(BlockAddr) = NULL) then
Data := (Data'range => 'U') ;
return ;
end if ;
-- Address of a word within a block
WordAddr := to_integer(aAddr(BlockkWidthVar -1 downto 0)) ;
if ArrayPtrVar(BlockAddr)(WordAddr) >= 0 then
-- Get the Word from the Array
Data := to_slv(ArrayPtrVar(BlockAddr)(WordAddr), Data'length) ;
elsif ArrayPtrVar(BlockAddr)(WordAddr) = -1 then
-- X in Word, return all X
Data := (Data'range => 'X') ;
else
-- Location Uninitialized, return all X
Data := (Data'range => 'U') ;
end if ;
end procedure MemRead ;
------------------------------------------------------------
impure function MemRead ( Addr : std_logic_vector ) return std_logic_vector is
------------------------------------------------------------
variable BlockAddr, WordAddr : integer ;
alias aAddr : std_logic_vector (Addr'length-1 downto 0) is Addr ;
variable Data : std_logic_vector(DataWidthVar-1 downto 0) ;
begin
MemRead(Addr, Data) ;
return Data ;
end function MemRead ;
------------------------------------------------------------
procedure MemErase is
-- Deallocate the memory, but not the array of pointers
------------------------------------------------------------
begin
for BlockAddr in ArrayPtrVar'range loop
if (ArrayPtrVar(BlockAddr) /= NULL) then
deallocate (ArrayPtrVar(BlockAddr)) ;
end if ;
end loop ;
end procedure ;
------------------------------------------------------------
procedure deallocate is
-- Deallocate all allocated memory
------------------------------------------------------------
begin
MemErase ;
deallocate(ArrayPtrVar) ;
AddrWidthVar := -1 ;
DataWidthVar := 1 ;
BlockkWidthVar := 0 ;
end procedure ;
------------------------------------------------------------
procedure SetAlertLogID (A : AlertLogIDType) is
------------------------------------------------------------
begin
AlertLogIDVar := A ;
end procedure SetAlertLogID ;
------------------------------------------------------------
procedure SetAlertLogID(Name : string ; ParentID : AlertLogIDType := ALERTLOG_BASE_ID ; CreateHierarchy : Boolean := TRUE) is
------------------------------------------------------------
begin
AlertLogIDVar := GetAlertLogID(Name, ParentID, CreateHierarchy) ;
end procedure SetAlertLogID ;
------------------------------------------------------------
impure function GetAlertLogID return AlertLogIDType is
------------------------------------------------------------
begin
return AlertLogIDVar ;
end function GetAlertLogID ;
------------------------------------------------------------
-- PT Local
procedure FileReadX (
-- Hexadecimal or Binary File Read
------------------------------------------------------------
FileName : string ;
DataFormat : FileFormatType ;
StartAddr : std_logic_vector ;
EndAddr : std_logic_vector
) is
-- Format:
-- @hh..h -- Address in hex
-- hhh_XX_ZZ -- data values in hex - space delimited
-- "--" or "//" -- comments
file MemFile : text open READ_MODE is FileName ;
variable Addr : std_logic_vector(AddrWidthVar - 1 downto 0) ;
variable SmallAddr : std_logic_vector(AddrWidthVar - 1 downto 0) ;
variable BigAddr : std_logic_vector(AddrWidthVar - 1 downto 0) ;
variable Data : std_logic_vector(DataWidthVar - 1 downto 0) ;
variable LineNum : natural ;
variable ItemNum : natural ;
variable AddrInc : std_logic_vector(AddrWidthVar - 1 downto 0) ;
variable buf : line ;
variable ReadValid : boolean ;
variable Empty : boolean ;
variable MultiLineComment : boolean ;
variable NextChar : character ;
variable StrLen : integer ;
begin
MultiLineComment := FALSE ;
if StartAddr'length /= AddrWidthVar and EndAddr'length /= AddrWidthVar then
if (ArrayPtrVar = NULL) then
Alert(AlertLogIDVar, "MemoryPType.FileReadX: Memory not initialized, FileRead Ignored.", FAILURE) ;
else
Alert(AlertLogIDVar, "MemoryPType.FileReadX: Addr'length: " & to_string(Addr'length) & " /= Memory Address Width: " & to_string(AddrWidthVar), FAILURE) ;
end if ;
return ;
end if ;
Addr := StartAddr ;
LineNum := 0 ;
if StartAddr <= EndAddr then
SmallAddr := StartAddr ;
BigAddr := EndAddr ;
AddrInc := (AddrWidthVar -1 downto 0 => '0') + 1 ;
else
SmallAddr := EndAddr ;
BigAddr := StartAddr ;
AddrInc := (others => '1') ; -- -1
end if;
ReadLineLoop : while not EndFile(MemFile) loop
ReadLine(MemFile, buf) ;
LineNum := LineNum + 1 ;
ItemNum := 0 ;
ItemLoop : loop
EmptyOrCommentLine(buf, Empty, MultiLineComment) ;
exit ItemLoop when Empty ;
ItemNum := ItemNum + 1 ;
NextChar := buf.all(buf'left) ;
if (NextChar = '@') then
-- Get Address
read(buf, NextChar) ;
ReadHexToken(buf, Addr, StrLen) ;
exit ReadLineLoop when AlertIf(AlertLogIDVar, StrLen = 0, "MemoryPType.FileReadX: Address length 0 on line: " & to_string(LineNum), FAILURE) ;
exit ItemLoop when AlertIf(AlertLogIDVar, Addr < SmallAddr,
"MemoryPType.FileReadX: Address in file: " & to_hstring(Addr) &
" < StartAddr: " & to_hstring(StartAddr) & " on line: " & to_string(LineNum)) ;
exit ItemLoop when AlertIf(AlertLogIDVar, Addr > BigAddr,
"MemoryPType.FileReadX: Address in file: " & to_hstring(Addr) &
" > EndAddr: " & to_hstring(BigAddr) & " on line: " & to_string(LineNum)) ;
elsif DataFormat = HEX and ishex(NextChar) then
-- Get Hex Data
ReadHexToken(buf, data, StrLen) ;
exit ReadLineLoop when AlertIfNot(AlertLogIDVar, StrLen > 0,
"MemoryPType.FileReadH: Error while reading data on line: " & to_string(LineNum) &
" Item number: " & to_string(ItemNum), FAILURE) ;
log("MemoryPType.FileReadX: MemWrite(Addr => " & to_hstring(Addr) & ", Data => " & to_hstring(Data) & ")", DEBUG) ;
MemWrite(Addr, data) ;
Addr := Addr + AddrInc ;
elsif DataFormat = BINARY and isstd_logic(NextChar) then
-- Get Binary Data
-- read(buf, data, ReadValid) ;
ReadBinaryToken(buf, data, StrLen) ;
-- exit ReadLineLoop when AlertIfNot(AlertLogIDVar, ReadValid,
exit ReadLineLoop when AlertIfNot(AlertLogIDVar, StrLen > 0,
"MemoryPType.FileReadB: Error while reading data on line: " & to_string(LineNum) &
" Item number: " & to_string(ItemNum), FAILURE) ;
log("MemoryPType.FileReadX: MemWrite(Addr => " & to_hstring(Addr) & ", Data => " & to_string(Data) & ")", DEBUG) ;
MemWrite(Addr, data) ;
Addr := Addr + AddrInc ;
else
-- Invalid Text, Issue Warning and skip it
Alert(AlertLogIDVar,
"MemoryPType.FileReadX: Invalid text on line: " & to_string(LineNum) &
" Item: " & to_string(ItemNum) & ". Skipping text: " & buf.all) ;
exit ItemLoop ;
end if ;
end loop ItemLoop ;
end loop ReadLineLoop ;
-- -- must read EndAddr-StartAddr number of words if both start and end specified
-- if (StartAddr /= 0 or (not EndAddr) /= 0) and (Addr /= EndAddr) then
-- Alert("MemoryPType.FileReadH: insufficient data values", WARNING) ;
-- end if ;
file_close(MemFile) ;
end FileReadX ;
------------------------------------------------------------
procedure FileReadH (
-- Hexadecimal File Read
------------------------------------------------------------
FileName : string ;
StartAddr : std_logic_vector ;
EndAddr : std_logic_vector
) is
begin
FileReadX(FileName, HEX, StartAddr, EndAddr) ;
end FileReadH ;
------------------------------------------------------------
procedure FileReadH (FileName : string ; StartAddr : std_logic_vector) is
-- Hexadecimal File Read
------------------------------------------------------------
constant EndAddr : std_logic_vector(AddrWidthVar - 1 downto 0) := (others => '1') ;
begin
FileReadX(FileName, HEX, StartAddr, EndAddr) ;
end FileReadH ;
------------------------------------------------------------
procedure FileReadH (FileName : string) is
-- Hexadecimal File Read
------------------------------------------------------------
constant StartAddr : std_logic_vector(AddrWidthVar - 1 downto 0) := (others => '0') ;
constant EndAddr : std_logic_vector(AddrWidthVar - 1 downto 0) := (others => '1') ;
begin
FileReadX(FileName, HEX, StartAddr, EndAddr) ;
end FileReadH ;
------------------------------------------------------------
procedure FileReadB (
-- Binary File Read
------------------------------------------------------------
FileName : string ;
StartAddr : std_logic_vector ;
EndAddr : std_logic_vector
) is
begin
FileReadX(FileName, BINARY, StartAddr, EndAddr) ;
end FileReadB ;
------------------------------------------------------------
procedure FileReadB (FileName : string ; StartAddr : std_logic_vector) is
-- Binary File Read
------------------------------------------------------------
constant EndAddr : std_logic_vector(AddrWidthVar - 1 downto 0) := (others => '1') ;
begin
FileReadX(FileName, BINARY, StartAddr, EndAddr) ;
end FileReadB ;
------------------------------------------------------------
procedure FileReadB (FileName : string) is
-- Binary File Read
------------------------------------------------------------
constant StartAddr : std_logic_vector(AddrWidthVar - 1 downto 0) := (others => '0') ;
constant EndAddr : std_logic_vector(AddrWidthVar - 1 downto 0) := (others => '1') ;
begin
FileReadX(FileName, BINARY, StartAddr, EndAddr) ;
end FileReadB ;
------------------------------------------------------------
-- PT Local
procedure FileWriteX (
-- Hexadecimal or Binary File Write
------------------------------------------------------------
FileName : string ;
DataFormat : FileFormatType ;
StartAddr : std_logic_vector ;
EndAddr : std_logic_vector
) is
-- Format:
-- @hh..h -- Address in hex
-- hhhhh -- data one per line in either hex or binary as specified
file MemFile : text open WRITE_MODE is FileName ;
alias normStartAddr : std_logic_vector(StartAddr'length-1 downto 0) is StartAddr ;
alias normEndAddr : std_logic_vector(EndAddr'length-1 downto 0) is EndAddr ;
variable StartBlockAddr : natural ;
variable EndBlockAddr : natural ;
variable StartWordAddr : natural ;
variable EndWordAddr : natural ;
variable Data : std_logic_vector(DataWidthVar - 1 downto 0) ;
variable FoundData : boolean ;
variable buf : line ;
begin
if StartAddr'length /= AddrWidthVar and EndAddr'length /= AddrWidthVar then
-- Check StartAddr and EndAddr Widths and Memory not initialized
if (ArrayPtrVar = NULL) then
Alert(AlertLogIDVar, "MemoryPType.FileWriteX: Memory not initialized, FileRead Ignored.", FAILURE) ;
else
AlertIf(AlertLogIDVar, StartAddr'length /= AddrWidthVar, "MemoryPType.FileWriteX: StartAddr'length: "
& to_string(StartAddr'length) &
" /= Memory Address Width: " & to_string(AddrWidthVar), FAILURE) ;
AlertIf(AlertLogIDVar, EndAddr'length /= AddrWidthVar, "MemoryPType.FileWriteX: EndAddr'length: "
& to_string(EndAddr'length) &
" /= Memory Address Width: " & to_string(AddrWidthVar), FAILURE) ;
end if ;
return ;
end if ;
if StartAddr > EndAddr then
-- Only support ascending addresses
Alert(AlertLogIDVar, "MemoryPType.FileWriteX: StartAddr: " & to_hstring(StartAddr) &
" > EndAddr: " & to_hstring(EndAddr), FAILURE) ;
return ;
end if ;
-- Slice out upper address to form block address
if AddrWidthVar >= BlockkWidthVar then
StartBlockAddr := to_integer(normStartAddr(AddrWidthVar-1 downto BlockkWidthVar)) ;
EndBlockAddr := to_integer( normEndAddr(AddrWidthVar-1 downto BlockkWidthVar)) ;
else
StartBlockAddr := 0 ;
EndBlockAddr := 0 ;
end if ;
BlockAddrLoop : for BlockAddr in StartBlockAddr to EndBlockAddr loop
next BlockAddrLoop when ArrayPtrVar(BlockAddr) = NULL ;
if BlockAddr = StartBlockAddr then
StartWordAddr := to_integer(normStartAddr(BlockkWidthVar-1 downto 0)) ;
else
StartWordAddr := 0 ;
end if ;
if BlockAddr = EndBlockAddr then
EndWordAddr := to_integer(normEndAddr(BlockkWidthVar-1 downto 0)) ;
else
EndWordAddr := 2**BlockkWidthVar-1 ;
end if ;
FoundData := FALSE ;
WordAddrLoop : for WordAddr in StartWordAddr to EndWordAddr loop
if (ArrayPtrVar(BlockAddr)(WordAddr) < 0) then
-- X in Word, return all X
Data := (Data'range => 'X') ;
FoundData := FALSE ;
else
-- Get the Word from the Array
Data := to_slv(ArrayPtrVar(BlockAddr)(WordAddr), Data'length) ;
if not FoundData then
-- Write Address
write(buf, '@') ;
hwrite(buf, to_slv(BlockAddr, AddrWidthVar-BlockkWidthVar) & to_slv(WordAddr, BlockkWidthVar)) ;
writeline(MemFile, buf) ;
end if ;
FoundData := TRUE ;
end if ;
if FoundData then -- Write Data
if DataFormat = HEX then
hwrite(buf, Data) ;
writeline(MemFile, buf) ;
else
write(buf, Data) ;
writeline(MemFile, buf) ;
end if;
end if ;
end loop WordAddrLoop ;
end loop BlockAddrLoop ;
file_close(MemFile) ;
end FileWriteX ;
------------------------------------------------------------
procedure FileWriteH (
-- Hexadecimal File Write
------------------------------------------------------------
FileName : string ;
StartAddr : std_logic_vector ;
EndAddr : std_logic_vector
) is
begin
FileWriteX(FileName, HEX, StartAddr, EndAddr) ;
end FileWriteH ;
------------------------------------------------------------
procedure FileWriteH (FileName : string ; StartAddr : std_logic_vector) is
-- Hexadecimal File Write
------------------------------------------------------------
constant EndAddr : std_logic_vector(AddrWidthVar - 1 downto 0) := (others => '1') ;
begin
FileWriteX(FileName, HEX, StartAddr, EndAddr) ;
end FileWriteH ;
------------------------------------------------------------
procedure FileWriteH (FileName : string) is
-- Hexadecimal File Write
------------------------------------------------------------
constant StartAddr : std_logic_vector(AddrWidthVar - 1 downto 0) := (others => '0') ;
constant EndAddr : std_logic_vector(AddrWidthVar - 1 downto 0) := (others => '1') ;
begin
FileWriteX(FileName, HEX, StartAddr, EndAddr) ;
end FileWriteH ;
------------------------------------------------------------
procedure FileWriteB (
-- Binary File Write
------------------------------------------------------------
FileName : string ;
StartAddr : std_logic_vector ;
EndAddr : std_logic_vector
) is
begin
FileWriteX(FileName, BINARY, StartAddr, EndAddr) ;
end FileWriteB ;
------------------------------------------------------------
procedure FileWriteB (FileName : string ; StartAddr : std_logic_vector) is
-- Binary File Write
------------------------------------------------------------
constant EndAddr : std_logic_vector(AddrWidthVar - 1 downto 0) := (others => '1') ;
begin
FileWriteX(FileName, BINARY, StartAddr, EndAddr) ;
end FileWriteB ;
------------------------------------------------------------
procedure FileWriteB (FileName : string) is
-- Binary File Write
------------------------------------------------------------
constant StartAddr : std_logic_vector(AddrWidthVar - 1 downto 0) := (others => '0') ;
constant EndAddr : std_logic_vector(AddrWidthVar - 1 downto 0) := (others => '1') ;
begin
FileWriteX(FileName, BINARY, StartAddr, EndAddr) ;
end FileWriteB ;
end protected body MemoryPType ;
end MemoryPkg ;

+ 0
- 165
OSVVM/MessagePkg.vhd View File

@ -1,165 +0,0 @@
--
-- File Name: MessagePkg.vhd
-- Design Unit Name: MessagePkg
-- Revision: STANDARD VERSION, revision 2015.01
--
-- Maintainer: Jim Lewis email: jim@synthworks.com
-- Contributor(s):
-- Jim Lewis SynthWorks
--
--
-- Package Defines
-- Data structure for multi-line name/message to be associated with a data structure.
--
-- Developed for:
-- SynthWorks Design Inc.
-- VHDL Training Classes
-- 11898 SW 128th Ave. Tigard, Or 97223
-- http://www.SynthWorks.com
--
-- Latest standard version available at:
-- http://www.SynthWorks.com/downloads
--
-- Revision History:
-- Date Version Description
-- 06/2010: 0.1 Initial revision
-- 07/2014: 2014.07 Moved specialization required by CoveragePkg to CoveragePkg
-- 07/2014: 2014.07a Removed initialized pointers which can lead to memory leaks.
-- 01/2015: 2015.01 Removed initialized parameter from Get
--
--
-- Copyright (c) 2010 - 2015 by SynthWorks Design Inc. All rights reserved.
--
-- Verbatim copies of this source file may be used and
-- distributed without restriction.
--
-- This source file is free software; you can redistribute it
-- and/or modify it under the terms of the ARTISTIC License
-- as published by The Perl Foundation; either version 2.0 of
-- the License, or (at your option) any later version.
--
-- This source is distributed in the hope that it will be
-- useful, but WITHOUT ANY WARRANTY; without even the implied
-- warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
-- PURPOSE. See the Artistic License for details.
--
-- You should have received a copy of the license with this source.
-- If not download it from,
-- http://www.perlfoundation.org/artistic_license_2_0
--
use work.OsvvmGlobalPkg.all ;
use work.AlertLogPkg.all ;
library ieee ;
use ieee.std_logic_1164.all ;
use ieee.numeric_std.all ;
use ieee.math_real.all ;
use std.textio.all ;
package MessagePkg is
type MessagePType is protected
procedure Set (MessageIn : String) ;
impure function Get (ItemNumber : integer) return string ;
impure function GetCount return integer ;
impure function IsSet return boolean ;
procedure Clear ; -- clear message
procedure Deallocate ; -- clear message
end protected MessagePType ;
end package MessagePkg ;
--- ///////////////////////////////////////////////////////////////////////////
--- ///////////////////////////////////////////////////////////////////////////
--- ///////////////////////////////////////////////////////////////////////////
package body MessagePkg is
-- Local Data Structure Types
type LineArrayType is array (natural range <>) of line ;
type LineArrayPtrType is access LineArrayType ;
type MessagePType is protected body
variable MessageCount : integer := 0 ;
constant INITIAL_ITEM_COUNT : integer := 16 ;
variable MaxMessageCount : integer := 0 ;
variable MessagePtr : LineArrayPtrType ;
------------------------------------------------------------
procedure Set (MessageIn : String) is
------------------------------------------------------------
variable NamePtr : line ;
variable OldMaxMessageCount : integer ;
variable OldMessagePtr : LineArrayPtrType ;
begin
MessageCount := MessageCount + 1 ;
if MessageCount > MaxMessageCount then
OldMaxMessageCount := MaxMessageCount ;
MaxMessageCount := MaxMessageCount + INITIAL_ITEM_COUNT ;
OldMessagePtr := MessagePtr ;
MessagePtr := new LineArrayType(1 to MaxMessageCount) ;
for i in 1 to OldMaxMessageCount loop
MessagePtr(i) := OldMessagePtr(i) ;
end loop ;
Deallocate( OldMessagePtr ) ;
end if ;
MessagePtr(MessageCount) := new string'(MessageIn) ;
end procedure Set ;
------------------------------------------------------------
impure function Get (ItemNumber : integer) return string is
------------------------------------------------------------
begin
if MessageCount > 0 then
if ItemNumber >= 1 and ItemNumber <= MessageCount then
return MessagePtr(ItemNumber).all ;
else
Alert(OSVVM_ALERTLOG_ID, "%% MessagePkg.Get input value out of range", FAILURE) ;
return "" ; -- error if this happens
end if ;
else
Alert(OSVVM_ALERTLOG_ID, "%% MessagePkg.Get message is not set", FAILURE) ;
return "" ; -- error if this happens
end if ;
end function Get ;
------------------------------------------------------------
impure function GetCount return integer is
------------------------------------------------------------
begin
return MessageCount ;
end function GetCount ;
------------------------------------------------------------
impure function IsSet return boolean is
------------------------------------------------------------
begin
return MessageCount > 0 ;
end function IsSet ;
------------------------------------------------------------
procedure Deallocate is -- clear message
------------------------------------------------------------
variable CurPtr : LineArrayPtrType ;
begin
for i in 1 to MessageCount loop
deallocate( MessagePtr(i) ) ;
end loop ;
MessageCount := 0 ;
MaxMessageCount := 0 ;
deallocate( MessagePtr ) ;
end procedure Deallocate ;
------------------------------------------------------------
procedure Clear is -- clear
------------------------------------------------------------
begin
Deallocate ;
end procedure Clear ;
end protected body MessagePType ;
end package body MessagePkg ;

+ 0
- 129
OSVVM/NamePkg.vhd View File

@ -1,129 +0,0 @@
--
-- File Name: NamePkg.vhd
-- Design Unit Name: NamePkg
-- Revision: STANDARD VERSION
--
-- Maintainer: Jim Lewis email: jim@synthworks.com
-- Contributor(s):
-- Jim Lewis SynthWorks
--
--
-- Package Defines
-- Data structure for name.
--
-- Developed for:
-- SynthWorks Design Inc.
-- VHDL Training Classes
-- 11898 SW 128th Ave. Tigard, Or 97223
-- http://www.SynthWorks.com
--
-- Latest standard version available at:
-- http://www.SynthWorks.com/downloads
--
-- Revision History:
-- Date Version Description
-- 06/2010: 0.1 Initial revision
-- 07/2014: 2014.07 Moved specialization required by CoveragePkg to CoveragePkg
-- Separated name handling from message handling to simplify naming
-- 12/2014: 2014.07a Removed initialized pointers which can lead to memory leaks.
-- 05/2015 2015.06 Added input to Get to return when not initialized
--
--
-- Copyright (c) 2010 - 2015 by SynthWorks Design Inc. All rights reserved.
--
-- Verbatim copies of this source file may be used and
-- distributed without restriction.
--
-- This source file is free software; you can redistribute it
-- and/or modify it under the terms of the ARTISTIC License
-- as published by The Perl Foundation; either version 2.0 of
-- the License, or (at your option) any later version.
--
-- This source is distributed in the hope that it will be
-- useful, but WITHOUT ANY WARRANTY; without even the implied
-- warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
-- PURPOSE. See the Artistic License for details.
--
-- You should have received a copy of the license with this source.
-- If not download it from,
-- http://www.perlfoundation.org/artistic_license_2_0
--
use std.textio.all ;
package NamePkg is
type NamePType is protected
procedure Set (NameIn : String) ;
impure function Get (DefaultName : string := "") return string ;
impure function GetOpt return string ;
impure function IsSet return boolean ;
procedure Clear ; -- clear name
procedure Deallocate ; -- effectively alias to clear name
end protected NamePType ;
end package NamePkg ;
--- ///////////////////////////////////////////////////////////////////////////
--- ///////////////////////////////////////////////////////////////////////////
--- ///////////////////////////////////////////////////////////////////////////
package body NamePkg is
type NamePType is protected body
variable NamePtr : line ;
------------------------------------------------------------
procedure Set (NameIn : String) is
------------------------------------------------------------
begin
deallocate(NamePtr) ;
NamePtr := new string'(NameIn) ;
end procedure Set ;
------------------------------------------------------------
impure function Get (DefaultName : string := "") return string is
------------------------------------------------------------
begin
if NamePtr = NULL then
return DefaultName ;
else
return NamePtr.all ;
end if ;
end function Get ;
------------------------------------------------------------
impure function GetOpt return string is
------------------------------------------------------------
begin
if NamePtr = NULL then
return NUL & "" ;
else
return NamePtr.all ;
end if ;
end function GetOpt ;
------------------------------------------------------------
impure function IsSet return boolean is
------------------------------------------------------------
begin
return NamePtr /= NULL ;
end function IsSet ;
------------------------------------------------------------
procedure Clear is -- clear name
------------------------------------------------------------
begin
deallocate(NamePtr) ;
end procedure Clear ;
------------------------------------------------------------
procedure Deallocate is -- clear name
------------------------------------------------------------
begin
Clear ;
end procedure Deallocate ;
end protected body NamePType ;
end package body NamePkg ;

+ 0
- 63
OSVVM/OsvvmContext.vhd View File

@ -1,63 +0,0 @@
--
-- File Name: OsvvmContext.vhd
-- Design Unit Name: OsvvmContext
-- Revision: STANDARD VERSION
--
-- Maintainer: Jim Lewis email: jim@synthworks.com--
--
-- Description
-- Context Declaration for OSVVM packages
--
-- Developed by/for:
-- SynthWorks Design Inc.
-- VHDL Training Classes
-- 11898 SW 128th Ave. Tigard, Or 97223
-- http://www.SynthWorks.com
--
-- Latest standard version available at:
-- http://www.SynthWorks.com/downloads
--
-- Revision History:
-- Date Version Description
-- 01/2015 2015.01 Initial Revision
-- 06/2015 2015.06 Added MemoryPkg
-- 11/2016 2016.11 Added TbUtilPkg and ResolutionPkg
--
--
-- Copyright (c) 2015 - 2016 by SynthWorks Design Inc. All rights reserved.
--
-- Verbatim copies of this source file may be used and
-- distributed without restriction.
--
-- This source file is free software; you can redistribute it
-- and/or modify it under the terms of the ARTISTIC License
-- as published by The Perl Foundation; either version 2.0 of
-- the License, or (at your option) any later version.
--
-- This source is distributed in the hope that it will be
-- useful, but WITHOUT ANY WARRANTY; without even the implied
-- warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
-- PURPOSE. See the Artistic License for details.
--
-- You should have received a copy of the license with this source.
-- If not download it from,
-- http://www.perlfoundation.org/artistic_license_2_0
--
--
context OsvvmContext is
library OSVVM ;
use OSVVM.NamePkg.all ;
use OSVVM.TranscriptPkg.all ;
use OSVVM.TextUtilPkg.all ;
use OSVVM.OsvvmGlobalPkg.all ;
use OSVVM.AlertLogPkg.all ;
use OSVVM.RandomPkg.all ;
use OSVVM.CoveragePkg.all ;
use OSVVM.MemoryPkg.all ;
use OSVVM.ResolutionPkg.all ;
use OSVVM.TbUtilPkg.all ;
end context OsvvmContext ;

+ 0
- 350
OSVVM/OsvvmGlobalPkg.vhd View File

@ -1,350 +0,0 @@
--
-- File Name: OsvvmGlobalPkg.vhd
-- Design Unit Name: OsvvmGlobalPkg
-- Revision: STANDARD VERSION, revision 2015.01
--
-- Maintainer: Jim Lewis email: jim@synthworks.com
-- Contributor(s):
-- Jim Lewis jim@synthworks.com
--
--
-- Description:
-- Global Settings for OSVVM packages
--
--
-- Developed for:
-- SynthWorks Design Inc.
-- VHDL Training Classes
-- 11898 SW 128th Ave. Tigard, Or 97223
-- http://www.SynthWorks.com
--
-- Revision History:
-- Date Version Description
-- 01/2014: 2015.01 Initial revision
--
--
-- Copyright (c) 2015 by SynthWorks Design Inc. All rights reserved.
--
-- Verbatim copies of this source file may be used and
-- distributed without restriction.
--
-- This source file is free software; you can redistribute it
-- and/or modify it under the terms of the ARTISTIC License
-- as published by The Perl Foundation; either version 2.0 of
-- the License, or (at your option) any later version.
--
-- This source is distributed in the hope that it will be
-- useful, but WITHOUT ANY WARRANTY; without even the implied
-- warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
-- PURPOSE. See the Artistic License for details.
--
-- You should have received a copy of the license with this source.
-- If not download it from,
-- http://www.perlfoundation.org/artistic_license_2_0
--
library ieee ;
use std.textio.all ;
use work.NamePkg.all ;
package OsvvmGlobalPkg is
-- FILE IO Global File Identifier -- Open using AlertLogPkg.TranscriptOpen
-- file TranscriptFile : text ;
-- Shared Options Type used in OSVVM
type OsvvmOptionsType is (OPT_INIT_PARM_DETECT, OPT_USE_DEFAULT, DISABLED, FALSE, ENABLED, TRUE) ;
function IsEnabled (A : OsvvmOptionsType) return boolean ; -- Requires that TRUE is last and ENABLED is 2nd to last
function to_OsvvmOptionsType (A : boolean) return OsvvmOptionsType ;
-- Defaults for String values
constant OSVVM_DEFAULT_ALERT_PREFIX : string := "%% Alert" ;
constant OSVVM_DEFAULT_LOG_PREFIX : string := "%% Log " ;
constant OSVVM_DEFAULT_WRITE_PREFIX : string := "%% " ;
constant OSVVM_DEFAULT_DONE_NAME : string := "DONE" ;
constant OSVVM_DEFAULT_PASS_NAME : string := "PASSED" ;
constant OSVVM_DEFAULT_FAIL_NAME : string := "FAILED" ;
constant OSVVM_STRING_INIT_PARM_DETECT : string := NUL & NUL & NUL ;
constant OSVVM_STRING_USE_DEFAULT : string := NUL & "" ;
-- Coverage Settings
constant OSVVM_DEFAULT_WRITE_PASS_FAIL : OsvvmOptionsType := FALSE ;
constant OSVVM_DEFAULT_WRITE_BIN_INFO : OsvvmOptionsType := TRUE ;
constant OSVVM_DEFAULT_WRITE_COUNT : OsvvmOptionsType := TRUE ;
constant OSVVM_DEFAULT_WRITE_ANY_ILLEGAL : OsvvmOptionsType := FALSE ;
------------------------------------------------------------
procedure SetOsvvmGlobalOptions (
------------------------------------------------------------
WritePassFail : OsvvmOptionsType := OPT_INIT_PARM_DETECT ;
WriteBinInfo : OsvvmOptionsType := OPT_INIT_PARM_DETECT ;
WriteCount : OsvvmOptionsType := OPT_INIT_PARM_DETECT ;
WriteAnyIllegal : OsvvmOptionsType := OPT_INIT_PARM_DETECT ;
WritePrefix : string := OSVVM_STRING_INIT_PARM_DETECT ;
DoneName : string := OSVVM_STRING_INIT_PARM_DETECT ;
PassName : string := OSVVM_STRING_INIT_PARM_DETECT ;
FailName : string := OSVVM_STRING_INIT_PARM_DETECT
) ;
------------------------------------------------------------
-- Accessor Functions
function ResolveOsvvmOption(A, B, C : OsvvmOptionsType) return OsvvmOptionsType ;
function ResolveOsvvmOption(A, B, C, D : OsvvmOptionsType) return OsvvmOptionsType ;
function IsOsvvmStringSet (A : string) return boolean ;
function ResolveOsvvmOption(A, B : string) return string ;
function ResolveOsvvmOption(A, B, C : string) return string ;
function ResolveOsvvmOption(A, B, C, D : string) return string ;
impure function ResolveOsvvmWritePrefix(A : String) return string ;
impure function ResolveOsvvmWritePrefix(A, B : String) return string ;
impure function ResolveOsvvmDoneName(A : String) return string ;
impure function ResolveOsvvmDoneName(A, B : String) return string ;
impure function ResolveOsvvmPassName(A : String) return string ;
impure function ResolveOsvvmPassName(A, B : String) return string ;
impure function ResolveOsvvmFailName(A : String) return string ;
impure function ResolveOsvvmFailName(A, B : String) return string ;
impure function ResolveCovWritePassFail(A, B : OsvvmOptionsType) return OsvvmOptionsType ; -- Cov
impure function ResolveCovWriteBinInfo(A, B : OsvvmOptionsType) return OsvvmOptionsType ; -- Cov
impure function ResolveCovWriteCount(A, B : OsvvmOptionsType) return OsvvmOptionsType ; -- Cov
impure function ResolveCovWriteAnyIllegal(A, B : OsvvmOptionsType) return OsvvmOptionsType ; -- Cov
procedure OsvvmDeallocate ;
type OptionsPType is protected
procedure Set (A: OsvvmOptionsType) ;
impure function get return OsvvmOptionsType ;
end protected OptionsPType ;
end OsvvmGlobalPkg ;
--- ///////////////////////////////////////////////////////////////////////////
--- ///////////////////////////////////////////////////////////////////////////
--- ///////////////////////////////////////////////////////////////////////////
package body OsvvmGlobalPkg is
type OptionsPType is protected body
variable GlobalVar : OsvvmOptionsType ;
procedure Set (A : OsvvmOptionsType) is
begin
GlobalVar := A ;
end procedure Set ;
impure function get return OsvvmOptionsType is
begin
return GlobalVar ;
end function get ;
end protected body OptionsPType ;
shared variable WritePrefixVar : NamePType ;
shared variable DoneNameVar : NamePType ;
shared variable PassNameVar : NamePType ;
shared variable FailNameVar : NamePType ;
shared variable WritePassFailVar : OptionsPType ; -- := FALSE ;
shared variable WriteBinInfoVar : OptionsPType ; -- := TRUE ;
shared variable WriteCountVar : OptionsPType ; -- := TRUE ;
shared variable WriteAnyIllegalVar : OptionsPType ; -- := FALSE ;
function IsEnabled (A : OsvvmOptionsType) return boolean is
begin
return A >= ENABLED ;
end function IsEnabled ;
function to_OsvvmOptionsType (A : boolean) return OsvvmOptionsType is
begin
if A then
return TRUE ;
else
return FALSE ;
end if ;
end function to_OsvvmOptionsType ;
------------------------------------------------------------
procedure SetOsvvmGlobalOptions (
------------------------------------------------------------
WritePassFail : OsvvmOptionsType := OPT_INIT_PARM_DETECT ;
WriteBinInfo : OsvvmOptionsType := OPT_INIT_PARM_DETECT ;
WriteCount : OsvvmOptionsType := OPT_INIT_PARM_DETECT ;
WriteAnyIllegal : OsvvmOptionsType := OPT_INIT_PARM_DETECT ;
WritePrefix : string := OSVVM_STRING_INIT_PARM_DETECT ;
DoneName : string := OSVVM_STRING_INIT_PARM_DETECT ;
PassName : string := OSVVM_STRING_INIT_PARM_DETECT ;
FailName : string := OSVVM_STRING_INIT_PARM_DETECT
) is
begin
if WritePassFail /= OPT_INIT_PARM_DETECT then
WritePassFailVar.Set(WritePassFail) ;
end if ;
if WriteBinInfo /= OPT_INIT_PARM_DETECT then
WriteBinInfoVar.Set(WriteBinInfo) ;
end if ;
if WriteCount /= OPT_INIT_PARM_DETECT then
WriteCountVar.Set(WriteCount) ;
end if ;
if WriteAnyIllegal /= OPT_INIT_PARM_DETECT then
WriteAnyIllegalVar.Set(WriteAnyIllegal) ;
end if ;
if WritePrefix /= OSVVM_STRING_INIT_PARM_DETECT then
WritePrefixVar.Set(WritePrefix) ;
end if ;
if DoneName /= OSVVM_STRING_INIT_PARM_DETECT then
DoneNameVar.Set(DoneName) ;
end if ;
if PassName /= OSVVM_STRING_INIT_PARM_DETECT then
PassNameVar.Set(PassName) ;
end if ;
if FailName /= OSVVM_STRING_INIT_PARM_DETECT then
FailNameVar.Set(FailName) ;
end if ;
end procedure SetOsvvmGlobalOptions ;
------------------------------------------------------------
-- Accessor Functions
-- Local Function
function IsOsvvmOptionSet (A : OsvvmOptionsType) return boolean is
begin
return A > OPT_USE_DEFAULT ;
end function IsOsvvmOptionSet ;
function ResolveOsvvmOption(A, B, C : OsvvmOptionsType) return OsvvmOptionsType is
begin
if IsOsvvmOptionSet(A) then
return A ;
elsif IsOsvvmOptionSet(B) then
return B ;
else
return C ;
end if ;
end function ResolveOsvvmOption ;
function ResolveOsvvmOption(A, B, C, D : OsvvmOptionsType) return OsvvmOptionsType is
begin
if IsOsvvmOptionSet(A) then
return A ;
elsif IsOsvvmOptionSet(B) then
return B ;
elsif IsOsvvmOptionSet(C) then
return C ;
else
return D ;
end if ;
end function ResolveOsvvmOption ;
-- Local Function
function IsOsvvmStringSet (A : string) return boolean is
begin
if A'length = 0 then -- Null strings permitted
return TRUE ;
else
return A(A'left) /= NUL ;
end if;
end function IsOsvvmStringSet ;
function ResolveOsvvmOption(A, B : string) return string is
begin
if IsOsvvmStringSet(A) then
return A ;
else
return B ;
end if ;
end function ResolveOsvvmOption ;
function ResolveOsvvmOption(A, B, C : string) return string is
begin
if IsOsvvmStringSet(A) then
return A ;
elsif IsOsvvmStringSet(B) then
return B ;
else
return C ;
end if ;
end function ResolveOsvvmOption ;
function ResolveOsvvmOption(A, B, C, D : string) return string is
begin
if IsOsvvmStringSet(A) then
return A ;
elsif IsOsvvmStringSet(B) then
return B ;
elsif IsOsvvmStringSet(C) then
return C ;
else
return D ;
end if ;
end function ResolveOsvvmOption ;
impure function ResolveOsvvmWritePrefix(A : String) return string is
begin
return ResolveOsvvmOption(A, WritePrefixVar.GetOpt, OSVVM_DEFAULT_WRITE_PREFIX) ;
end function ResolveOsvvmWritePrefix ;
impure function ResolveOsvvmWritePrefix(A, B : String) return string is
begin
return ResolveOsvvmOption(A, B, WritePrefixVar.GetOpt, OSVVM_DEFAULT_WRITE_PREFIX) ;
end function ResolveOsvvmWritePrefix ;
impure function ResolveOsvvmDoneName(A : String) return string is
begin
return ResolveOsvvmOption(A, DoneNameVar.GetOpt, OSVVM_DEFAULT_DONE_NAME) ;
end function ResolveOsvvmDoneName ;
impure function ResolveOsvvmDoneName(A, B : String) return string is
begin
return ResolveOsvvmOption(A, DoneNameVar.GetOpt, OSVVM_DEFAULT_DONE_NAME) ;
end function ResolveOsvvmDoneName ;
impure function ResolveOsvvmPassName(A : String) return string is
begin
return ResolveOsvvmOption(A, PassNameVar.GetOpt, OSVVM_DEFAULT_PASS_NAME) ;
end function ResolveOsvvmPassName ;
impure function ResolveOsvvmPassName(A, B : String) return string is
begin
return ResolveOsvvmOption(A, B, PassNameVar.GetOpt, OSVVM_DEFAULT_PASS_NAME) ;
end function ResolveOsvvmPassName ;
impure function ResolveOsvvmFailName(A : String) return string is
begin
return ResolveOsvvmOption(A, FailNameVar.GetOpt, OSVVM_DEFAULT_FAIL_NAME) ;
end function ResolveOsvvmFailName ;
impure function ResolveOsvvmFailName(A, B : String) return string is
begin
return ResolveOsvvmOption(A, B, FailNameVar.GetOpt, OSVVM_DEFAULT_FAIL_NAME) ;
end function ResolveOsvvmFailName ;
impure function ResolveCovWritePassFail(A, B : OsvvmOptionsType) return OsvvmOptionsType is
begin
return ResolveOsvvmOption(A, B, WritePassFailVar.Get, OSVVM_DEFAULT_WRITE_PASS_FAIL) ;
end function ResolveCovWritePassFail ; -- Cov
impure function ResolveCovWriteBinInfo(A, B : OsvvmOptionsType) return OsvvmOptionsType is
begin
return ResolveOsvvmOption(A, B, WriteBinInfoVar.Get, OSVVM_DEFAULT_WRITE_BIN_INFO) ;
end function ResolveCovWriteBinInfo ; -- Cov
impure function ResolveCovWriteCount(A, B : OsvvmOptionsType) return OsvvmOptionsType is
begin
return ResolveOsvvmOption(A, B, WriteCountVar.Get, OSVVM_DEFAULT_WRITE_COUNT) ;
end function ResolveCovWriteCount ; -- Cov
impure function ResolveCovWriteAnyIllegal(A, B : OsvvmOptionsType) return OsvvmOptionsType is
begin
return ResolveOsvvmOption(A, B, WriteAnyIllegalVar.Get, OSVVM_DEFAULT_WRITE_ANY_ILLEGAL) ;
end function ResolveCovWriteAnyIllegal ; -- Cov
procedure OsvvmDeallocate is
begin
-- Free up space used by NamePType within OsvvmGlobalPkg
WritePrefixVar.Deallocate ;
DoneNameVar.Deallocate ;
PassNameVar.Deallocate ;
FailNameVar.Deallocate ;
WritePassFailVar.Set(FALSE) ; -- := FALSE ;
WriteBinInfoVar.Set(TRUE ) ; -- := TRUE ;
WriteCountVar.Set(TRUE ) ; -- := TRUE ;
WriteAnyIllegalVar.Set(FALSE) ; -- := FALSE ;
end procedure OsvvmDeallocate ;
end package body OsvvmGlobalPkg ;

+ 0
- 234
OSVVM/RandomBasePkg.vhd View File

@ -1,234 +0,0 @@
--
-- File Name: RandomBasePkg.vhd
-- Design Unit Name: RandomBasePkg
-- Revision: STANDARD VERSION
--
-- Maintainer: Jim Lewis email: jim@synthworks.com
-- Contributor(s):
-- Jim Lewis jim@synthworks.com
--
--
-- Description:
-- Defines Base randomization, seed definition, seed generation,
-- and seed IO functionality for RandomPkg.vhd
-- Defines:
-- Procedure Uniform - baseline randomization
-- Type RandomSeedType - the seed as a single object
-- function GenRandSeed from integer_vector, integer, or string
-- IO function to_string, & procedures write, read
--
-- In revision 2.0 these types and functions are included by package reference.
-- Long term these will be passed as generics to RandomGenericPkg
--
--
-- Developed for:
-- SynthWorks Design Inc.
-- VHDL Training Classes
-- 11898 SW 128th Ave. Tigard, Or 97223
-- http://www.SynthWorks.com
--
-- Revision History:
-- Date Version Description
-- 01/2008: 0.1 Initial revision
-- Numerous revisions for VHDL Testbenches and Verification
-- 02/2009: 1.0 First Public Released Version
-- 02/25/2009 1.1 Replaced reference to std_2008 with a reference
-- to ieee_proposed.standard_additions.all ;
-- 03/01/2011 2.0 STANDARD VERSION
-- Fixed abstraction by moving RandomParmType to RandomPkg.vhd
-- 4/2013 2013.04 No Changes
-- 5/2013 2013.05 No Changes
-- 1/2015 2015.01 Changed Assert/Report to Alert
-- 6/2015 2015.06 Changed GenRandSeed to impure
--
--
-- Copyright (c) 2008 - 2015 by SynthWorks Design Inc. All rights reserved.
--
-- Verbatim copies of this source file may be used and
-- distributed without restriction.
--
-- This source file is free software; you can redistribute it
-- and/or modify it under the terms of the ARTISTIC License
-- as published by The Perl Foundation; either version 2.0 of
-- the License, or (at your option) any later version.
--
-- This source is distributed in the hope that it will be
-- useful, but WITHOUT ANY WARRANTY; without even the implied
-- warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
-- PURPOSE. See the Artistic License for details.
--
-- You should have received a copy of the license with this source.
-- If not download it from,
-- http://www.perlfoundation.org/artistic_license_2_0
--
library ieee ;
use ieee.math_real.all ;
use std.textio.all ;
use work.OsvvmGlobalPkg.all ;
use work.AlertLogPkg.all ;
-- comment out following 2 lines with VHDL-2008. Leave in for VHDL-2002
-- library ieee_proposed ; -- remove with VHDL-2008
-- use ieee_proposed.standard_additions.all ; -- remove with VHDL-2008
package RandomBasePkg is
-- RandomSeedType and Uniform can be replaced by any procedure that
-- produces a uniform distribution with 0 <= Value < 1 or 0 < Value < 1
-- and maintains the same call interface
type RandomSeedType is array (1 to 2) of integer ;
procedure Uniform (Result : out real ; Seed : inout RandomSeedType) ;
-- Translate from integer_vector, integer, or string to RandomSeedType
-- Required by RandomPkg.InitSeed
-- GenRandSeed makes sure all values are in a valid range
impure function GenRandSeed(IV : integer_vector) return RandomSeedType ;
impure function GenRandSeed(I : integer) return RandomSeedType ;
impure function GenRandSeed(S : string) return RandomSeedType ;
-- IO for RandomSeedType. If use subtype, then create aliases here
-- in a similar fashion VHDL-2008 std_logic_textio.
-- Not required by RandomPkg
function to_string(A : RandomSeedType) return string ;
procedure write(variable L: inout line ; A : RandomSeedType ) ;
procedure read (variable L: inout line ; A : out RandomSeedType ; good : out boolean ) ;
procedure read (variable L: inout line ; A : out RandomSeedType ) ;
end RandomBasePkg ;
--- ///////////////////////////////////////////////////////////////////////////
--- ///////////////////////////////////////////////////////////////////////////
--- ///////////////////////////////////////////////////////////////////////////
package body RandomBasePkg is
-----------------------------------------------------------------
-- Uniform
-- Generate a random number with a Uniform distribution
-- Required by RandomPkg. All randomization is derived from here.
-- Value produced must be either:
-- 0 <= Value < 1 or 0 < Value < 1
--
-- Current version uses ieee.math_real.Uniform
-- This abstraction allows higher precision version
-- of a uniform distribution to be used provided
--
procedure Uniform (
Result : out real ;
Seed : inout RandomSeedType
) is
begin
ieee.math_real.Uniform (Seed(Seed'left), Seed(Seed'right), Result) ;
end procedure Uniform ;
-----------------------------------------------------------------
-- GenRandSeed
-- Convert integer_vector to RandomSeedType
-- Uniform requires two seed values of the form:
-- 1 <= SEED1 <= 2147483562; 1 <= SEED2 <= 2147483398
--
-- if 2 seed values are passed to GenRandSeed and they are
-- in the above range, then they must remain unmodified.
--
impure function GenRandSeed(IV : integer_vector) return RandomSeedType is
alias iIV : integer_vector(1 to IV'length) is IV ;
variable Seed1 : integer ;
variable Seed2 : integer ;
constant SEED1_MAX : integer := 2147483562 ;
constant SEED2_MAX : integer := 2147483398 ;
begin
if iIV'Length <= 0 then -- no seed
Alert(OSVVM_ALERTLOG_ID, "RandomBasePkg.GenRandSeed received NULL integer_vector", FAILURE) ;
return (3, 17) ; -- if continue seed = (3, 17)
elsif iIV'Length = 1 then -- one seed value
-- inefficient handling, but condition is unlikely
return GenRandSeed(iIV(1)) ; -- generate a seed
else -- only use the left two values
-- 1 <= SEED1 <= 2147483562
-- mod returns 0 to MAX-1, the -1 adjusts legal values, +1 adjusts them back
Seed1 := ((iIV(1)-1) mod SEED1_MAX) + 1 ;
-- 1 <= SEED2 <= 2147483398
Seed2 := ((iIV(2)-1) mod SEED2_MAX) + 1 ;
return (Seed1, Seed2) ;
end if ;
end function GenRandSeed ;
-----------------------------------------------------------------
-- GenRandSeed
-- transform a single integer into the internal seed
--
impure function GenRandSeed(I : integer) return RandomSeedType is
variable result : integer_vector(1 to 2) ;
begin
result(1) := I ;
result(2) := I/3 + 1 ;
return GenRandSeed(result) ; -- make value ranges legal
end function GenRandSeed ;
-----------------------------------------------------------------
-- GenRandSeed
-- transform a string value into the internal seed
-- usage: RV.GenRandSeed(RV'instance_path));
--
impure function GenRandSeed(S : string) return RandomSeedType is
constant LEN : integer := S'length ;
constant HALF_LEN : integer := LEN/2 ;
alias revS : string(LEN downto 1) is S ;
variable result : integer_vector(1 to 2) ;
variable temp : integer := 0 ;
begin
for i in 1 to HALF_LEN loop
temp := (temp + character'pos(revS(i))) mod (integer'right - 2**8) ;
end loop ;
result(1) := temp ;
for i in HALF_LEN + 1 to LEN loop
temp := (temp + character'pos(revS(i))) mod (integer'right - 2**8) ;
end loop ;
result(2) := temp ;
return GenRandSeed(result) ; -- make value ranges legal
end function GenRandSeed ;
-----------------------------------------------------------------
function to_string(A : RandomSeedType) return string is
begin
return to_string(A(A'left)) & " " & to_string(A(A'right)) ;
end function to_string ;
-----------------------------------------------------------------
procedure write(variable L: inout line ; A : RandomSeedType ) is
begin