Skip to content

Verilog: one bit signed/unsigned types #715

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions regression/verilog/data-types/signed1.desc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
CORE
signed1.sv
--bound 0
^EXIT=0$
^SIGNAL=0$
--
13 changes: 13 additions & 0 deletions regression/verilog/data-types/signed1.sv
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module main;

wire signed one_bit_signed = -1;

assert final (one_bit_signed == -1);
assert final ($bits(one_bit_signed) == 1);

wire unsigned one_bit_unsigned = 1;

assert final (one_bit_unsigned == 1);
assert final ($bits(one_bit_unsigned) == 1);

endmodule
10 changes: 10 additions & 0 deletions src/verilog/verilog_elaborate_type.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,16 @@ typet verilog_typecheck_exprt::elaborate_type(const typet &src)
// it's just a bit
return bool_typet().with_source_location(source_location);
}
else if(src.id() == ID_signed)
{
// one bit, signed
return signedbv_typet{1}.with_source_location(source_location);
}
else if(src.id() == ID_unsigned)
{
// one bit, unsigned
return unsignedbv_typet{1}.with_source_location(source_location);
}
else if(src.id() == ID_verilog_byte)
{
return signedbv_typet{8}.with_source_location(source_location);
Expand Down