File tree Expand file tree Collapse file tree 11 files changed +113
-3
lines changed
regression/verilog/data-types Expand file tree Collapse file tree 11 files changed +113
-3
lines changed Original file line number Diff line number Diff line change 1+ CORE
2+ chandle1.sv
3+ --bound 0
4+ ^EXIT=0$
5+ ^SIGNAL=0$
6+ --
Original file line number Diff line number Diff line change 1+ module main ;
2+
3+ // IEEE 1800-2017 6.14
4+ chandle some_handle = null ;
5+
6+ assert final (! some_handle);
7+ assert final ($typename (some_handle) == " chandle" );
8+
9+ endmodule
Original file line number Diff line number Diff line change @@ -97,7 +97,8 @@ IREP_ID_ONE(verilog_property_declaration)
9797IREP_ID_ONE (verilog_value_range )
9898IREP_ID_ONE (verilog_streaming_concatenation_left_to_right )
9999IREP_ID_ONE (verilog_streaming_concatenation_right_to_left )
100- IREP_ID_ONE (chandle )
100+ IREP_ID_ONE (verilog_chandle )
101+ IREP_ID_ONE (verilog_null )
101102IREP_ID_ONE (event )
102103IREP_ID_ONE (reg )
103104IREP_ID_ONE (macromodule )
Original file line number Diff line number Diff line change @@ -25,6 +25,7 @@ SRC = aval_bval_encoding.cpp \
2525 verilog_typecheck_base.cpp \
2626 verilog_typecheck_expr.cpp \
2727 verilog_typecheck_sva.cpp \
28+ verilog_types.cpp \
2829 verilog_y.tab.cpp \
2930 vtype.cpp
3031
Original file line number Diff line number Diff line change @@ -1878,6 +1878,8 @@ std::string expr2verilogt::convert(const typet &type)
18781878
18791879 return dest;
18801880 }
1881+ else if (type.id () == ID_verilog_chandle)
1882+ return " chandle" ;
18811883 else if (type.id () == ID_verilog_genvar)
18821884 return " genvar" ;
18831885 else if (type.id ()==ID_integer)
@@ -1888,6 +1890,8 @@ std::string expr2verilogt::convert(const typet &type)
18881890 return " real" ;
18891891 else if (type.id ()==ID_verilog_realtime)
18901892 return " realtime" ;
1893+ else if (type.id () == ID_verilog_null)
1894+ return " null" ;
18911895 else if (type.id () == ID_verilog_enum)
18921896 {
18931897 return " enum" ;
Original file line number Diff line number Diff line change @@ -1453,7 +1453,7 @@ data_type:
14531453 | TOK_STRING
14541454 { init ($$, ID_string); }
14551455 | TOK_CHANDLE
1456- { init ($$, ID_chandle ); }
1456+ { init ($$, ID_verilog_chandle ); }
14571457 | TOK_VIRTUAL interface_opt interface_identifier
14581458 { init ($$, " virtual_interface" ); }
14591459 | /* scope_opt*/ type_identifier packed_dimension_brace
@@ -3955,7 +3955,7 @@ primary: primary_literal
39553955 | cast
39563956 | assignment_pattern_expression
39573957 | streaming_concatenation
3958- | TOK_NULL { init ($$, ID_NULL ); }
3958+ | TOK_NULL { init ($$, ID_verilog_null ); }
39593959 | TOK_THIS { init ($$, ID_this); }
39603960 ;
39613961
Original file line number Diff line number Diff line change @@ -333,6 +333,10 @@ typet verilog_typecheck_exprt::elaborate_type(const typet &src)
333333 {
334334 return src;
335335 }
336+ else if (src.id () == ID_verilog_chandle)
337+ {
338+ return src;
339+ }
336340 else
337341 {
338342 throw errort ().with_location (source_location)
Original file line number Diff line number Diff line change 1515#include " aval_bval_encoding.h"
1616#include " verilog_bits.h"
1717#include " verilog_expr.h"
18+ #include " verilog_types.h"
1819
1920exprt extract (
2021 const exprt &src,
@@ -157,9 +158,24 @@ exprt verilog_lowering(exprt expr)
157158 {
158159 return lower_to_aval_bval (to_constant_expr (expr));
159160 }
161+ else if (expr.type ().id () == ID_verilog_chandle)
162+ {
163+ // this is 'null'
164+ return to_verilog_chandle_type (expr.type ()).null_expr ();
165+ }
160166
161167 return expr;
162168 }
169+ else if (expr.id () == ID_symbol)
170+ {
171+ auto &symbol_expr = to_symbol_expr (expr);
172+ if (expr.type ().id () == ID_verilog_chandle)
173+ {
174+ return symbol_exprt{symbol_expr.get_identifier (), unsignedbv_typet{32 }};
175+ }
176+ else
177+ return expr;
178+ }
163179 else if (expr.id () == ID_concatenation)
164180 {
165181 if (
Original file line number Diff line number Diff line change @@ -1004,6 +1004,11 @@ exprt verilog_typecheck_exprt::convert_nullary_expr(nullary_exprt expr)
10041004 throw errort ().with_location (expr.source_location ())
10051005 << " 'this' outside of method" ;
10061006 }
1007+ else if (expr.id () == ID_verilog_null)
1008+ {
1009+ return constant_exprt{ID_NULL, typet{ID_verilog_null}}.with_source_location (
1010+ expr.source_location ());
1011+ }
10071012 else
10081013 {
10091014 throw errort ().with_location (expr.source_location ())
@@ -2027,6 +2032,17 @@ void verilog_typecheck_exprt::implicit_typecast(
20272032 return ;
20282033 }
20292034 }
2035+ else if (src_type.id () == ID_verilog_null)
2036+ {
2037+ if (dest_type.id () == ID_verilog_chandle)
2038+ {
2039+ if (expr.id () == ID_constant)
2040+ {
2041+ expr.type () = dest_type;
2042+ return ;
2043+ }
2044+ }
2045+ }
20302046
20312047 throw errort ().with_location (expr.source_location ())
20322048 << " failed to convert `" << to_string (src_type) << " ' to `"
Original file line number Diff line number Diff line change 1+ /* ******************************************************************\
2+
3+ Module: Verilog Types
4+
5+ Author: Daniel Kroening, [email protected] 6+
7+ \*******************************************************************/
8+
9+ #include " verilog_types.h"
10+
11+ #include < util/std_expr.h>
12+
13+ constant_exprt verilog_chandle_typet::null_expr () const
14+ {
15+ return encoding ().all_zeros_expr ();
16+ }
You can’t perform that action at this time.
0 commit comments