我正在尝试使用DSPComplex和FixedPoint类型构建基于ROM的Window函数,但是似乎一直遇到以下错误:
chisel3.core.Binding$ExpectedHardwareException: vec element 'dsptools.numbers.DspComplex@32' must be hardware, not a bare Chisel type
我尝试这样做的源代码如下所示:
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(24.W, 8.BP), FixedPoint(24.W, 8.BP)))
val d_valid_out = Output(Bool())
})
val win_coeff = Vec(window.map(x=>DspComplex(x, FixedPoint(0, 16.W, 8.BP))).toSeq) // ROM storing our coefficients.
io.d_valid_out := io.d_valid_in
val counter = Reg(UInt(10.W))
// Implicit reset
io.windowed_sample:= io.sample * win_coeff(counter)
when(io.d_valid_in) {
counter := counter + 1.U
}
}
println(getVerilog(new TaylorWindow(1024, fp_seq)))
我实际上是通过以下步骤从文件中读取系数的(这个特定的窗口具有我在其他地方用Python执行的复杂的生成函数)
val filename = "../generated/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
这是否意味着DSPComplex类型无法转换为Verilog?
注释掉win_coeff行似乎使整个事情产生了(但显然不执行我想要的操作)
最佳答案
我认为您应该尝试使用
val win_coeff = VecInit(window.map(x=>DspComplex.wire(x, FixedPoint.fromDouble(0.0, 16.W, 8.BP))).toSeq) // ROM storing our coefficients.
它将创建您想要的硬件值。 Vec只是创建指定类型的Vec
关于signal-processing - 在Chisel中构建DspComplex ROM,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/53656686/