forked from OSVVM/OSVVM
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCoveragePkg.vhd
5072 lines (4455 loc) · 210 KB
/
CoveragePkg.vhd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
--
-- File Name: CoveragePkg.vhd
-- Design Unit Name: CoveragePkg
-- Revision: STANDARD VERSION
--
-- Maintainer: Jim Lewis email: [email protected]
-- Contributor(s):
-- Jim Lewis SynthWorks
-- Matthias Alles Creonic. Inspired GetMinBinVal, GetMinPoint, GetCov
-- Jerry Kaczynski Aldec. Inspired GetBin function
-- Sebastian Dunst Inspired GetBinName function
-- ... Aldec Worked on VendorCov functional coverage interface
--
-- Package Defines
-- Functional coverage modeling utilities and data structure
--
-- 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: For more details, see CoveragePkg_release_notes.pdf
-- Date Version Description
-- 06/2010: 0.1 Initial revision
-- 09/2010 Release in SynthWorks' VHDL Testbenches and Verification classes
-- 02/2011: 1.0 Changed CoverBinType to facilitage long term support of cross coverage
-- 02/2011: 1.1 Added GetMinCov, GetMaxCov, CountCovHoles, GetCovHole
-- 04/2011: 2.0 Added protected type based data structure: CovPType
-- 06/2011: 2.1 Removed signal based coverage modeling
-- 07/2011: 2.2 Added randomization with coverage goals (AtLeast), weight, and percentage thresholds
-- 11/2011: 2.2a Changed constants ALL_RANGE, ZERO_BIN, and ONE_BIN to have a 1 index
-- 12/2011: 2.2b Fixed minor inconsistencies on interface declarations.
-- 01/2012: 2.3 Added Function GetBin from Jerry K. Made write for RangeArrayType visible
-- 01/2012: 2.4 Added Merging of bins
-- 04/2013: 2013.04 Thresholding, CovTarget, Merging off by default,
-- 5/2013 2013.05 Release with updated RandomPkg. Minimal changes.
-- 1/2014 2014.01 Merging of Cov Models, LastIndex
-- 7/2014 2014.07 Bin Naming (for requirements tracking), WriteBin with Pass/Fail, GenBin[integer_vector]
-- 12/2014 2014.07a Fix memory leak in deallocate. Removed initialied pointers which can lead to leaks.
-- 01/2015 2015.01 Use AlertLogPkg to count assertions and filter log messages
-- 06/2015 2015.06 AddCross[CovMatrix?Type], Mirroring for WriteBin
-- 01/2016 2016.01 Fixes for pure functions. Added bounds checking on ICover
-- 03/2016 2016.03 Added GetBinName(Index) to retrieve a bin's name
-- 11/2016 2016.11 Added VendorCovApiPkg and calls to bind it in.
-- 05/2017 2017.05 Updated WriteBin name printing
-- ClearCov (deprecates SetCovZero)
-- 04/2018 2018.04 Updated PercentCov calculation so AtLeast of <= 0 is correct
-- String' Fix for GHDL
-- Removed Deprecated procedure Increment - see TbUtilPkg as it moved there
--
--
-- Development Notes:
-- The coverage procedures are named ICover to avoid conflicts with
-- future language changes which may add cover as a keyword
-- Procedure WriteBin writes each CovBin on a separate line, as such
-- it was inappropriate to overload either textio write or to_string
-- In the notes VHDL-2008 notes refers to
-- composites with unconstrained elements
--
--
-- Copyright (c) 2010 - 2018 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
--
-- Credits:
-- CovBinBaseType is inspired by a structure proposed in the
-- paper "Functional Coverage - without SystemVerilog!"
-- by Alan Fitch and Doug Smith. Presented at DVCon 2010
-- However the approach in their paper uses entities and
-- architectures where this approach relies on functions
-- and procedures, so the usage models differ greatly however.
--
library ieee ;
use ieee.std_logic_1164.all ;
use ieee.numeric_std.all ;
use ieee.math_real.all ;
use std.textio.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
use work.TextUtilPkg.all ;
use work.TranscriptPkg.all ;
use work.AlertLogPkg.all ;
use work.RandomBasePkg.all ;
use work.RandomPkg.all ;
use work.NamePkg.all ;
use work.MessagePkg.all ;
use work.OsvvmGlobalPkg.all ;
use work.VendorCovApiPkg.all ;
package CoveragePkg is
-- CovPType allocates bins that are multiples of MIN_NUM_BINS
constant MIN_NUM_BINS : integer := 2**7 ; -- power of 2
type RangeType is record
min : integer ;
max : integer ;
end record ;
type RangeArrayType is array (integer range <>) of RangeType ;
constant ALL_RANGE : RangeArrayType := (1=>(Integer'left, Integer'right)) ;
procedure write ( file f : text ; BinVal : RangeArrayType ) ;
procedure write ( variable buf : inout line ; constant BinVal : in RangeArrayType) ;
-- CovBinBaseType.action values.
-- Note that coverage counting depends on these values
constant COV_COUNT : integer := 1 ;
constant COV_IGNORE : integer := 0 ;
constant COV_ILLEGAL : integer := -1 ;
-- type OsvvmOptionsType is (OPT_DEFAULT, FALSE, TRUE) ;
alias CovOptionsType is work.OsvvmGlobalPkg.OsvvmOptionsType ;
constant COV_OPT_INIT_PARM_DETECT : CovOptionsType := work.OsvvmGlobalPkg.OPT_INIT_PARM_DETECT ;
-- For backward compatibility. Don't add to other packages.
alias DISABLED is work.OsvvmGlobalPkg.DISABLED [return work.OsvvmGlobalPkg.OsvvmOptionsType ];
alias ENABLED is work.OsvvmGlobalPkg.ENABLED [return work.OsvvmGlobalPkg.OsvvmOptionsType ];
-- Deprecated
-- Used for easy manual entry. Order: min, max, action
-- Intentionally did not use a record to allow other input
-- formats in the future with VHDL-2008 unconstrained arrays
-- of unconstrained elements
-- type CovBinManualType is array (natural range <>) of integer_vector(0 to 2) ;
type CovBinBaseType is record
BinVal : RangeArrayType(1 to 1) ;
Action : integer ;
Count : integer ;
AtLeast : integer ;
Weight : integer ;
end record ;
type CovBinType is array (natural range <>) of CovBinBaseType ;
constant ALL_BIN : CovBinType := (0 => ( BinVal => ALL_RANGE, Action => COV_COUNT, Count => 0, AtLeast => 1, Weight => 1 )) ;
constant ALL_COUNT : CovBinType := (0 => ( BinVal => ALL_RANGE, Action => COV_COUNT, Count => 0, AtLeast => 1, Weight => 1 )) ;
constant ALL_ILLEGAL : CovBinType := (0 => ( BinVal => ALL_RANGE, Action => COV_ILLEGAL, Count => 0, AtLeast => 0, Weight => 0 )) ;
constant ALL_IGNORE : CovBinType := (0 => ( BinVal => ALL_RANGE, Action => COV_IGNORE, Count => 0, AtLeast => 0, Weight => 0 )) ;
constant ZERO_BIN : CovBinType := (0 => ( BinVal => (1=>(0,0)), Action => COV_COUNT, Count => 0, AtLeast => 1, Weight => 1 )) ;
constant ONE_BIN : CovBinType := (0 => ( BinVal => (1=>(1,1)), Action => COV_COUNT, Count => 0, AtLeast => 1, Weight => 1 )) ;
constant NULL_BIN : CovBinType(work.RandomPkg.NULL_RANGE_TYPE) := (others => ( BinVal => ALL_RANGE, Action => integer'high, Count => 0, AtLeast => integer'high, Weight => integer'high )) ;
type CountModeType is (COUNT_FIRST, COUNT_ALL) ;
type IllegalModeType is (ILLEGAL_ON, ILLEGAL_FAILURE, ILLEGAL_OFF) ;
type WeightModeType is (AT_LEAST, WEIGHT, REMAIN, REMAIN_EXP, REMAIN_SCALED, REMAIN_WEIGHT ) ;
-- In VHDL-2008 CovMatrix?BaseType and CovMatrix?Type will be subsumed
-- by CovBinBaseType and CovBinType with RangeArrayType as an unconstrained array.
type CovMatrix2BaseType is record
BinVal : RangeArrayType(1 to 2) ;
Action : integer ;
Count : integer ;
AtLeast : integer ;
Weight : integer ;
end record ;
type CovMatrix2Type is array (natural range <>) of CovMatrix2BaseType ;
type CovMatrix3BaseType is record
BinVal : RangeArrayType(1 to 3) ;
Action : integer ;
Count : integer ;
AtLeast : integer ;
Weight : integer ;
end record ;
type CovMatrix3Type is array (natural range <>) of CovMatrix3BaseType ;
type CovMatrix4BaseType is record
BinVal : RangeArrayType(1 to 4) ;
Action : integer ;
Count : integer ;
AtLeast : integer ;
Weight : integer ;
end record ;
type CovMatrix4Type is array (natural range <>) of CovMatrix4BaseType ;
type CovMatrix5BaseType is record
BinVal : RangeArrayType(1 to 5) ;
Action : integer ;
Count : integer ;
AtLeast : integer ;
Weight : integer ;
end record ;
type CovMatrix5Type is array (natural range <>) of CovMatrix5BaseType ;
type CovMatrix6BaseType is record
BinVal : RangeArrayType(1 to 6) ;
Action : integer ;
Count : integer ;
AtLeast : integer ;
Weight : integer ;
end record ;
type CovMatrix6Type is array (natural range <>) of CovMatrix6BaseType ;
type CovMatrix7BaseType is record
BinVal : RangeArrayType(1 to 7) ;
Action : integer ;
Count : integer ;
AtLeast : integer ;
Weight : integer ;
end record ;
type CovMatrix7Type is array (natural range <>) of CovMatrix7BaseType ;
type CovMatrix8BaseType is record
BinVal : RangeArrayType(1 to 8) ;
Action : integer ;
Count : integer ;
AtLeast : integer ;
Weight : integer ;
end record ;
type CovMatrix8Type is array (natural range <>) of CovMatrix8BaseType ;
type CovMatrix9BaseType is record
BinVal : RangeArrayType(1 to 9) ;
Action : integer ;
Count : integer ;
AtLeast : integer ;
Weight : integer ;
end record ;
type CovMatrix9Type is array (natural range <>) of CovMatrix9BaseType ;
------------------------------------------------------------ VendorCov
-- VendorCov Conversion for Vendor supported functional coverage modeling
function ToVendorCovBinVal (BinVal : RangeArrayType) return VendorCovRangeArrayType ;
------------------------------------------------------------
function ToMinPoint (A : RangeArrayType) return integer ;
function ToMinPoint (A : RangeArrayType) return integer_vector ;
-- BinVal to Minimum Point
------------------------------------------------------------
procedure ToRandPoint(
-- BinVal to Random Point
-- better as a function, however, inout not supported on functions
------------------------------------------------------------
variable RV : inout RandomPType ;
constant BinVal : in RangeArrayType ;
variable result : out integer
) ;
------------------------------------------------------------
procedure ToRandPoint(
-- BinVal to Random Point
------------------------------------------------------------
variable RV : inout RandomPType ;
constant BinVal : in RangeArrayType ;
variable result : out integer_vector
) ;
------------------------------------------------------------------------------------------
-- XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX CovPType XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
-- XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX CovPType XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
-- XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX CovPType XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
------------------------------------------------------------------------------------------
type CovPType is protected
procedure FileOpenWriteBin (FileName : string; OpenKind : File_Open_Kind ) ;
procedure FileCloseWriteBin ;
procedure SetAlertLogID (A : AlertLogIDType) ;
procedure SetAlertLogID(Name : string ; ParentID : AlertLogIDType := ALERTLOG_BASE_ID ; CreateHierarchy : Boolean := TRUE) ;
impure function GetAlertLogID return AlertLogIDType ;
-- procedure FileOpenWriteCovDb (FileName : string; OpenKind : File_Open_Kind ) ;
-- procedure FileCloseWriteCovDb ;
procedure SetIllegalMode (A : IllegalModeType) ;
procedure SetWeightMode (A : WeightModeType; Scale : real := 1.0) ;
procedure SetName (Name : String) ;
impure function SetName (Name : String) return string ;
impure function GetName return String ;
impure function GetCovModelName return String ;
procedure SetMessage (Message : String) ;
procedure DeallocateName ; -- clear name
procedure DeallocateMessage ; -- clear message
procedure SetThresholding(A : boolean := TRUE ) ; -- 2.5
procedure SetCovThreshold (Percent : real) ;
procedure SetCovTarget (Percent : real) ; -- 2.5
impure function GetCovTarget return real ; -- 2.5
procedure SetMerging(A : boolean := TRUE ) ; -- 2.5
procedure SetCountMode (A : CountModeType) ;
procedure InitSeed (S : string ) ;
impure function InitSeed (S : string ) return string ;
procedure InitSeed (I : integer ) ;
procedure SetSeed (RandomSeedIn : RandomSeedType ) ;
impure function GetSeed return RandomSeedType ;
------------------------------------------------------------
procedure SetReportOptions (
WritePassFail : CovOptionsType := COV_OPT_INIT_PARM_DETECT ;
WriteBinInfo : CovOptionsType := COV_OPT_INIT_PARM_DETECT ;
WriteCount : CovOptionsType := COV_OPT_INIT_PARM_DETECT ;
WriteAnyIllegal : CovOptionsType := COV_OPT_INIT_PARM_DETECT ;
WritePrefix : string := OSVVM_STRING_INIT_PARM_DETECT ;
PassName : string := OSVVM_STRING_INIT_PARM_DETECT ;
FailName : string := OSVVM_STRING_INIT_PARM_DETECT
) ;
procedure SetBinSize (NewNumBins : integer) ;
------------------------------------------------------------
procedure AddBins (
------------------------------------------------------------
Name : String ;
AtLeast : integer ;
Weight : integer ;
CovBin : CovBinType
) ;
procedure AddBins ( Name : String ; AtLeast : integer ; CovBin : CovBinType ) ;
procedure AddBins ( Name : String ; CovBin : CovBinType) ;
procedure AddBins ( AtLeast : integer ; Weight : integer ; CovBin : CovBinType ) ;
procedure AddBins ( AtLeast : integer ; CovBin : CovBinType ) ;
procedure AddBins ( CovBin : CovBinType ) ;
------------------------------------------------------------
procedure AddCross(
------------------------------------------------------------
Name : string ;
AtLeast : integer ;
Weight : integer ;
Bin1, Bin2 : CovBinType ;
Bin3, Bin4, Bin5, Bin6, Bin7, Bin8, Bin9, Bin10, Bin11, Bin12, Bin13,
Bin14, Bin15, Bin16, Bin17, Bin18, Bin19, Bin20 : CovBinType := NULL_BIN
) ;
------------------------------------------------------------
procedure AddCross(
Name : string ;
AtLeast : integer ;
Bin1, Bin2 : CovBinType ;
Bin3, Bin4, Bin5, Bin6, Bin7, Bin8, Bin9, Bin10, Bin11, Bin12, Bin13,
Bin14, Bin15, Bin16, Bin17, Bin18, Bin19, Bin20 : CovBinType := NULL_BIN
) ;
------------------------------------------------------------
procedure AddCross(
Name : string ;
Bin1, Bin2 : CovBinType ;
Bin3, Bin4, Bin5, Bin6, Bin7, Bin8, Bin9, Bin10, Bin11, Bin12, Bin13,
Bin14, Bin15, Bin16, Bin17, Bin18, Bin19, Bin20 : CovBinType := NULL_BIN
) ;
------------------------------------------------------------
procedure AddCross(
AtLeast : integer ;
Weight : integer ;
Bin1, Bin2 : CovBinType ;
Bin3, Bin4, Bin5, Bin6, Bin7, Bin8, Bin9, Bin10, Bin11, Bin12, Bin13,
Bin14, Bin15, Bin16, Bin17, Bin18, Bin19, Bin20 : CovBinType := NULL_BIN
) ;
------------------------------------------------------------
procedure AddCross(
AtLeast : integer ;
Bin1, Bin2 : CovBinType ;
Bin3, Bin4, Bin5, Bin6, Bin7, Bin8, Bin9, Bin10, Bin11, Bin12, Bin13,
Bin14, Bin15, Bin16, Bin17, Bin18, Bin19, Bin20 : CovBinType := NULL_BIN
) ;
------------------------------------------------------------
procedure AddCross(
Bin1, Bin2 : CovBinType ;
Bin3, Bin4, Bin5, Bin6, Bin7, Bin8, Bin9, Bin10, Bin11, Bin12, Bin13,
Bin14, Bin15, Bin16, Bin17, Bin18, Bin19, Bin20 : CovBinType := NULL_BIN
) ;
procedure Deallocate ;
procedure ICoverLast ;
procedure ICover( CovPoint : integer) ;
procedure ICover( CovPoint : integer_vector) ;
procedure ClearCov ;
procedure SetCovZero ;
impure function IsInitialized return boolean ;
impure function GetNumBins return integer ;
impure function GetMinIndex return integer ;
impure function GetMinCov return real ; -- PercentCov
impure function GetMinCount return integer ; -- Count
impure function GetMaxIndex return integer ;
impure function GetMaxCov return real ; -- PercentCov
impure function GetMaxCount return integer ; -- Count
impure function CountCovHoles ( PercentCov : real ) return integer ;
impure function CountCovHoles return integer ;
impure function IsCovered return boolean ;
impure function IsCovered ( PercentCov : real ) return boolean ;
impure function GetCov ( PercentCov : real ) return real ;
impure function GetCov return real ; -- PercentCov of entire model/all bins
impure function GetItemCount return integer ;
impure function GetTotalCovGoal ( PercentCov : real ) return integer ;
impure function GetTotalCovGoal return integer ;
impure function GetLastIndex return integer ;
-- Return BinVal
impure function GetBinVal ( BinIndex : integer ) return RangeArrayType ;
impure function GetLastBinVal return RangeArrayType ;
impure function RandCovBinVal ( PercentCov : real ) return RangeArrayType ;
impure function RandCovBinVal return RangeArrayType ;
impure function GetMinBinVal return RangeArrayType ;
impure function GetMaxBinVal return RangeArrayType ;
impure function GetHoleBinVal ( ReqHoleNum : integer ; PercentCov : real ) return RangeArrayType ;
impure function GetHoleBinVal ( PercentCov : real ) return RangeArrayType ;
impure function GetHoleBinVal ( ReqHoleNum : integer := 1 ) return RangeArrayType ;
-- Return Points
impure function RandCovPoint return integer ;
impure function RandCovPoint ( PercentCov : real ) return integer ;
impure function RandCovPoint return integer_vector ;
impure function RandCovPoint ( PercentCov : real ) return integer_vector ;
impure function GetPoint ( BinIndex : integer ) return integer ;
impure function GetPoint ( BinIndex : integer ) return integer_vector ;
impure function GetMinPoint return integer ;
impure function GetMinPoint return integer_vector ;
impure function GetMaxPoint return integer ;
impure function GetMaxPoint return integer_vector ;
-- GetBin returns an internal value of the coverage data structure
-- The return value may change as the package evolves
-- Use it only for debugging.
-- GetBinInfo is a for development only.
impure function GetBinInfo ( BinIndex : integer ) return CovBinBaseType ;
impure function GetBinValLength return integer ;
impure function GetBin ( BinIndex : integer ) return CovBinBaseType ;
impure function GetBin ( BinIndex : integer ) return CovMatrix2BaseType ;
impure function GetBin ( BinIndex : integer ) return CovMatrix3BaseType ;
impure function GetBin ( BinIndex : integer ) return CovMatrix4BaseType ;
impure function GetBin ( BinIndex : integer ) return CovMatrix5BaseType ;
impure function GetBin ( BinIndex : integer ) return CovMatrix6BaseType ;
impure function GetBin ( BinIndex : integer ) return CovMatrix7BaseType ;
impure function GetBin ( BinIndex : integer ) return CovMatrix8BaseType ;
impure function GetBin ( BinIndex : integer ) return CovMatrix9BaseType ;
impure function GetBinName ( BinIndex : integer; DefaultName : string := "" ) return string ;
------------------------------------------------------------
procedure WriteBin (
WritePassFail : CovOptionsType := COV_OPT_INIT_PARM_DETECT ;
WriteBinInfo : CovOptionsType := COV_OPT_INIT_PARM_DETECT ;
WriteCount : CovOptionsType := COV_OPT_INIT_PARM_DETECT ;
WriteAnyIllegal : CovOptionsType := COV_OPT_INIT_PARM_DETECT ;
WritePrefix : string := OSVVM_STRING_INIT_PARM_DETECT ;
PassName : string := OSVVM_STRING_INIT_PARM_DETECT ;
FailName : string := OSVVM_STRING_INIT_PARM_DETECT
) ;
------------------------------------------------------------
procedure WriteBin ( -- With LogLevel
LogLevel : LogType ;
WritePassFail : CovOptionsType := COV_OPT_INIT_PARM_DETECT ;
WriteBinInfo : CovOptionsType := COV_OPT_INIT_PARM_DETECT ;
WriteCount : CovOptionsType := COV_OPT_INIT_PARM_DETECT ;
WriteAnyIllegal : CovOptionsType := COV_OPT_INIT_PARM_DETECT ;
WritePrefix : string := OSVVM_STRING_INIT_PARM_DETECT ;
PassName : string := OSVVM_STRING_INIT_PARM_DETECT ;
FailName : string := OSVVM_STRING_INIT_PARM_DETECT
) ;
------------------------------------------------------------
procedure WriteBin (
FileName : string;
OpenKind : File_Open_Kind := APPEND_MODE ;
WritePassFail : CovOptionsType := COV_OPT_INIT_PARM_DETECT ;
WriteBinInfo : CovOptionsType := COV_OPT_INIT_PARM_DETECT ;
WriteCount : CovOptionsType := COV_OPT_INIT_PARM_DETECT ;
WriteAnyIllegal : CovOptionsType := COV_OPT_INIT_PARM_DETECT ;
WritePrefix : string := OSVVM_STRING_INIT_PARM_DETECT ;
PassName : string := OSVVM_STRING_INIT_PARM_DETECT ;
FailName : string := OSVVM_STRING_INIT_PARM_DETECT
) ;
------------------------------------------------------------
procedure WriteBin ( -- With LogLevel
LogLevel : LogType ;
FileName : string;
OpenKind : File_Open_Kind := APPEND_MODE ;
WritePassFail : CovOptionsType := COV_OPT_INIT_PARM_DETECT ;
WriteBinInfo : CovOptionsType := COV_OPT_INIT_PARM_DETECT ;
WriteCount : CovOptionsType := COV_OPT_INIT_PARM_DETECT ;
WriteAnyIllegal : CovOptionsType := COV_OPT_INIT_PARM_DETECT ;
WritePrefix : string := OSVVM_STRING_INIT_PARM_DETECT ;
PassName : string := OSVVM_STRING_INIT_PARM_DETECT ;
FailName : string := OSVVM_STRING_INIT_PARM_DETECT
) ;
procedure WriteCovHoles ( LogLevel : LogType := ALWAYS ) ;
procedure WriteCovHoles ( PercentCov : real ) ;
procedure WriteCovHoles ( LogLevel : LogType ; PercentCov : real ) ;
procedure WriteCovHoles ( FileName : string; OpenKind : File_Open_Kind := APPEND_MODE ) ;
procedure WriteCovHoles ( LogLevel : LogType ; FileName : string; OpenKind : File_Open_Kind := APPEND_MODE ) ;
procedure WriteCovHoles ( FileName : string; PercentCov : real ; OpenKind : File_Open_Kind := APPEND_MODE ) ;
procedure WriteCovHoles ( LogLevel : LogType ; FileName : string; PercentCov : real ; OpenKind : File_Open_Kind := APPEND_MODE ) ;
procedure DumpBin (LogLevel : LogType := DEBUG) ; -- Development only
procedure ReadCovDb (FileName : string; Merge : boolean := FALSE) ;
procedure WriteCovDb (FileName : string; OpenKind : File_Open_Kind := WRITE_MODE ) ;
impure function GetErrorCount return integer ;
-- These support usage of cross coverage constants
-- Also support the older AddBins(GenCross(...)) methodology
-- which has been replaced by AddCross
procedure AddCross (CovBin : CovMatrix2Type ; Name : String := "") ;
procedure AddCross (CovBin : CovMatrix3Type ; Name : String := "") ;
procedure AddCross (CovBin : CovMatrix4Type ; Name : String := "") ;
procedure AddCross (CovBin : CovMatrix5Type ; Name : String := "") ;
procedure AddCross (CovBin : CovMatrix6Type ; Name : String := "") ;
procedure AddCross (CovBin : CovMatrix7Type ; Name : String := "") ;
procedure AddCross (CovBin : CovMatrix8Type ; Name : String := "") ;
procedure AddCross (CovBin : CovMatrix9Type ; Name : String := "") ;
------------------------------------------------------------
-- Remaining are Deprecated
--
-- Deprecated. Replaced by SetName with multi-line support
procedure SetItemName (ItemNameIn : String) ; -- deprecated
-- Deprecated. Consistency across packages
impure function CovBinErrCnt return integer ;
-- Deprecated. Due to name changes to promote greater consistency
-- Maintained for backward compatibility.
-- RandCovHole replaced by RandCovBinVal
impure function RandCovHole ( PercentCov : real ) return RangeArrayType ; -- Deprecated
impure function RandCovHole return RangeArrayType ; -- Deprecated
-- GetCovHole replaced by GetHoleBinVal
impure function GetCovHole ( ReqHoleNum : integer ; PercentCov : real ) return RangeArrayType ;
impure function GetCovHole ( PercentCov : real ) return RangeArrayType ;
impure function GetCovHole ( ReqHoleNum : integer := 1 ) return RangeArrayType ;
-- Deprecated/ Subsumed by versions with PercentCov Parameter
-- Maintained for backward compatibility only and
-- may be removed in the future.
impure function GetMinCov return integer ;
impure function GetMaxCov return integer ;
impure function CountCovHoles ( AtLeast : integer ) return integer ;
impure function IsCovered ( AtLeast : integer ) return boolean ;
impure function RandCovBinVal ( AtLeast : integer ) return RangeArrayType ;
impure function RandCovHole ( AtLeast : integer ) return RangeArrayType ; -- Deprecated
impure function RandCovPoint (AtLeast : integer ) return integer ;
impure function RandCovPoint (AtLeast : integer ) return integer_vector ;
impure function GetHoleBinVal ( ReqHoleNum : integer ; AtLeast : integer ) return RangeArrayType ;
impure function GetCovHole ( ReqHoleNum : integer ; AtLeast : integer ) return RangeArrayType ;
procedure WriteCovHoles ( AtLeast : integer ) ;
procedure WriteCovHoles ( LogLevel : LogType ; AtLeast : integer ) ;
procedure WriteCovHoles ( FileName : string; AtLeast : integer ; OpenKind : File_Open_Kind := APPEND_MODE ) ;
procedure WriteCovHoles ( LogLevel : LogType ; FileName : string; AtLeast : integer ; OpenKind : File_Open_Kind := APPEND_MODE ) ;
-- Replaced by a more appropriately named AddCross
procedure AddBins (CovBin : CovMatrix2Type ; Name : String := "") ;
procedure AddBins (CovBin : CovMatrix3Type ; Name : String := "") ;
procedure AddBins (CovBin : CovMatrix4Type ; Name : String := "") ;
procedure AddBins (CovBin : CovMatrix5Type ; Name : String := "") ;
procedure AddBins (CovBin : CovMatrix6Type ; Name : String := "") ;
procedure AddBins (CovBin : CovMatrix7Type ; Name : String := "") ;
procedure AddBins (CovBin : CovMatrix8Type ; Name : String := "") ;
procedure AddBins (CovBin : CovMatrix9Type ; Name : String := "") ;
end protected CovPType ;
------------------------------------------------------------------------------------------
-- XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX CovPType XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
-- XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX CovPType XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
------------------------------------------------------------------------------------------
------------------------------------------------------------
-- Experimental. Intended primarily for development.
procedure CompareBins (
------------------------------------------------------------
variable Bin1 : inout CovPType ;
variable Bin2 : inout CovPType ;
variable ErrorCount : inout integer
) ;
------------------------------------------------------------
-- Experimental. Intended primarily for development.
procedure CompareBins (
------------------------------------------------------------
variable Bin1 : inout CovPType ;
variable Bin2 : inout CovPType
) ;
--
-- Support for AddBins and AddCross
--
------------------------------------------------------------
function GenBin(
------------------------------------------------------------
AtLeast : integer ;
Weight : integer ;
Min, Max : integer ;
NumBin : integer
) return CovBinType ;
-- Each item in range in a separate CovBin
function GenBin(AtLeast : integer ; Min, Max, NumBin : integer ) return CovBinType ;
function GenBin(Min, Max, NumBin : integer ) return CovBinType ;
function GenBin(Min, Max : integer) return CovBinType ;
function GenBin(A : integer) return CovBinType ;
------------------------------------------------------------
function GenBin(
------------------------------------------------------------
AtLeast : integer ;
Weight : integer ;
A : integer_vector
) return CovBinType ;
function GenBin ( AtLeast : integer ; A : integer_vector ) return CovBinType ;
function GenBin ( A : integer_vector ) return CovBinType ;
------------------------------------------------------------
function IllegalBin ( Min, Max, NumBin : integer ) return CovBinType ;
------------------------------------------------------------
-- All items in range in a single CovBin
function IllegalBin ( Min, Max : integer ) return CovBinType ;
function IllegalBin ( A : integer ) return CovBinType ;
-- IgnoreBin should never have an AtLeast parameter
------------------------------------------------------------
function IgnoreBin (Min, Max, NumBin : integer) return CovBinType ;
------------------------------------------------------------
function IgnoreBin (Min, Max : integer) return CovBinType ; -- All items in range in a single CovBin
function IgnoreBin (A : integer) return CovBinType ;
-- With VHDL-2008, there will be one GenCross that returns CovBinType
-- and has inputs initialized to NULL_BIN - see AddCross
------------------------------------------------------------
function GenCross( -- 2
-- Cross existing bins
-- Use AddCross for adding values directly to coverage database
-- Use GenCross for constants
------------------------------------------------------------
AtLeast : integer ;
Weight : integer ;
Bin1, Bin2 : CovBinType
) return CovMatrix2Type ;
function GenCross(AtLeast : integer ; Bin1, Bin2 : CovBinType) return CovMatrix2Type ;
function GenCross(Bin1, Bin2 : CovBinType) return CovMatrix2Type ;
------------------------------------------------------------
function GenCross( -- 3
------------------------------------------------------------
AtLeast : integer ;
Weight : integer ;
Bin1, Bin2, Bin3 : CovBinType
) return CovMatrix3Type ;
function GenCross( AtLeast : integer ; Bin1, Bin2, Bin3 : CovBinType ) return CovMatrix3Type ;
function GenCross( Bin1, Bin2, Bin3 : CovBinType ) return CovMatrix3Type ;
------------------------------------------------------------
function GenCross( -- 4
------------------------------------------------------------
AtLeast : integer ;
Weight : integer ;
Bin1, Bin2, Bin3, Bin4 : CovBinType
) return CovMatrix4Type ;
function GenCross( AtLeast : integer ; Bin1, Bin2, Bin3, Bin4 : CovBinType ) return CovMatrix4Type ;
function GenCross( Bin1, Bin2, Bin3, Bin4 : CovBinType ) return CovMatrix4Type ;
------------------------------------------------------------
function GenCross( -- 5
------------------------------------------------------------
AtLeast : integer ;
Weight : integer ;
Bin1, Bin2, Bin3, Bin4, Bin5 : CovBinType
) return CovMatrix5Type ;
function GenCross( AtLeast : integer ; Bin1, Bin2, Bin3, Bin4, Bin5 : CovBinType ) return CovMatrix5Type ;
function GenCross( Bin1, Bin2, Bin3, Bin4, Bin5 : CovBinType ) return CovMatrix5Type ;
------------------------------------------------------------
function GenCross( -- 6
------------------------------------------------------------
AtLeast : integer ;
Weight : integer ;
Bin1, Bin2, Bin3, Bin4, Bin5, Bin6 : CovBinType
) return CovMatrix6Type ;
function GenCross( AtLeast : integer ; Bin1, Bin2, Bin3, Bin4, Bin5, Bin6 : CovBinType ) return CovMatrix6Type ;
function GenCross( Bin1, Bin2, Bin3, Bin4, Bin5, Bin6 : CovBinType ) return CovMatrix6Type ;
------------------------------------------------------------
function GenCross( -- 7
------------------------------------------------------------
AtLeast : integer ;
Weight : integer ;
Bin1, Bin2, Bin3, Bin4, Bin5, Bin6, Bin7 : CovBinType
) return CovMatrix7Type ;
function GenCross( AtLeast : integer ; Bin1, Bin2, Bin3, Bin4, Bin5, Bin6, Bin7 : CovBinType ) return CovMatrix7Type ;
function GenCross( Bin1, Bin2, Bin3, Bin4, Bin5, Bin6, Bin7 : CovBinType ) return CovMatrix7Type ;
------------------------------------------------------------
function GenCross( -- 8
------------------------------------------------------------
AtLeast : integer ;
Weight : integer ;
Bin1, Bin2, Bin3, Bin4, Bin5, Bin6, Bin7, Bin8 : CovBinType
) return CovMatrix8Type ;
function GenCross( AtLeast : integer ; Bin1, Bin2, Bin3, Bin4, Bin5, Bin6, Bin7, Bin8 : CovBinType ) return CovMatrix8Type ;
function GenCross( Bin1, Bin2, Bin3, Bin4, Bin5, Bin6, Bin7, Bin8 : CovBinType ) return CovMatrix8Type ;
------------------------------------------------------------
function GenCross( -- 9
------------------------------------------------------------
AtLeast : integer ;
Weight : integer ;
Bin1, Bin2, Bin3, Bin4, Bin5, Bin6, Bin7, Bin8, Bin9 : CovBinType
) return CovMatrix9Type ;
function GenCross( AtLeast : integer ; Bin1, Bin2, Bin3, Bin4, Bin5, Bin6, Bin7, Bin8, Bin9 : CovBinType ) return CovMatrix9Type ;
function GenCross( Bin1, Bin2, Bin3, Bin4, Bin5, Bin6, Bin7, Bin8, Bin9 : CovBinType ) return CovMatrix9Type ;
------------------------------------------------------------
-- Utilities. Remove if added to std.standard
function to_integer ( B : boolean ) return integer ;
function to_integer ( SL : std_logic ) return integer ;
function to_integer_vector ( BV : boolean_vector ) return integer_vector ;
function to_integer_vector ( SLV : std_logic_vector ) return integer_vector ;
------------------------------------------------------------
------------------------------------------------------------
-- Deprecated: These are not part of the coverage model
-- procedure increment( signal Count : inout integer ) ;
-- procedure increment( signal Count : inout integer ; enable : boolean ) ;
-- procedure increment( signal Count : inout integer ; enable : std_ulogic ) ;
end package CoveragePkg ;
--- ///////////////////////////////////////////////////////////////////////////
--- ///////////////////////////////////////////////////////////////////////////
--- ///////////////////////////////////////////////////////////////////////////
package body CoveragePkg is
------------------------------------------------------------
function inside (
-- package local
------------------------------------------------------------
CovPoint : integer_vector ;
BinVal : RangeArrayType
) return boolean is
alias iCovPoint : integer_vector(BinVal'range) is CovPoint ;
begin
for i in BinVal'range loop
if not (iCovPoint(i) >= BinVal(i).min and iCovPoint(i) <= BinVal(i).max) then
return FALSE ;
end if ;
end loop ;
return TRUE ;
end function inside ;
------------------------------------------------------------
function inside (
-- package local, used by InsertBin
-- True when BinVal1 is inside BinVal2
------------------------------------------------------------
BinVal1 : RangeArrayType ;
BinVal2 : RangeArrayType
) return boolean is
alias iBinVal2 : RangeArrayType(BinVal1'range) is BinVal2 ;
begin
for i in BinVal1'range loop
if not (BinVal1(i).min >= iBinVal2(i).min and BinVal1(i).max <= iBinVal2(i).max) then
return FALSE ;
end if ;
end loop ;
return TRUE ;
end function inside ;
------------------------------------------------------------
procedure write (
variable buf : inout line ;
CovPoint : integer_vector
) is
-- package local. called by ICover
------------------------------------------------------------
alias iCovPoint : integer_vector(1 to CovPoint'length) is CovPoint ;
begin
write(buf, "(" & integer'image(iCovPoint(1)) ) ;
for i in 2 to iCovPoint'right loop
write(buf, "," & integer'image(iCovPoint(i)) ) ;
end loop ;
swrite(buf, ")") ;
end procedure write ;
------------------------------------------------------------
procedure write ( file f : text ; BinVal : RangeArrayType ) is
-- called by WriteBin and WriteCovHoles
------------------------------------------------------------
begin
for i in BinVal'range loop
if BinVal(i).min = BinVal(i).max then
write(f, "(" & integer'image(BinVal(i).min) & ") " ) ;
elsif (BinVal(i).min = integer'left) and (BinVal(i).max = integer'right) then
write(f, "(ALL) " ) ;
else
write(f, "(" & integer'image(BinVal(i).min) & " to " &
integer'image(BinVal(i).max) & ") " ) ;
end if ;
end loop ;
end procedure write ;
------------------------------------------------------------
procedure write (
-- called by WriteBin and WriteCovHoles
------------------------------------------------------------
variable buf : inout line ;
constant BinVal : in RangeArrayType
) is
------------------------------------------------------------
begin
for i in BinVal'range loop
if BinVal(i).min = BinVal(i).max then
write(buf, "(" & integer'image(BinVal(i).min) & ") " ) ;
elsif (BinVal(i).min = integer'left) and (BinVal(i).max = integer'right) then
swrite(buf, "(ALL) " ) ;
else
write(buf, "(" & integer'image(BinVal(i).min) & " to " &
integer'image(BinVal(i).max) & ") " ) ;
end if ;
end loop ;
end procedure write ;
------------------------------------------------------------
procedure WriteBinVal (
-- package local for now
------------------------------------------------------------
variable buf : inout line ;
constant BinVal : in RangeArrayType
) is
begin
for i in BinVal'range loop
write(buf, BinVal(i).min) ;
write(buf, ' ') ;
write(buf, BinVal(i).max) ;
write(buf, ' ') ;
end loop ;
end procedure WriteBinVal ;
------------------------------------------------------------
-- package local for now
procedure read (
-- if public, also create one that does not use valid flag
------------------------------------------------------------
variable buf : inout line ;
variable BinVal : out RangeArrayType ;
variable Valid : out boolean
) is
variable ReadValid : boolean ;
begin
for i in BinVal'range loop
read(buf, BinVal(i).min, ReadValid) ;
exit when not ReadValid ;
read(buf, BinVal(i).max, ReadValid) ;
exit when not ReadValid ;
end loop ;
Valid := ReadValid ;
end procedure read ;
------------------------------------------------------------
function CalcPercentCov( Count : integer ; AtLeast : integer ) return real is
-- package local, called by MergeBin, InsertBin, ClearCov, ReadCovDbDatabase
------------------------------------------------------------
variable PercentCov : real ;
begin
if AtLeast > 0 then
return real(Count)*100.0/real(AtLeast) ;
elsif AtLeast = 0 then
return 100.0 ;
else
return real'right ;
end if ;
end function CalcPercentCov ;
-- ------------------------------------------------------------
function BinLengths (
-- package local, used by AddCross, GenCross
-- ------------------------------------------------------------
Bin1, Bin2, Bin3, Bin4, Bin5, Bin6, Bin7, Bin8, Bin9, Bin10, Bin11,
Bin12, Bin13, Bin14, Bin15, Bin16, Bin17, Bin18, Bin19, Bin20 : CovBinType := NULL_BIN
) return integer_vector is
variable result : integer_vector(1 to 20) := (others => 0 ) ;
variable i : integer := result'left ;
variable Len : integer ;
begin
loop
case i is
when 1 => Len := Bin1'length ;
when 2 => Len := Bin2'length ;
when 3 => Len := Bin3'length ;
when 4 => Len := Bin4'length ;
when 5 => Len := Bin5'length ;
when 6 => Len := Bin6'length ;
when 7 => Len := Bin7'length ;
when 8 => Len := Bin8'length ;
when 9 => Len := Bin9'length ;
when 10 => Len := Bin10'length ;
when 11 => Len := Bin11'length ;
when 12 => Len := Bin12'length ;
when 13 => Len := Bin13'length ;
when 14 => Len := Bin14'length ;
when 15 => Len := Bin15'length ;
when 16 => Len := Bin16'length ;
when 17 => Len := Bin17'length ;
when 18 => Len := Bin18'length ;
when 19 => Len := Bin19'length ;
when 20 => Len := Bin20'length ;
when others => Len := 0 ;
end case ;
result(i) := Len ;
exit when Len = 0 ;
i := i + 1 ;
exit when i = 21 ;
end loop ;
return result(1 to (i-1)) ;
end function BinLengths ;
-- ------------------------------------------------------------
function CalcNumCrossBins ( BinLens : integer_vector ) return integer is
-- package local, used by AddCross
-- ------------------------------------------------------------
variable result : integer := 1 ;
begin
for i in BinLens'range loop
result := result * BinLens(i) ;
end loop ;
return result ;
end function CalcNumCrossBins ;
-- ------------------------------------------------------------
procedure IncBinIndex (
-- package local, used by AddCross
-- ------------------------------------------------------------
variable BinIndex : inout integer_vector ;
constant BinLens : in integer_vector
) is
alias aBinIndex : integer_vector(1 to BinIndex'length) is BinIndex ;
alias aBinLens : integer_vector(aBinIndex'range) is BinLens ;
begin
-- increment right most one, then if overflow, increment next
-- assumes bins numbered from 1 to N. - assured by ConcatenateBins
for i in aBinIndex'reverse_range loop
aBinIndex(i) := aBinIndex(i) + 1 ;
exit when aBinIndex(i) <= aBinLens(i) ;
aBinIndex(i) := 1 ;
end loop ;
end procedure IncBinIndex ;