netreal_t: Report as signed and scalar

reals are both signed and scalar. But the real_type_t currently reports as
neither.

This isn't much of a problem because most real signals are implemented
using netvector_t with the base type set to IVL_VT_REAL, for which the
signedness is correctly reported. Function return values and class
properties use the netreal_t as their data type, but most places that work
with reals check the base type and assume that the value is signed when the
base type is real.

The only place where this really makes a difference at the moment is the
Verilog-AMS function when being passed a function call as its argument. In
that case the `abs()` function will be optimized away and a negative value
will be passed through as negative.

But going forward netreal_t is also going to be used for the data type of
real type signals.

To fix the `abs()` issue and to be ready  to switch real signals over to
using netreal_t as their type implement the appropriate methods on
netreal_t.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
This commit is contained in:
Lars-Peter Clausen 2022-01-09 18:27:36 +01:00
parent 6f0d3ae332
commit 4d0f005a10
1 changed files with 2 additions and 0 deletions

View File

@ -28,6 +28,8 @@ class netreal_t : public ivl_type_s {
~netreal_t(); ~netreal_t();
ivl_variable_type_t base_type() const; ivl_variable_type_t base_type() const;
bool get_signed() const { return true; }
bool get_scalar() const { return true; }
std::ostream& debug_dump(std::ostream&) const; std::ostream& debug_dump(std::ostream&) const;