Skip to content

Verilog: aval/bval lowering of 4-valued logic #561

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
Jun 19, 2024
Merged

Verilog: aval/bval lowering of 4-valued logic #561

merged 1 commit into from
Jun 19, 2024

Conversation

kroening
Copy link
Member

This introduces the standard aval/bval lowering of Verilog's 4-valued logic into bit vectors.

@kroening kroening marked this pull request as ready for review June 19, 2024 20:35
@@ -1,20 +1,20 @@
module main(input clk, x, y);

reg [1:0] cnt1;
reg z;
reg result;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am assuming this was just drive-by cleanup?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, z could be read as high-impedance state.

Comment on lines 12 to 15
#include <util/expr.h>

class bv_typet;
class constant_exprt;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit-picking: I'd expect util/bitvector_types.h and util/std_expr.h to be included here for bv_typet and constant_exprt are returned by value. Or pick the other extreme and also forward-declare class exprt; and class typet;.

return result;
}

bv_typet lower_to_aval_bval(const typet &src)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be a bitvector_typet instead of just typet? This will then also avoid the to_bitvector_type a few lines further down.

src, from_integer(width, integer_typet()), bv_typet{width}};
}

exprt adjust_size(const exprt &src, std::size_t dest_width)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could use static

return src;
}

exprt combine_aval_bval(const exprt &aval, const exprt &bval, const typet &dest)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could use static

This introduces the standard aval/bval lowering of Verilog's 4-valued logic
into bit vectors.
@kroening kroening merged commit c9fe05c into main Jun 19, 2024
6 checks passed
@kroening kroening deleted the aval_bval branch June 19, 2024 21:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants