📄 grt-signals.ads
字号:
-- GHDL Run Time (GRT) - signals management.-- Copyright (C) 2002, 2003, 2004, 2005 Tristan Gingold---- GHDL is free software; you can redistribute it and/or modify it under-- the terms of the GNU General Public License as published by the Free-- Software Foundation; either version 2, or (at your option) any later-- version.---- GHDL is distributed in the hope that it will be useful, but WITHOUT ANY-- WARRANTY; without even the implied warranty of MERCHANTABILITY or-- FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License-- for more details.---- You should have received a copy of the GNU General Public License-- along with GCC; see the file COPYING. If not, write to the Free-- Software Foundation, 59 Temple Place - Suite 330, Boston, MA-- 02111-1307, USA.with System;with Ada.Unchecked_Conversion;with GNAT.Table;with Grt.Types; use Grt.Types;with Grt.Rtis; use Grt.Rtis;package Grt.Signals is pragma Suppress (All_Checks); -- Kind of transaction. type Transaction_Kind is ( -- Normal transaction, with a value. Trans_Value, -- Null transaction. Trans_Null, -- Like a normal transaction, but without a value due to check error. Trans_Error ); type Transaction; type Transaction_Acc is access Transaction; type Transaction (Kind : Transaction_Kind) is record Time : Std_Time; Next : Transaction_Acc; case Kind is when Trans_Value => Val : Value_Union; when Trans_Null => null; when Trans_Error => -- FIXME: should have a location field, to be able to display -- a message. null; end case; end record; -- A driver is bound to a process (PROC) and contains a list of -- transactions. type Driver_Type is record First_Trans : Transaction_Acc; Last_Trans : Transaction_Acc; Proc : Process_Id; end record; type Driver_Acc is access all Driver_Type; type Driver_Fat_Array is array (Ghdl_Index_Type) of aliased Driver_Type; type Driver_Arr_Ptr is access Driver_Fat_Array; -- Function access type used to evaluate the guard expression. type Guard_Func_Acc is access function (This : System.Address) return Ghdl_B2; -- Simply linked list of processes to be resumed in case of events. type Ghdl_Signal; type Ghdl_Signal_Ptr is access Ghdl_Signal; function To_Ghdl_Signal_Ptr is new Ada.Unchecked_Conversion (Source => System.Address, Target => Ghdl_Signal_Ptr); type Signal_Fat_Array is array (Ghdl_Index_Type) of Ghdl_Signal_Ptr; type Signal_Arr_Ptr is access Signal_Fat_Array; function To_Signal_Arr_Ptr is new Ada.Unchecked_Conversion (Source => System.Address, Target => Signal_Arr_Ptr); type Action_List; type Action_List_Acc is access Action_List; type Action_Kind is (Action_Signal, Action_Process); type Action_List (Kind : Action_Kind) is record Next : Action_List_Acc; case Kind is when Action_Signal => Sig : Ghdl_Signal_Ptr; when Action_Process => Proc : Process_Id; end case; end record; -- How to compute resolved signal. type Resolved_Signal_Type is record Resolv_Proc : System.Address; Resolv_Inst : System.Address; Resolv_Ptr : System.Address; Sig_Range : Sig_Table_Range; Disconnect_Time : Std_Time; end record; type Resolved_Signal_Acc is access Resolved_Signal_Type; -- Signal conversion data. type Sig_Conversion_Type is record -- Function which performs the conversion. Func : System.Address; Instance : System.Address; Src : Sig_Table_Range; Dest : Sig_Table_Range; end record; type Sig_Conversion_Acc is access Sig_Conversion_Type; -- Used to order the signals for the propagation of signals values. type Propag_Order_Flag is ( -- The signal was not yet ordered. Propag_None, -- The signal is being ordered for driving value. -- This stage is used to catch loop (which can not occur). Propag_Being_Driving, -- The signal has been ordered for driving value. Propag_Driving, -- The signal is being ordered for effective value. Propag_Being_Effective, -- The signal has completly been ordered. Propag_Done); -- Each signal belongs to a signal_net. -- Signals on the same net must be updated in order. -- Signals on different nets have no direct relation-ship, and thus may -- be updated without order. -- Net NO_SIGNAL_NET is special: it groups all lonely signals. type Signal_Net_Type is new Integer; No_Signal_Net : constant Signal_Net_Type := 0; Net_One_Driver : constant Signal_Net_Type := -1; Net_One_Resolved : constant Signal_Net_Type := -2; -- Flush the list of active signals. procedure Flush_Active_List; type Ghdl_Signal_Data (Mode_Sig : Mode_Signal_Type := Mode_Signal) is record case Mode_Sig is when Mode_Signal_User => Nbr_Drivers : Ghdl_Index_Type; Drivers : Driver_Arr_Ptr; -- Signal which defines the effective value of this signal, -- if any. Effective : Ghdl_Signal_Ptr; -- Null if not resolved. Resolv : Resolved_Signal_Acc; when Mode_Conv_In | Mode_Conv_Out => -- Conversion paramaters for conv_in, conv_out. Conv : Sig_Conversion_Acc; when Mode_Stable | Mode_Quiet | Mode_Delayed => -- Time parameter for 'stable, 'quiet or 'delayed Time : Std_Time; Attr_Trans : Transaction_Acc; when Mode_Guard => -- Guard function and instance used to compute the -- guard expression. Guard_Func : Guard_Func_Acc; Guard_Instance : System.Address; when Mode_Transaction | Mode_End => null; end case; end record; pragma Suppress (Discriminant_Check, On => Ghdl_Signal_Data); type Ghdl_Signal_Flags is record -- Status of the ordering. Propag : Propag_Order_Flag; -- If set, the activity of the signal is required by the user. Has_Active : Boolean; -- If set, the signal is dumped in a GHW file. Is_Dumped : Boolean; -- Set when an event occured. -- Only reset by GHW file dumper. Cyc_Event : Boolean; end record; pragma Pack (Ghdl_Signal_Flags); type Ghdl_Signal is record -- Fields known by ghdl. Value : Value_Union; Driving_Value : Value_Union; Last_Value : Value_Union; Last_Event : Std_Time; Last_Active : Std_Time; Event : Boolean; Active : Boolean; -- Internal fields. -- Values mode of this signal. Mode : Mode_Type; -- Misc flags. Flags : Ghdl_Signal_Flags; -- Net of the signal. Net : Signal_Net_Type; -- Chain of signals. -- Used to build nets. -- This is also the simply linked list of future active signals. Link : Ghdl_Signal_Ptr; -- Chain of signals whose active flag was set. Used to clear it. Alink : Ghdl_Signal_Ptr; -- Chain of signals that have a projected waveform in the real future. Flink : Ghdl_Signal_Ptr; -- List of processes to resume when there is an event on -- this signal. Event_List : Action_List_Acc; -- Path of the signal (with its name) in the design hierarchy. -- Used to get the type of the signal. Rti : Ghdl_Rtin_Object_Acc; -- For user signals: the sources of a signals are drivers -- and connected ports. -- For implicit signals: PORTS is used as dependence list. Nbr_Ports : Ghdl_Index_Type; Ports : Signal_Arr_Ptr; -- Mode of the signal (in, out ...) --Mode_Signal : Mode_Signal_Type; S : Ghdl_Signal_Data; end record; -- Each simple signal declared can be accessed by SIG_TABLE. package Sig_Table is new GNAT.Table (Table_Component_Type => Ghdl_Signal_Ptr, Table_Index_Type => Sig_Table_Index, Table_Low_Bound => 0, Table_Initial => 128, Table_Increment => 100); -- Return the next time at which a driver becomes active. function Find_Next_Time return Std_Time; -- Elementary propagation computation. -- See LRM 12.6.2 and 12.6.3 type Propagation_Kind_Type is ( -- How to compute driving value: -- Default value. Drv_Error, -- One source, a driver and not resolved: -- the driving value is the driver. Drv_One_Driver, -- Same as previous, and the effective value is the driving value. Eff_One_Driver, -- One source, a port and not resolved: -- the driving value is the driving value of the port. -- Dependence. Drv_One_Port, -- Same as previous, and the effective value is the driving value. Eff_One_Port, -- Several sources or resolved: -- signal is not composite. Drv_One_Resolved, Eff_One_Resolved, -- Use the resolution function, signal is composite. Drv_Multiple, -- Same as previous, but the effective value is the previous value. Eff_Multiple, -- The effective value is the actual associated. Eff_Actual, -- Implicit guard signal. -- Its value must be evaluated after the effective value of its -- dependences. Imp_Guard, -- Implicit stable. -- Its value must be evaluated after the effective value of its -- dependences. Imp_Stable, -- Implicit quiet. -- Its value must be evaluated after the driving value of its -- dependences. Imp_Quiet, -- Implicit transaction. -- Its value must be evaluated after the driving value of its -- dependences. Imp_Transaction, -- Implicit delayed -- Its value must be evaluated after the driving value of its -- dependences. Imp_Delayed, -- in_conversion. -- Pseudo-signal which is set by conversion function. In_Conversion, Out_Conversion, -- End of propagation. Prop_End ); type Propagation_Type (Kind : Propagation_Kind_Type := Drv_Error) is record case Kind is when Drv_Error => null; when Drv_One_Driver | Eff_One_Driver | Drv_One_Port | Eff_One_Port | Imp_Guard | Imp_Quiet | Imp_Transaction | Imp_Stable | Imp_Delayed | Eff_Actual | Eff_One_Resolved | Drv_One_Resolved => Sig : Ghdl_Signal_Ptr; when Drv_Multiple | Eff_Multiple => Resolv : Resolved_Signal_Acc; when In_Conversion | Out_Conversion => Conv : Sig_Conversion_Acc; when Prop_End => Updated : Boolean; end case; end record;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -