-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Determine how to handle non-Verilog legal Extmodule DefName, i.e., Literal Identifiers #115
Comments
Related discussion: ucb-bar/chipyard#1542 After checking the behavior of the original FIRRTL tool, by using the Chisel bootcamp notebook, it appears that it adds an underscore to the end of any instance names which are a reserved word in Verilog. Test with this code: class Passthrough extends Module {
val io = IO(new Bundle {
val in = Input(UInt(4.W))
val out = Output(UInt(4.W))
})
io.out := io.in
}
class Passthrough2 extends Module {
val io = IO(new Bundle {
val in = Input(UInt(4.W))
val out = Output(UInt(4.W))
})
val module = Module(new Passthrough())
module.io.in := io.in
io.out := module.io.out
} Change the name module Passthrough(
input [3:0] io_in,
output [3:0] io_out
);
assign io_out = io_in; // @[cmd24.sc 6:12]
endmodule
module Passthrough2(
input clock,
input reset,
input [3:0] io_in,
output [3:0] io_out
);
wire [3:0] module__io_in; // @[cmd24.sc 14:24]
wire [3:0] module__io_out; // @[cmd24.sc 14:24]
Passthrough module_ ( // @[cmd24.sc 14:24]
.io_in(module__io_in),
.io_out(module__io_out)
);
assign io_out = module__io_out; // @[cmd24.sc 16:12]
assign module__io_in = io_in; // @[cmd24.sc 15:18]
endmodule I tested with a handful of random Verilog reserved words, namely If it's a non reserved word, there'll be no underscore added to the end. I believe that this exact behavior should be added to the spec, so that EDIT: Looks like firtool adds
Maybe it can go into the Instances section of the spec? |
Thanks for the detailed post. The issue you bring up is slightly different from the issue I was worried about here. I'll comment on the issue I was worried about and then address your points. Are you seeing any crashes in My IssueWhat I'm worried about is if a user says, "This external module has a Verilog-exact defname that isn't a legal Verilog name." I was concerned about this for literal identifiers (identifiers which start with a number and are not legal Verilog identifiers), but the problem is the same for Verilog keyword collisions. Consider:
The For the above code, the SFC (maintenance mode Scala-based FIRRTL Compiler) will produce illegal Verilog: module Foo(
output a
);
wire bar_a;
module bar (
.a(bar_a)
);
assign a = bar_a;
endmodule CIRCT/MFC (MLIR-based FIRRTL Compiler) will produce equivalent illegal Verilog and print an error during Verilog emission:
Your IssueThe issue you are bringing up is more about specifying the name mangling behavior of a FIRRTL compiler. The new FIRRTL ABI document talks about this a bit for certain things. The current language around modules is:
This pedantically means that any public module, e.g,. the main module, needs to have a legal Verilog name in order for it to be compiled. One place that this is not fully specified is for ports of public modules which are illegal Verilog names. @darthscsi: thoughts on what to do here? The issue that you bring up about an internal instance name is more in the realm of, "The compiler can do whatever it wants so long as the output is legal Verilog". I.e., I think the name mangling algorithm of internal things should be implementation defined. |
I see, thanks for clarifying the difference between the two issues.
Actually, I just checked the most recent release of Firtool and it looks like the issue I was seeing is present in firtool version 1.30, but was fixed by the most recent version, 1.45. Version 1.30 is what Chipyard is using, since it's the most recent version published to Anaconda. In Firtool v1.45, it no longer gives the error |
👍 Sounds good. We aren't coordinating any releases through Anaconda (and I wasn't even aware that CIRCT was getting released there 😅 ). @jackkoenig has been working on improving CIRCT ( |
Nice, that sounds useful. After I wrote the reply, I found out that the Anaconda package is from some folks from UC Berkeley, which seems to grab the Github release and publish it to the Anaconda repo: https://github.com/ucb-bar/firtool-feedstock |
A circuit that includes a Verilog-illegal defname in an extmodule should be handled or rejected. This depends on the interpretation of whether the
defname
is the "Verilog name" or if it is an identifier used to uniquely group multiple external modules together. Practically, it's the former.Consider:
For now, let's just reject this and require Verilog-legal names.
How should this work for literal identifiers? Is this any different?
The text was updated successfully, but these errors were encountered: