File tree Expand file tree Collapse file tree 4 files changed +76
-12
lines changed
regression/verilog/system-functions Expand file tree Collapse file tree 4 files changed +76
-12
lines changed Original file line number Diff line number Diff line change 1
1
CORE
2
2
typename1.sv
3
3
--module main --bound 0
4
- ^\[.*\] always \$typename\(main\.some_bit\) == 24'h626974 : PROVED up to bound 0$
5
- ^\[.*\] always \$typename\(main\.vector1\) == 72'h6269745B33313A305D : PROVED up to bound 0$
6
- ^\[.*\] always \$typename\(main\.vector2\) == 72'h6269745B303A33315D : PROVED up to bound 0$
7
- ^\[.*\] always \$typename\(main\.vector3\) == 128'h626974207369676E65645B33313A305D : PROVED up to bound 0$
8
- ^\[.*\] always \$typename\(real'\(1\)\) == 32'h7265616C : PROVED up to bound 0$
9
- ^\[.*\] always \$typename\(shortreal'\(1\)\) == 72'h73686F72747265616C : PROVED up to bound 0$
10
- ^\[.*\] always \$typename\(realtime'\(1\)\) == 64'h7265616C74696D65 : PROVED up to bound 0$
4
+ ^\[.*\] always \$typename\(main\.some_bit\) == "bit" : PROVED up to bound 0$
5
+ ^\[.*\] always \$typename\(main\.vector1\) == "bit\[31:0\]" : PROVED up to bound 0$
6
+ ^\[.*\] always \$typename\(main\.vector2\) == "bit\[0:31\]" : PROVED up to bound 0$
7
+ ^\[.*\] always \$typename\(main\.vector3\) == "bit signed\[31:0\]" : PROVED up to bound 0$
8
+ ^\[.*\] always \$typename\(real'\(1\)\) == "real" : PROVED up to bound 0$
9
+ ^\[.*\] always \$typename\(shortreal'\(1\)\) == "shortreal" : PROVED up to bound 0$
10
+ ^\[.*\] always \$typename\(realtime'\(1\)\) == "realtime" : PROVED up to bound 0$
11
11
^EXIT=0$
12
12
^SIGNAL=0$
13
13
--
Original file line number Diff line number Diff line change 24
24
25
25
#include < algorithm>
26
26
#include < cstdlib>
27
+ #include < iomanip>
27
28
#include < sstream>
28
29
29
30
/* ******************************************************************\
@@ -350,7 +351,10 @@ expr2verilogt::convert_function_call(const function_call_exprt &src)
350
351
else
351
352
dest+=" , " ;
352
353
353
- dest += convert_rec (op).s ;
354
+ if (op.id () == ID_type)
355
+ dest += convert (op.type ());
356
+ else
357
+ dest += convert_rec (op).s ;
354
358
}
355
359
356
360
dest+=" )" ;
@@ -1208,6 +1212,54 @@ expr2verilogt::resultt expr2verilogt::convert_constant(
1208
1212
ieee_float.from_expr (tmp);
1209
1213
return {precedence, ieee_float.to_ansi_c_string ()};
1210
1214
}
1215
+ else if (type.id () == ID_string)
1216
+ {
1217
+ dest = ' "' ;
1218
+
1219
+ for (auto &ch : id2string (src.get_value ()))
1220
+ {
1221
+ // Follows Table Table 5-1 in 1800-2017.
1222
+ switch (ch)
1223
+ {
1224
+ case ' \n ' :
1225
+ dest += " \\ n" ;
1226
+ break ;
1227
+ case ' \t ' :
1228
+ dest += " \\ t" ;
1229
+ break ;
1230
+ case ' \\ ' :
1231
+ dest += " \\\\ " ;
1232
+ break ;
1233
+ case ' "' :
1234
+ dest += " \\\" " ;
1235
+ break ;
1236
+ case ' \v ' :
1237
+ dest += " \\ v" ;
1238
+ break ;
1239
+ case ' \f ' :
1240
+ dest += " \\ f" ;
1241
+ break ;
1242
+ case ' \a ' :
1243
+ dest += " \\ a" ;
1244
+ break ;
1245
+ default :
1246
+ if (
1247
+ (unsigned (ch) >= ' ' && unsigned (ch) <= 126 ) ||
1248
+ (unsigned (ch) >= 128 && unsigned (ch) <= 254 ))
1249
+ {
1250
+ dest += ch;
1251
+ }
1252
+ else
1253
+ {
1254
+ std::ostringstream oss;
1255
+ oss << " \\ x" << std::setw (2 ) << std::setfill (' 0' ) << std::hex << ch;
1256
+ dest += oss.str ();
1257
+ }
1258
+ }
1259
+ }
1260
+
1261
+ dest += ' "' ;
1262
+ }
1211
1263
else
1212
1264
return convert_norep (src, precedence);
1213
1265
Original file line number Diff line number Diff line change 15
15
#include < util/ieee_float.h>
16
16
17
17
#include " aval_bval_encoding.h"
18
+ #include " convert_literals.h"
18
19
#include " verilog_bits.h"
19
20
#include " verilog_expr.h"
20
21
@@ -182,12 +183,14 @@ exprt verilog_lowering(exprt expr)
182
183
183
184
if (expr.id () == ID_constant)
184
185
{
186
+ auto &constant_expr = to_constant_expr (expr);
187
+
185
188
if (
186
189
expr.type ().id () == ID_verilog_unsignedbv ||
187
190
expr.type ().id () == ID_verilog_signedbv)
188
191
{
189
192
// encode into aval/bval
190
- return lower_to_aval_bval (to_constant_expr (expr) );
193
+ return lower_to_aval_bval (constant_expr );
191
194
}
192
195
else if (
193
196
expr.type ().id () == ID_verilog_real ||
@@ -198,6 +201,12 @@ exprt verilog_lowering(exprt expr)
198
201
// no need to change value
199
202
expr.type () = lower_verilog_real_types (expr.type ());
200
203
}
204
+ else if (expr.type ().id () == ID_string)
205
+ {
206
+ auto result = convert_string_literal (constant_expr.get_value ());
207
+ result.add_source_location () = expr.source_location ();
208
+ expr = std::move (result);
209
+ }
201
210
202
211
return expr;
203
212
}
Original file line number Diff line number Diff line change @@ -756,7 +756,10 @@ exprt verilog_typecheck_exprt::typename_string(const exprt &expr)
756
756
else
757
757
s = " ?" ;
758
758
759
- return convert_constant (constant_exprt{s, string_typet{}});
759
+ auto result = convert_string_literal (s);
760
+ result.add_source_location () = expr.source_location ();
761
+
762
+ return std::move (result);
760
763
}
761
764
762
765
/* ******************************************************************\
@@ -1301,8 +1304,8 @@ exprt verilog_typecheck_exprt::convert_constant(constant_exprt expr)
1301
1304
if (expr.type ().id ()==ID_string)
1302
1305
{
1303
1306
auto result = convert_string_literal (expr.get_value ());
1304
- result. add_source_location () = source_location;
1305
- return std::move (result) ;
1307
+ // only add a typecast for now
1308
+ return typecast_exprt{ std::move (expr), std::move ( result. type ())} ;
1306
1309
}
1307
1310
else if (expr.type ().id ()==ID_unsignedbv ||
1308
1311
expr.type ().id ()==ID_signedbv ||
You can’t perform that action at this time.
0 commit comments