|
| 1 | + ------------------------------------------------------------ |
| 2 | + -- package local, Used by GenBin, IllegalBin, and IgnoreBin |
| 3 | + function MakeBin( |
| 4 | + ------------------------------------------------------------ |
| 5 | + Min, Max : integer ; |
| 6 | + NumBin : integer ; |
| 7 | + AtLeast : integer ; |
| 8 | + Weight : integer ; |
| 9 | + Action : integer |
| 10 | + ) return CovBinType is |
| 11 | + variable iCovBin : CovBinType(1 to NumBin) ; |
| 12 | + variable TotalBins : integer ; -- either real or integer |
| 13 | + variable rMax, rCurMin, rNextMin, rNumItemsInBin, rRemainingBins : real ; -- must be real |
| 14 | + variable CurMin, Offset : integer ; |
| 15 | + begin |
| 16 | + if Min > Max then |
| 17 | + Alert(OSVVM_ALERTLOG_ID, "CoveragePkg.MakeBin (GenBin, IllegalBin, IgnoreBin): Min must be <= Max", FAILURE) ; |
| 18 | + return NULL_BIN ; |
| 19 | + |
| 20 | + elsif NumBin <= 0 then |
| 21 | + Alert(OSVVM_ALERTLOG_ID, "CoveragePkg.MakeBin (GenBin, IllegalBin, IgnoreBin): NumBin must be <= 0", FAILURE) ; |
| 22 | + return NULL_BIN ; |
| 23 | + |
| 24 | + elsif NumBin = 1 then |
| 25 | + iCovBin(1) := ( |
| 26 | + BinVal => (1 => (Min, Max)), |
| 27 | + Action => Action, |
| 28 | + Count => 0, |
| 29 | + Weight => Weight, |
| 30 | + AtLeast => AtLeast |
| 31 | + ) ; |
| 32 | + return iCovBin ; |
| 33 | + |
| 34 | + else |
| 35 | + CurMin := Min ; |
| 36 | + TotalBins := integer( (minimum( real(NumBin), real(Max) - real(Min) + 1.0))) ; |
| 37 | + RemainingBins := TotalBins ; |
| 38 | + |
| 39 | + for i in iCovBin'range loop |
| 40 | + exit when RemainingBins = 0 ; |
| 41 | + |
| 42 | + Offset := CalcOffset(Min, Max, ) |
| 43 | + RemainingBins := CALC_NUM_BINS - i ; |
| 44 | + NumItemsInBin := (Max - CurMin + 1) / RemainingBins ; |
| 45 | + NextMin := CurMin + NumItemsInBin ; |
| 46 | + iCovBin(i) := ( |
| 47 | + BinVal => (1 => (CurMin, NextMin - 1)), |
| 48 | + Action => Action, |
| 49 | + Count => 0, |
| 50 | + Weight => Weight, |
| 51 | + AtLeast => AtLeast |
| 52 | + ) ; |
| 53 | + CurMin := NextMin ; |
| 54 | + end loop ; |
| 55 | + return iCovBin ; |
| 56 | + |
| 57 | + |
| 58 | + rCurMin := real(Min) ; |
| 59 | + rMax := real(Max) ; |
| 60 | + rRemainingBins := (minimum( real(NumBin), rMax - rCurMin + 1.0 )) ; |
| 61 | + TotalBins := integer(rRemainingBins) ; |
| 62 | + for i in iCovBin'range loop |
| 63 | + exit when rRemainingBins = 0.0 ; |
| 64 | + rNumItemsInBin := trunc((rMax - rCurMin + 1.0) / rRemainingBins) ; -- can be too large |
| 65 | + rNextMin := rCurMin + rNumItemsInBin ; -- can be 2**31 |
| 66 | + iCovBin(i) := ( |
| 67 | + BinVal => (1 => (integer(rCurMin), integer(rNextMin - 1.0))), |
| 68 | + Action => Action, |
| 69 | + Count => 0, |
| 70 | + Weight => Weight, |
| 71 | + AtLeast => AtLeast |
| 72 | + ) ; |
| 73 | + rCurMin := rNextMin ; |
| 74 | + rRemainingBins := rRemainingBins - 1.0 ; |
| 75 | + end loop ; |
| 76 | + return iCovBin(1 to TotalBins) ; |
| 77 | + end if ; |
| 78 | + end function MakeBin ; |
| 79 | + |
| 80 | + |
| 81 | + ------------------------------------------------------------ |
| 82 | + -- Local, Used by GenBin, IllegalBin, and IgnoreBin |
| 83 | + function MakeBin( |
| 84 | + ------------------------------------------------------------ |
| 85 | + Min, Max : integer ; |
| 86 | + NumBin : integer ; |
| 87 | + AtLeast : integer ; |
| 88 | + Weight : integer ; |
| 89 | + Action : integer |
| 90 | + ) return CovBinType is |
| 91 | + constant CALC_NUM_BINS : integer := minimum(NumBin, Max-Min+1) ; |
| 92 | + variable iCovBin : CovBinType(0 to CALC_NUM_BINS -1) ; |
| 93 | + variable CurMin, NextMin, RemainingBins, NumItemsInBin : integer ; |
| 94 | + begin |
| 95 | + CurMin := Min ; |
| 96 | + for i in iCovBin'range loop |
| 97 | + RemainingBins := CALC_NUM_BINS - i ; |
| 98 | + NumItemsInBin := (Max - CurMin + 1) / RemainingBins ; |
| 99 | + NextMin := CurMin + NumItemsInBin ; |
| 100 | + iCovBin(i) := ( |
| 101 | + BinVal => (1 => (CurMin, NextMin - 1)), |
| 102 | + Action => Action, |
| 103 | + Count => 0, |
| 104 | + Weight => Weight, |
| 105 | + AtLeast => AtLeast |
| 106 | + ) ; |
| 107 | + CurMin := NextMin ; |
| 108 | + end loop ; |
| 109 | + return iCovBin ; |
| 110 | + end function MakeBin ; |
| 111 | + |
0 commit comments