diff --git a/CoveragePkg.vhd b/CoveragePkg.vhd index 3743ff1..7bcdfc0 100644 --- a/CoveragePkg.vhd +++ b/CoveragePkg.vhd @@ -100,6 +100,7 @@ use work.RandomPkg.all ; use work.NamePkg.all ; use work.MessagePkg.all ; use work.OsvvmGlobalPkg.all ; +use work.VendorCovApiPkg.all ; package CoveragePkg is @@ -231,6 +232,10 @@ package CoveragePkg is Weight : integer ; end record ; type CovMatrix9Type is array (natural range <>) of CovMatrix9BaseType ; + + ------------------------------------------------------------ VendorCov + -- VendorCov Conversion for Vendor supported functional coverage modeling + function ToVendorCovBinVal (A : RangeArrayType) return VendorCovRangeArrayType ; ------------------------------------------------------------ function ToMinPoint (A : RangeArrayType) return integer ; @@ -1109,7 +1114,21 @@ package body CoveragePkg is return result ; end function MergeWeight ; + + ------------------------------------------------------------ VendorCov + -- VendorCov Conversion for Vendor supported functional coverage modeling + function ToVendorCovBinVal (A : RangeArrayType) return VendorCovRangeArrayType is + ------------------------------------------------------------ + variable VendorCovBinVal : VendorCovRangeArrayType(BinVal'range); + begin -- VendorCov + for ArrIdx in BinVal'LEFT to BinVal'RIGHT loop -- VendorCov + VendorCovBinVal(ArrIdx) := (min => BinVal(ArrIdx).min, -- VendorCov + max => BinVal(ArrIdx).max) ; -- VendorCov + end loop; -- VendorCov + return VendorCovBinVal ; + end function ToVendorCovBinVal ; + ------------------------------------------------------------ function ToMinPoint (A : RangeArrayType) return integer is -- Used in testing @@ -1181,8 +1200,11 @@ package body CoveragePkg is type CovPType is protected body -- Name Data Structure - variable CovNameVar : NamePType ; - variable CovMessageVar : MessagePType ; + variable CovNameVar : NamePType ; + variable CovMessageVar : MessagePType ; + + -- Handle into Vendor Data Structure + variable VendorCovHandleVar : VendorCovHandleType ; -- CoverageBin Data Structures type RangeArrayPtrType is access RangeArrayType ; @@ -1305,6 +1327,10 @@ package body CoveragePkg is ------------------------------------------------------------ begin CovNameVar.Set(Name) ; + -- VendorCov update if name updated after model created + if IsInitialized then -- VendorCov + VendorCovSetName(Name) ; -- VendorCov + end if ; -- VendorCov if not RvSeedInit then -- Init seed if not initialized RV.InitSeed(Name) ; RvSeedInit := TRUE ; @@ -1315,11 +1341,7 @@ package body CoveragePkg is impure function SetName (Name : String) return string is ------------------------------------------------------------ begin - CovNameVar.Set(Name) ; - if not RvSeedInit then -- Init seed if not initialized - RV.InitSeed(Name) ; - RvSeedInit := TRUE ; - end if ; + SetName(Name) ; -- call procedure above return Name ; end function SetName ; @@ -1368,6 +1390,10 @@ package body CoveragePkg is ------------------------------------------------------------ begin CovMessageVar.Set(Message) ; + -- VendorCov update if name updated after model created + if IsInitialized then -- VendorCov + VendorCovSetName(GetNamePlus) ; -- VendorCov + end if ; -- VendorCov if not RvSeedInit then -- Init seed if not initialized RV.InitSeed(Message) ; RvSeedInit := TRUE ; @@ -1669,6 +1695,7 @@ package body CoveragePkg is PercentCov : real := 0.0 ) is begin + VendorCovBinAdd(CovHandle, ToVendorCovBinVal(BinVal), Action, AtLeast, Name) ; NumBins := NumBins + 1 ; CovBinPtr.all(NumBins).BinVal := new RangeArrayType'(BinVal) ; CovBinPtr.all(NumBins).Action := Action ; @@ -1777,6 +1804,11 @@ package body CoveragePkg is variable calcWeight : integer ; begin CheckBinValLength( 1, "AddBins") ; + + if not IsInitialized then -- VendorCov + VendorCovHandleVar := VendorCovPointCreate(GetNamePlus) ; -- VendorCov + end if ; -- VendorCov + GrowBins(CovBin'length) ; for i in CovBin'range loop if CovBin(i).Action = COV_COUNT then @@ -1860,6 +1892,11 @@ package body CoveragePkg is variable calcBinVal : RangeArrayType(BinIndex'range) ; begin CheckBinValLength( BIN_LENS'length, "AddCross") ; + + if not IsInitialized then -- VendorCov + VendorCovHandleVar := VendorCovCrossCreate(GetNamePlus) ; -- VendorCov + end if ; -- VendorCov + GrowBins(NUM_NEW_BINS) ; calcCount := 0 ; for MatrixIndex in 1 to NUM_NEW_BINS loop @@ -2001,6 +2038,7 @@ package body CoveragePkg is begin -- Update Count, PercentCov CovBinPtr(Index).Count := CovBinPtr(Index).Count + CovBinPtr(Index).action ; + VendorCovBinInc(CovHandle,Index); -- VendorCov CovBinPtr(Index).PercentCov := real(CovBinPtr(Index).Count)*100.0/maximum(real(CovBinPtr(Index).AtLeast), 1.0) ; -- OrderCount handling - Statistics OrderCount := OrderCount + 1 ; @@ -2134,7 +2172,6 @@ package body CoveragePkg is end function GetMinCount ; - ------------------------------------------------------------ impure function GetMaxIndex return integer is ------------------------------------------------------------ diff --git a/VendorCovApiPkg.vhd b/VendorCovApiPkg.vhd new file mode 100644 index 0000000..718fbd5 --- /dev/null +++ b/VendorCovApiPkg.vhd @@ -0,0 +1,125 @@ +-- +-- File Name: VendorCovApiPkg.vhd +-- Design Unit Name: VendorCovApiPkg +-- Revision: STANDARD VERSION +-- +-- Maintainer: Jim Lewis email: jim@synthworks.com +-- +-- Package Defines +-- A set of foreign procedures that link OSVVM's CoveragePkg +-- coverage model creation and coverage capture with the +-- built-in capability of a simulator. +-- +-- +-- Revision History: For more details, see CoveragePkg_release_notes.pdf +-- Date Version Description +-- 10/2016: 1.0 Initial revision +-- +-- +-- Copyright (c) 2016 by SynthWorks Design Inc. All rights reserved. +-- +-- Verbatim copies of this source file may be used and +-- distributed without restriction. +-- +-- Modified copies of this source file may be distributed +-- 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 +-- -- +-------------------------------------------------------------------------- + +package VendorCovApiPkg is + + subtype VendorCovHandleType is integer; + + -- Types for how coverage bins are represented. Matches OSVVM types. + type VendorCovRangeType is record + min: integer; + max: integer; + end record; + + type VendorCovRangeArrayType is array ( integer range <> ) of VendorCovRangeType; + + -- Create Initial Data Structure for Point/Item Functional Coverage Model + -- Sets initial name of the coverage model if available + impure function VendorCovPointCreate( name: string ) return VendorCovHandleType; + -- attribute foreign of VendorCovPointCreate[ string return VendorCovHandleType ]: function is "VHPI systf; cvg_CvpCreate"; + + -- Create Initial Data Structure for Cross Functional Coverage Model + -- Sets initial name of the coverage model if available + impure function VendorCovCrossCreate( name: string ) return VendorCovHandleType; + -- attribute foreign of VendorCovCrossCreate[ string return VendorCovHandleType ]: function is "VHPI systf; cvg_CrCreate"; + + -- Sets/Updates the name of the Coverage Model. + -- Should not be called until the data structure is created by VendorCovPointCreate or VendorCovCrossCreate. + -- Replaces name that was set by VendorCovPointCreate or VendorCovCrossCreate. + procedure VendorCovSetName( obj: VendorCovHandleType; name: string ); + -- attribute foreign of VendorCovSetName[ VendorCovHandleType, string ]: procedure is "VHPI systf; cvg_SetCoverName"; + + -- Add a bin or set of bins to either a Point/Item or Cross Functional Coverage Model + -- Checking for sizing that is different from original sizing already done in OSVVM CoveragePkg + -- It is important to maintain an index that corresponds to the order the bins were entered as + -- that is used when coverage is recorded. + procedure VendorCovBinAdd( obj: VendorCovHandleType; bins: CovRangeArrayType; Action: integer; atleast: integer; name: string ); + -- attribute foreign of CvpCrBinCreate[ VendorCovHandleType, CovRangeArrayType, integer, integer, string ]: procedure is "VHPI systf; cvg_CvpCrBinCreate"; + + -- Increment the coverage of bin identified by index number. + -- Index ranges from 1 to Number of Bins. + -- Index corresponds to the order the bins were entered (starting from 1) + procedure VendorCovBinInc( obj: VendorCovHandleType; index: integer ); + -- attribute foreign of VendorCovBinInc[ VendorCovHandleType, integer ]: procedure is "VHPI systf; cvg_CvpCrBinIncr"; + +-- Action (integer): +-- constant COV_COUNT : integer := 1; +-- constant COV_IGNORE : integer := 0; +-- constant COV_ILLEGAL : integer := -1; + +end package; + +package body VendorCovApiPkg is + -- Create Initial Data Structure for Point/Item Functional Coverage Model + -- Sets initial name of the coverage model if available + impure function VendorCovPointCreate( name: string ) return VendorCovHandleType is + begin + return 0 ; + end function VendorCovPointCreate ; + + -- Create Initial Data Structure for Cross Functional Coverage Model + -- Sets initial name of the coverage model if available + impure function VendorCovCrossCreate( name: string ) return VendorCovHandleType is + begin + return 0 ; + end function VendorCovCrossCreate ; + + -- Sets/Updates the name of the Coverage Model. + -- Should not be called until the data structure is created by VendorCovPointCreate or VendorCovCrossCreate. + -- Replaces name that was set by VendorCovPointCreate or VendorCovCrossCreate. + procedure VendorCovSetName( obj: VendorCovHandleType; name: string ) is + begin + end procedure VendorCovSetName ; + + -- Add a bin or set of bins to either a Point/Item or Cross Functional Coverage Model + -- Checking for sizing that is different from original sizing already done in OSVVM CoveragePkg + -- It is important to maintain an index that corresponds to the order the bins were entered as + -- that is used when coverage is recorded. + procedure VendorCovBinAdd( obj: VendorCovHandleType; bins: CovRangeArrayType; Action: integer; atleast: integer; name: string )is + begin + end procedure VendorCovBinAdd ; + + -- Increment the coverage of bin identified by index number. + -- Index ranges from 1 to Number of Bins. + -- Index corresponds to the order the bins were entered (starting from 1) + procedure VendorCovBinInc( obj: VendorCovHandleType; index: integer )is + begin + end procedure VendorCovBinInc ; + +end package; diff --git a/VendorCovApiPkg_Aldec.vhd b/VendorCovApiPkg_Aldec.vhd new file mode 100644 index 0000000..d088614 --- /dev/null +++ b/VendorCovApiPkg_Aldec.vhd @@ -0,0 +1,90 @@ +-- +-- File Name: VendorCovApiPkg.vhd +-- Design Unit Name: VendorCovApiPkg +-- Revision: STANDARD VERSION +-- +-- Maintainer: Jim Lewis email: jim@synthworks.com +-- +-- Package Defines +-- A set of foreign procedures that link OSVVM's CoveragePkg +-- coverage model creation and coverage capture with the +-- built-in capability of a simulator. +-- +-- +-- Revision History: For more details, see CoveragePkg_release_notes.pdf +-- Date Version Description +-- 10/2016: 1.0 Initial revision +-- +-- +-- Copyright (c) 2016 by SynthWorks Design Inc. All rights reserved. +-- +-- Verbatim copies of this source file may be used and +-- distributed without restriction. +-- +-- Modified copies of this source file may be distributed +-- 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 +-- -- +-------------------------------------------------------------------------- + +package VendorCovApiPkg is + + subtype VendorCovHandleType is integer; + + -- Types for how coverage bins are represented. Matches OSVVM types. + type VendorCovRangeType is record + min: integer; + max: integer; + end record; + + type VendorCovRangeArrayType is array ( integer range <> ) of VendorCovRangeType; + + -- Create Initial Data Structure for Point/Item Functional Coverage Model + -- Sets initial name of the coverage model if available + impure function VendorCovPointCreate( name: string ) return VendorCovHandleType; + attribute foreign of VendorCovPointCreate[ string return VendorCovHandleType ]: function is "VHPI systf; cvg_CvpCreate"; + + -- Create Initial Data Structure for Cross Functional Coverage Model + -- Sets initial name of the coverage model if available + impure function VendorCovCrossCreate( name: string ) return VendorCovHandleType; + attribute foreign of VendorCovCrossCreate[ string return VendorCovHandleType ]: function is "VHPI systf; cvg_CrCreate"; + + -- Sets/Updates the name of the Coverage Model. + -- Should not be called until the data structure is created by VendorCovPointCreate or VendorCovCrossCreate. + -- Replaces name that was set by VendorCovPointCreate or VendorCovCrossCreate. + procedure VendorCovSetName( obj: VendorCovHandleType; name: string ); + attribute foreign of VendorCovSetName[ VendorCovHandleType, string ]: procedure is "VHPI systf; cvg_SetCoverName"; + + -- Add a bin or set of bins to either a Point/Item or Cross Functional Coverage Model + -- Checking for sizing that is different from original sizing already done in OSVVM CoveragePkg + -- It is important to maintain an index that corresponds to the order the bins were entered as + -- that is used when coverage is recorded. + procedure VendorCovBinAdd( obj: VendorCovHandleType; bins: CovRangeArrayType; Action: integer; atleast: integer; name: string ); + attribute foreign of CvpCrBinCreate[ VendorCovHandleType, CovRangeArrayType, integer, integer, string ]: procedure is "VHPI systf; cvg_CvpCrBinCreate"; + + -- Increment the coverage of bin identified by index number. + -- Index ranges from 1 to Number of Bins. + -- Index corresponds to the order the bins were entered (starting from 1) + procedure VendorCovBinInc( obj: VendorCovHandleType; index: integer ); + attribute foreign of VendorCovBinInc[ VendorCovHandleType, integer ]: procedure is "VHPI systf; cvg_CvpCrBinIncr"; + +-- Action (integer): +-- constant COV_COUNT : integer := 1; +-- constant COV_IGNORE : integer := 0; +-- constant COV_ILLEGAL : integer := -1; + +end package; + +package body VendorCovApiPkg is + -- Removes any previously compiled package body +end package;