aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTristan Gingold <tgingold@free.fr>2021-02-12 18:12:04 +0100
committerTristan Gingold <tgingold@free.fr>2021-02-12 18:12:55 +0100
commit7cf780c73be8429720195ddeaeb3682b106f4c38 (patch)
tree606288cd3781746e82e1640fb995896dac2a767e /src
parenta2664544dc58caaedf84cd235aa3ee17b164f1f3 (diff)
downloadghdl-7cf780c73be8429720195ddeaeb3682b106f4c38.tar.gz
ghdl-7cf780c73be8429720195ddeaeb3682b106f4c38.tar.bz2
ghdl-7cf780c73be8429720195ddeaeb3682b106f4c38.zip
synth-expr: compute signess for range array attributes. Fix #1645
Diffstat (limited to 'src')
-rw-r--r--src/synth/synth-decls.adb3
-rw-r--r--src/synth/synth-expr.adb21
-rw-r--r--src/synth/synth-expr.ads2
3 files changed, 9 insertions, 17 deletions
diff --git a/src/synth/synth-decls.adb b/src/synth/synth-decls.adb
index db510e856..f1835e5b9 100644
--- a/src/synth/synth-decls.adb
+++ b/src/synth/synth-decls.adb
@@ -304,8 +304,7 @@ package body Synth.Decls is
begin
L := Get_Value (Get_Left_Limit (Cst));
R := Get_Value (Get_Right_Limit (Cst));
- Rng := Synth_Discrete_Range_Expression
- (L, R, Get_Direction (Cst));
+ Rng := Build_Discrete_Range_Type (L, R, Get_Direction (Cst));
W := Discrete_Range_Width (Rng);
Typ := Create_Discrete_Type
(Rng, Scalar_Size_To_Size (Def), W);
diff --git a/src/synth/synth-expr.adb b/src/synth/synth-expr.adb
index 0e3849149..ad5d2f50b 100644
--- a/src/synth/synth-expr.adb
+++ b/src/synth/synth-expr.adb
@@ -425,14 +425,14 @@ package body Synth.Expr is
N := Arr (Arr'First);
end Concat_Array;
- function Synth_Discrete_Range_Expression
+ function Build_Discrete_Range_Type
(L : Int64; R : Int64; Dir : Direction_Type) return Discrete_Range_Type is
begin
return (Dir => Dir,
Left => L,
Right => R,
Is_Signed => L < 0 or R < 0);
- end Synth_Discrete_Range_Expression;
+ end Build_Discrete_Range_Type;
function Synth_Discrete_Range_Expression
(Syn_Inst : Synth_Instance_Acc; Rng : Node) return Discrete_Range_Type
@@ -457,10 +457,7 @@ package body Synth.Expr is
Lval := Read_Discrete (L);
Rval := Read_Discrete (R);
- return (Dir => Get_Direction (Rng),
- Left => Lval,
- Right => Rval,
- Is_Signed => Lval < 0 or Rval < 0);
+ return Build_Discrete_Range_Type (Lval, Rval, Get_Direction (Rng));
end Synth_Discrete_Range_Expression;
function Synth_Float_Range_Expression
@@ -595,10 +592,8 @@ package body Synth.Expr is
B : Bound_Type;
begin
B := Synth_Array_Attribute (Syn_Inst, Bound);
- Rng := Discrete_Range_Type'(Dir => B.Dir,
- Is_Signed => True,
- Left => Int64 (B.Left),
- Right => Int64 (B.Right));
+ Rng := Build_Discrete_Range_Type
+ (Int64 (B.Left), Int64 (B.Right), B.Dir);
end;
when Iir_Kind_Reverse_Range_Array_Attribute =>
declare
@@ -617,10 +612,8 @@ package body Synth.Expr is
B.Right := B.Left;
B.Left := T;
- Rng := Discrete_Range_Type'(Dir => B.Dir,
- Is_Signed => True,
- Left => Int64 (B.Left),
- Right => Int64 (B.Right));
+ Rng := Build_Discrete_Range_Type
+ (Int64 (B.Left), Int64 (B.Right), B.Dir);
end;
when Iir_Kinds_Denoting_Name =>
-- A discrete subtype name.
diff --git a/src/synth/synth-expr.ads b/src/synth/synth-expr.ads
index 0d1c92fa3..2d977c70c 100644
--- a/src/synth/synth-expr.ads
+++ b/src/synth/synth-expr.ads
@@ -100,7 +100,7 @@ package Synth.Expr is
Atype : Node;
Dim : Dim_Type) return Bound_Type;
- function Synth_Discrete_Range_Expression
+ function Build_Discrete_Range_Type
(L : Int64; R : Int64; Dir : Direction_Type) return Discrete_Range_Type;
function Synth_Discrete_Range_Expression
(Syn_Inst : Synth_Instance_Acc; Rng : Node) return Discrete_Range_Type;