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 16
16
#include < util/std_expr.h>
17
17
18
18
#include " aval_bval_encoding.h"
19
+ #include " convert_literals.h"
19
20
#include " verilog_bits.h"
20
21
#include " verilog_expr.h"
21
22
@@ -322,12 +323,14 @@ exprt verilog_lowering(exprt expr)
322
323
323
324
if (expr.id () == ID_constant)
324
325
{
326
+ auto &constant_expr = to_constant_expr (expr);
327
+
325
328
if (
326
329
expr.type ().id () == ID_verilog_unsignedbv ||
327
330
expr.type ().id () == ID_verilog_signedbv)
328
331
{
329
332
// encode into aval/bval
330
- return lower_to_aval_bval (to_constant_expr (expr) );
333
+ return lower_to_aval_bval (constant_expr );
331
334
}
332
335
else if (
333
336
expr.type ().id () == ID_verilog_real ||
@@ -338,6 +341,12 @@ exprt verilog_lowering(exprt expr)
338
341
// no need to change value
339
342
expr.type () = verilog_lowering (expr.type ());
340
343
}
344
+ else if (expr.type ().id () == ID_string)
345
+ {
346
+ auto result = convert_string_literal (constant_expr.get_value ());
347
+ result.add_source_location () = expr.source_location ();
348
+ expr = std::move (result);
349
+ }
341
350
342
351
return expr;
343
352
}
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
/* ******************************************************************\
@@ -1379,8 +1382,8 @@ exprt verilog_typecheck_exprt::convert_constant(constant_exprt expr)
1379
1382
if (expr.type ().id ()==ID_string)
1380
1383
{
1381
1384
auto result = convert_string_literal (expr.get_value ());
1382
- result. add_source_location () = source_location;
1383
- return std::move (result) ;
1385
+ // only add a typecast for now
1386
+ return typecast_exprt{ std::move (expr), std::move ( result. type ())} ;
1384
1387
}
1385
1388
else if (expr.type ().id ()==ID_unsignedbv ||
1386
1389
expr.type ().id ()==ID_signedbv ||
You can’t perform that action at this time.
0 commit comments