object FormalContract extends FormalContract$Intf
Create a contract
block.
Outside of verification uses, the arguments passed to the contract are simply returned as contract results. During formal verification, the contract may act as a cutpoint by returning symbolic values for its results and using the contract body as constraint.
Within the contract body, RequireProperty
and EnsureProperty
can be
used to describe the pre and post-conditions of the contract. During
formal verification, contracts can be used to divide large formal checks
into smaller pieces by first asserting some local properties hold, and
then assuming those properties hold in the context of the larger proof.
- Source
- FormalContract.scala
The following is a contract with no arguments.
FormalContract { RequireProperty(a >= 1) EnsureProperty(a + a >= 2) }
The following is a contract with a single argument. It expresses the fact that the hardware implementation
(a << 3) + a
is equivalent toa * 9
. During formal verification, this contract is interpreted as: -assert((a << 3) + a === a * 9)
as a proof that the contract holds. -assume(b === a * 9)
on a new symbolic valueb
as a simplification of other proofs.val b = FormalContract((a << 3) + a) { b => EnsureProperty(b === a * 9) }
The following is a contract with multiple arguments. It expresses the fact that a carry-save adder with
p
,q
, andr
as inputs reduces the number of sum terms fromp + q + r
toc + s
but doesn't change the sum of the terms. During formal verification, this contract is interpreted as: -assert(c + s === p + q + r)
as a proof that the carry-save adder indeed compresses the three terms down to only two terms which have the same sum. -assume(u + v === p + q + r)
on new symbolic valuesu
andv
as a simplification of other proofs.val s = p ^ q ^ r val c = (p & q | (p ^ q) & r) << 1 val (u, v) = FormalContract(c, s) { case (u, v) => EnsureProperty(u + v === p + q + r) }
- Alphabetic
- By Inheritance
- FormalContract
- FormalContract$Intf
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Value Members
- final def !=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def ##: Int
- Definition Classes
- AnyRef → Any
- final def ==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- def apply(body: => Unit)(implicit sourceInfo: SourceInfo): Unit
Create a
contract
block with no arguments and results. - macro def apply(head: Data, tail: Data*): ((Any) => Unit) => Any
Create a
contract
block with one or more arguments and results.Create a
contract
block with one or more arguments and results.- Definition Classes
- FormalContract$Intf
- final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- def clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @native()
- final def eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def equals(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef → Any
- def finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.Throwable])
- final def getClass(): Class[_ <: AnyRef]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- def hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- def mapped[R](args: Seq[Data], mapping: (Seq[Data]) => R)(body: (R) => Unit)(implicit sourceInfo: SourceInfo): R
Create a formal contract from a sequence of expressions.
Create a formal contract from a sequence of expressions.
The
mapping
function is used to convert theSeq[Data]
to a user-defined typeR
, which is then passed to the contract body and returned as a result.This function is mainly intended for internal use, where the
mapping
function can be used to map the args sequence to a tuple that is more convenient for a user to work with.Example with identity mapping. The
Seq(a, b)
is passed towithSeqArgs
unmodified, and the contract returns aSeq[Data]
result.def withSeqArgs(args: Seq[Data]): Unit = ... val seqResult: Seq[Data] = FormalContract.mapping(Seq(a, b), _ => _)(withSeqArgs)
Example with a mapping from sequence to a tuple. The
Seq(a, b)
is mapped to a(UInt, UInt)
tuple throughmapToTuple
, which is then passed towithTupleArgs
, and the contract returns a corresponding(UInt, UInt)
result.def mapToTuple(args: Seq[Data]): (UInt, UInt) = { // check number of args and types, convert to tuple } def withTupleArgs(args: (UInt, UInt)): Unit = ... val tupleResult: (UInt, UInt) = FormalContract.mapping(Seq(a, b), mapToTuple)(withTupleArgs)
Example: - final def ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- final def notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- final def notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- final def synchronized[T0](arg0: => T0): T0
- Definition Classes
- AnyRef
- def toString(): String
- Definition Classes
- AnyRef → Any
- final def wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException]) @native()
This is the documentation for Chisel.
Package structure
The chisel3 package presents the public API of Chisel. It contains the concrete core types
UInt
,SInt
,Bool
,Clock
, andReg
, the abstract typesBits
,Aggregate
, andData
, and the aggregate typesBundle
andVec
.The Chisel package is a compatibility layer that attempts to provide chisel2 compatibility in chisel3.
Utility objects and methods are found in the
util
package.The
testers
package defines the basic interface for chisel testers.