简体   繁体   English

有没有办法使用chisel从verilog文本内容生成黑盒? (根据scala中的文本内容定义val)

[英]Is there any way to use chisel to generate blackbox from verilog text content? (define val based on text content in scala)

I'm working with a team that use verilog as well.我正在与一个使用 verilog 的团队合作。 I feel it is way faster to use chisel power to manage the interconnections between modules than bare verilog.我觉得使用 chisel power 来管理模块之间的互连比裸 verilog 要快得多。 I can see from the chisel tutorial that blackbox wrappers are written manually.The io signals are defined by hand.从chisel教程中可以看到blackbox wrappers是手工编写的。io信号是手工定义的。

Is it possible to extract the io info from verilog and define chisel blackbox io automatically?是否可以从verilog中提取io信息并自动定义chisel blackbox io? (aka, generate a blackbox from verilog instead of defining a blackbox class by some human being by reading the verilog. ) (又名,从 verilog 生成黑盒,而不是由某些人通过阅读 verilog 来定义黑盒类。)

for example:例如:

val bbox = blackbox("someModule.v")

and then, the bbox will be an functioning blackbox with all the ios and name defined.然后,bbox 将是一个功能齐全的黑盒,其中定义了所有 ios 和名称。

Since the io signal is val s in scala, I wonder if there is a meta way towards this goal.由于 io 信号在 scala 中是val s,我想知道是否有实现这个目标的元方式。

Yes there is!就在这里! Check out HasBlackBoxInline :查看HasBlackBoxInline

https://www.chisel-lang.org/chisel3/blackboxes.html#blackboxes-with-in-line-verilog https://www.chisel-lang.org/chisel3/blackboxes.html#blackboxes-with-in-line-verilog

class BlackBoxRealAdd extends BlackBox with HasBlackBoxInline {
  val io = IO(new Bundle() {
    val in1 = Input(UInt(64.W))
    val in2 = Input(UInt(64.W))
    val out = Output(UInt(64.W))
  })
  setInline("BlackBoxRealAdd.v",
    s"""
      |module BlackBoxRealAdd(
      |    input  [15:0] in1,
      |    input  [15:0] in2,
      |    output [15:0] out
      |);
      |always @* begin
      |  out <= $realtobits($bitstoreal(in1) + $bitstoreal(in2));
      |end
      |endmodule
    """.stripMargin)
}

By default this BlackBox will be emitted to the output directory with its given name.默认情况下,此 BlackBox 将以其给定的名称发送到输出目录。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM