1--  GHDL Run Time (GRT) - VCD generator.
2--  Copyright (C) 2002 - 2014 Tristan Gingold
3--
4--  This program is free software: you can redistribute it and/or modify
5--  it under the terms of the GNU General Public License as published by
6--  the Free Software Foundation, either version 2 of the License, or
7--  (at your option) any later version.
8--
9--  This program is distributed in the hope that it will be useful,
10--  but WITHOUT ANY WARRANTY; without even the implied warranty of
11--  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12--  GNU General Public License for more details.
13--
14--  You should have received a copy of the GNU General Public License
15--  along with this program.  If not, see <gnu.org/licenses>.
16--
17--  As a special exception, if other files instantiate generics from this
18--  unit, or you link this unit with other files to produce an executable,
19--  this unit does not by itself cause the resulting executable to be
20--  covered by the GNU General Public License. This exception does not
21--  however invalidate any other reasons why the executable file might be
22--  covered by the GNU Public License.
23
24with System;
25with Grt.Types; use Grt.Types;
26with Grt.Avhpi; use Grt.Avhpi;
27with Grt.Rtis;
28
29package Grt.Vcd is
30   --  Abstract type for IO.
31   type Vcd_Put_Acc is access procedure (Str : String);
32   type Vcd_Putc_Acc is access procedure (C : Character);
33   type Vcd_Close_Acc is access procedure;
34
35   Vcd_Put : Vcd_Put_Acc;
36   Vcd_Putc : Vcd_Putc_Acc;
37   Vcd_Close : Vcd_Close_Acc;
38
39   --  VCD type of an object
40   type Vcd_Var_Type is
41     (
42      --  Incompatible vcd type
43      Vcd_Bad,
44
45      --  A user-defined enumerated type (other than bit or boolean)
46      Vcd_Enum8,
47
48      --  Boolean
49      Vcd_Bool,
50
51      --  32bit integer
52      Vcd_Integer32,
53
54      --  64bit float
55      Vcd_Float64,
56
57      --  A bit type
58      Vcd_Bit, Vcd_Stdlogic,
59
60      --  A bit vector type
61      Vcd_Bitvector, Vcd_Stdlogic_Vector
62     );
63
64   subtype Vcd_Var_Vectors is Vcd_Var_Type
65     range Vcd_Bitvector .. Vcd_Stdlogic_Vector;
66
67   --  Which value to be displayed: effective or driving (for out signals).
68   type Vcd_Value_Kind is (Vcd_Effective, Vcd_Driving, Vcd_Variable);
69
70   --  For signals.
71   subtype Vcd_Value_Signals is Vcd_Value_Kind
72     range Vcd_Effective .. Vcd_Driving;
73
74   type Verilog_Wire_Info (Vtype : Vcd_Var_Type := Vcd_Bad) is record
75      Val : Vcd_Value_Kind;
76
77      --  Access to an array of signals or access to the value.
78      Ptr : System.Address;
79
80      case Vtype is
81         when Vcd_Var_Vectors =>
82            --  Vector bounds.
83            Irange : Ghdl_Range_Ptr;
84         when Vcd_Enum8 =>
85            --  Base type.
86            Rti : Rtis.Ghdl_Rti_Access;
87         when others =>
88            null;
89      end case;
90   end record;
91
92   procedure Get_Verilog_Wire (Sig : VhpiHandleT;
93                               Info : out Verilog_Wire_Info);
94
95   --  Number of signals in INFO (at least one).
96   function Get_Wire_Length (Info : Verilog_Wire_Info) return Ghdl_Index_Type;
97
98   --  Return TRUE if last change time of the wire described by INFO is LAST.
99   --  Used by vcd to know if a signal has changed and should be dumped.
100   function Verilog_Wire_Changed (Info : Verilog_Wire_Info;
101                                  Last : Std_Time)
102                                 return Boolean;
103
104   --  Return TRUE if there is an event on the wire, for the current cycle.
105   function Verilog_Wire_Event (Info : Verilog_Wire_Info) return Boolean;
106
107   --  Return a pointer to the value of a wire.
108   function Verilog_Wire_Val (Info : Verilog_Wire_Info) return Ghdl_Value_Ptr;
109   function Verilog_Wire_Val (Info : Verilog_Wire_Info; Idx : Ghdl_Index_Type)
110                             return Ghdl_Value_Ptr;
111
112   procedure Register;
113end Grt.Vcd;
114