chisel - 使用 Cat 运算符维护 FIRRTL 上的连接顺序
问题描述
我想就以下问题询问任何想法:我想将一个名为dut的块的输入端口连接到一个字节接口,该块的宽度为 787:0 位。我正在做以下事情:
val io = this.IO(new VerilatorHarnessIO(input_byte_count, output_byte_count*2))
val dut = Module(new DUT(dut_conf))
// inputs
val input_bytes = Cat(io.input_bytes)
val input_width = input_byte_count * 8
dut.io.inputs := input_bytes(input_width-1, input_width - dut_conf.inputBits)
我希望保留连接的顺序,即:
字节_0[7:0] ->输入[7:0]
字节_1[7:0] ->输入[15:8]
但我得到的是:
字节_0[7:0]->输入[787:780]
字节_1[7:0] ->输入[779:772]
如果端口匹配,调试会容易得多。
有没有办法以正确的顺序建立这种联系?谢谢
解决方案
在你应该做你想做的事之前使用该reverse
方法。Cat
考虑以下凿子:
import chisel3._
import chisel3.stage.{ChiselStage, ChiselGeneratorAnnotation}
import chisel3.util.Cat
class Foo extends RawModule {
val in = IO(Input(Vec(4, UInt(8.W))))
val out = IO(Output(UInt(32.W)))
out := Cat(in.reverse)
}
(new ChiselStage)
.execute(Array.empty, Seq(ChiselGeneratorAnnotation(() => new Foo)))
这将生成以下 Verilog,其中的字节按您要查找的顺序排列:
module Foo(
input [7:0] in_0,
input [7:0] in_1,
input [7:0] in_2,
input [7:0] in_3,
output [31:0] out
);
wire [15:0] _T; // @[Cat.scala 29:58]
wire [15:0] _T_1; // @[Cat.scala 29:58]
assign _T = {in_1,in_0}; // @[Cat.scala 29:58]
assign _T_1 = {in_3,in_2}; // @[Cat.scala 29:58]
assign out = {_T_1,_T}; // @[<pastie> 25:7]
endmodule
推荐阅读
- python - Python Marshmallow 和 PyCharm 类型提示
- python - 获取下一个交易日功能太慢
- json - 如何为已经外部化值的下拉列表填充数组 [Angular]
- android - 如何在 android (kotlin) 中使用双向数据绑定
- amazon-web-services - 是否可以使用 JNDI 从 Tomcat 访问 AWS Secret Manager?
- php - 如何使用 PHP 上传多个文本文件并将路径保存到 MySQL 数据库?
- python - 如何让我的导航栏在 Django 中工作?
- selenium - 如何获取属于特定 TestNG 组的所有测试方法的列表?
- javascript - 在 wordpress add_action 中,javascript 警报仅在 init 中有效,为什么?
- swift - 无法在 UIViewController 上保存 UIImage