Replace Parameters in cover with globally setable implementation (#1200)
This change is made in anticipation of a proper coverage library
This commit is contained in:
parent
5854fb5f7c
commit
bf5dd6dac3
@ -5,10 +5,6 @@ package freechips.rocketchip.util.property
|
|||||||
import Chisel._
|
import Chisel._
|
||||||
import chisel3.internal.sourceinfo.{SourceInfo, SourceLine}
|
import chisel3.internal.sourceinfo.{SourceInfo, SourceLine}
|
||||||
import chisel3.util.{ReadyValidIO}
|
import chisel3.util.{ReadyValidIO}
|
||||||
import freechips.rocketchip.config.{Field, Parameters}
|
|
||||||
|
|
||||||
case object PropertyLibrary extends Field[BasePropertyLibrary](new DefaultPropertyLibrary)
|
|
||||||
|
|
||||||
|
|
||||||
sealed abstract class PropertyType(name: String) {
|
sealed abstract class PropertyType(name: String) {
|
||||||
override def toString: String = name
|
override def toString: String = name
|
||||||
@ -133,24 +129,30 @@ class CrossProperty(cond: Seq[Seq[CoverBoolean]], exclude: Seq[Seq[String]], mes
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// The implementation using a setable global is bad, but removes dependence on Parameters
|
||||||
|
// This change was made in anticipation of a proper cover library
|
||||||
object cover {
|
object cover {
|
||||||
def apply(cond: Bool)(implicit sourceInfo: SourceInfo, p: Parameters): Unit = {
|
private var propLib: BasePropertyLibrary = new DefaultPropertyLibrary
|
||||||
p(PropertyLibrary).generateProperty(CoverPropertyParameters(cond))
|
def setPropLib(lib: BasePropertyLibrary): Unit = this.synchronized {
|
||||||
|
propLib = lib
|
||||||
}
|
}
|
||||||
def apply(cond: Bool, label: String)(implicit sourceInfo: SourceInfo, p: Parameters): Unit = {
|
def apply(cond: Bool)(implicit sourceInfo: SourceInfo): Unit = {
|
||||||
p(PropertyLibrary).generateProperty(CoverPropertyParameters(cond, label))
|
propLib.generateProperty(CoverPropertyParameters(cond))
|
||||||
}
|
}
|
||||||
def apply(cond: Bool, label: String, message: String)(implicit sourceInfo: SourceInfo, p: Parameters): Unit = {
|
def apply(cond: Bool, label: String)(implicit sourceInfo: SourceInfo): Unit = {
|
||||||
p(PropertyLibrary).generateProperty(CoverPropertyParameters(cond, label, message))
|
propLib.generateProperty(CoverPropertyParameters(cond, label))
|
||||||
}
|
}
|
||||||
def apply(prop: BaseProperty)(implicit sourceInfo: SourceInfo, p: Parameters): Unit = {
|
def apply(cond: Bool, label: String, message: String)(implicit sourceInfo: SourceInfo): Unit = {
|
||||||
|
propLib.generateProperty(CoverPropertyParameters(cond, label, message))
|
||||||
|
}
|
||||||
|
def apply(prop: BaseProperty)(implicit sourceInfo: SourceInfo): Unit = {
|
||||||
prop.generateProperties().foreach( (pp: BasePropertyParameters) => {
|
prop.generateProperties().foreach( (pp: BasePropertyParameters) => {
|
||||||
if (pp.pType == PropertyType.Cover) {
|
if (pp.pType == PropertyType.Cover) {
|
||||||
p(PropertyLibrary).generateProperty(CoverPropertyParameters(pp.cond, pp.label, pp.message))
|
propLib.generateProperty(CoverPropertyParameters(pp.cond, pp.label, pp.message))
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
def apply[T <: Data](rv: ReadyValidIO[T], label: String, message: String)(implicit sourceInfo: SourceInfo, p: Parameters): Unit = {
|
def apply[T <: Data](rv: ReadyValidIO[T], label: String, message: String)(implicit sourceInfo: SourceInfo): Unit = {
|
||||||
apply( rv.valid && rv.ready, label + "_FIRE", message + ": valid and ready")
|
apply( rv.valid && rv.ready, label + "_FIRE", message + ": valid and ready")
|
||||||
apply( rv.valid && !rv.ready, label + "_STALL", message + ": valid and not ready")
|
apply( rv.valid && !rv.ready, label + "_STALL", message + ": valid and not ready")
|
||||||
apply(!rv.valid && rv.ready, label + "_IDLE", message + ": not valid and ready")
|
apply(!rv.valid && rv.ready, label + "_IDLE", message + ": not valid and ready")
|
||||||
|
Loading…
Reference in New Issue
Block a user