diff options
author | Tristan Gingold <tgingold@free.fr> | 2019-07-04 18:21:12 +0200 |
---|---|---|
committer | Tristan Gingold <tgingold@free.fr> | 2019-07-04 18:21:12 +0200 |
commit | 7b3d3e5871bd7b3bb304d3ed63e16ac7143b0128 (patch) | |
tree | 5a58ae4fc056008e691a3760259a5d84be1d4887 /src/synth | |
parent | 3b896eb128469c2c5fad8946d10db94c661999ad (diff) | |
download | ghdl-7b3d3e5871bd7b3bb304d3ed63e16ac7143b0128.tar.gz ghdl-7b3d3e5871bd7b3bb304d3ed63e16ac7143b0128.tar.bz2 ghdl-7b3d3e5871bd7b3bb304d3ed63e16ac7143b0128.zip |
netlists: add reduce_or/reduce_and gates.
Diffstat (limited to 'src/synth')
-rw-r--r-- | src/synth/netlists-builders.adb | 16 | ||||
-rw-r--r-- | src/synth/netlists-builders.ads | 5 | ||||
-rw-r--r-- | src/synth/netlists-disp_vhdl.adb | 13 | ||||
-rw-r--r-- | src/synth/netlists-gates.ads | 2 |
4 files changed, 36 insertions, 0 deletions
diff --git a/src/synth/netlists-builders.adb b/src/synth/netlists-builders.adb index 089781aad..ebf9964e8 100644 --- a/src/synth/netlists-builders.adb +++ b/src/synth/netlists-builders.adb @@ -362,6 +362,7 @@ package body Netlists.Builders is M_Compare => (others => No_Module), M_Concat => (others => No_Module), M_Truncate | M_Extend => (others => No_Module), + M_Reduce => (others => No_Module), others => No_Module); Create_Dyadic_Module (Design, Res.M_Dyadic (Id_And), Name_And, Id_And); @@ -480,6 +481,21 @@ package body Netlists.Builders is return O; end Build_Monadic; + function Build_Reduce (Ctxt : Context_Acc; + Id : Reduce_Module_Id; + Op : Net) return Net + is + pragma Assert (Ctxt.M_Reduce (Id) /= No_Module); + Inst : Instance; + O : Net; + begin + Inst := New_Internal_Instance (Ctxt, Ctxt.M_Reduce (Id)); + O := Get_Output (Inst, 0); + Set_Width (O, 1); + Connect (Get_Input (Inst, 0), Op); + return O; + end Build_Reduce; + function Build_Compare (Ctxt : Context_Acc; Id : Compare_Module_Id; L, R : Net) return Net diff --git a/src/synth/netlists-builders.ads b/src/synth/netlists-builders.ads index 08b67789b..4c444bf05 100644 --- a/src/synth/netlists-builders.ads +++ b/src/synth/netlists-builders.ads @@ -42,6 +42,10 @@ package Netlists.Builders is Id : Compare_Module_Id; L, R : Net) return Net; + function Build_Reduce (Ctxt : Context_Acc; + Id : Reduce_Module_Id; + Op : Net) return Net; + function Build_Const_UB32 (Ctxt : Context_Acc; Val : Uns32; W : Width) return Net; @@ -133,6 +137,7 @@ private M_Iadff : Module; M_Truncate : Module_Arr (Truncate_Module_Id); M_Extend : Module_Arr (Extend_Module_Id); + M_Reduce : Module_Arr (Reduce_Module_Id); M_Extract : Module; M_Insert : Module; M_Dyn_Extract : Module; diff --git a/src/synth/netlists-disp_vhdl.adb b/src/synth/netlists-disp_vhdl.adb index a7999ba0c..fdd4c308a 100644 --- a/src/synth/netlists-disp_vhdl.adb +++ b/src/synth/netlists-disp_vhdl.adb @@ -605,6 +605,19 @@ package body Netlists.Disp_Vhdl is Put ((1 .. Natural (Ow - Iw) => '0')); Disp_Template (""" & \i0; -- uext" & NL, Inst); end; + when Id_Red_Or => + declare + Iw : constant Width := Get_Width (Get_Input_Net (Inst, 0)); + begin + if Iw > 1 then + Disp_Template + (" \o0 <= '1' when \i0 /= (\n0 downto 0 => '0') else '0';" + & NL, Inst, (0 => Iw - 1)); + else + Disp_Template + (" \o0 <= \i1; -- reduce or" & NL, Inst); + end if; + end; when Id_Assert => Disp_Template (" assert \i0 = '1' severity error;" & NL, Inst); when Id_Assume => diff --git a/src/synth/netlists-gates.ads b/src/synth/netlists-gates.ads index 6e196f38d..8d8d5af42 100644 --- a/src/synth/netlists-gates.ads +++ b/src/synth/netlists-gates.ads @@ -56,6 +56,8 @@ package Netlists.Gates is Id_Red_And : constant Module_Id := 26; Id_Red_Or : constant Module_Id := 27; + subtype Reduce_Module_Id is Module_Id range Id_Red_And .. Id_Red_Or; + Id_Concat2 : constant Module_Id := 28; Id_Concat3 : constant Module_Id := 29; Id_Concat4 : constant Module_Id := 30; |