3
0
Fork 0
mirror of https://github.com/YosysHQ/yosys synced 2025-04-23 00:55:32 +00:00

sv: extended support for integer types

- Standard data declarations can now use any integer type
- Parameters and localparams can now use any integer type
- Function returns types can now use any integer type
- Fix `parameter logic`, `localparam reg`, etc. to be 1 bit (previously 32 bits)
- Added longint type (64 bits)
- Unified parser source for integer type widths
This commit is contained in:
Zachary Snow 2021-02-28 15:49:16 -05:00
parent d882b6fe3c
commit 0f5b646ab8
6 changed files with 148 additions and 39 deletions

View file

@ -0,0 +1,47 @@
`define TEST(typ, width, is_signed) \
if (1) begin \
typ x = -1; \
localparam typ y = -1; \
logic [127:0] a = x; \
logic [127:0] b = y; \
if ($bits(x) != width) \
$error(`"typ doesn't have expected size width`"); \
if ($bits(x) != $bits(y)) \
$error(`"localparam typ doesn't match size of typ`"); \
function automatic typ f; \
input integer x; \
f = x; \
endfunction \
logic [127:0] c = f(-1); \
always @* begin \
assert (x == y); \
assert (a == b); \
assert (a == c); \
assert ((a == -1) == is_signed); \
end \
end
`define TEST_INTEGER_ATOM(typ, width) \
`TEST(typ, width, 1) \
`TEST(typ signed, width, 1) \
`TEST(typ unsigned, width, 0)
`define TEST_INTEGER_VECTOR(typ) \
`TEST(typ, 1, 0) \
`TEST(typ signed, 1, 1) \
`TEST(typ unsigned, 1, 0) \
`TEST(typ [1:0], 2, 0) \
`TEST(typ signed [1:0], 2, 1) \
`TEST(typ unsigned [1:0], 2, 0)
module top;
`TEST_INTEGER_ATOM(integer, 32)
`TEST_INTEGER_ATOM(int, 32)
`TEST_INTEGER_ATOM(shortint, 16)
`TEST_INTEGER_ATOM(longint, 64)
`TEST_INTEGER_ATOM(byte, 8)
`TEST_INTEGER_VECTOR(reg)
`TEST_INTEGER_VECTOR(logic)
`TEST_INTEGER_VECTOR(bit)
endmodule

View file

@ -0,0 +1,7 @@
read_verilog -sv int_types.sv
hierarchy
proc
flatten
opt -full
select -module top
sat -verify -seq 1 -tempinduct -prove-asserts -show-all

View file

@ -0,0 +1,19 @@
module gate(out);
parameter integer a = -1;
parameter int b = -2;
parameter shortint c = -3;
parameter longint d = -4;
parameter byte e = -5;
output wire [1023:0] out;
assign out = {a, b, c, d, e};
endmodule
module gold(out);
integer a = -1;
int b = -2;
shortint c = -3;
longint d = -4;
byte e = -5;
output wire [1023:0] out;
assign out = {a, b, c, d, e};
endmodule

View file

@ -0,0 +1,5 @@
read_verilog -sv param_int_types.sv
proc
equiv_make gold gate equiv
equiv_simple
equiv_status -assert