diff options
author | umarcor <unai.martinezcorral@ehu.eus> | 2021-06-19 00:18:04 +0200 |
---|---|---|
committer | Patrick Lehmann <Patrick.Lehmann@plc2.de> | 2021-06-19 15:25:07 +0200 |
commit | 5764b4a86c3389ed0388c9382a112640a04dc0b0 (patch) | |
tree | dcc2db03a994871fcab4f6028dcd70d47e00a49c | |
parent | a81f2f777e30dadc775380a362c7fe38280a5234 (diff) | |
download | ghdl-5764b4a86c3389ed0388c9382a112640a04dc0b0.tar.gz ghdl-5764b4a86c3389ed0388c9382a112640a04dc0b0.tar.bz2 ghdl-5764b4a86c3389ed0388c9382a112640a04dc0b0.zip |
pyGHDL: handle c_double
-rw-r--r-- | pyGHDL/dom/Literal.py | 2 | ||||
-rw-r--r-- | pyGHDL/libghdl/_decorator.py | 7 | ||||
-rw-r--r-- | testsuite/pyunit/SimpleEntity.vhdl | 2 |
3 files changed, 7 insertions, 4 deletions
diff --git a/pyGHDL/dom/Literal.py b/pyGHDL/dom/Literal.py index 8b32d7163..7c722583b 100644 --- a/pyGHDL/dom/Literal.py +++ b/pyGHDL/dom/Literal.py @@ -57,7 +57,7 @@ class FloatingPointLiteral(VHDLModel_FloatingPointLiteral): @classmethod def parse(cls, node): value = nodes.Get_Fp_Value(node) - return cls(float(value)) + return cls(value) @export diff --git a/pyGHDL/libghdl/_decorator.py b/pyGHDL/libghdl/_decorator.py index b3d17fd01..ffec1f497 100644 --- a/pyGHDL/libghdl/_decorator.py +++ b/pyGHDL/libghdl/_decorator.py @@ -31,7 +31,7 @@ # SPDX-License-Identifier: GPL-2.0-or-later # ============================================================================ # -from ctypes import c_int32, c_uint32, c_char_p, c_bool, Structure, c_char +from ctypes import c_int32, c_uint32, c_char_p, c_bool, c_double, Structure, c_char from functools import wraps from typing import Callable, List, Dict, Any, TypeVar @@ -82,6 +82,8 @@ def BindToLibGHDL(subprogramName): return None elif typ is int: return c_int32 + elif type is float: + return c_double elif typ is bool: return c_bool elif typ is bytes: @@ -92,8 +94,9 @@ def BindToLibGHDL(subprogramName): # Humm, recurse ? if typ.__bound__ is int: return c_int32 - if typ.__bound__ in (c_uint32, c_int32): + if typ.__bound__ in (c_uint32, c_int32, c_double): return typ.__bound__ + raise TypeError("Unsupported typevar bound to {!s}".format(typ.__bound__)) elif issubclass(typ, Structure): return typ raise TypeError diff --git a/testsuite/pyunit/SimpleEntity.vhdl b/testsuite/pyunit/SimpleEntity.vhdl index 12068c06d..2a076d124 100644 --- a/testsuite/pyunit/SimpleEntity.vhdl +++ b/testsuite/pyunit/SimpleEntity.vhdl @@ -4,7 +4,7 @@ use ieee.numeric_std.all; entity entity_1 is generic ( - FREQ : real := 100.0; + FREQ : real := -25.7; BITS : positive := 8 ); port ( |