mirror of
https://github.com/YosysHQ/yosys
synced 2025-05-10 01:05:49 +00:00
Merge ef9772bd8d
into a0e94e506d
This commit is contained in:
commit
b058049610
6 changed files with 84 additions and 10 deletions
|
@ -4,6 +4,11 @@ List of major changes and improvements between releases
|
||||||
|
|
||||||
Yosys 0.53 .. Yosys 0.54-dev
|
Yosys 0.53 .. Yosys 0.54-dev
|
||||||
--------------------------
|
--------------------------
|
||||||
|
* Verilog
|
||||||
|
- Fixed an issue that prevented using `{<expr>}` or `$unsigned(<expr>)` for
|
||||||
|
certain signed expressions in port connections
|
||||||
|
- Fixed an issue that prevented writing to a memory word via a concatenation
|
||||||
|
in an output port connection
|
||||||
|
|
||||||
Yosys 0.52 .. Yosys 0.53
|
Yosys 0.52 .. Yosys 0.53
|
||||||
--------------------------
|
--------------------------
|
||||||
|
|
|
@ -2124,11 +2124,9 @@ RTLIL::SigSpec AstNode::genRTLIL(int width_hint, bool sign_hint)
|
||||||
if (sig.is_wire()) {
|
if (sig.is_wire()) {
|
||||||
// if the resulting SigSpec is a wire, its
|
// if the resulting SigSpec is a wire, its
|
||||||
// signedness should match that of the AstNode
|
// signedness should match that of the AstNode
|
||||||
if (arg->type == AST_IDENTIFIER && arg->id2ast && arg->id2ast->is_signed && !arg->is_signed)
|
// unless this instantiation depends on module
|
||||||
// fully-sliced signed wire will be resolved
|
// information that isn't available yet
|
||||||
// once the module becomes available
|
if (!attributes.count(ID::reprocess_after))
|
||||||
log_assert(attributes.count(ID::reprocess_after));
|
|
||||||
else
|
|
||||||
log_assert(arg->is_signed == sig.as_wire()->is_signed);
|
log_assert(arg->is_signed == sig.as_wire()->is_signed);
|
||||||
} else if (arg->is_signed) {
|
} else if (arg->is_signed) {
|
||||||
// non-trivial signed nodes are indirected through
|
// non-trivial signed nodes are indirected through
|
||||||
|
|
|
@ -1260,6 +1260,8 @@ bool AstNode::simplify(bool const_fold, int stage, int width_hint, bool sign_hin
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type == AST_CELL) {
|
if (type == AST_CELL) {
|
||||||
|
// when a module lookup is suggested, any port connection that is not a
|
||||||
|
// plain identifier will be indirected through a new wire
|
||||||
bool lookup_suggested = false;
|
bool lookup_suggested = false;
|
||||||
|
|
||||||
for (AstNode *child : children) {
|
for (AstNode *child : children) {
|
||||||
|
@ -1282,7 +1284,7 @@ bool AstNode::simplify(bool const_fold, int stage, int width_hint, bool sign_hin
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (elem->type == AST_MEMORY)
|
if (elem->type == AST_MEMORY)
|
||||||
// need to determine is the is a read or wire
|
// need to determine is the is a read or write
|
||||||
lookup_suggested = true;
|
lookup_suggested = true;
|
||||||
else if (elem->type == AST_WIRE && elem->is_signed && !value->children.empty())
|
else if (elem->type == AST_WIRE && elem->is_signed && !value->children.empty())
|
||||||
// this may be a fully sliced signed wire which needs
|
// this may be a fully sliced signed wire which needs
|
||||||
|
@ -1292,6 +1294,15 @@ bool AstNode::simplify(bool const_fold, int stage, int width_hint, bool sign_hin
|
||||||
else if (contains_unbased_unsized(value))
|
else if (contains_unbased_unsized(value))
|
||||||
// unbased unsized literals extend to width of the context
|
// unbased unsized literals extend to width of the context
|
||||||
lookup_suggested = true;
|
lookup_suggested = true;
|
||||||
|
else if (value->type == AST_TO_UNSIGNED)
|
||||||
|
// inner expression may be signed by default
|
||||||
|
lookup_suggested = true;
|
||||||
|
else if (value->type == AST_CONCAT) {
|
||||||
|
// concat of a single expression is equivalent to $unsigned;
|
||||||
|
// concats could also contain one or references to memories,
|
||||||
|
// which may ambiguously be reads or writes
|
||||||
|
lookup_suggested = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,9 +5,17 @@ module producer(
|
||||||
endmodule
|
endmodule
|
||||||
|
|
||||||
module top(
|
module top(
|
||||||
output logic [3:0] out
|
output logic [3:0] out0, out1, out2, out3
|
||||||
);
|
);
|
||||||
logic [3:0] v[0:0];
|
logic [3:0] v[1:0];
|
||||||
producer p(v[0]);
|
logic [1:0] u[1:0];
|
||||||
assign out = v[0];
|
logic [1:0] t[1:0];
|
||||||
|
producer p0(v[0]);
|
||||||
|
producer p1({v[1]});
|
||||||
|
producer p2({u[1], u[0]});
|
||||||
|
producer p3({{t[1]}, {t[0]}});
|
||||||
|
assign out0 = v[0];
|
||||||
|
assign out1 = v[1];
|
||||||
|
assign out2 = {u[1], u[0]};
|
||||||
|
assign out3 = {t[1], t[0]};
|
||||||
endmodule
|
endmodule
|
||||||
|
|
45
tests/verilog/signed_concat.v
Normal file
45
tests/verilog/signed_concat.v
Normal file
|
@ -0,0 +1,45 @@
|
||||||
|
`define OUTPUTS(mode) \
|
||||||
|
o``mode``0, \
|
||||||
|
o``mode``1, \
|
||||||
|
o``mode``2, \
|
||||||
|
o``mode``3, \
|
||||||
|
o``mode``4
|
||||||
|
|
||||||
|
module gate(
|
||||||
|
input [1:0] iu,
|
||||||
|
input signed [1:0] is,
|
||||||
|
output [2:0] `OUTPUTS(u),
|
||||||
|
output signed [2:0] `OUTPUTS(s)
|
||||||
|
);
|
||||||
|
`define INSTANCES(mode) \
|
||||||
|
mod m``mode``0({i``mode}, {o``mode``0}); \
|
||||||
|
mod m``mode``1($unsigned(i``mode), o``mode``1); \
|
||||||
|
mod m``mode``2({i``mode[1:0]}, o``mode``2); \
|
||||||
|
mod m``mode``3({$signed(i``mode)}, o``mode``3); \
|
||||||
|
mod m``mode``4($unsigned({i``mode}), o``mode``4);
|
||||||
|
`INSTANCES(u)
|
||||||
|
`INSTANCES(s)
|
||||||
|
`undef INSTANCES
|
||||||
|
endmodule
|
||||||
|
|
||||||
|
module gold(
|
||||||
|
input [1:0] iu, is,
|
||||||
|
output [2:0] `OUTPUTS(u), `OUTPUTS(s)
|
||||||
|
);
|
||||||
|
`define INSTANCES(mode) \
|
||||||
|
assign o``mode``0 = i``mode; \
|
||||||
|
assign o``mode``1 = i``mode; \
|
||||||
|
assign o``mode``2 = i``mode; \
|
||||||
|
assign o``mode``3 = i``mode; \
|
||||||
|
assign o``mode``4 = i``mode;
|
||||||
|
`INSTANCES(u)
|
||||||
|
`INSTANCES(s)
|
||||||
|
`undef INSTANCES
|
||||||
|
endmodule
|
||||||
|
|
||||||
|
module mod(
|
||||||
|
input [2:0] inp,
|
||||||
|
output [2:0] out
|
||||||
|
);
|
||||||
|
assign out = inp;
|
||||||
|
endmodule
|
7
tests/verilog/signed_concat.ys
Normal file
7
tests/verilog/signed_concat.ys
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
read_verilog signed_concat.v
|
||||||
|
hierarchy
|
||||||
|
proc
|
||||||
|
flatten gate
|
||||||
|
equiv_make gold gate equiv
|
||||||
|
equiv_simple
|
||||||
|
equiv_status -assert
|
Loading…
Add table
Add a link
Reference in a new issue