Skip to content

Commit 1e06e97

Browse files
authored
Merge pull request #1138 from diffblue/cast_from_real2
Verilog: casts from real to int
2 parents b97a3e7 + b2993cf commit 1e06e97

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
KNOWNBUG
1+
CORE
22
cast_from_real2.sv
33

44
^EXIT=0$
55
^SIGNAL=0$
66
--
77
^warning: ignoring
88
--
9-
The implicit cast is currently not allowed.

src/verilog/verilog_typecheck_expr.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2123,6 +2123,14 @@ void verilog_typecheck_exprt::implicit_typecast(
21232123
expr = typecast_exprt{expr, dest_type};
21242124
return;
21252125
}
2126+
else if(
2127+
dest_type.id() == ID_bool || dest_type.id() == ID_signedbv ||
2128+
dest_type.id() == ID_unsignedbv)
2129+
{
2130+
// Cast from float to int -- the rounding mode is added during lowering.
2131+
expr = typecast_exprt{expr, dest_type};
2132+
return;
2133+
}
21262134
}
21272135
else if(src_type.id() == ID_verilog_null)
21282136
{

0 commit comments

Comments
 (0)