aboutsummaryrefslogtreecommitdiffstats
path: root/src/synth/netlists-builders.adb
diff options
context:
space:
mode:
authorTristan Gingold <tgingold@free.fr>2022-07-12 08:03:53 +0200
committerTristan Gingold <tgingold@free.fr>2022-07-12 21:00:03 +0200
commit9e6785615586ef208c5643e4bd8880aacf98fe99 (patch)
treeb5199e93c2317edf4fd8cf4f6423defab5648339 /src/synth/netlists-builders.adb
parent1541c5d742f5860dfff92c12de11415b94ee0709 (diff)
downloadghdl-9e6785615586ef208c5643e4bd8880aacf98fe99.tar.gz
ghdl-9e6785615586ef208c5643e4bd8880aacf98fe99.tar.bz2
ghdl-9e6785615586ef208c5643e4bd8880aacf98fe99.zip
netlists: add d-latch
Diffstat (limited to 'src/synth/netlists-builders.adb')
-rw-r--r--src/synth/netlists-builders.adb30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/synth/netlists-builders.adb b/src/synth/netlists-builders.adb
index d0d4b20be..d3eaf6a0a 100644
--- a/src/synth/netlists-builders.adb
+++ b/src/synth/netlists-builders.adb
@@ -566,6 +566,20 @@ package body Netlists.Builders is
Outputs);
end Create_Dff_Modules;
+ procedure Create_Latch_Modules (Ctxt : Context_Acc)
+ is
+ Outputs : Port_Desc_Array (0 .. 0);
+ begin
+ Ctxt.M_Dlatch := New_User_Module
+ (Ctxt.Design,
+ New_Sname_Artificial (Get_Identifier ("dlatch"), No_Sname),
+ Id_Dlatch, 2, 1, 0);
+ Outputs := (0 => Create_Output ("q"));
+ Set_Ports_Desc (Ctxt.M_Dlatch, (0 => Create_Input ("d"),
+ 1 => Create_Input ("en", 1)),
+ Outputs);
+ end Create_Latch_Modules;
+
procedure Create_Assert_Assume_Cover (Ctxt : Context_Acc)
is
Outputs : Port_Desc_Array (1 .. 0);
@@ -758,6 +772,7 @@ package body Netlists.Builders is
Create_Mux_Modules (Res);
Create_Objects_Module (Res);
Create_Dff_Modules (Res);
+ Create_Latch_Modules (Res);
Create_Assert_Assume_Cover (Res);
@@ -1589,6 +1604,21 @@ package body Netlists.Builders is
return O;
end Build_Midff;
+ function Build_Dlatch (Ctxt : Context_Acc; En : Net; D : Net) return Net
+ is
+ Wd : constant Width := Get_Width (D);
+ pragma Assert (Get_Width (En) = 1);
+ Inst : Instance;
+ O : Net;
+ begin
+ Inst := New_Internal_Instance (Ctxt, Ctxt.M_Dlatch);
+ O := Get_Output (Inst, 0);
+ Set_Width (O, Wd);
+ Connect (Get_Input (Inst, 0), D);
+ Connect (Get_Input (Inst, 1), En);
+ return O;
+ end Build_Dlatch;
+
function Build_Tri (Ctxt : Context_Acc; En : Net; D : Net) return Net
is
Wd : constant Width := Get_Width (D);