class PrintfModule extends Module {
val io = new DecoupledUIntIO
val counter = Reg(Flo(), init = Flo(0))
val counterString = "counter = %e\n"
counter := counter + Flo(1)
printf(counterString, counter);
}
trait FlushPrintfOutputTests extends Tests {
val expectedOutputs = collection.mutable.ArrayBuffer[String]()
def tests(m: PrintfModule) {
for (i <- 0 until 4) {
step(1)
expectedOutputs += m.counterString.format(i.toFloat)
}
assertTrue("Not enough printf outputs", printfs.length == expectedOutputs.length)
(printfs zip expectedOutputs) foreach {case (printf, expected) =>
assertTrue("incorrect output - %s".format(printf),
eliminateWhiteSpace(printf) == eliminateWhiteSpace(expected))
}
}
}
class FlushPrintfOutputTester(m: PrintfModule) extends Tester(m) with FlushPrintfOutputTests {
tests(m)
}
launchCppTester((m: PrintfModule) => new FlushPrintfOutputTester(m))
Fails with assertion as printfs length is 0
Printing a UInt is fine and the function print() seems to be generated correctly for float so I am a bit lost as to the cause. Any ideas?
See the following
Fails with assertion as printfs length is 0 Printing a UInt is fine and the function print() seems to be generated correctly for float so I am a bit lost as to the cause. Any ideas?