aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTristan Gingold <tgingold@free.fr>2019-11-28 05:56:40 +0100
committerTristan Gingold <tgingold@free.fr>2019-11-28 05:57:08 +0100
commit0b6a37376975313f34efd161e60f53ef7b5763c1 (patch)
tree7d708fb212182ef0bf43a46c17a4783b0b4b1ac1
parentf156922d3362d7076da6f42f13804d11cc1b069a (diff)
downloadghdl-0b6a37376975313f34efd161e60f53ef7b5763c1.tar.gz
ghdl-0b6a37376975313f34efd161e60f53ef7b5763c1.tar.bz2
ghdl-0b6a37376975313f34efd161e60f53ef7b5763c1.zip
netlists: remove port API (make it easier to interface).
-rw-r--r--src/synth/netlists-builders.adb106
-rw-r--r--src/synth/netlists-disp_vhdl.adb45
-rw-r--r--src/synth/netlists-dump.adb33
-rw-r--r--src/synth/netlists.adb81
-rw-r--r--src/synth/netlists.ads16
-rw-r--r--src/synth/synth-insts.adb14
6 files changed, 165 insertions, 130 deletions
diff --git a/src/synth/netlists-builders.adb b/src/synth/netlists-builders.adb
index 1e16a0e4b..48b08a2fd 100644
--- a/src/synth/netlists-builders.adb
+++ b/src/synth/netlists-builders.adb
@@ -26,15 +26,13 @@ package body Netlists.Builders is
function Create_Input (Id : String; W : Width := 0) return Port_Desc is
begin
return (Name => New_Sname_Artificial (Get_Identifier (Id), No_Sname),
- W => W,
- Dir => Port_In);
+ W => W);
end Create_Input;
function Create_Output (Id : String; W : Width := 0) return Port_Desc is
begin
return (Name => New_Sname_Artificial (Get_Identifier (Id), No_Sname),
- W => W,
- Dir => Port_Out);
+ W => W);
end Create_Output;
procedure Create_Dyadic_Module (Design : Module;
@@ -50,7 +48,7 @@ package body Netlists.Builders is
Inputs := (0 => Create_Input ("a"),
1 => Create_Input ("b"));
Outputs := (0 => Create_Output ("o"));
- Set_Port_Desc (Res, Inputs, Outputs);
+ Set_Ports_Desc (Res, Inputs, Outputs);
end Create_Dyadic_Module;
procedure Create_Monadic_Module (Design : Module;
@@ -65,7 +63,7 @@ package body Netlists.Builders is
Id, 1, 1, 0);
Inputs := (0 => Create_Input ("i"));
Outputs := (0 => Create_Output ("o"));
- Set_Port_Desc (Res, Inputs, Outputs);
+ Set_Ports_Desc (Res, Inputs, Outputs);
end Create_Monadic_Module;
procedure Create_Compare_Module (Design : Module;
@@ -81,7 +79,7 @@ package body Netlists.Builders is
Inputs := (0 => Create_Input ("a"),
1 => Create_Input ("b"));
Outputs := (0 => Create_Output ("o", 1));
- Set_Port_Desc (Res, Inputs, Outputs);
+ Set_Ports_Desc (Res, Inputs, Outputs);
end Create_Compare_Module;
procedure Create_Concat_Modules (Ctxt : Context_Acc)
@@ -101,29 +99,29 @@ package body Netlists.Builders is
New_Sname_Artificial (Get_Identifier ("concat2"), No_Sname),
Id_Concat2, 2, 1, 0);
Ctxt.M_Concat (Id_Concat2) := Res;
- Set_Port_Desc (Res, Inputs (0 .. 1), Outputs);
+ Set_Ports_Desc (Res, Inputs (0 .. 1), Outputs);
Res := New_User_Module
(Ctxt.Design,
New_Sname_Artificial (Get_Identifier ("concat3"), No_Sname),
Id_Concat3, 3, 1, 0);
Ctxt.M_Concat (Id_Concat3) := Res;
- Set_Port_Desc (Res, Inputs (0 .. 2), Outputs);
+ Set_Ports_Desc (Res, Inputs (0 .. 2), Outputs);
Res := New_User_Module
(Ctxt.Design,
New_Sname_Artificial (Get_Identifier ("concat4"), No_Sname),
Id_Concat4, 4, 1, 0);
Ctxt.M_Concat (Id_Concat4) := Res;
- Set_Port_Desc (Res, Inputs (0 .. 3), Outputs);
+ Set_Ports_Desc (Res, Inputs (0 .. 3), Outputs);
Res := New_User_Module
(Ctxt.Design,
New_Sname_Artificial (Get_Identifier ("concatn"), No_Sname),
Id_Concatn, 0, 1, 1);
Ctxt.M_Concatn := Res;
- Set_Port_Desc (Res, Inputs (1 .. 0), Outputs);
- Set_Param_Desc
+ Set_Ports_Desc (Res, Inputs (1 .. 0), Outputs);
+ Set_Params_Desc
(Res, (0 => (New_Sname_Artificial (Get_Identifier ("n"), No_Sname),
Typ => Param_Uns32)));
end Create_Concat_Modules;
@@ -139,8 +137,8 @@ package body Netlists.Builders is
Id_Const_UB32, 0, 1, 1);
Ctxt.M_Const_UB32 := Res;
Outputs := (0 => Create_Output ("o"));
- Set_Port_Desc (Res, Port_Desc_Array'(1 .. 0 => <>), Outputs);
- Set_Param_Desc
+ Set_Ports_Desc (Res, Port_Desc_Array'(1 .. 0 => <>), Outputs);
+ Set_Params_Desc
(Res, (0 => (New_Sname_Artificial (Get_Identifier ("val"), No_Sname),
Typ => Param_Uns32)));
@@ -150,8 +148,8 @@ package body Netlists.Builders is
Id_Const_SB32, 0, 1, 1);
Ctxt.M_Const_SB32 := Res;
Outputs := (0 => Create_Output ("o"));
- Set_Port_Desc (Res, Port_Desc_Array'(1 .. 0 => <>), Outputs);
- Set_Param_Desc
+ Set_Ports_Desc (Res, Port_Desc_Array'(1 .. 0 => <>), Outputs);
+ Set_Params_Desc
(Res, (0 => (New_Sname_Artificial (Get_Identifier ("val"), No_Sname),
Typ => Param_Uns32)));
@@ -160,8 +158,8 @@ package body Netlists.Builders is
New_Sname_Artificial (Get_Identifier ("const_UL32"), No_Sname),
Id_Const_UL32, 0, 1, 2);
Ctxt.M_Const_UL32 := Res;
- Set_Port_Desc (Res, Port_Desc_Array'(1 .. 0 => <>), Outputs);
- Set_Param_Desc
+ Set_Ports_Desc (Res, Port_Desc_Array'(1 .. 0 => <>), Outputs);
+ Set_Params_Desc
(Res, (0 => (New_Sname_Artificial (Get_Identifier ("val"), No_Sname),
Typ => Param_Uns32),
1 => (New_Sname_Artificial (Get_Identifier ("xz"), No_Sname),
@@ -173,7 +171,7 @@ package body Netlists.Builders is
Id_Const_Z, 0, 1, 0);
Ctxt.M_Const_Z := Res;
Outputs := (0 => Create_Output ("o"));
- Set_Port_Desc (Res, Port_Desc_Array'(1 .. 0 => <>), Outputs);
+ Set_Ports_Desc (Res, Port_Desc_Array'(1 .. 0 => <>), Outputs);
Res := New_User_Module
(Ctxt.Design,
@@ -181,7 +179,7 @@ package body Netlists.Builders is
Id_Const_X, 0, 1, 0);
Ctxt.M_Const_X := Res;
Outputs := (0 => Create_Output ("o"));
- Set_Port_Desc (Res, Port_Desc_Array'(1 .. 0 => <>), Outputs);
+ Set_Ports_Desc (Res, Port_Desc_Array'(1 .. 0 => <>), Outputs);
Res := New_User_Module
(Ctxt.Design,
@@ -189,7 +187,7 @@ package body Netlists.Builders is
Id_Const_Bit, 0, 1, 0);
Ctxt.M_Const_Bit := Res;
Outputs := (0 => Create_Output ("o"));
- Set_Port_Desc (Res, Port_Desc_Array'(1 .. 0 => <>), Outputs);
+ Set_Ports_Desc (Res, Port_Desc_Array'(1 .. 0 => <>), Outputs);
Res := New_User_Module
(Ctxt.Design,
@@ -197,7 +195,7 @@ package body Netlists.Builders is
Id_Const_Log, 0, 1, 0);
Ctxt.M_Const_Log := Res;
Outputs := (0 => Create_Output ("o"));
- Set_Port_Desc (Res, Port_Desc_Array'(1 .. 0 => <>), Outputs);
+ Set_Ports_Desc (Res, Port_Desc_Array'(1 .. 0 => <>), Outputs);
end Create_Const_Modules;
procedure Create_Extract_Module (Ctxt : Context_Acc)
@@ -213,8 +211,8 @@ package body Netlists.Builders is
Ctxt.M_Extract := Res;
Outputs := (0 => Create_Output ("o"));
Inputs := (0 => Create_Input ("i"));
- Set_Port_Desc (Res, Inputs, Outputs);
- Set_Param_Desc
+ Set_Ports_Desc (Res, Inputs, Outputs);
+ Set_Params_Desc
(Res, (0 => (New_Sname_Artificial (Get_Identifier ("offset"),
No_Sname),
Typ => Param_Uns32)));
@@ -234,8 +232,8 @@ package body Netlists.Builders is
Outputs := (0 => Create_Output ("o"));
Inputs := (0 => Create_Input ("v"),
1 => Create_Input ("i"));
- Set_Port_Desc (Res, Inputs, Outputs);
- Set_Param_Desc
+ Set_Ports_Desc (Res, Inputs, Outputs);
+ Set_Params_Desc
(Res, (0 => (New_Sname_Artificial (Get_Identifier ("offset"),
No_Sname),
Typ => Param_Uns32)));
@@ -257,8 +255,8 @@ package body Netlists.Builders is
1 => Create_Input ("d"),
2 => Create_Input ("i"),
3 => Create_Input ("en"));
- Set_Port_Desc (Res, Inputs (0 .. 2), Outputs);
- Set_Param_Desc
+ Set_Ports_Desc (Res, Inputs (0 .. 2), Outputs);
+ Set_Params_Desc
(Res, (0 => (New_Sname_Artificial (Get_Identifier ("offset"),
No_Sname),
Typ => Param_Uns32)));
@@ -268,8 +266,8 @@ package body Netlists.Builders is
New_Sname_Artificial (Get_Identifier ("dyn_insert_en"), No_Sname),
Id_Dyn_Insert_En, 4, 1, 1);
Ctxt.M_Dyn_Insert_En := Res;
- Set_Port_Desc (Res, Inputs (0 .. 3), Outputs);
- Set_Param_Desc
+ Set_Ports_Desc (Res, Inputs (0 .. 3), Outputs);
+ Set_Params_Desc
(Res, (0 => (New_Sname_Artificial (Get_Identifier ("offset"),
No_Sname),
Typ => Param_Uns32)));
@@ -288,8 +286,8 @@ package body Netlists.Builders is
Ctxt.M_Memidx := Res;
Outputs := (0 => Create_Output ("o"));
Inputs (0) := Create_Input ("i");
- Set_Port_Desc (Res, Inputs (0 .. 0), Outputs);
- Set_Param_Desc
+ Set_Ports_Desc (Res, Inputs (0 .. 0), Outputs);
+ Set_Params_Desc
(Res, (0 => (New_Sname_Artificial (Get_Identifier ("step"), No_Sname),
Typ => Param_Uns32),
1 => (New_Sname_Artificial (Get_Identifier ("max"), No_Sname),
@@ -310,7 +308,7 @@ package body Netlists.Builders is
Outputs := (0 => Create_Output ("o"));
Inputs := (0 => Create_Input ("i0"),
1 => Create_Input ("i1"));
- Set_Port_Desc (Res, Inputs, Outputs);
+ Set_Ports_Desc (Res, Inputs, Outputs);
end Create_Addidx_Module;
procedure Create_Memory_Modules (Ctxt : Context_Acc)
@@ -325,7 +323,7 @@ package body Netlists.Builders is
Id_Memory, 0, 1, 0);
Ctxt.M_Memory := Res;
Outputs (0 .. 0) := (0 => Create_Output ("ports"));
- Set_Port_Desc (Res, Port_Desc_Array'(1 .. 0 => <>), Outputs (0 .. 0));
+ Set_Ports_Desc (Res, Port_Desc_Array'(1 .. 0 => <>), Outputs (0 .. 0));
Res := New_User_Module
(Ctxt.Design,
@@ -334,7 +332,7 @@ package body Netlists.Builders is
Ctxt.M_Memory_Init := Res;
Outputs (0 .. 0) := (0 => Create_Output ("ports"));
Inputs (0 .. 0) := (0 => Create_Input ("init"));
- Set_Port_Desc (Res, Inputs (0 .. 0), Outputs (0 .. 0));
+ Set_Ports_Desc (Res, Inputs (0 .. 0), Outputs (0 .. 0));
Res := New_User_Module
(Ctxt.Design,
@@ -345,7 +343,7 @@ package body Netlists.Builders is
1 => Create_Input ("addr"));
Outputs (0 .. 1) := (0 => Create_Output ("nport"),
1 => Create_Output ("data"));
- Set_Port_Desc (Res, Inputs (0 .. 1), Outputs (0 .. 1));
+ Set_Ports_Desc (Res, Inputs (0 .. 1), Outputs (0 .. 1));
Res := New_User_Module
(Ctxt.Design,
@@ -357,7 +355,7 @@ package body Netlists.Builders is
2 => Create_Input ("clk"));
Outputs (0 .. 1) := (0 => Create_Output ("nport"),
1 => Create_Output ("data"));
- Set_Port_Desc (Res, Inputs (0 .. 2), Outputs (0 .. 1));
+ Set_Ports_Desc (Res, Inputs (0 .. 2), Outputs (0 .. 1));
Res := New_User_Module
(Ctxt.Design,
@@ -370,7 +368,7 @@ package body Netlists.Builders is
3 => Create_Input ("en"),
4 => Create_Input ("data"));
Outputs (0 .. 0) := (0 => Create_Output ("nport"));
- Set_Port_Desc (Res, Inputs (0 .. 4), Outputs (0 .. 0));
+ Set_Ports_Desc (Res, Inputs (0 .. 4), Outputs (0 .. 0));
end Create_Memory_Modules;
procedure Create_Edge_Module (Ctxt : Context_Acc;
@@ -385,7 +383,7 @@ package body Netlists.Builders is
(Ctxt.Design, New_Sname_Artificial (Name, No_Sname), Id_Edge, 1, 1, 0);
Inputs := (0 => Create_Input ("i", 1));
Outputs := (0 => Create_Output ("o", 1));
- Set_Port_Desc (Res, Inputs, Outputs);
+ Set_Ports_Desc (Res, Inputs, Outputs);
end Create_Edge_Module;
procedure Create_Mux_Modules (Ctxt : Context_Acc)
@@ -404,13 +402,13 @@ package body Netlists.Builders is
(Ctxt.Design,
New_Sname_Artificial (Get_Identifier ("mux2"), No_Sname),
Id_Mux2, 3, 1, 0);
- Set_Port_Desc (Ctxt.M_Mux2, Inputs (0 .. 2), Outputs);
+ Set_Ports_Desc (Ctxt.M_Mux2, Inputs (0 .. 2), Outputs);
Inputs (0).W := 2;
Ctxt.M_Mux4 := New_User_Module
(Ctxt.Design, New_Sname_Artificial (Get_Identifier ("mux4"), No_Sname),
Id_Mux4, 5, 1, 0);
- Set_Port_Desc (Ctxt.M_Mux4, Inputs (0 .. 4), Outputs);
+ Set_Ports_Desc (Ctxt.M_Mux4, Inputs (0 .. 4), Outputs);
end Create_Mux_Modules;
procedure Create_Objects_Module (Ctxt : Context_Acc)
@@ -425,12 +423,12 @@ package body Netlists.Builders is
Ctxt.M_Output := New_User_Module
(Ctxt.Design, New_Sname_Artificial (Name_Output, No_Sname),
Id_Output, 1, 1, 0);
- Set_Port_Desc (Ctxt.M_Output, Inputs, Outputs);
+ Set_Ports_Desc (Ctxt.M_Output, Inputs, Outputs);
Ctxt.M_Signal := New_User_Module
(Ctxt.Design, New_Sname_Artificial (Name_Signal, No_Sname),
Id_Signal, 1, 1, 0);
- Set_Port_Desc (Ctxt.M_Signal, Inputs, Outputs);
+ Set_Ports_Desc (Ctxt.M_Signal, Inputs, Outputs);
Inputs2 := (0 => Create_Input ("i"),
1 => Create_Input ("init"));
@@ -438,12 +436,12 @@ package body Netlists.Builders is
(Ctxt.Design,
New_Sname_Artificial (Get_Identifier ("isignal"), No_Sname),
Id_Isignal, 2, 1, 0);
- Set_Port_Desc (Ctxt.M_Isignal, Inputs2, Outputs);
+ Set_Ports_Desc (Ctxt.M_Isignal, Inputs2, Outputs);
Ctxt.M_Port := New_User_Module
(Ctxt.Design, New_Sname_Artificial (Name_Port, No_Sname),
Id_Port, 1, 1, 0);
- Set_Port_Desc (Ctxt.M_Port, Inputs, Outputs);
+ Set_Ports_Desc (Ctxt.M_Port, Inputs, Outputs);
end Create_Objects_Module;
procedure Create_Dff_Modules (Ctxt : Context_Acc)
@@ -454,14 +452,14 @@ package body Netlists.Builders is
(Ctxt.Design, New_Sname_Artificial (Get_Identifier ("dff"), No_Sname),
Id_Dff, 2, 1, 0);
Outputs := (0 => Create_Output ("q"));
- Set_Port_Desc (Ctxt.M_Dff, (0 => Create_Input ("clk", 1),
+ Set_Ports_Desc (Ctxt.M_Dff, (0 => Create_Input ("clk", 1),
1 => Create_Input ("d")),
Outputs);
Ctxt.M_Idff := New_User_Module
(Ctxt.Design, New_Sname_Artificial (Get_Identifier ("idff"), No_Sname),
Id_Idff, 3, 1, 0);
- Set_Port_Desc (Ctxt.M_Idff, (0 => Create_Input ("clk", 1),
+ Set_Ports_Desc (Ctxt.M_Idff, (0 => Create_Input ("clk", 1),
1 => Create_Input ("d"),
2 => Create_Input ("init")),
Outputs);
@@ -472,7 +470,7 @@ package body Netlists.Builders is
New_Sname_Artificial (Get_Identifier ("adff"), No_Sname),
Id_Adff, 4, 1, 0);
Outputs := (0 => Create_Output ("q"));
- Set_Port_Desc (Ctxt.M_Adff, (0 => Create_Input ("clk", 1),
+ Set_Ports_Desc (Ctxt.M_Adff, (0 => Create_Input ("clk", 1),
1 => Create_Input ("d"),
2 => Create_Input ("rst", 1),
3 => Create_Input ("rst_val")),
@@ -483,7 +481,7 @@ package body Netlists.Builders is
New_Sname_Artificial (Get_Identifier ("iadff"), No_Sname),
Id_Iadff, 5, 1, 0);
Outputs := (0 => Create_Output ("q"));
- Set_Port_Desc (Ctxt.M_Iadff, (0 => Create_Input ("clk", 1),
+ Set_Ports_Desc (Ctxt.M_Iadff, (0 => Create_Input ("clk", 1),
1 => Create_Input ("d"),
2 => Create_Input ("rst"),
3 => Create_Input ("rst_val"),
@@ -498,26 +496,26 @@ package body Netlists.Builders is
Ctxt.M_Assert := New_User_Module
(Ctxt.Design, New_Sname_Artificial (Name_Assert, No_Sname), Id_Assert,
1, 0, 0);
- Set_Port_Desc (Ctxt.M_Assert, (0 => Create_Input ("cond", 1)),
+ Set_Ports_Desc (Ctxt.M_Assert, (0 => Create_Input ("cond", 1)),
Outputs);
Ctxt.M_Assume := New_User_Module
(Ctxt.Design, New_Sname_Artificial (Name_Assume, No_Sname), Id_Assume,
1, 0, 0);
- Set_Port_Desc (Ctxt.M_Assume, (0 => Create_Input ("cond", 1)),
+ Set_Ports_Desc (Ctxt.M_Assume, (0 => Create_Input ("cond", 1)),
Outputs);
Ctxt.M_Cover := New_User_Module
(Ctxt.Design, New_Sname_Artificial (Name_Cover, No_Sname), Id_Cover,
1, 0, 0);
- Set_Port_Desc (Ctxt.M_Cover, (0 => Create_Input ("cond", 1)),
+ Set_Ports_Desc (Ctxt.M_Cover, (0 => Create_Input ("cond", 1)),
Outputs);
Ctxt.M_Assert_Cover := New_User_Module
(Ctxt.Design,
New_Sname_Artificial (Get_Identifier ("assert_cover"), No_Sname),
Id_Assert_Cover, 1, 0, 0);
- Set_Port_Desc (Ctxt.M_Assert_Cover, (0 => Create_Input ("cond", 1)),
+ Set_Ports_Desc (Ctxt.M_Assert_Cover, (0 => Create_Input ("cond", 1)),
Outputs);
end Create_Assert_Assume_Cover;
@@ -531,7 +529,7 @@ package body Netlists.Builders is
(Ctxt.Design, New_Sname_Artificial (Name, No_Sname), Id, 0, 1, 0);
Ctxt.M_Formal_Input (Id) := Res;
Outputs := (0 => Create_Output ("o"));
- Set_Port_Desc (Res, Port_Desc_Array'(1 .. 0 => <>), Outputs);
+ Set_Ports_Desc (Res, Port_Desc_Array'(1 .. 0 => <>), Outputs);
end Create_Formal_Input;
function Build_Builders (Design : Module) return Context_Acc
diff --git a/src/synth/netlists-disp_vhdl.adb b/src/synth/netlists-disp_vhdl.adb
index fd25e00f1..847deab34 100644
--- a/src/synth/netlists-disp_vhdl.adb
+++ b/src/synth/netlists-disp_vhdl.adb
@@ -1176,29 +1176,38 @@ package body Netlists.Disp_Vhdl is
New_Line;
end Disp_Architecture;
+ procedure Disp_Entity_Port
+ (Desc : Port_Desc; Dir : Port_Kind; First : in out Boolean) is
+ begin
+ if First then
+ Put_Line (" port (");
+ First := False;
+ else
+ Put_Line (";");
+ end if;
+ Put (" ");
+ Put_Name (Desc.Name);
+ Put (" : ");
+ case Dir is
+ when Port_In =>
+ Put ("in");
+ when Port_Out =>
+ Put ("out");
+ end case;
+ Put (' ');
+ Put_Type (Desc.W);
+ end Disp_Entity_Port;
+
procedure Disp_Entity_Ports (M : Module)
is
First : Boolean;
begin
First := True;
- for P of Ports_Desc (M) loop
- if First then
- Put_Line (" port (");
- First := False;
- else
- Put_Line (";");
- end if;
- Put (" ");
- Put_Name (P.Name);
- Put (" : ");
- case P.Dir is
- when Port_In =>
- Put ("in");
- when Port_Out =>
- Put ("out");
- end case;
- Put (' ');
- Put_Type (P.W);
+ for I in 1 .. Get_Nbr_Inputs (M) loop
+ Disp_Entity_Port (Get_Input_Desc (M, I - 1), Port_In, First);
+ end loop;
+ for I in 1 .. Get_Nbr_Outputs (M) loop
+ Disp_Entity_Port (Get_Output_Desc (M, I - 1), Port_Out, First);
end loop;
if not First then
Put_Line (");");
diff --git a/src/synth/netlists-dump.adb b/src/synth/netlists-dump.adb
index c008a1372..22069083a 100644
--- a/src/synth/netlists-dump.adb
+++ b/src/synth/netlists-dump.adb
@@ -212,6 +212,21 @@ package body Netlists.Dump is
end if;
end Disp_Width;
+ procedure Dump_Module_Port (Desc : Port_Desc; Dir : Port_Kind) is
+ begin
+ case Dir is
+ when Port_In =>
+ Put ("input");
+ when Port_Out =>
+ Put ("output");
+ end case;
+ Put (' ');
+ Dump_Name (Desc.Name);
+ Disp_Width (Desc.W);
+ Put (';');
+ New_Line;
+ end Dump_Module_Port;
+
procedure Dump_Module_Header (M : Module; Indent : Natural := 0) is
begin
-- Module id and name.
@@ -239,19 +254,13 @@ package body Netlists.Dump is
end loop;
-- Ports.
- for P of Ports_Desc (M) loop
+ for I in 1 .. Get_Nbr_Inputs (M) loop
Put_Indent (Indent + 1);
- case P.Dir is
- when Port_In =>
- Put ("input");
- when Port_Out =>
- Put ("output");
- end case;
- Put (' ');
- Dump_Name (P.Name);
- Disp_Width (P.W);
- Put (';');
- New_Line;
+ Dump_Module_Port (Get_Input_Desc (M, I - 1), Port_In);
+ end loop;
+ for I in 1 .. Get_Nbr_Outputs (M) loop
+ Put_Indent (Indent + 1);
+ Dump_Module_Port (Get_Output_Desc (M, I - 1), Port_Out);
end loop;
end Dump_Module_Header;
diff --git a/src/synth/netlists.adb b/src/synth/netlists.adb
index a67265030..7760e7629 100644
--- a/src/synth/netlists.adb
+++ b/src/synth/netlists.adb
@@ -106,6 +106,12 @@ package body Netlists is
Table_Low_Bound => No_Module,
Table_Initial => 1024);
+ package Port_Desc_Table is new Tables
+ (Table_Component_Type => Port_Desc,
+ Table_Index_Type => Port_Desc_Idx,
+ Table_Low_Bound => No_Port_Desc_Idx,
+ Table_Initial => 1024);
+
function New_Design (Name : Sname) return Module
is
Res : Module;
@@ -146,13 +152,19 @@ package body Netlists is
is
pragma Assert (Is_Valid (Parent));
Parent_Rec : Module_Record renames Modules_Table.Table (Parent);
+ Ports_Desc : Port_Desc_Idx;
Res : Module;
begin
+ Ports_Desc := Port_Desc_Table.Last + 1;
+ for I in 1 .. Nbr_Inputs + Nbr_Outputs loop
+ Port_Desc_Table.Append ((Name => No_Sname, W => 0));
+ end loop;
+
Modules_Table.Append
((Parent => Parent,
Name => Name,
Id => Id,
- First_Port_Desc => No_Port_Desc_Idx,
+ First_Port_Desc => Ports_Desc,
Nbr_Inputs => Nbr_Inputs,
Nbr_Outputs => Nbr_Outputs,
First_Param_Desc => No_Param_Desc_Idx,
@@ -652,23 +664,22 @@ package body Netlists is
-- Port_Desc
- package Port_Desc_Table is new Tables
- (Table_Component_Type => Port_Desc,
- Table_Index_Type => Port_Desc_Idx,
- Table_Low_Bound => No_Port_Desc_Idx,
- Table_Initial => 1024);
-
function Get_Port_Desc (Idx : Port_Desc_Idx) return Port_Desc is
begin
return Port_Desc_Table.Table (Idx);
end Get_Port_Desc;
+ procedure Set_Port_Desc (Idx : Port_Desc_Idx; Desc : Port_Desc) is
+ begin
+ Port_Desc_Table.Table (Idx) := Desc;
+ end Set_Port_Desc;
+
function Get_Input_Desc (M : Module; I : Port_Idx) return Port_Desc
is
F : constant Port_Desc_Idx := Get_Input_First_Desc (M);
pragma Assert (I < Get_Nbr_Inputs (M));
begin
- return Port_Desc_Table.Table (F + Port_Desc_Idx (I));
+ return Get_Port_Desc (F + Port_Desc_Idx (I));
end Get_Input_Desc;
function Get_Output_Desc (M : Module; O : Port_Idx) return Port_Desc
@@ -676,32 +687,45 @@ package body Netlists is
F : constant Port_Desc_Idx := Get_Output_First_Desc (M);
pragma Assert (O < Get_Nbr_Outputs (M));
begin
- return Port_Desc_Table.Table (F + Port_Desc_Idx (O));
+ return Get_Port_Desc (F + Port_Desc_Idx (O));
end Get_Output_Desc;
- procedure Set_Port_Desc (M : Module;
- Input_Descs : Port_Desc_Array;
- Output_Descs : Port_Desc_Array)
+ procedure Set_Input_Desc (M : Module; I : Port_Idx; Desc : Port_Desc)
+ is
+ F : constant Port_Desc_Idx := Get_Input_First_Desc (M);
+ pragma Assert (I < Get_Nbr_Inputs (M));
+ Idx : constant Port_Desc_Idx := F + Port_Desc_Idx (I);
+ begin
+ pragma Assert (Get_Port_Desc (Idx).Name = No_Sname);
+ Set_Port_Desc (Idx, Desc);
+ end Set_Input_Desc;
+
+ procedure Set_Output_Desc (M : Module; O : Port_Idx; Desc : Port_Desc)
+ is
+ F : constant Port_Desc_Idx := Get_Output_First_Desc (M);
+ pragma Assert (O < Get_Nbr_Outputs (M));
+ Idx : constant Port_Desc_Idx := F + Port_Desc_Idx (O);
+ begin
+ pragma Assert (Get_Port_Desc (Idx).Name = No_Sname);
+ Set_Port_Desc (Idx, Desc);
+ end Set_Output_Desc;
+
+ procedure Set_Ports_Desc (M : Module;
+ Input_Descs : Port_Desc_Array;
+ Output_Descs : Port_Desc_Array)
is
pragma Assert (Is_Valid (M));
pragma Assert (Input_Descs'Length = Get_Nbr_Inputs (M));
pragma Assert (Output_Descs'Length = Get_Nbr_Outputs (M));
begin
- pragma Assert
- (Modules_Table.Table (M).First_Port_Desc = No_Port_Desc_Idx);
-
- Modules_Table.Table (M).First_Port_Desc := Port_Desc_Table.Last + 1;
-
- for I of Input_Descs loop
- pragma Assert (I.Dir = Port_In);
- Port_Desc_Table.Append (I);
+ for I in Input_Descs'Range loop
+ Set_Input_Desc (M, I - Input_Descs'First, Input_Descs (I));
end loop;
- for O of Output_Descs loop
- pragma Assert (O.Dir = Port_Out);
- Port_Desc_Table.Append (O);
+ for O in Output_Descs'Range loop
+ Set_Output_Desc (M, O - Output_Descs'First, Output_Descs (O));
end loop;
- end Set_Port_Desc;
+ end Set_Ports_Desc;
-- Param_Desc
@@ -711,8 +735,8 @@ package body Netlists is
Table_Low_Bound => No_Param_Desc_Idx,
Table_Initial => 256);
- procedure Set_Param_Desc (M : Module;
- Params : Param_Desc_Array)
+ procedure Set_Params_Desc (M : Module;
+ Params : Param_Desc_Array)
is
pragma Assert (Is_Valid (M));
pragma Assert (Params'Length = Get_Nbr_Params (M));
@@ -725,7 +749,7 @@ package body Netlists is
for P of Params loop
Param_Desc_Table.Append (P);
end loop;
- end Set_Param_Desc;
+ end Set_Params_Desc;
function Get_Param_Desc (M : Module; Param : Param_Idx) return Param_Desc
is
@@ -927,8 +951,7 @@ begin
pragma Assert (Inputs_Table.Last = No_Input);
Port_Desc_Table.Append ((Name => No_Sname,
- W => 0,
- Dir => Port_In));
+ W => 0));
pragma Assert (Port_Desc_Table.Last = No_Port_Desc_Idx);
Param_Desc_Table.Append ((Name => No_Sname,
diff --git a/src/synth/netlists.ads b/src/synth/netlists.ads
index c85336385..8ecfc5408 100644
--- a/src/synth/netlists.ads
+++ b/src/synth/netlists.ads
@@ -153,10 +153,8 @@ package Netlists is
-- Port width (number of bits).
W : Width;
-
- -- Direction.
- Dir : Port_Kind;
end record;
+ pragma Convention (C, Port_Desc);
type Port_Desc_Array is array (Port_Idx range <>) of Port_Desc;
@@ -192,11 +190,13 @@ package Netlists is
Nbr_Outputs : Port_Nbr;
Nbr_Params : Param_Nbr := 0)
return Module;
- procedure Set_Port_Desc (M : Module;
- Input_Descs : Port_Desc_Array;
- Output_Descs : Port_Desc_Array);
- procedure Set_Param_Desc (M : Module;
- Params : Param_Desc_Array);
+ procedure Set_Input_Desc (M : Module; I : Port_Idx; Desc : Port_Desc);
+ procedure Set_Output_Desc (M : Module; O : Port_Idx; Desc : Port_Desc);
+ procedure Set_Ports_Desc (M : Module;
+ Input_Descs : Port_Desc_Array;
+ Output_Descs : Port_Desc_Array);
+ procedure Set_Params_Desc (M : Module;
+ Params : Param_Desc_Array);
-- Create the self instance, once ports are defined. This is required if
-- the internal netlist will be defined.
diff --git a/src/synth/synth-insts.adb b/src/synth/synth-insts.adb
index ad2cd73fb..63a4db96d 100644
--- a/src/synth/synth-insts.adb
+++ b/src/synth/synth-insts.adb
@@ -66,16 +66,14 @@ package body Synth.Insts is
end Mode_To_Port_Kind;
function Make_Port_Desc (Syn_Inst : Synth_Instance_Acc;
- Inter : Node;
- Dir : Port_Kind) return Port_Desc
+ Inter : Node) return Port_Desc
is
Val : constant Value_Acc := Get_Value (Syn_Inst, Inter);
Name : Sname;
begin
Name := New_Sname_User (Get_Identifier (Inter), No_Sname);
return (Name => Name,
- W => Get_Type_Width (Val.Typ),
- Dir => Dir);
+ W => Get_Type_Width (Val.Typ));
end Make_Port_Desc;
-- Parameters that define an instance.
@@ -226,18 +224,16 @@ package body Synth.Insts is
case Mode_To_Port_Kind (Get_Mode (Inter)) is
when Port_In =>
Nbr_Inputs := Nbr_Inputs + 1;
- Inports (Nbr_Inputs) :=
- Make_Port_Desc (Syn_Inst, Inter, Port_In);
+ Inports (Nbr_Inputs) := Make_Port_Desc (Syn_Inst, Inter);
when Port_Out =>
Nbr_Outputs := Nbr_Outputs + 1;
- Outports (Nbr_Outputs) :=
- Make_Port_Desc (Syn_Inst, Inter, Port_Out);
+ Outports (Nbr_Outputs) := Make_Port_Desc (Syn_Inst, Inter);
end case;
Inter := Get_Chain (Inter);
end loop;
pragma Assert (Nbr_Inputs = Inports'Last);
pragma Assert (Nbr_Outputs = Outports'Last);
- Set_Port_Desc (Cur_Module, Inports, Outports);
+ Set_Ports_Desc (Cur_Module, Inports, Outports);
end;
return Inst_Object'(Decl => Decl,