aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTristan Gingold <tgingold@free.fr>2019-07-19 06:50:12 +0200
committerTristan Gingold <tgingold@free.fr>2019-07-19 06:50:53 +0200
commite812443cafb5284eef69a3aaf44b69192964bf0e (patch)
tree878a761fadd0ccb1db07c63d02bdcbf16a89da34 /src
parent7f0a70e0d4777a2b9c29d6b17f2385d2d3bc1ced (diff)
downloadghdl-e812443cafb5284eef69a3aaf44b69192964bf0e.tar.gz
ghdl-e812443cafb5284eef69a3aaf44b69192964bf0e.tar.bz2
ghdl-e812443cafb5284eef69a3aaf44b69192964bf0e.zip
synth: add const_z gate.
Diffstat (limited to 'src')
-rw-r--r--src/synth/netlists-builders.adb23
-rw-r--r--src/synth/netlists-builders.ads5
-rw-r--r--src/synth/netlists-disp_vhdl.adb6
-rw-r--r--src/synth/netlists-gates.ads2
4 files changed, 33 insertions, 3 deletions
diff --git a/src/synth/netlists-builders.adb b/src/synth/netlists-builders.adb
index 78ed38a41..9cb357b34 100644
--- a/src/synth/netlists-builders.adb
+++ b/src/synth/netlists-builders.adb
@@ -142,6 +142,13 @@ package body Netlists.Builders is
Typ => Param_Uns32),
1 => (New_Sname_Artificial (Get_Identifier ("xz")),
Typ => Param_Uns32)));
+
+ Res := New_User_Module
+ (Ctxt.Design, New_Sname_Artificial (Get_Identifier ("const_Z")),
+ 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);
end Create_Const_Modules;
procedure Create_Extract_Module (Ctxt : Context_Acc)
@@ -529,11 +536,23 @@ package body Netlists.Builders is
return O;
end Build_Compare;
+ function Build_Const_Z (Ctxt : Context_Acc; W : Width) return Net
+ is
+ pragma Assert (W > 0);
+ Inst : Instance;
+ O : Net;
+ begin
+ Inst := New_Internal_Instance (Ctxt, Ctxt.M_Const_Z);
+ O := Get_Output (Inst, 0);
+ Set_Width (O, W);
+ return O;
+ end Build_Const_Z;
+
function Build_Const_UB32 (Ctxt : Context_Acc;
Val : Uns32;
W : Width) return Net
is
- pragma Assert (W <= 32);
+ pragma Assert (W > 0 and W <= 32);
Inst : Instance;
O : Net;
begin
@@ -549,7 +568,7 @@ package body Netlists.Builders is
Xz : Uns32;
W : Width) return Net
is
- pragma Assert (W <= 32);
+ pragma Assert (W > 0 and W <= 32);
Inst : Instance;
O : Net;
begin
diff --git a/src/synth/netlists-builders.ads b/src/synth/netlists-builders.ads
index 7c016dedc..654fc6e9a 100644
--- a/src/synth/netlists-builders.ads
+++ b/src/synth/netlists-builders.ads
@@ -48,6 +48,9 @@ package Netlists.Builders is
Id : Reduce_Module_Id;
Op : Net) return Net;
+ function Build_Const_Z (Ctxt : Context_Acc;
+ W : Width) return Net;
+
function Build_Const_UB32 (Ctxt : Context_Acc;
Val : Uns32;
W : Width) return Net;
@@ -65,6 +68,7 @@ package Netlists.Builders is
Sel : Net;
I0, I1, I2, I3 : Net) return Net;
+ -- Build: I0 & I1 [ & I2 [ & I3 ]]
function Build_Concat2 (Ctxt : Context_Acc; I0, I1 : Net) return Net;
function Build_Concat3 (Ctxt : Context_Acc; I0, I1, I2 : Net) return Net;
function Build_Concat4 (Ctxt : Context_Acc; I0, I1, I2, I3 : Net)
@@ -129,6 +133,7 @@ private
M_Concat : Module_Arr (Concat_Module_Id);
M_Const_UB32 : Module;
M_Const_UL32 : Module;
+ M_Const_Z : Module;
M_Edge : Module;
M_Mux2 : Module;
M_Mux4 : Module;
diff --git a/src/synth/netlists-disp_vhdl.adb b/src/synth/netlists-disp_vhdl.adb
index 139b2c0d0..5525d54ee 100644
--- a/src/synth/netlists-disp_vhdl.adb
+++ b/src/synth/netlists-disp_vhdl.adb
@@ -480,6 +480,9 @@ package body Netlists.Disp_Vhdl is
Disp_Binary_Lit (Get_Param_Uns32 (Inst, 0),
Get_Param_Uns32 (Inst, 1),
Get_Width (O));
+ when Id_Const_Z =>
+ Disp_Template ("(\n0 downto 0 => 'Z')",
+ Inst, (0 => Get_Width (O) - 1));
when others =>
raise Internal_Error;
end case;
@@ -550,7 +553,8 @@ package body Netlists.Disp_Vhdl is
Inst, (0 => Iw - 1));
end;
when Id_Const_UB32
- | Id_Const_UL32 =>
+ | Id_Const_UL32
+ | Id_Const_Z =>
Disp_Template (" \o0 <= ", Inst);
Disp_Constant_Inline (Inst);
Put_Line (";");
diff --git a/src/synth/netlists-gates.ads b/src/synth/netlists-gates.ads
index 44b5486bf..61d5ab8d4 100644
--- a/src/synth/netlists-gates.ads
+++ b/src/synth/netlists-gates.ads
@@ -154,4 +154,6 @@ package Netlists.Gates is
Id_Const_SB128 : constant Module_Id := 69;
Id_Const_UL32 : constant Module_Id := 70;
Id_Const_SL32 : constant Module_Id := 71;
+ Id_Const_Z : constant Module_Id := 72;
+ Id_Const_0 : constant Module_Id := 73;
end Netlists.Gates;