简体   繁体   English

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

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

Here is some genereated Verilog from the PassTrough module found in: https://github.com/freechipsproject/chisel-bootcamp/blob/master/2.1_first_module.ipynb 这是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

Are there any resources about understanding what is in the comments. 是否有任何资源可以理解注释中的内容。 I can see that they related to the code location in the original scala file but would like to know more details. 我可以看到它们与原始scala文件中的代码位置有关,但想了解更多详细信息。

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

A more detailed explanation of this line would be useful. 此行的更详细的解释将很有用。

These are source locators and will show up in generated FIRRTL or Verilog. 这些是源定位器,将显示在生成的FIRRTL或Verilog中。 These tell you what line in a source file (Chisel or FIRRTL) was used to generate a specific line in the downstream FIRRTL or Verilog. 这些告诉您源文件(Chisel或FIRRTL)中的哪一行用于在下游FIRRTL或Verilog中生成特定行。

The format is generally: @[<file> <line>:<column> ...] 格式通常为: @[<file> <line>:<column> ...]

More than one source locator may be present. 可能存在多个源定位器。

Example

Consider the following example pulled from the BoringUtilsSpec . 考虑以下示例,该示例是从BoringUtilsSpec The line numbers (which do not start at zero as this was extracted from a larger file) are shown along with the column numbers. 显示行号(因为它是从较大的文件中提取的,所以不从零开始)与列号一起显示。 You can see how things line up between them. 您可以看到它们之间的排列方式。 For example, the declaration of notA happens on line 27 column 20 and the assignment notA := ~a happens on line 30, column 10. You see 27:20 and 30:10 show up in the FIRRTL. 例如, notA的声明发生在第27行的第20列,赋值notA := ~a发生在第30行的第10列。您会在FIRRTL中看到27:2030:10 In the Verilog, these get merged somewhat and you wind up with source locators indicating both 27:20 and 30: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 |
// -------------------------------------------+----+

This produces the following FIRRTL: 这将产生以下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

And the following Verilog: 以及以下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

Caveats 注意事项

Generator Bootcamp 发电机训练营

If you are running this in the Chisel Bootcamp Jupyter Notebook or through an sbt console/REPL, the source locators may not make as much sense as there really isn't a file here with lines. 如果您是在Chisel Bootcamp Jupyter Notebook中或通过sbt控制台/ REPL运行此命令,则源定位器可能没有什么意义,因为此处实际上没有带行的文件。

Difference with Annotation Annotation区别

These source locators are not Annotation s, in case anyone has come across that name. 这些源定位符不是 Annotation ,以防有人碰到该名称。

Annotation s are metadata associated with circuit components. Annotation s是与电路组件关联的元数据。 Source locators (which map to Info in the FIRRTL IR) are associated with specific statements in some source file. 源定位器(其映射到Info在FIRRTL IR)与在一些源文件特定语句相关联。 Under the hood they're just strings that get generated and then copied around. 在幕后,它们只是生成并随后复制的字符串。 There is no guarantee that source locators will be preserved---they may be changed or deleted arbitrarily. 无法保证将保留源定位器-可以任意更改或删除它们。 Conversely, Annotation s are preserved and renamed across transformations and have strong guarantees on how they behave. 相反, Annotation在转换中被保留和重命名,并对其行为有很强的保证。

Consequently, do not rely on source locators for anything other than an aid if you need to debug the Chisel or FIRRTL compiler stages. 因此,如果您需要调试Chisel或FIRRTL编译器阶段,请不要依赖源定位器来提供帮助。

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

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