aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTristan Gingold <tgingold@free.fr>2019-09-22 17:26:38 +0200
committerTristan Gingold <tgingold@free.fr>2019-09-22 17:26:38 +0200
commit6f9f27d4a643aaae6e5f04bae104f28473c9b695 (patch)
treec243106609294590668e370d4005336ce1cb4457 /src
parent51d105ce7368344753ef90f84c2209dd514715bb (diff)
downloadghdl-6f9f27d4a643aaae6e5f04bae104f28473c9b695.tar.gz
ghdl-6f9f27d4a643aaae6e5f04bae104f28473c9b695.tar.bz2
ghdl-6f9f27d4a643aaae6e5f04bae104f28473c9b695.zip
synth: handle rotate.
Diffstat (limited to 'src')
-rw-r--r--src/synth/netlists-builders.adb24
-rw-r--r--src/synth/netlists-builders.ads8
-rw-r--r--src/synth/netlists-gates.ads60
-rw-r--r--src/synth/synth-oper.adb24
4 files changed, 71 insertions, 45 deletions
diff --git a/src/synth/netlists-builders.adb b/src/synth/netlists-builders.adb
index 14e0827d4..3e0b2ebbc 100644
--- a/src/synth/netlists-builders.adb
+++ b/src/synth/netlists-builders.adb
@@ -394,7 +394,7 @@ package body Netlists.Builders is
Parent => No_Module,
Num => 0,
M_Dyadic => (others => No_Module),
- M_Shift => (others => No_Module),
+ M_Shift_Rotate => (others => No_Module),
M_Monadic => (others => No_Module),
M_Compare => (others => No_Module),
M_Concat => (others => No_Module),
@@ -421,12 +421,16 @@ package body Netlists.Builders is
Get_Identifier ("smul"), Id_Smul);
Create_Dyadic_Module (Design, Res.M_Dyadic (Id_Umul),
Get_Identifier ("umul"), Id_Umul);
- Create_Dyadic_Module (Design, Res.M_Shift (Id_Lsl),
+ Create_Dyadic_Module (Design, Res.M_Shift_Rotate (Id_Lsl),
Get_Identifier ("lsl"), Id_Lsl);
- Create_Dyadic_Module (Design, Res.M_Shift (Id_Lsr),
+ Create_Dyadic_Module (Design, Res.M_Shift_Rotate (Id_Lsr),
Get_Identifier ("lsr"), Id_Lsr);
- Create_Dyadic_Module (Design, Res.M_Shift (Id_Asr),
+ Create_Dyadic_Module (Design, Res.M_Shift_Rotate (Id_Asr),
Get_Identifier ("asr"), Id_Asr);
+ Create_Dyadic_Module (Design, Res.M_Shift_Rotate (Id_Rol),
+ Name_Rol, Id_Rol);
+ Create_Dyadic_Module (Design, Res.M_Shift_Rotate (Id_Ror),
+ Name_Ror, Id_Ror);
Create_Monadic_Module (Design, Res.M_Monadic (Id_Not), Name_Not, Id_Not);
Create_Monadic_Module (Design, Res.M_Monadic (Id_Neg),
@@ -532,24 +536,24 @@ package body Netlists.Builders is
return O;
end Build_Dyadic;
- function Build_Shift (Ctxt : Context_Acc;
- Id : Shift_Module_Id;
- L, R : Net) return Net
+ function Build_Shift_Rotate (Ctxt : Context_Acc;
+ Id : Shift_Rotate_Module_Id;
+ L, R : Net) return Net
is
Wd : constant Width := Get_Width (L);
pragma Assert (Wd /= No_Width);
pragma Assert (Get_Width (R) /= No_Width);
- pragma Assert (Ctxt.M_Shift (Id) /= No_Module);
+ pragma Assert (Ctxt.M_Shift_Rotate (Id) /= No_Module);
Inst : Instance;
O : Net;
begin
- Inst := New_Internal_Instance (Ctxt, Ctxt.M_Shift (Id));
+ Inst := New_Internal_Instance (Ctxt, Ctxt.M_Shift_Rotate (Id));
O := Get_Output (Inst, 0);
Set_Width (O, Wd);
Connect (Get_Input (Inst, 0), L);
Connect (Get_Input (Inst, 1), R);
return O;
- end Build_Shift;
+ end Build_Shift_Rotate;
function Build_Monadic (Ctxt : Context_Acc;
Id : Monadic_Module_Id;
diff --git a/src/synth/netlists-builders.ads b/src/synth/netlists-builders.ads
index 8395c6292..6d76d4663 100644
--- a/src/synth/netlists-builders.ads
+++ b/src/synth/netlists-builders.ads
@@ -43,9 +43,9 @@ package Netlists.Builders is
Id : Dyadic_Module_Id;
L, R : Net) return Net;
- function Build_Shift (Ctxt : Context_Acc;
- Id : Shift_Module_Id;
- L, R : Net) return Net;
+ function Build_Shift_Rotate (Ctxt : Context_Acc;
+ Id : Shift_Rotate_Module_Id;
+ L, R : Net) return Net;
function Build_Monadic (Ctxt : Context_Acc;
Id : Monadic_Module_Id;
@@ -175,7 +175,7 @@ private
Parent : Module;
Num : Uns32;
M_Dyadic : Module_Arr (Dyadic_Module_Id);
- M_Shift : Module_Arr (Shift_Module_Id);
+ M_Shift_Rotate : Module_Arr (Shift_Rotate_Module_Id);
M_Monadic : Module_Arr (Monadic_Module_Id);
M_Compare : Module_Arr (Compare_Module_Id);
M_Concat : Module_Arr (Concat_Module_Id);
diff --git a/src/synth/netlists-gates.ads b/src/synth/netlists-gates.ads
index e1de55289..e9c153c97 100644
--- a/src/synth/netlists-gates.ads
+++ b/src/synth/netlists-gates.ads
@@ -39,61 +39,69 @@ package Netlists.Gates is
subtype Dyadic_Module_Id is Module_Id range Id_And .. Id_Smul;
-- Logical and arithmetic shifts.
+ -- FIXME: clarify right operand: width, large values
Id_Lsl : constant Module_Id := 13;
Id_Lsr : constant Module_Id := 14;
Id_Asr : constant Module_Id := 15;
subtype Shift_Module_Id is Module_Id range Id_Lsl .. Id_Asr;
- Id_Buf : constant Module_Id := 16;
- Id_Not : constant Module_Id := 17;
+ -- Rotations.
+ -- FIXME: clarify right operand.
+ Id_Rol : constant Module_Id := 16;
+ Id_Ror : constant Module_Id := 17;
- Id_Neg : constant Module_Id := 18;
+ subtype Rotate_Module_Id is Module_Id range Id_Lsl .. Id_Asr;
- subtype Monadic_Module_Id is Module_Id range Id_Buf .. Id_Neg;
+ subtype Shift_Rotate_Module_Id is Module_Id range Id_Lsl .. Id_Ror;
- Id_Eq : constant Module_Id := 20;
- Id_Ne : constant Module_Id := 21;
- Id_Ule : constant Module_Id := 22;
- Id_Sle : constant Module_Id := 23;
- Id_Ult : constant Module_Id := 24;
- Id_Slt : constant Module_Id := 25;
- Id_Uge : constant Module_Id := 26;
- Id_Sge : constant Module_Id := 27;
- Id_Ugt : constant Module_Id := 28;
- Id_Sgt : constant Module_Id := 29;
+ Id_Not : constant Module_Id := 18;
+ Id_Neg : constant Module_Id := 19;
+
+ subtype Monadic_Module_Id is Module_Id range Id_Not .. Id_Neg;
+
+ Id_Eq : constant Module_Id := 21;
+ Id_Ne : constant Module_Id := 22;
+ Id_Ule : constant Module_Id := 23;
+ Id_Sle : constant Module_Id := 24;
+ Id_Ult : constant Module_Id := 25;
+ Id_Slt : constant Module_Id := 26;
+ Id_Uge : constant Module_Id := 27;
+ Id_Sge : constant Module_Id := 28;
+ Id_Ugt : constant Module_Id := 29;
+ Id_Sgt : constant Module_Id := 30;
subtype Compare_Module_Id is Module_Id range Id_Eq .. Id_Sgt;
- Id_Red_And : constant Module_Id := 30;
- Id_Red_Or : constant Module_Id := 31;
+ Id_Red_And : constant Module_Id := 31;
+ Id_Red_Or : constant Module_Id := 32;
subtype Reduce_Module_Id is Module_Id range Id_Red_And .. Id_Red_Or;
- Id_Concat2 : constant Module_Id := 32;
- Id_Concat3 : constant Module_Id := 33;
- Id_Concat4 : constant Module_Id := 34;
+ Id_Concat2 : constant Module_Id := 40;
+ Id_Concat3 : constant Module_Id := 41;
+ Id_Concat4 : constant Module_Id := 42;
subtype Concat_Module_Id is Module_Id range Id_Concat2 .. Id_Concat4;
-- Concatenation with N inputs.
- Id_Concatn : constant Module_Id := 35;
+ Id_Concatn : constant Module_Id := 43;
-- Inputs: s, i0, i1
-- Output: o
- Id_Mux2 : constant Module_Id := 36;
+ Id_Mux2 : constant Module_Id := 44;
-- Inputs: s, i0, i1, s2, s3
-- Output: o
- Id_Mux4 : constant Module_Id := 37;
+ Id_Mux4 : constant Module_Id := 45;
subtype Mux_Module_Id is Module_Id range Id_Mux2 .. Id_Mux4;
-- Like a wire: the output is equal to the input, but could be elimited
-- at any time. Isignal has an initial value.
- Id_Signal : constant Module_Id := 38;
- Id_Isignal : constant Module_Id := 39;
- Id_Output : constant Module_Id := 40;
- Id_Port : constant Module_Id := 41;
+ Id_Signal : constant Module_Id := 46;
+ Id_Isignal : constant Module_Id := 47;
+ Id_Output : constant Module_Id := 48;
+ Id_Port : constant Module_Id := 49;
-- Note: initial values must be constant nets.
--
diff --git a/src/synth/synth-oper.adb b/src/synth/synth-oper.adb
index d50ca1862..8f960a6c2 100644
--- a/src/synth/synth-oper.adb
+++ b/src/synth/synth-oper.adb
@@ -767,17 +767,17 @@ package body Synth.Oper is
end case;
end Synth_Monadic_Operation;
- function Synth_Shift (Id : Shift_Module_Id;
+ function Synth_Shift_Rotate (Id : Shift_Rotate_Module_Id;
Left, Right : Value_Acc;
Expr : Node) return Value_Acc
is
L : constant Net := Get_Net (Left);
N : Net;
begin
- N := Build_Shift (Build_Context, Id, L, Get_Net (Right));
+ N := Build_Shift_Rotate (Build_Context, Id, L, Get_Net (Right));
Set_Location (N, Expr);
return Create_Value_Net (N, Create_Res_Bound (Left, L));
- end Synth_Shift;
+ end Synth_Shift_Rotate;
function Synth_Std_Match (Cst : Value_Acc;
Oper : Value_Acc;
@@ -973,14 +973,28 @@ package body Synth.Oper is
L : constant Value_Acc := Get_Value (Subprg_Inst, Param1);
R : constant Value_Acc := Get_Value (Subprg_Inst, Param2);
begin
- return Synth_Shift (Id_Lsl, L, R, Expr);
+ return Synth_Shift_Rotate (Id_Lsl, L, R, Expr);
end;
when Iir_Predefined_Ieee_Numeric_Std_Shr_Uns_Nat =>
declare
L : constant Value_Acc := Get_Value (Subprg_Inst, Param1);
R : constant Value_Acc := Get_Value (Subprg_Inst, Param2);
begin
- return Synth_Shift (Id_Lsr, L, R, Expr);
+ return Synth_Shift_Rotate (Id_Lsr, L, R, Expr);
+ end;
+ when Iir_Predefined_Ieee_Numeric_Std_Rol_Uns_Nat =>
+ declare
+ L : constant Value_Acc := Get_Value (Subprg_Inst, Param1);
+ R : constant Value_Acc := Get_Value (Subprg_Inst, Param2);
+ begin
+ return Synth_Shift_Rotate (Id_Rol, L, R, Expr);
+ end;
+ when Iir_Predefined_Ieee_Numeric_Std_Ror_Uns_Nat =>
+ declare
+ L : constant Value_Acc := Get_Value (Subprg_Inst, Param1);
+ R : constant Value_Acc := Get_Value (Subprg_Inst, Param2);
+ begin
+ return Synth_Shift_Rotate (Id_Ror, L, R, Expr);
end;
when Iir_Predefined_Ieee_Numeric_Std_Match_Suv =>
declare