diff options
author | Tristan Gingold <tgingold@free.fr> | 2019-07-01 18:21:59 +0200 |
---|---|---|
committer | Tristan Gingold <tgingold@free.fr> | 2019-07-01 18:21:59 +0200 |
commit | 10e0d932d67e90263dfd393be8b3719e26fe6514 (patch) | |
tree | 1ed2df92180c602fb428378ef9fadac452f5bc8c /src/synth/netlists-builders.adb | |
parent | 5ee88f60d0052fc028cfc55e9182349343260e2f (diff) | |
download | ghdl-10e0d932d67e90263dfd393be8b3719e26fe6514.tar.gz ghdl-10e0d932d67e90263dfd393be8b3719e26fe6514.tar.bz2 ghdl-10e0d932d67e90263dfd393be8b3719e26fe6514.zip |
synth: add dyn_insert module.
Diffstat (limited to 'src/synth/netlists-builders.adb')
-rw-r--r-- | src/synth/netlists-builders.adb | 51 |
1 files changed, 47 insertions, 4 deletions
diff --git a/src/synth/netlists-builders.adb b/src/synth/netlists-builders.adb index bc5e4aa68..957ba565c 100644 --- a/src/synth/netlists-builders.adb +++ b/src/synth/netlists-builders.adb @@ -202,6 +202,28 @@ package body Netlists.Builders is Typ => Param_Uns32))); end Create_Insert_Module; + procedure Create_Dyn_Insert_Module (Ctxt : Context_Acc) + is + Outputs : Port_Desc_Array (0 .. 0); + Inputs : Port_Desc_Array (0 .. 2); + Res : Module; + begin + Res := New_User_Module + (Ctxt.Design, New_Sname_Artificial (Get_Identifier ("dyn_insert")), + Id_Dyn_Insert, 3, 1, 2); + Ctxt.M_Dyn_Insert := Res; + Outputs := (0 => Create_Output ("o")); + Inputs := (0 => Create_Input ("i"), + 1 => Create_Input ("v"), + 2 => Create_Input ("p")); + Set_Port_Desc (Res, Inputs, Outputs); + Set_Param_Desc + (Res, (0 => (New_Sname_Artificial (Get_Identifier ("step")), + Typ => Param_Uns32), + 1 => (New_Sname_Artificial (Get_Identifier ("offset")), + Typ => Param_Uns32))); + end Create_Dyn_Insert_Module; + procedure Create_Edge_Module (Ctxt : Context_Acc; Res : out Module; Name : Name_Id) @@ -363,6 +385,7 @@ package body Netlists.Builders is Create_Extract_Module (Res); Create_Dyn_Extract_Module (Res); Create_Insert_Module (Res); + Create_Dyn_Insert_Module (Res); Create_Monadic_Module (Design, Res.M_Truncate (Id_Utrunc), Get_Identifier ("utrunc"), Id_Utrunc); @@ -630,6 +653,27 @@ package body Netlists.Builders is return O; end Build_Insert; + function Build_Dyn_Insert + (Ctxt : Context_Acc; + I : Net; V : Net; P : Net; Step : Uns32; Off : Int32) + return Net + is + Wd : constant Width := Get_Width (I); + pragma Assert (Wd /= No_Width); + Inst : Instance; + O : Net; + begin + Inst := New_Internal_Instance (Ctxt, Ctxt.M_Dyn_Insert); + O := Get_Output (Inst, 0); + Set_Width (O, Wd); + Connect (Get_Input (Inst, 0), I); + Connect (Get_Input (Inst, 1), V); + Connect (Get_Input (Inst, 2), P); + Set_Param_Uns32 (Inst, 0, Step); + Set_Param_Uns32 (Inst, 1, To_Uns32 (Off)); + return O; + end Build_Dyn_Insert; + function Build_Object (Ctxt : Context_Acc; M : Module; W : Width) return Net is Inst : Instance; @@ -775,12 +819,11 @@ package body Netlists.Builders is function Build_Dyn_Extract (Ctxt : Context_Acc; - I : Net; V : Net; Step : Uns32; Off : Uns32; W : Width) return Net + I : Net; P : Net; Step : Uns32; Off : Int32; W : Width) return Net is Wd : constant Width := Get_Width (I); pragma Assert (Wd /= No_Width); pragma Assert (W > 0); - pragma Assert (W + Off <= Wd); Inst : Instance; O : Net; begin @@ -788,9 +831,9 @@ package body Netlists.Builders is O := Get_Output (Inst, 0); Set_Width (O, W); Connect (Get_Input (Inst, 0), I); - Connect (Get_Input (Inst, 1), V); + Connect (Get_Input (Inst, 1), P); Set_Param_Uns32 (Inst, 0, Step); - Set_Param_Uns32 (Inst, 1, Off); + Set_Param_Uns32 (Inst, 1, To_Uns32 (Off)); return O; end Build_Dyn_Extract; |