Тестирование ПЗУ DSPComplex - PullRequest
       5

Тестирование ПЗУ DSPComplex

0 голосов
/ 12 декабря 2018

Я все еще работаю над созданием ПЗУ DSPComplex и столкнулся с тем, что, по моему мнению, может быть реальной проблемой с долотом.

Я собрал ПЗУ, могу генерировать вывод verilog из кода, который выглядит разумно, но не могу проверить модуль даже с самыми простыми из тестеров.Ниже я упростил ее до самой простой проверки.

Ошибка - переполнение стека, подобное следующему:

$ sbt 'testOnly taylor.TaylorTest'
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=8G; support was removed in 8.0
[info] Loading settings from plugins.sbt ...
[info] Loading project definition from /home/jcondley/Zendar/kodo/ZenFPGA/chisel/project
[info] Loading settings from build.sbt ...
[info] Set current project to zen-chisel (in build file:/home/jcondley/Zendar/kodo/ZenFPGA/chisel/)
[info] Compiling 1 Scala source to /home/jcondley/Zendar/kodo/ZenFPGA/chisel/target/scala-2.12/classes ...
[warn] there were 5 feature warnings; re-run with -feature for details
[warn] one warning found
[info] Done compiling.
[info] Compiling 1 Scala source to /home/jcondley/Zendar/kodo/ZenFPGA/chisel/target/scala-2.12/test-classes ...
[warn] there were two deprecation warnings (since chisel3, will be removed by end of 2017); re-run with -deprecation for details
[warn] there were two feature warnings; re-run with -feature for details
[warn] two warnings found
[info] Done compiling.
[info] [0.004] Elaborating design...
[deprecated] DspComplex.scala:22 (1029 calls): isLit is deprecated: "isLit is deprecated, use litOption.isDefined"
[deprecated] DspComplex.scala:22 (1029 calls): litArg is deprecated: "litArg is deprecated, use litOption or litTo*Option"
[deprecated] DspComplex.scala:23 (1029 calls): isLit is deprecated: "isLit is deprecated, use litOption.isDefined"
[deprecated] DspComplex.scala:23 (1029 calls): litArg is deprecated: "litArg is deprecated, use litOption or litTo*Option"
[warn] There were 4 deprecated function(s) used. These may stop compiling in a future release - you are encouraged to fix these issues.
[warn] Line numbers for deprecations reported by Chisel may be inaccurate; enable scalac compiler deprecation warnings via either of the following methods:
[warn]   In the sbt interactive console, enter:
[warn]     set scalacOptions in ThisBuild ++= Seq("-unchecked", "-deprecation")
[warn]   or, in your build.sbt, add the line:
[warn]     scalacOptions := Seq("-unchecked", "-deprecation")
[info] [1.487] Done elaborating.
Total FIRRTL Compile Time: 1887.8 ms
Total FIRRTL Compile Time: 770.6 ms
End of dependency graph
Circuit state created
[info] TaylorTest:
[info] TaylorWindow
[info] taylor.TaylorTest *** ABORTED ***
[info]   java.lang.StackOverflowError:
[info]   at firrtl_interpreter.LoFirrtlExpressionEvaluator.evaluate(LoFirrtlExpressionEvaluator.scala:264)
[info]   at firrtl_interpreter.LoFirrtlExpressionEvaluator.$anonfun$resolveDependency$1(LoFirrtlExpressionEvaluator.scala:453)
[info]   at firrtl_interpreter.Timer.apply(Timer.scala:40)
[info]   at firrtl_interpreter.LoFirrtlExpressionEvaluator.resolveDependency(LoFirrtlExpressionEvaluator.scala:445)
[info]   at firrtl_interpreter.LoFirrtlExpressionEvaluator.getValue(LoFirrtlExpressionEvaluator.scala:81)
[info]   at firrtl_interpreter.LoFirrtlExpressionEvaluator.evaluate(LoFirrtlExpressionEvaluator.scala:304)
[info]   at firrtl_interpreter.LoFirrtlExpressionEvaluator.$anonfun$resolveDependency$1(LoFirrtlExpressionEvaluator.scala:453)
[info]   at firrtl_interpreter.Timer.apply(Timer.scala:40)
[info]   at firrtl_interpreter.LoFirrtlExpressionEvaluator.resolveDependency(LoFirrtlExpressionEvaluator.scala:445)
[info]   at firrtl_interpreter.LoFirrtlExpressionEvaluator.getValue(LoFirrtlExpressionEvaluator.scala:81)
[info]   ...

Это выглядит подозрительно как еще одна проблема с ПЗУ:

https://github.com/freechipsproject/chisel3/issues/642

, но попытка ответа Чика здесь:

export SBT_OPTS="-Xmx2G -XX:+UseConcMarkSweepGC -XX:+CMSClassUnloadingEnabled -XX:MaxPermSize=2G -Xss2M  -Duser.timezone=GMT"

, похоже, не решает проблему (и один из параметров, MaxPermSize игнорируется)

Это допустимая ошибка долота с ПЗУ или что-то еще здесь происходит?

Фактический модуль с ПЗУ:

package taylor

import chisel3._
import chisel3.util._
import chisel3.experimental.FixedPoint
import dsptools.numbers._
import scala.io.Source


class TaylorWindow(len: Int, window: Seq[FixedPoint]) extends Module {
    val io = IO(new Bundle {
        val d_valid_in = Input(Bool())
        val sample = Input(DspComplex(FixedPoint(16.W, 8.BP), FixedPoint(16.W, 8.BP)))
        val windowed_sample = Output(DspComplex(FixedPoint(32.W, 8.BP), FixedPoint(32.W, 8.BP)))
        val d_valid_out = Output(Bool())
    })
     val win_coeff = VecInit(window.map(x=>DspComplex.wire(x, FixedPoint(0, 16.W, 8.BP))).toSeq) // ROM storing our coefficients.       

    io.d_valid_out := io.d_valid_in
    val counter = RegInit(UInt(10.W), 0.U)

    // Implicit reset
    io.windowed_sample:= io.sample * win_coeff(counter)
    when(io.d_valid_in) {
        counter := counter + 1.U
    }
}

object TaylorDriver extends App {                                                                                                       
    val filename = "src/test/test_data/taylor_coeffs"                                                                                   
    val coeff_file = Source.fromFile(filename).getLines                                                                                 
    val double_coeffs = coeff_file.map(x => x.toDouble)                                                                                 
    val fp_coeffs = double_coeffs.map(x => FixedPoint.fromDouble(x, 16.W, 8.BP))                                                        
    val fp_seq = fp_coeffs.toSeq                                                                                                        
    chisel3.Driver.execute(args, () => new TaylorWindow(1024, fp_seq))                                                                  
} 

Код тестера:

package taylor

import chisel3._
import chisel3.util._
import chisel3.experimental.FixedPoint
import dsptools.numbers.implicits._
import scala.io.Source


import chisel3.iotesters
import chisel3.iotesters.{ChiselFlatSpec, Driver, PeekPokeTester}

class TaylorWindowUnitTest(dut: TaylorWindow) extends PeekPokeTester(dut) {

    val filename = "src/test/test_data/taylor_coeffs"
    val coeff_file = Source.fromFile(filename).getLines
    val double_coeffs = coeff_file.map(x => x.toDouble)
    val fp_coeffs = double_coeffs.map(x => FixedPoint.fromDouble(x, 16.W, 8.BP))
    val fp_seq = fp_coeffs.toSeq

  poke(dut.io.d_valid_in, Bool(false))
  expect(dut.io.d_valid_out, Bool(false))
}

class TaylorTest extends ChiselFlatSpec {
    behavior of "TaylorWindow"

    backends foreach {backend =>
        it should s"test the basic Taylow Window" in {
            Driver(() => new TaylorWindow(1024, getSeq()), backend)(c => new TaylorWindowUnitTest(c)) should be (true)
        }
    }

  def getSeq() : Seq[FixedPoint] = {
    val filename = "src/test/test_data/taylor_coeffs"
    val coeff_file = Source.fromFile(filename).getLines
    val double_coeffs = coeff_file.map(x => x.toDouble)
    val fp_coeffs = double_coeffs.map(x => FixedPoint.fromDouble(x, 16.W, 8.BP))
    fp_coeffs.toSeq
    }
}

1 Ответ

0 голосов
/ 12 декабря 2018

Это похоже на сбой в интерпретаторе firrtl (одном из симуляторов долот на основе Scala), который может иметь проблемы с рядом крупных конструкций firrtl.Если у вас установлен verilator, можете попробовать изменить

backends foreach {backend =>

на

Seq("verilator") foreach {backend =>

и посмотреть, что произойдет.Еще одна идея, которую стоит попробовать, - это Treadle, которая является новой версией интерпретатора и еще не полностью выпущена, но доступна в версиях моментальных снимков экосистемы долот.Это должно быть в состоянии справиться и с этим.

...