improved portability of logic conversion

- indirect converted reg continuous assignments through wires
- fix typeof for implicitly typed ports
- fix typeof for sized implicitly typed params
This commit is contained in:
Zachary Snow
2021-01-25 19:23:54 -05:00
parent 5f0dc6be0c
commit b22cd210a4
9 changed files with 51 additions and 19 deletions
+2 -1
View File
@@ -1,9 +1,10 @@
module Example(inp, out);
parameter ENABLED = 1;
localparam [0:0] DEFAULT = 1'b0;
input logic inp;
output logic out;
if (ENABLED)
always_comb out = inp;
else
assign out = '0;
assign out = DEFAULT;
endmodule
+2 -1
View File
@@ -1,11 +1,12 @@
module Example(inp, out);
parameter ENABLED = 1;
localparam [0:0] DEFAULT = 1'b0;
input wire inp;
output reg out;
generate
if (ENABLED)
always @* out = inp;
else
initial out = 0;
initial out = DEFAULT;
endgenerate
endmodule
+4
View File
@@ -77,12 +77,16 @@ module top;
localparam X = 5'b10110;
localparam Y = X + 6'b00001;
localparam [7:0] Z = 234;
initial begin
type(X) tX = X;
type(Y) tY = Y;
type(Z) tZ = Z;
$display("%b %d %d %d", X, X, $left(X), $right(X));
$display("%b %d %d %d", Y, Y, $left(Y), $right(Y));
$display("%b %d %d %d", Z, Z, $left(Z), $right(Z));
$display("%b %d %d %d", tX, tX, $left(tX), $right(tX));
$display("%b %d %d %d", tY, tY, $left(tY), $right(tY));
$display("%b %d %d %d", tZ, tZ, $left(tZ), $right(tZ));
end
endmodule
+5
View File
@@ -94,14 +94,19 @@ module top;
localparam X = 5'b10110;
localparam Y = X + 6'b00001;
localparam [7:0] Z = 234;
initial begin : block5
reg [4:0] tX;
reg [5:0] tY;
reg [7:0] tZ;
tX = X;
tY = Y;
tZ = Z;
$display("%b %d %d %d", X, X, 4, 0);
$display("%b %d %d %d", Y, Y, 5, 0);
$display("%b %d %d %d", Z, Z, 7, 0);
$display("%b %d %d %d", tX, tX, 4, 0);
$display("%b %d %d %d", tY, tY, 5, 0);
$display("%b %d %d %d", tZ, tZ, 7, 0);
end
endmodule
+7
View File
@@ -0,0 +1,7 @@
module Example(inp, out);
input inp;
output out;
type(inp) data;
assign data = ~inp;
assign out = data;
endmodule
+7
View File
@@ -0,0 +1,7 @@
module Example(inp, out);
input inp;
output out;
wire data;
assign data = ~inp;
assign out = data;
endmodule
+8
View File
@@ -0,0 +1,8 @@
module top;
reg inp;
wire out;
Example e(inp, out);
initial begin
$monitor("%0d %b %b", $time, inp, out);
end
endmodule