hardware - For 循环未在凿子中展开

标签 hardware chisel

我试图理解我们如何从凿子中的“for”循环生成verilog代码。 通常,verilog 代码用于展开主体的次数与循环进度一样多,但在 chisel 中,它只展开一次。

val io = new Bundle {

    val a = UInt(INPUT, 2)

    val output = UInt(OUTPUT, 2)
  }

    io.output := UInt(0)

    for(j <- 0 to 4){

      io.output := io.a
    }

上述程序对应的verilog代码是:

module LutSimpleALU(

    input [1:0] io_a,
    output[1:0] io_output
);

   assign io_output = io_a;

endmodule

如果有人能告诉我 for 循环是如何工作的,那将会非常有帮助。

最佳答案

您的 for 循环为每次迭代执行相同的操作。您没有在任何地方使用“j”迭代器变量,因此它扩展为:

io.output := io.a
io.output := io.a
io.output := io.a 
io.output := io.a 

这里的语义是最后一个编写者获胜,因此“io.output = io.a”的最后一个语句将是最终值。事实上,前三个语句没有任何意义,因此它们将从图中被删除。

关于hardware - For 循环未在凿子中展开,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26112803/

相关文章:

.net - DataGridView 性能 - 是否取决于视频卡?

linux - 为什么Linux不需要驱动程序

scala - 使用 MixedVec 在 chisel 中使用动态参数创建 IO 包

chisel - 如何使用 ChiselStage 将模块拆分为单独的文件?

chisel - 如何覆盖/扩展凿子信号命名

chisel - 我可以在 Chisel 开始设计硬件之前在软件中计算常量吗?

c - libPAPI : Maximum simultaneous events measure

serial-port - 是否有处理串行端口通信的设计模式?

hardware - 机器周期、总线周期和执行周期的区别

凿子3 : How to create a register without reset signal in RawModule?