aboutsummaryrefslogtreecommitdiffstats
path: root/src/synth
diff options
context:
space:
mode:
authorTristan Gingold <tgingold@free.fr>2019-11-13 19:47:50 +0100
committerTristan Gingold <tgingold@free.fr>2019-11-13 19:47:50 +0100
commit320a18c681edd29d8f58bd7f3109ae6ee1faffca (patch)
tree63a9957904cc22fb965d7555e3a6f8fed8c52b1b /src/synth
parent444fb962c6612f9c68d5211ab0fabb1d2aac854e (diff)
downloadghdl-320a18c681edd29d8f58bd7f3109ae6ee1faffca.tar.gz
ghdl-320a18c681edd29d8f58bd7f3109ae6ee1faffca.tar.bz2
ghdl-320a18c681edd29d8f58bd7f3109ae6ee1faffca.zip
synth: renames Is_Const to Is_Static.
Diffstat (limited to 'src/synth')
-rw-r--r--src/synth/synth-decls.adb2
-rw-r--r--src/synth/synth-expr.adb46
-rw-r--r--src/synth/synth-expr.ads2
-rw-r--r--src/synth/synth-insts.adb4
-rw-r--r--src/synth/synth-oper.adb34
-rw-r--r--src/synth/synth-static_oper.adb14
-rw-r--r--src/synth/synth-stmts.adb14
-rw-r--r--src/synth/synth-values.adb10
-rw-r--r--src/synth/synth-values.ads5
9 files changed, 66 insertions, 65 deletions
diff --git a/src/synth/synth-decls.adb b/src/synth/synth-decls.adb
index 774bebd06..436ade478 100644
--- a/src/synth/synth-decls.adb
+++ b/src/synth/synth-decls.adb
@@ -472,7 +472,7 @@ package body Synth.Decls is
(Syn_Inst, Get_Default_Value (Decl), Obj_Type);
-- For constant functions, the value must be constant.
pragma Assert (not Get_Instance_Const (Syn_Inst)
- or else Is_Const (Val));
+ or else Is_Static (Val));
if Val.Kind = Value_Const then
Cst := Val;
else
diff --git a/src/synth/synth-expr.adb b/src/synth/synth-expr.adb
index 701724aa1..e6a0566ac 100644
--- a/src/synth/synth-expr.adb
+++ b/src/synth/synth-expr.adb
@@ -48,7 +48,7 @@ package body Synth.Expr is
procedure Set_Location (N : Net; Loc : Node)
renames Synth.Source.Set_Location;
- function Get_Const_Discrete (V : Value_Acc) return Int64
+ function Get_Static_Discrete (V : Value_Acc) return Int64
is
N : Net;
begin
@@ -65,7 +65,7 @@ package body Synth.Expr is
raise Internal_Error;
end case;
return Get_Net_Int64 (N);
- end Get_Const_Discrete;
+ end Get_Static_Discrete;
procedure From_Std_Logic (Enum : Int64; Val : out Uns32; Zx : out Uns32) is
begin
@@ -146,7 +146,7 @@ package body Synth.Expr is
N : Net;
Res : Net;
begin
- if Is_Const (Val) then
+ if Is_Static (Val) then
if Wn /= W then
pragma Assert (Val.Kind = Value_Discrete);
if Val.Typ.Drange.Is_Signed then
@@ -267,7 +267,7 @@ package body Synth.Expr is
Res.V (Iir_Index32 (Pos + 1)) := Val;
pragma Assert (not Is_Set (Pos + 1));
Is_Set (Pos + 1) := True;
- if Const_P and then not Is_Const (Val) then
+ if Const_P and then not Is_Static (Val) then
Const_P := False;
end if;
else
@@ -349,7 +349,7 @@ package body Synth.Expr is
Idx : Value_Acc;
begin
Idx := Synth_Expression (Syn_Inst, Ch);
- if not Is_Const (Idx) then
+ if not Is_Static (Idx) then
Error_Msg_Synth (+Ch, "choice is not static");
else
Set_Elem (Get_Index_Offset (Idx, Bound, Ch));
@@ -424,7 +424,7 @@ package body Synth.Expr is
Val := Synth_Expression_With_Type (Syn_Inst, Value, El_Type);
Rec.V (Iir_Index32 (Pos + 1)) := Synth_Subtype_Conversion
(Val, El_Type, False, Value);
- if Const_P and not Is_Const (Val) then
+ if Const_P and not Is_Static (Val) then
Const_P := False;
end if;
end Set_Elem;
@@ -522,7 +522,7 @@ package body Synth.Expr is
Strip_Const (L);
Strip_Const (R);
- if not (Is_Const (L) and Is_Const (R)) then
+ if not (Is_Static (L) and Is_Static (R)) then
Error_Msg_Synth (+Rng, "limits of range are not constant");
raise Internal_Error;
end if;
@@ -745,7 +745,7 @@ package body Synth.Expr is
for I in Flist_First .. Last loop
Val := Synth_Expression_With_Type
(Syn_Inst, Get_Nth_Element (Els, I), El_Typ);
- pragma Assert (Is_Const (Val));
+ pragma Assert (Is_Static (Val));
Arr.V (Iir_Index32 (Last - I + 1)) := Val;
end loop;
@@ -1028,7 +1028,7 @@ package body Synth.Expr is
end if;
end Synth_Indexed_Name;
- function Is_Const (N : Net) return Boolean is
+ function Is_Static (N : Net) return Boolean is
begin
case Get_Id (Get_Module (Get_Net_Parent (N))) is
when Id_Const_UB32 =>
@@ -1036,7 +1036,7 @@ package body Synth.Expr is
when others =>
return False;
end case;
- end Is_Const;
+ end Is_Static;
function Get_Const (N : Net) return Int32
is
@@ -1068,10 +1068,10 @@ package body Synth.Expr is
when Id_Add =>
Val_I0 := Get_Input_Net (Inst, 0);
Val_I1 := Get_Input_Net (Inst, 1);
- if Is_Const (Val_I0) then
+ if Is_Static (Val_I0) then
Addend := Addend + Get_Const (Val_I0) * Factor;
Inp := Val_I1;
- elsif Is_Const (Val_I1) then
+ elsif Is_Static (Val_I1) then
Addend := Addend + Get_Const (Val_I1) * Factor;
Inp := Val_I0;
else
@@ -1081,7 +1081,7 @@ package body Synth.Expr is
when Id_Sub =>
Val_I0 := Get_Input_Net (Inst, 0);
Val_I1 := Get_Input_Net (Inst, 1);
- if Is_Const (Val_I1) then
+ if Is_Static (Val_I1) then
Addend := Addend - Get_Const (Val_I1) * Factor;
Inp := Val_I0;
else
@@ -1091,10 +1091,10 @@ package body Synth.Expr is
when Id_Smul =>
Val_I0 := Get_Input_Net (Inst, 0);
Val_I1 := Get_Input_Net (Inst, 1);
- if Is_Const (Val_I0) then
+ if Is_Static (Val_I0) then
Factor := Factor * Get_Const (Val_I0);
Inp := Val_I1;
- elsif Is_Const (Val_I1) then
+ elsif Is_Static (Val_I1) then
Factor := Factor * Get_Const (Val_I1);
Inp := Val_I0;
else
@@ -1293,11 +1293,11 @@ package body Synth.Expr is
(+Expr, "only range expression supported for slices");
end case;
- if Is_Const_Val (Left) and then Is_Const_Val (Right) then
+ if Is_Static_Val (Left) and then Is_Static_Val (Right) then
Inp := No_Net;
Synth_Slice_Const_Suffix
(Name, Pfx_Bnd,
- Get_Const_Discrete (Left), Get_Const_Discrete (Right), Dir,
+ Get_Static_Discrete (Left), Get_Static_Discrete (Right), Dir,
El_Wd, Res_Bnd, Off, Wd);
else
if Pfx_Bnd.Dir /= Dir then
@@ -1308,7 +1308,7 @@ package body Synth.Expr is
return;
end if;
- if Is_Const (Left) or else Is_Const (Right) then
+ if Is_Static (Left) or else Is_Static (Right) then
Error_Msg_Synth
(+Name, "left and right bounds of a slice must be "
& "either constant or dynamic");
@@ -1456,7 +1456,7 @@ package body Synth.Expr is
return null;
end if;
when Iir_Kind_Floating_Subtype_Definition =>
- if Is_Const (Val) then
+ if Is_Static (Val) then
return Create_Value_Float (Fp64 (Val.Scal), Conv_Typ);
else
Error_Msg_Synth (+Conv, "unhandled type conversion (to float)");
@@ -1565,7 +1565,7 @@ package body Synth.Expr is
end case;
Left := Synth_Expression_With_Type (Syn_Inst, Left_Expr, Typ);
- if Is_Const_Val (Left) and then Get_Const_Discrete (Left) = Val then
+ if Is_Static_Val (Left) and then Get_Static_Discrete (Left) = Val then
return Create_Value_Discrete (Val, Boolean_Type);
end if;
@@ -1575,8 +1575,8 @@ package body Synth.Expr is
-- Return a static value if both operands are static.
-- Note: we know the value of left if it is not constant.
- if Is_Const_Val (Left) and then Is_Const_Val (Right) then
- Val := Get_Const_Discrete (Right);
+ if Is_Static_Val (Left) and then Is_Static_Val (Right) then
+ Val := Get_Static_Discrete (Right);
return Create_Value_Discrete (Val, Boolean_Type);
end if;
@@ -1667,7 +1667,7 @@ package body Synth.Expr is
begin
Synth_Assignment_Prefix (Syn_Inst, Expr,
Obj, Off, Voff, Rdwd, Typ);
- if Voff = No_Net and then Is_Const (Obj) then
+ if Voff = No_Net and then Is_Static (Obj) then
pragma Assert (Off = 0);
return Obj;
end if;
diff --git a/src/synth/synth-expr.ads b/src/synth/synth-expr.ads
index 0fc4eb697..50f85cbbc 100644
--- a/src/synth/synth-expr.ads
+++ b/src/synth/synth-expr.ads
@@ -36,7 +36,7 @@ package Synth.Expr is
Loc : Source.Syn_Src)
return Value_Acc;
- function Get_Const_Discrete (V : Value_Acc) return Int64;
+ function Get_Static_Discrete (V : Value_Acc) return Int64;
-- Return the bounds of a one dimensional array/vector type and the
-- width of the element.
diff --git a/src/synth/synth-insts.adb b/src/synth/synth-insts.adb
index 3665e8954..33072da57 100644
--- a/src/synth/synth-insts.adb
+++ b/src/synth/synth-insts.adb
@@ -556,7 +556,7 @@ package body Synth.Insts is
Val := Synth_Subtype_Conversion (Val, Inter_Type, True, Assoc);
- pragma Assert (Is_Const (Val));
+ pragma Assert (Is_Static (Val));
Create_Object (Sub_Inst, Inter, Val);
@@ -982,7 +982,7 @@ package body Synth.Insts is
Inter_Type := Get_Value_Type (Syn_Inst, Get_Type (Inter));
Val := Synth_Expression_With_Type
(Syn_Inst, Get_Default_Value (Inter), Inter_Type);
- pragma Assert (Is_Const (Val));
+ pragma Assert (Is_Static (Val));
Create_Object (Syn_Inst, Inter, Val);
end;
Inter := Get_Chain (Inter);
diff --git a/src/synth/synth-oper.adb b/src/synth/synth-oper.adb
index 7e063fdf7..884c9de10 100644
--- a/src/synth/synth-oper.adb
+++ b/src/synth/synth-oper.adb
@@ -57,7 +57,7 @@ package body Synth.Oper is
is
Res : Net;
begin
- if Is_Const (Val) and then Val.Typ.Kind = Type_Discrete then
+ if Is_Static (Val) and then Val.Typ.Kind = Type_Discrete then
if Val.Typ.Drange.Is_Signed and then Val.Scal < 0 then
-- TODO.
raise Internal_Error;
@@ -74,7 +74,7 @@ package body Synth.Oper is
is
Res : Net;
begin
- if Is_Const (Val) and then Val.Typ.Kind = Type_Discrete then
+ if Is_Static (Val) and then Val.Typ.Kind = Type_Discrete then
if Val.Typ.Drange.Is_Signed then
Res := Build2_Const_Int (Build_Context, Val.Scal, W);
else
@@ -95,7 +95,7 @@ package body Synth.Oper is
Zx : Uns32;
N : Net;
begin
- if Is_Const (Expr) then
+ if Is_Static (Expr) then
return Create_Value_Discrete (Boolean'Pos (Cst.Scal = Expr.Scal),
Boolean_Type);
end if;
@@ -378,7 +378,7 @@ package body Synth.Oper is
Right := Synth_Subtype_Conversion (Right, Right_Typ, False, Expr);
Strip_Const (Right);
- if Is_Const_Val (Left) and Is_Const_Val (Right) then
+ if Is_Static_Val (Left) and Is_Static_Val (Right) then
return Synth_Static_Dyadic_Predefined
(Syn_Inst, Imp, Left, Right, Expr);
end if;
@@ -438,9 +438,9 @@ package body Synth.Oper is
if Left_Typ = Bit_Type
or else Left_Typ = Logic_Type
then
- if Is_Const (Left) then
+ if Is_Static (Left) then
return Synth_Bit_Eq_Const (Left, Right, Expr);
- elsif Is_Const (Right) then
+ elsif Is_Static (Right) then
return Synth_Bit_Eq_Const (Right, Left, Expr);
end if;
end if;
@@ -591,7 +591,7 @@ package body Synth.Oper is
when Iir_Predefined_Ieee_Numeric_Std_Lt_Uns_Nat =>
-- "<" (Unsigned, Natural)
- if Is_Const (Right) and then Right.Scal = 0 then
+ if Is_Static (Right) and then Right.Scal = 0 then
-- Always false.
return Create_Value_Discrete (0, Boolean_Type);
end if;
@@ -679,7 +679,7 @@ package body Synth.Oper is
(N, Create_Onedimensional_Array_Subtype (Ret_Typ, Bnd));
end;
when Iir_Predefined_Array_Array_Concat =>
- if Is_Const (Left) and then Is_Const (Right) then
+ if Is_Static (Left) and then Is_Static (Right) then
declare
Ret_Typ : constant Type_Acc :=
Get_Value_Type (Syn_Inst, Get_Return_Type (Imp));
@@ -817,7 +817,7 @@ package body Synth.Oper is
return Synth_Bit_Monadic (Id_Not);
when Iir_Predefined_Boolean_Not
| Iir_Predefined_Bit_Not =>
- if Is_Const (Operand) then
+ if Is_Static (Operand) then
return Create_Value_Discrete (1 - Operand.Scal, Oper_Typ);
else
return Synth_Bit_Monadic (Id_Not);
@@ -850,7 +850,7 @@ package body Synth.Oper is
return Operand;
end if;
when Iir_Predefined_Integer_Negation =>
- if Is_Const (Operand) then
+ if Is_Static (Operand) then
return Create_Value_Discrete (-Operand.Scal, Operand.Typ);
else
declare
@@ -1038,7 +1038,7 @@ package body Synth.Oper is
R : constant Value_Acc := Get_Value (Subprg_Inst, Param2);
pragma Unreferenced (R);
begin
- if Is_Const (L) then
+ if Is_Static (L) then
raise Internal_Error;
end if;
return Create_Value_Net (Get_Net (L), Create_Res_Bound (L));
@@ -1051,13 +1051,13 @@ package body Synth.Oper is
Arg_Net : Net;
begin
Size := Get_Value (Subprg_Inst, Param2);
- if not Is_Const (Size) then
+ if not Is_Static (Size) then
Error_Msg_Synth (+Expr, "to_unsigned size must be constant");
return Arg;
else
Strip_Const (Size);
-- FIXME: what if the arg is constant too ?
- if Is_Const (Arg) then
+ if Is_Static (Arg) then
return Eval_To_Unsigned
(Arg.Scal, Size.Scal,
Get_Value_Type (Syn_Inst, Get_Type (Imp)));
@@ -1090,7 +1090,7 @@ package body Synth.Oper is
Sz : constant Value_Acc := Get_Value (Subprg_Inst, Param2);
W : Width;
begin
- if not Is_Const (Sz) then
+ if not Is_Static (Sz) then
Error_Msg_Synth (+Expr, "size must be constant");
return null;
end if;
@@ -1105,7 +1105,7 @@ package body Synth.Oper is
Sz : constant Value_Acc := Get_Value (Subprg_Inst, Param2);
W : Width;
begin
- if not Is_Const (Sz) then
+ if not Is_Static (Sz) then
Error_Msg_Synth (+Expr, "size must be constant");
return null;
end if;
@@ -1156,9 +1156,9 @@ package body Synth.Oper is
L : constant Value_Acc := Get_Value (Subprg_Inst, Param1);
R : constant Value_Acc := Get_Value (Subprg_Inst, Param2);
begin
- if Is_Const (L) then
+ if Is_Static (L) then
return Synth_Std_Match (L, R, Expr);
- elsif Is_Const (R) then
+ elsif Is_Static (R) then
return Synth_Std_Match (R, L, Expr);
else
Error_Msg_Synth
diff --git a/src/synth/synth-static_oper.adb b/src/synth/synth-static_oper.adb
index 5626427c6..4b301b128 100644
--- a/src/synth/synth-static_oper.adb
+++ b/src/synth/synth-static_oper.adb
@@ -129,15 +129,15 @@ package body Synth.Static_Oper is
when Iir_Predefined_Integer_Plus =>
return Create_Value_Discrete
- (Get_Const_Discrete (Left) + Get_Const_Discrete (Right),
+ (Get_Static_Discrete (Left) + Get_Static_Discrete (Right),
Res_Typ);
when Iir_Predefined_Integer_Minus =>
return Create_Value_Discrete
- (Get_Const_Discrete (Left) - Get_Const_Discrete (Right),
+ (Get_Static_Discrete (Left) - Get_Static_Discrete (Right),
Res_Typ);
when Iir_Predefined_Integer_Mul =>
return Create_Value_Discrete
- (Get_Const_Discrete (Left) * Get_Const_Discrete (Right),
+ (Get_Static_Discrete (Left) * Get_Static_Discrete (Right),
Res_Typ);
when Iir_Predefined_Integer_Div =>
return Create_Value_Discrete
@@ -165,12 +165,12 @@ package body Synth.Static_Oper is
(Boolean'Pos (Left.Scal > Right.Scal), Boolean_Type);
when Iir_Predefined_Integer_Equality =>
return Create_Value_Discrete
- (Boolean'Pos (Get_Const_Discrete (Left)
- = Get_Const_Discrete (Right)), Boolean_Type);
+ (Boolean'Pos (Get_Static_Discrete (Left)
+ = Get_Static_Discrete (Right)), Boolean_Type);
when Iir_Predefined_Integer_Inequality =>
return Create_Value_Discrete
- (Boolean'Pos (Get_Const_Discrete (Left)
- /= Get_Const_Discrete (Right)), Boolean_Type);
+ (Boolean'Pos (Get_Static_Discrete (Left)
+ /= Get_Static_Discrete (Right)), Boolean_Type);
when Iir_Predefined_Physical_Physical_Div =>
return Create_Value_Discrete
(Left.Scal / Right.Scal, Res_Typ);
diff --git a/src/synth/synth-stmts.adb b/src/synth/synth-stmts.adb
index 5cf3e0e67..a510d1765 100644
--- a/src/synth/synth-stmts.adb
+++ b/src/synth/synth-stmts.adb
@@ -451,7 +451,7 @@ package body Synth.Stmts is
Synth_Assign (Target.Obj.W, Target.Targ_Type,
Val, Target.Off, Loc);
else
- if not Is_Const (Val) then
+ if not Is_Static (Val) then
-- Maybe the error message is too cryptic ?
Error_Msg_Synth
(+Loc, "cannot assign a net to a static value");
@@ -502,7 +502,7 @@ package body Synth.Stmts is
N := Build_Dyn_Extract
(Get_Build (Syn_Inst), Get_Net (Obj), Voff, Off, Typ.W);
else
- pragma Assert (not Is_Const (Obj));
+ pragma Assert (not Is_Static (Obj));
if Off = 0
and then Typ.W = Obj.Typ.W
and then Typ /= Get_Array_Element (Obj.Typ)
@@ -625,7 +625,7 @@ package body Synth.Stmts is
Phi_False : Phi_Type;
begin
Cond_Val := Synth_Expression (C.Inst, Cond);
- if Is_Const (Cond_Val) then
+ if Is_Static (Cond_Val) then
if Cond_Val.Scal = 1 then
-- True.
Synth_Sequential_Statements
@@ -1356,7 +1356,7 @@ package body Synth.Stmts is
-- FIXME: conversion only for constants, reshape for all.
Val := Synth_Subtype_Conversion (Val, Inter_Type, True, Assoc);
- if Get_Instance_Const (Subprg_Inst) and then not Is_Const (Val) then
+ if Get_Instance_Const (Subprg_Inst) and then not Is_Static (Val) then
Set_Instance_Const (Subprg_Inst, False);
end if;
@@ -1537,7 +1537,7 @@ package body Synth.Stmts is
if Is_Func then
if C.Nbr_Ret = 0 then
raise Internal_Error;
- elsif C.Nbr_Ret = 1 and then Is_Const (C.Ret_Value) then
+ elsif C.Nbr_Ret = 1 and then Is_Static (C.Ret_Value) then
Res := C.Ret_Value;
else
Res := Create_Value_Net
@@ -1845,7 +1845,7 @@ package body Synth.Stmts is
loop
if Cond /= Null_Node then
Val := Synth_Expression_With_Type (C.Inst, Cond, Boolean_Type);
- if not Is_Const (Val) then
+ if not Is_Static (Val) then
Error_Msg_Synth (+Cond, "loop condition must be static");
exit;
end if;
@@ -2088,7 +2088,7 @@ package body Synth.Stmts is
Inst : Instance;
begin
Val := Synth_Expression (Syn_Inst, Cond);
- if Is_Const (Val) then
+ if Is_Static (Val) then
if Val.Scal /= 1 then
raise Internal_Error;
end if;
diff --git a/src/synth/synth-values.adb b/src/synth/synth-values.adb
index b8bd2cfad..9e1aef9eb 100644
--- a/src/synth/synth-values.adb
+++ b/src/synth/synth-values.adb
@@ -39,7 +39,7 @@ package body Synth.Values is
function To_Value_Array_Acc is new Ada.Unchecked_Conversion
(System.Address, Values.Value_Array_Acc);
- function Is_Const (Val : Value_Acc) return Boolean is
+ function Is_Static (Val : Value_Acc) return Boolean is
begin
case Val.Kind is
when Value_Discrete
@@ -58,7 +58,7 @@ package body Synth.Values is
| Value_File =>
return False;
when Value_Alias =>
- return Is_Const (Val.A_Obj);
+ return Is_Static (Val.A_Obj);
when Value_Const =>
return True;
when Value_Instance
@@ -66,9 +66,9 @@ package body Synth.Values is
-- Not really a value.
raise Internal_Error;
end case;
- end Is_Const;
+ end Is_Static;
- function Is_Const_Val (Val : Value_Acc) return Boolean is
+ function Is_Static_Val (Val : Value_Acc) return Boolean is
begin
case Val.Kind is
when Value_Discrete
@@ -96,7 +96,7 @@ package body Synth.Values is
-- Not really a value.
raise Internal_Error;
end case;
- end Is_Const_Val;
+ end Is_Static_Val;
function Is_Bounded_Type (Typ : Type_Acc) return Boolean is
begin
diff --git a/src/synth/synth-values.ads b/src/synth/synth-values.ads
index 03fa9d52e..a1e75d1bd 100644
--- a/src/synth/synth-values.ads
+++ b/src/synth/synth-values.ads
@@ -278,10 +278,11 @@ package Synth.Values is
function Is_Bounded_Type (Typ : Type_Acc) return Boolean;
- function Is_Const (Val : Value_Acc) return Boolean;
+ -- True if VAL is static, ie contains neither nets nor wires.
+ function Is_Static (Val : Value_Acc) return Boolean;
-- Can also return true for nets and wires.
- function Is_Const_Val (Val : Value_Acc) return Boolean;
+ function Is_Static_Val (Val : Value_Acc) return Boolean;
function Is_Equal (L, R : Value_Acc) return Boolean;