Skip to content

Commit e58075d

Browse files
committed
SystemVerilog: conversion functions
This adds the conversion functions from 1800-2017 20.5.
1 parent f457b5e commit e58075d

17 files changed

+349
-63
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
KNOWNBUG
2+
cast_from_real1.sv
3+
--bound 0
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
--
7+
^warning: ignoring
8+
--
9+
Verilog casts from real to integer round, and do not truncate.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
module main;
2+
3+
always assert (integer'(1.0) == 1);
4+
always assert (integer'(-1.0) == -1);
5+
6+
// Casting rounds away from zero (1800-2017 6.12.2)
7+
always assert (integer'(1.9) == 2);
8+
9+
endmodule
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
CORE
2+
bitstoreal1.sv
3+
--module main --bound 0
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
--
7+
^warning: ignoring
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
module main;
2+
3+
// Not a conversion, just reinterpretation
4+
always assert ($bitstoreal(0)==0.0);
5+
always assert ($bitstoreal('h3ff00000_00000000)==1);
6+
// always assert ($bitstoreal('hc0000000_00000000)==-2.0);
7+
8+
endmodule
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
CORE
2+
bitstoshortreal1.sv
3+
--module main --bound 0
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
--
7+
^warning: ignoring
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
module main;
2+
3+
// Not a conversion, just reinterpretation
4+
always assert ($bitstoshortreal(0)==0.0);
5+
always assert ($bitstoshortreal('h3f80_0000)==1.0);
6+
// always assert ($bitstoshortreal('hc000_0000)==-2.0);
7+
8+
endmodule
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
CORE
2+
itor1.sv
3+
--module main --bound 0
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
--
7+
^warning: ignoring
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
module main;
2+
3+
always assert ($itor(1)==1.0);
4+
always assert ($itor(-1)==-1.0);
5+
6+
endmodule
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
CORE
2+
realtobits1.sv
3+
--module main --bound 0
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
--
7+
^warning: ignoring
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
module main;
2+
3+
// Not a conversion, just reinterpretation
4+
always assert ($realtobits(0.0)==0);
5+
always assert ($realtobits(1.0)=='h3ff00000_00000000);
6+
always assert ($realtobits(-2.0)=='hc0000000_00000000);
7+
8+
endmodule

0 commit comments

Comments
 (0)