Skip to content
This repository has been archived by the owner on Aug 21, 2024. It is now read-only.

Commit

Permalink
- asserts => assumes (#351)
Browse files Browse the repository at this point in the history
- printlns removed
- change leq_assert to leq_cover where appropriate
  • Loading branch information
chick authored Aug 24, 2021
1 parent b4ca70e commit ac0c7d0
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 2 deletions.
19 changes: 17 additions & 2 deletions src/main/scala/treadle/TreadleTester.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ package treadle

import java.io.PrintWriter
import java.util.Calendar

import firrtl.AnnotationSeq
import firrtl.ir.ClockType
import firrtl.options.StageOptions
import firrtl.options.Viewer.view
import firrtl.stage.OutputFileAnnotation
Expand Down Expand Up @@ -74,8 +74,23 @@ class TreadleTester(annotationSeq: AnnotationSeq) {

val startTime: Long = System.nanoTime()

private def findTopLevelClocks() = {
engine.symbolTable.symbols.collect {
case symbol if symbol.firrtlType == ClockType && !(symbol.name.contains(".") || symbol.name.endsWith("/prev")) =>
symbol
}.toList
}

val clockInfoList: Seq[ClockInfo] = if (clockInfo.isEmpty) {
if (engine.symbolTable.contains("clock")) {
val topClocks = findTopLevelClocks()

if (topClocks.length > 2) {
println(s"Warning: multiple top level clocks found without any ClockInfo information, is this intentional?")
}

if (topClocks.length == 1) {
Seq(ClockInfo(topClocks.head.name))
} else if (engine.symbolTable.contains("clock")) {
Seq(ClockInfo())
} else if (engine.symbolTable.contains("clk")) {
Seq(ClockInfo("clk"))
Expand Down
21 changes: 21 additions & 0 deletions src/test/scala/treadle/ClockSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,27 @@ class ClockSpec extends AnyFreeSpec with Matchers with LazyLogging {
}
}

"clocks can have names other than clock" in {
val input =
"""
|circuit OddClockName :
| module OddClockName :
| input tardigrade : Clock
| input reset : UInt<1>
| output out2 : UInt<8>
|
| reg reg2 : UInt<8>, tardigrade with : (reset => (reset, UInt<8>("h0")))
| reg2 <= add(reg2, UInt<8>("h01"))
| out2 <= reg2
|
""".stripMargin

TreadleTestHarness(Seq(FirrtlSourceAnnotation(input))) { tester =>
tester.step(100)
tester.expect("out2", 100)
}
}

"clocks must behave properly behind validif" in {
val input =
"""
Expand Down

0 comments on commit ac0c7d0

Please sign in to comment.