aboutsummaryrefslogtreecommitdiffstats
path: root/src/synth/synth-decls.adb
diff options
context:
space:
mode:
authorTristan Gingold <tgingold@free.fr>2019-06-12 07:58:06 +0200
committerTristan Gingold <tgingold@free.fr>2019-06-12 08:04:46 +0200
commit5525cc11604efbcb33c513f6092c8e2e029dfbe3 (patch)
tree389eac077822afe626d18a97a9f4f50e23dc992d /src/synth/synth-decls.adb
parentf33a5d30e472927125c3129832556563692bfac8 (diff)
downloadghdl-5525cc11604efbcb33c513f6092c8e2e029dfbe3.tar.gz
ghdl-5525cc11604efbcb33c513f6092c8e2e029dfbe3.tar.bz2
ghdl-5525cc11604efbcb33c513f6092c8e2e029dfbe3.zip
synth: handle enumerated types.
Diffstat (limited to 'src/synth/synth-decls.adb')
-rw-r--r--src/synth/synth-decls.adb42
1 files changed, 38 insertions, 4 deletions
diff --git a/src/synth/synth-decls.adb b/src/synth/synth-decls.adb
index 2c464758e..8352707e2 100644
--- a/src/synth/synth-decls.adb
+++ b/src/synth/synth-decls.adb
@@ -19,6 +19,7 @@
-- MA 02110-1301, USA.
with Types; use Types;
+with Mutils; use Mutils;
with Netlists; use Netlists;
with Netlists.Builders; use Netlists.Builders;
with Vhdl.Errors; use Vhdl.Errors;
@@ -40,6 +41,7 @@ package body Synth.Decls is
begin
case Val.Kind is
when Value_Wire =>
+ -- FIXME: get the width directly from the wire ?
W := Get_Width (Syn_Inst, Get_Type (Decl));
Name := New_Sname (Syn_Inst.Name, Get_Identifier (Decl));
if Init /= null then
@@ -55,7 +57,38 @@ package body Synth.Decls is
end case;
end Create_Var_Wire;
- procedure Synth_Declaration (Syn_Inst : Synth_Instance_Acc; Decl : Iir) is
+ procedure Synth_Type_Definition (Syn_Inst : Synth_Instance_Acc; Def : Node)
+ is
+ pragma Unreferenced (Syn_Inst);
+ begin
+ case Get_Kind (Def) is
+ when Iir_Kind_Enumeration_Type_Definition =>
+ declare
+ Info : constant Sim_Info_Acc := Get_Info (Def);
+ Enum_List : constant Node_Flist :=
+ Get_Enumeration_Literal_List (Def);
+ begin
+ if Is_Bit_Type (Def) then
+ Info.Width := 1;
+ else
+ Info.Width :=
+ Uns32 (Clog2 (Uns64 (Get_Nbr_Elements (Enum_List))));
+ end if;
+ end;
+ when Iir_Kind_Integer_Type_Definition
+ | Iir_Kind_Floating_Type_Definition
+ | Iir_Kind_Physical_Type_Definition
+ | Iir_Kind_Array_Type_Definition =>
+ null;
+ when Iir_Kind_Access_Type_Definition
+ | Iir_Kind_File_Type_Definition =>
+ null;
+ when others =>
+ Error_Kind ("synth_type_definition", Def);
+ end case;
+ end Synth_Type_Definition;
+
+ procedure Synth_Declaration (Syn_Inst : Synth_Instance_Acc; Decl : Node) is
begin
case Get_Kind (Decl) is
when Iir_Kind_Variable_Declaration =>
@@ -104,9 +137,10 @@ package body Synth.Decls is
when Iir_Kind_Attribute_Specification =>
null;
when Iir_Kind_Type_Declaration
- | Iir_Kind_Anonymous_Type_Declaration
- | Iir_Kind_Subtype_Declaration =>
- -- TODO, in particular enumerated types.
+ | Iir_Kind_Anonymous_Type_Declaration =>
+ Synth_Type_Definition (Syn_Inst, Get_Type_Definition (Decl));
+ when Iir_Kind_Subtype_Declaration =>
+ -- TODO
null;
when Iir_Kind_Component_Declaration =>
null;