verilog backend: preserve signed on wire and port declarations#5880
Open
alaindargelas wants to merge 1 commit into
Open
verilog backend: preserve signed on wire and port declarations#5880alaindargelas wants to merge 1 commit into
signed on wire and port declarations#5880alaindargelas wants to merge 1 commit into
Conversation
`dump_wire` had no code path that emits the `signed` keyword for
wires/ports whose RTLIL `is_signed` flag is set. Reading
module top(input signed [9:0] in, output signed [31:0] o);
assign o = in;
endmodule
and writing it back via `write_verilog` produced
input [9:0] in;
output [31:0] o;
losing the declared signedness even though `wire->is_signed` was
tracked correctly in RTLIL throughout the round trip. The IEEE
1364-2001 grammar (Annex A.2.1.2 / A.2.1.3) allows `signed` after the
direction / net-type keyword, which is the dialect `write_verilog`
targets by default — so the fix is to emit ` signed` between the
direction/net-type and the range when `wire->is_signed`.
Closes the half of chipsalliance/synlig#2425 that lives in Yosys: the
SystemVerilog frontend correctly produces a signed wire for `output int`,
but the Verilog backend dropped it on write.
Adds `tests/various/write_verilog_signed_port.ys`, which round-trips a
module with `signed` inputs, outputs, and an internal wire and greps
for the keyword on each declaration — fails without the fix, passes
with it.
Collaborator
|
@Goubermouche does #5771 cover this too? |
Contributor
|
@widlarizer Seems like it, the provided test cases passes under #5771 too. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
dump_wirehad no code path that emits thesignedkeyword for wires/ports whose RTLILis_signedflag is set. Readingmodule top(input signed [9:0] in, output signed [31:0] o);
assign o = in;
endmodule
and writing it back via
write_verilogproducedinput [9:0] in;
output [31:0] o;
losing the declared signedness even though
wire->is_signedwas tracked correctly in RTLIL throughout the round trip. The IEEE 1364-2001 grammar (Annex A.2.1.2 / A.2.1.3) allowssignedafter the direction / net-type keyword, which is the dialectwrite_verilogtargets by default — so the fix is to emitsignedbetween the direction/net-type and the range whenwire->is_signed.Closes the half of chipsalliance/synlig#2425 that lives in Yosys: the SystemVerilog frontend correctly produces a signed wire for
output int, but the Verilog backend dropped it on write.Adds
tests/various/write_verilog_signed_port.ys, which round-trips a module withsignedinputs, outputs, and an internal wire and greps for the keyword on each declaration — fails without the fix, passes with it.If your work is part of a larger effort, please discuss your general plans on Discourse first to align your vision with maintainers.
What are the reasons/motivation for this change?
Explain how this is achieved.
Make sure your change comes with tests. If not possible, share how a reviewer might evaluate it.
These template prompts can be deleted when you're done responding to them.