-
Notifications
You must be signed in to change notification settings - Fork 177
Extmodule port name check fails with length-parameterized Vec ports #2437
Comments
Thanks for the bug report, @johnsbrew. I have some questions... I think the output Verilog is actually malformed though. The only way that would be valid is if Full definition of `johnsbrew.v`module ExampleBB
#(
parameter WIDTH = 5,
parameter LEN = 4
)
(
input [4:0] in,
output [4:0] out_0,
output [4:0] out_1,
output [4:0] out_2,
output [4:0] out_3
);
endmodule
module Example(
input clock,
input reset,
input [4:0] in,
output [4:0] out_a_0,
output [4:0] out_a_1,
output [4:0] out_b_0,
output [4:0] out_b_1,
output [4:0] out_b_2,
output [4:0] out_b_3
);
wire [4:0] inst_a_in; // @[main.scala 30:22]
wire [4:0] inst_a_out_0; // @[main.scala 30:22]
wire [4:0] inst_a_out_1; // @[main.scala 30:22]
wire [4:0] inst_b_in; // @[main.scala 34:22]
wire [4:0] inst_b_out_0; // @[main.scala 34:22]
wire [4:0] inst_b_out_1; // @[main.scala 34:22]
wire [4:0] inst_b_out_2; // @[main.scala 34:22]
wire [4:0] inst_b_out_3; // @[main.scala 34:22]
ExampleBB #(.WIDTH(5), .LEN(2)) inst_a ( // @[main.scala 30:22]
.in(inst_a_in),
.out_0(inst_a_out_0),
.out_1(inst_a_out_1)
);
ExampleBB #(.WIDTH(5), .LEN(4)) inst_b ( // @[main.scala 34:22]
.in(inst_b_in),
.out_0(inst_b_out_0),
.out_1(inst_b_out_1),
.out_2(inst_b_out_2),
.out_3(inst_b_out_3)
);
assign out_a_0 = inst_a_out_0; // @[main.scala 32:9]
assign out_a_1 = inst_a_out_1; // @[main.scala 32:9]
assign out_b_0 = inst_b_out_0; // @[main.scala 36:9]
assign out_b_1 = inst_b_out_1; // @[main.scala 36:9]
assign out_b_2 = inst_b_out_2; // @[main.scala 36:9]
assign out_b_3 = inst_b_out_3; // @[main.scala 36:9]
assign inst_a_in = in; // @[main.scala 31:16]
assign inst_b_in = in; // @[main.scala 35:16]
endmodule
The check is extremely conservative. It's trying to assert that if a user defines a blackbox, that all the blackboxes that the user said are the same are actually the same. This check hinges on one lemma: Verilog does not have optional ports, but may have parametric port widths. One of the following checks is then applied:
This is erroring out, because the Chisel code said, "Hey, I have two instances of It seems like removing this check is allowing circumvention of the guarantee that everything in the circuit is connected to, including extmodules. This seems unsafe. If these are actually different Verilog modules, then you can set the FIRRTL |
Thanks for your quick answer @seldridge, I drafted this report a few weeks ago, convinced that this issue could be solved very simply, however it seems I overlooked it. Thanks to your answer I've come back to my actual problem which is the conversion of Do we have any chisel-based solution for such case? Any thoughts about this underlying issue? Regarding the relevance of the check itself, I do understand your point of view, which provides some kind of safety in most cases, but I am really not a big fan of failing while being able to generate meaningful verilog.
|
Checklist
What is the current behavior?
https://scastie.scala-lang.org/chXB5p5iTd29RZQwJPZV8A
Given a parameterized blackbox, whose parameter
LEN
is used as portout
Vec
length:Instantiating this blackbox twice in the same design will lead to fatal FIRRTL error.
FIRRTL raises error on
What is the expected behavior?
obtained with a simple comment at
firrtl/src/main/scala/firrtl/passes/CheckHighForm.scala
Line 145 in 4347f57
Steps to Reproduce
https://scastie.scala-lang.org/chXB5p5iTd29RZQwJPZV8A
Your environment
How to fix discussion
Preferred solution: purely remove this check
Alternative solution: add explicit support for flattened vecs
The text was updated successfully, but these errors were encountered: