aboutsummaryrefslogtreecommitdiffstats
path: root/translate/grt
diff options
context:
space:
mode:
authorTristan Gingold <tgingold@free.fr>2014-05-29 13:45:07 +0200
committerTristan Gingold <tgingold@free.fr>2014-05-29 13:45:07 +0200
commit3ab38c9b97e4e268d7ea5ae09e8acd2658c753e0 (patch)
tree8e66a1da3fea6327e9ac57dd56e5806643d22acb /translate/grt
parent192f73f79c4f275a18c398e5f85e12dd5a62391b (diff)
downloadghdl-3ab38c9b97e4e268d7ea5ae09e8acd2658c753e0.tar.gz
ghdl-3ab38c9b97e4e268d7ea5ae09e8acd2658c753e0.tar.bz2
ghdl-3ab38c9b97e4e268d7ea5ae09e8acd2658c753e0.zip
grt-signals: add comments, add Ghdl_Signal_Set_Mode.
Diffstat (limited to 'translate/grt')
-rw-r--r--translate/grt/grt-signals.adb76
-rw-r--r--translate/grt/grt-signals.ads45
-rw-r--r--translate/grt/grt-types.ads1
3 files changed, 86 insertions, 36 deletions
diff --git a/translate/grt/grt-signals.adb b/translate/grt/grt-signals.adb
index 4443bd936..dfcda9694 100644
--- a/translate/grt/grt-signals.adb
+++ b/translate/grt/grt-signals.adb
@@ -48,25 +48,26 @@ package body Grt.Signals is
end Free_In;
pragma Inline (Free_In);
- function Is_Signal_Guarded (Sig : Ghdl_Signal_Ptr) return Boolean
- is
- begin
- return (Sig.Rti.Common.Mode and Ghdl_Rti_Signal_Kind_Mask)
- /= Ghdl_Rti_Signal_Kind_No;
- end Is_Signal_Guarded;
-
+ -- RTI for the current signal.
Sig_Rti : Ghdl_Rtin_Object_Acc;
+
+ -- Signal mode (and flags) for the current signal.
+ Sig_Mode : Mode_Signal_Type;
+ Sig_Has_Active : Boolean;
+ Sig_Kind : Kind_Signal_Type;
+
+ -- Last created implicit signal. This is used to add dependencies on
+ -- the prefix.
Last_Implicit_Signal : Ghdl_Signal_Ptr;
+
+ -- Current signal resolver.
Current_Resolv : Resolved_Signal_Acc := null;
- function Get_Current_Mode_Signal return Mode_Signal_Type
- is
+ function Get_Current_Mode_Signal return Mode_Signal_Type is
begin
- return Mode_Signal_Type'Val
- (Sig_Rti.Common.Mode and Ghdl_Rti_Signal_Mode_Mask);
+ return Sig_Mode;
end Get_Current_Mode_Signal;
-
procedure Ghdl_Signal_Name_Rti (Sig : Ghdl_Rti_Access;
Ctxt : Ghdl_Rti_Access;
Addr : Address)
@@ -75,8 +76,30 @@ package body Grt.Signals is
pragma Unreferenced (Addr);
begin
Sig_Rti := To_Ghdl_Rtin_Object_Acc (Sig);
+ Sig_Mode := Mode_Signal_Type'Val
+ (Sig.Mode and Ghdl_Rti_Signal_Mode_Mask);
+ Sig_Kind := Kind_Signal_Type'Val
+ ((Sig.Mode and Ghdl_Rti_Signal_Kind_Mask)
+ / Ghdl_Rti_Signal_Kind_Offset);
+ Sig_Has_Active :=
+ (Sig_Rti.Common.Mode and Ghdl_Rti_Signal_Has_Active) /= 0;
end Ghdl_Signal_Name_Rti;
+ procedure Ghdl_Signal_Set_Mode (Mode : Mode_Signal_Type;
+ Kind : Kind_Signal_Type;
+ Has_Active : Boolean) is
+ begin
+ Sig_Rti := null;
+ Sig_Mode := Mode;
+ Sig_Kind := Kind;
+ Sig_Has_Active := Has_Active;
+ end Ghdl_Signal_Set_Mode;
+
+ function Is_Signal_Guarded (Sig : Ghdl_Signal_Ptr) return Boolean is
+ begin
+ return Sig.Sig_Kind /= Kind_Signal_No;
+ end Is_Signal_Guarded;
+
function To_Address is new Ada.Unchecked_Conversion
(Source => Ghdl_Signal_Ptr, Target => Address);
@@ -148,6 +171,7 @@ package body Grt.Signals is
Event => False,
Active => False,
Has_Active => False,
+ Sig_Kind => Sig_Kind,
Mode => Mode,
Flags => (Propag => Propag_None,
@@ -176,9 +200,7 @@ package body Grt.Signals is
when Activity_All =>
Res.Has_Active := True;
when Activity_Minimal =>
- if (Sig_Rti.Common.Mode and Ghdl_Rti_Signal_Has_Active) /= 0 then
- Res.Has_Active := True;
- end if;
+ Res.Has_Active := Sig_Has_Active;
when Activity_None =>
Res.Has_Active := False;
end case;
@@ -237,11 +259,12 @@ package body Grt.Signals is
-- LRM 4.3.1.2 Signal Declaration
-- It is an error if, after the elaboration of a description, a
-- signal has multiple sources and it is not a resolved signal.
- Put ("for signal: ");
- Disp_Signals.Put_Signal_Name (stderr, Sig);
- New_Line (stderr);
+ if Sig.Rti /= null then
+ Put ("for signal: ");
+ Disp_Signals.Put_Signal_Name (stderr, Sig);
+ New_Line (stderr);
+ end if;
Error ("several sources for unresolved signal");
- -- FIXME: display signal name.
elsif Sig.S.Mode_Sig = Mode_Buffer and False then
-- LRM 1.1.1.2 Ports
-- A BUFFER port may have at most one source.
@@ -1359,7 +1382,7 @@ package body Grt.Signals is
Res := Create_Signal
(Mode_B2, Value_Union'(Mode => Mode_B2, B2 => True),
Mode, null, Null_Address);
-
+ Sig_Rti := null;
Last_Implicit_Signal := Res;
if Mode /= Mode_Transaction then
@@ -1429,6 +1452,7 @@ package body Grt.Signals is
Res := Create_Signal
(Mode_B2, Value_Union'(Mode => Mode_B2, B2 => Proc.all (This)),
Mode_Guard, null, Null_Address);
+ Sig_Rti := null;
Res.S.Guard_Func := Proc;
Res.S.Guard_Instance := This;
Last_Implicit_Signal := Res;
@@ -1812,9 +1836,9 @@ package body Grt.Signals is
end loop;
-- if no driving sources and register, exit.
- if Length = 0 and then Sig.Nbr_Ports = 0
- and then ((Sig.Rti.Common.Mode and Ghdl_Rti_Signal_Kind_Mask)
- = Ghdl_Rti_Signal_Kind_Register)
+ if Length = 0
+ and then Sig.Nbr_Ports = 0
+ and then Sig.Sig_Kind = Kind_Signal_Register
then
return;
end if;
@@ -1828,11 +1852,6 @@ package body Grt.Signals is
Sig.Nbr_Ports);
end Compute_Resolved_Signal;
- type Conversion_Func_Acc is access procedure (Instance : System.Address);
- pragma Convention (C, Conversion_Func_Acc);
- function To_Conversion_Func_Acc is new Ada.Unchecked_Conversion
- (Source => System.Address, Target => Conversion_Func_Acc);
-
procedure Call_Conversion_Function (Conv : Sig_Conversion_Acc)
is
F : Conversion_Func_Acc;
@@ -3305,6 +3324,7 @@ package body Grt.Signals is
Event => False,
Active => False,
Has_Active => False,
+ Sig_Kind => Kind_Signal_No,
Mode => Mode_B2,
Flags => (Propag => Propag_None,
diff --git a/translate/grt/grt-signals.ads b/translate/grt/grt-signals.ads
index 76595c75b..eac47a782 100644
--- a/translate/grt/grt-signals.ads
+++ b/translate/grt/grt-signals.ads
@@ -166,6 +166,12 @@ package Grt.Signals is
type Resolved_Signal_Acc is access Resolved_Signal_Type;
+ type Conversion_Func_Acc is access procedure (Instance : System.Address);
+ pragma Convention (C, Conversion_Func_Acc);
+
+ function To_Conversion_Func_Acc is new Ada.Unchecked_Conversion
+ (Source => System.Address, Target => Conversion_Func_Acc);
+
-- Signal conversion data.
type Sig_Conversion_Type is record
-- Function which performs the conversion.
@@ -287,6 +293,11 @@ package Grt.Signals is
Has_Active : Boolean;
-- Internal fields.
+ -- NOTE: keep above fields (components) in sync with translation.
+
+ -- Kind of the signal (none, bus or register).
+ Sig_Kind : Kind_Signal_Type;
+
-- Values mode of this signal.
Mode : Mode_Type;
@@ -468,16 +479,25 @@ package Grt.Signals is
(Sig : Ghdl_Signal_Ptr; Proc : Process_Acc);
-- Creating a signal:
- -- 1) call Ghdl_Signal_Name_Rti (CTXT and ADDR are unused) to register
- -- the RTI for the whole signal (in particular the mode and the
- -- has_active flag)
+ -- 1a) call Ghdl_Signal_Name_Rti (CTXT and ADDR are unused) to register
+ -- the RTI for the whole signal (in particular the mode and the
+ -- has_active flag)
+ -- or
+ -- 1b) call Ghdl_Signal_Set_Mode to register the mode and the has_active
+ -- flag. In that case, the signal has no name.
+ --
-- 2) call Ghdl_Create_Signal_XXX for each non-composite element
procedure Ghdl_Signal_Name_Rti (Sig : Ghdl_Rti_Access;
Ctxt : Ghdl_Rti_Access;
Addr : System.Address);
+ procedure Ghdl_Signal_Set_Mode (Mode : Mode_Signal_Type;
+ Kind : Kind_Signal_Type;
+ Has_Active : Boolean);
+
-- FIXME: document.
+ -- Merge RTI with SIG: adjust the has_active flag of SIG according to RTI.
procedure Ghdl_Signal_Merge_Rti (Sig : Ghdl_Signal_Ptr;
Rti : Ghdl_Rti_Access);
@@ -641,13 +661,28 @@ package Grt.Signals is
procedure Ghdl_Signal_Add_Source (Targ : Ghdl_Signal_Ptr;
Src : Ghdl_Signal_Ptr);
+ -- The effective value of TARG is the effective value of SRC.
+ procedure Ghdl_Signal_Effective_Value (Targ : Ghdl_Signal_Ptr;
+ Src : Ghdl_Signal_Ptr);
+
+ -- Conversions. In order to do conversion from A to B, an intermediate
+ -- signal T must be created. The flow is A -> T -> B.
+ -- The link from A -> T is a conversion, added by one of the two
+ -- following procedures. The type of A and T is different.
+ -- The link from T -> B is a normal connection: either an effective
+ -- one (for in conversion) or a source (for out conversion).
+
-- Add an in conversion (from SRC to DEST using function FUNC).
+ -- The effective value can be read and writen directly.
procedure Ghdl_Signal_In_Conversion (Func : System.Address;
Instance : System.Address;
Src : Ghdl_Signal_Ptr;
Src_Len : Ghdl_Index_Type;
Dst : Ghdl_Signal_Ptr;
Dst_Len : Ghdl_Index_Type);
+
+ -- Add an out conversion.
+ -- The driving value can be read and writen directly.
procedure Ghdl_Signal_Out_Conversion (Func : System.Address;
Instance : System.Address;
Src : Ghdl_Signal_Ptr;
@@ -661,10 +696,6 @@ package Grt.Signals is
Sig : System.Address;
Nbr_Sig : Ghdl_Index_Type);
- -- The effective value of TARG is the effective value of SRC.
- procedure Ghdl_Signal_Effective_Value (Targ : Ghdl_Signal_Ptr;
- Src : Ghdl_Signal_Ptr);
-
-- Create a new 'stable (VAL) signal. The prefixes are set by
-- ghdl_signal_attribute_register_prefix.
function Ghdl_Create_Stable_Signal (Val : Std_Time) return Ghdl_Signal_Ptr;
diff --git a/translate/grt/grt-types.ads b/translate/grt/grt-types.ads
index 1b6db8d42..acefe3376 100644
--- a/translate/grt/grt-types.ads
+++ b/translate/grt/grt-types.ads
@@ -277,7 +277,6 @@ package Grt.Types is
-- Kind of a signal.
type Kind_Signal_Type is
(Kind_Signal_No, Kind_Signal_Register, Kind_Signal_Bus);
- pragma Convention (C, Kind_Signal_Type);
-- Note: we could use system.storage_elements, but unfortunatly,
-- this doesn't work with pragma no_run_time (gnat 3.15p).