ucb-bar / chisel2-deprecated

chisel.eecs.berkeley.edu
387 stars 90 forks source link

Flo is not printed with printf #573

Closed da-steve101 closed 8 years ago

da-steve101 commented 8 years ago

See the following

    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?