繁体   English   中英

如何从凿子解读生成的Verilog中的注释?

[英]How to decipher comments in generated Verilog from chisel?

这是PassTrough模块中的一些通用Verilog,可在以下位置找到: https : //github.com/freechipsproject/chisel-bootcamp/blob/master/2.1_first_module.ipynb

module PassTrough( // @[:@3.2]
  input        clock, // @[:@4.4]
  input        reset, // @[:@5.4]
  input  [9:0] io_in, // @[:@6.4]
  output [9:0] io_out // @[:@6.4]
);
  assign io_out = io_in; // @[buffer.scala 10:10:@8.4]
endmodule

是否有任何资源可以理解注释中的内容。 我可以看到它们与原始scala文件中的代码位置有关,但想了解更多详细信息。

// @[buffer.scala 10:10:@8.4]

此行的更详细的解释将很有用。

这些是源定位器,将显示在生成的FIRRTL或Verilog中。 这些告诉您源文件(Chisel或FIRRTL)中的哪一行用于在下游FIRRTL或Verilog中生成特定行。

格式通常为: @[<file> <line>:<column> ...]

可能存在多个源定位器。

考虑以下示例,该示例是从BoringUtilsSpec 显示行号(因为它是从较大的文件中提取的,所以不从零开始)与列号一起显示。 您可以看到它们之间的排列方式。 例如, notA的声明发生在第27行的第20列,赋值notA := ~a发生在第30行的第10列。您会在FIRRTL中看到27:2030:10 在Verilog中,这些内容有些合并,并且您会看到指示27:2030:10源定位符:

// -------------------------------------------+----+
// File: BoringUtilsSpec.scala                |    |
// -------------------------------------------+----+
// Column Number                              |    |
// -------------------------------------------+----+
//           1         2         3         4  |    |
// 01234567890123456789012345678901234567890  |    |
// -------------------------------------------+----|
     class BoringInverter extends Module { // | 24 | Line Number
       val io = IO(new Bundle{})           // |  5 |
       val a = Wire(UInt(1.W))             // |  6 |
       val notA = Wire(UInt(1.W))          // |  7 |
       val b = Wire(UInt(1.W))             // |  8 |
       a := 0.U                            // |  9 |
       notA := ~a                          // | 30 |
       b := a                              // |  1 |
       chisel3.assert(b === 1.U)           // |  2 |
       BoringUtils.addSource(notA, "x")    // |  3 |
       BoringUtils.addSink(b, "x")         // |  4 |
     }                                     // |  5 |
// -------------------------------------------+----+

这将产生以下FIRRTL:

module BoringUtilsSpecBoringInverter : 
  input clock : Clock
  input reset : UInt<1>
  output io : {}

  wire a : UInt<1> @[BoringUtilsSpec.scala 26:17]
  wire notA : UInt<1> @[BoringUtilsSpec.scala 27:20]
  wire b : UInt<1> @[BoringUtilsSpec.scala 28:17]
  a <= UInt<1>("h00") @[BoringUtilsSpec.scala 29:7]
  node _T = not(a) @[BoringUtilsSpec.scala 30:13]
  notA <= _T @[BoringUtilsSpec.scala 30:10]
  b <= a @[BoringUtilsSpec.scala 31:7]
  node _T_1 = eq(b, UInt<1>("h01")) @[BoringUtilsSpec.scala 32:22]
  node _T_2 = bits(reset, 0, 0) @[BoringUtilsSpec.scala 32:19]
  node _T_3 = or(_T_1, _T_2) @[BoringUtilsSpec.scala 32:19]
  node _T_4 = eq(_T_3, UInt<1>("h00")) @[BoringUtilsSpec.scala 32:19]
  // assert not shown

以及以下Verilog:

module BoringUtilsSpecBoringInverter(
  input   clock,
  input   reset
);
  wire  _T; // @[BoringUtilsSpec.scala 30:13]
  wire  notA; // @[BoringUtilsSpec.scala 27:20 BoringUtilsSpec.scala 30:10]
  wire  _T_3; // @[BoringUtilsSpec.scala 32:19]
  wire  _T_4; // @[BoringUtilsSpec.scala 32:19]
  assign _T = 1'h1; // @[BoringUtilsSpec.scala 30:13]
  assign notA = 1'h1; // @[BoringUtilsSpec.scala 27:20 BoringUtilsSpec.scala 30:10]
  assign _T_3 = _T | reset; // @[BoringUtilsSpec.scala 32:19]
  assign _T_4 = _T_3 == 1'h0; // @[BoringUtilsSpec.scala 32:19]
  // assert not shown
endmodule

注意事项

发电机训练营

如果您是在Chisel Bootcamp Jupyter Notebook中或通过sbt控制台/ REPL运行此命令,则源定位器可能没有什么意义,因为此处实际上没有带行的文件。

Annotation区别

这些源定位符不是 Annotation ,以防有人碰到该名称。

Annotation s是与电路组件关联的元数据。 源定位器(其映射到Info在FIRRTL IR)与在一些源文件特定语句相关联。 在幕后,它们只是生成并随后复制的字符串。 无法保证将保留源定位器-可以任意更改或删除它们。 相反, Annotation在转换中被保留和重命名,并对其行为有很强的保证。

因此,如果您需要调试Chisel或FIRRTL编译器阶段,请不要依赖源定位器来提供帮助。

暂无
暂无

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

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