Skip to content

CoverCondition

Andrew Dobis edited this page Jun 17, 2021 · 4 revisions

CoverConition is a Cover construct that is entirely based on Conditions.

case class CoverCondition(pointName: String, ports: Data*)(conditions: Condition*)

The Condtion construct allows one to attach a readable name to a function that takes a set of DUT port values and returns a Boolean.

case class Condition(name: String, cond: Seq[BigInt] => Boolean, expectedHits: Option[BigInt] = None)

The expectedHits field is used in order to define a goal for the Condition. The coverage percentage for the Condition will then be given in relation to the expectedHits field, where 100% => nHits == expectedHits.

The CoverCondition construct can work on a arbitrary number of ports and can thus be used in two ways: with a single port or with multiple ports.

Single Port

This is the same thing as a CoverPoint using a purely conditional Bin.

CoverCondition("condA", dut.io.outA)(Condition("onlyEven", {case Seq(x) => x % 2 == 0}))

//Is the same as
CoverPoint("condA", dut.io.outA)(Bins("binOnlyEven", Condition("onlyEven", {case Seq(x) => x % 2 == 0})))

The only difference between the two is that the CoverCondition syntax is a bit lighter and should thus be preferred to trying to use a purely conditional CoverPoint. CoverPoints should thus be preferred when wanting to apply a condition over a specific range of values.

Multiple Ports

In this case, a CoverCondition is a relation between multiple ports, defined by a set of Conditions. A hit is thus considered only when all of the given ports satisfy a condition at the same time.

Example

Here a simple example showing how to define a CoverCondition.

CoverCondition("aAndB",dut.io.outA, dut.io.outB)(
    Condition("aeqb", { case Seq(a, b) => a == b }),
    Condition("asuptobAtLeast100", { case Seq(a, b) => a > b }, Some(100))
)

The coverage report will then, for example, look like:

=========================================
COVER_CONDITION NAME: aAndB
CONDITION aeqb HAS 0 HITS
CONDITION asuptobAtLeast100 HAS 5 HITS EXPECTED 100 = 5.0%
=========================================

Next topic: CrossPoint or return home.

Clone this wiki locally