aboutsummaryrefslogtreecommitdiffstats
path: root/src/grt/grt-disp.adb
blob: 025e56e7b225fbc449cfd5815e90975758fe8f6d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
--  GHDL Run Time (GRT) - Common display subprograms.
--  Copyright (C) 2002 - 2014 Tristan Gingold
--
--  This program 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 of the License, or
--  (at your option) any later version.
--
--  This program 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 this program.  If not, see <gnu.org/licenses>.
--
--  As a special exception, if other files instantiate generics from this
--  unit, or you link this unit with other files to produce an executable,
--  this unit does not by itself cause the resulting executable to be
--  covered by the GNU General Public License. This exception does not
--  however invalidate any other reasons why the executable file might be
--  covered by the GNU Public License.
with Grt.Vhdl_Types; use Grt.Vhdl_Types;
with Grt.Astdio; use Grt.Astdio;
with Grt.Astdio.Vhdl; use Grt.Astdio.Vhdl;
with Grt.Stdio; use Grt.Stdio;

package body Grt.Disp is

--    procedure Put_Trim (Stream : FILEs; Str : String)
--    is
--       Start : Natural;
--    begin
--       Start := Str'First;
--       while Start <= Str'Last and then Str (Start) = ' ' loop
--          Start := Start + 1;
--       end loop;
--       Put (Stream, Str (Start .. Str'Last));
--    end Put_Trim;

--   procedure Put_E8 (Stream : FILEs; E8 : Ghdl_E8; Type_Desc : Ghdl_Desc_Ptr)
--    is
--    begin
--       Put_Str_Len (Stream, Type_Desc.E8.Values (Natural (E8)));
--    end Put_E8;

   --procedure Put_E32
   --  (Stream : FILEs; E32 : Ghdl_E32; Type_Desc : Ghdl_Desc_Ptr)
   --is
   --begin
   --   Put_Str_Len (Stream, Type_Desc.E32.Values (Natural (E32)));
   --end Put_E32;

   procedure Put_Sig_Index (Sig : Sig_Table_Index) is
   begin
      Put_I32 (stdout, Ghdl_I32 (Sig));
   end Put_Sig_Index;

   procedure Put_Sig_Range (Sig : Sig_Table_Range) is
   begin
      Put_Sig_Index (Sig.First);
      if Sig.Last /= Sig.First then
         Put ("-");
         Put_Sig_Index (Sig.Last);
      end if;
   end Put_Sig_Range;

   procedure Disp_Now is
   begin
      Put ("Now is ");
      Put_Time (stdout, Current_Time);
      Put (" +");
      Put_I32 (stdout, Ghdl_I32 (Current_Delta));
      New_Line;
   end Disp_Now;

   procedure Disp_Propagation_Kind (Kind : Propagation_Kind_Type) is
   begin
      case Kind is
         when Drv_One_Driver =>
            Put ("Drv (1 drv) ");
         when Eff_One_Driver =>
            Put ("Eff (1 drv) ");
         when Drv_One_Port =>
            Put ("Drv (1 prt) ");
         when Eff_One_Port =>
            Put ("Eff (1 prt) ");
         when Imp_Forward =>
            Put ("Forward ");
         when Imp_Forward_Build =>
            Put ("Forward_Build ");
         when Imp_Guard =>
            Put ("Guard ");
         when Imp_Stable =>
            Put ("Stable ");
         when Imp_Quiet =>
            Put ("Quiet ");
         when Imp_Transaction =>
            Put ("Transaction ");
         when Imp_Delayed =>
            Put ("Delayed ");
         when Eff_Actual =>
            Put ("Eff Actual ");
         when Eff_Multiple =>
            Put ("Eff multiple ");
         when Drv_One_Resolved =>
            Put ("Drv 1 resolved ");
         when Eff_One_Resolved =>
            Put ("Eff 1 resolved ");
         when In_Conversion =>
            Put ("In conv ");
         when Out_Conversion =>
            Put ("Out conv ");
         when Drv_Error =>
            Put ("Drv error ");
         when Drv_Multiple =>
            Put ("Drv multiple ");
         when Prop_End =>
            Put ("end ");
      end case;
   end Disp_Propagation_Kind;

   procedure Disp_Signals_Order is
   begin
      for I in Propagation.First .. Propagation.Last loop
         Put_I32 (stdout, Ghdl_I32 (I));
         Put (": ");
         Disp_Propagation_Kind (Propagation.Table (I).Kind);
         case Propagation.Table (I).Kind is
            when Drv_One_Driver
              | Eff_One_Driver
              | Drv_One_Port
              | Eff_One_Port
              | Drv_One_Resolved
              | Eff_One_Resolved
              | Imp_Guard
              | Imp_Stable
              | Imp_Quiet
              | Imp_Transaction
              | Imp_Delayed
              | Eff_Actual =>
               Put_Sig_Index (Signal_Ptr_To_Index (Propagation.Table (I).Sig));
               New_Line;
            when Imp_Forward =>
               Put_I32 (stdout, Ghdl_I32 (Propagation.Table (I).Sig.Net));
               New_Line;
            when Imp_Forward_Build =>
               declare
                  Forward : Forward_Build_Acc;
               begin
                  Forward := Propagation.Table (I).Forward;
                  Put_Sig_Index (Signal_Ptr_To_Index (Forward.Src));
                  Put (" -> ");
                  Put_Sig_Index (Signal_Ptr_To_Index (Forward.Targ));
                  New_Line;
               end;
            when Eff_Multiple
              | Drv_Multiple =>
               Put_Sig_Range (Propagation.Table (I).Resolv.Sig_Range);
               New_Line;
            when In_Conversion
              | Out_Conversion =>
               declare
                  Conv : Sig_Conversion_Acc;
               begin
                  Conv := Propagation.Table (I).Conv;
                  Put_Sig_Range (Conv.Src);
                  Put (" -> ");
                  Put_Sig_Range (Conv.Dest);
                  New_Line;
               end;
            when Prop_End =>
               New_Line;
            when Drv_Error =>
               null;
         end case;
      end loop;
   end Disp_Signals_Order;

   procedure Disp_Mode (Mode : Mode_Type) is
   begin
      case Mode is
         when Mode_B1 =>
            Put (" b1");
         when Mode_E8 =>
            Put (" e8");
         when Mode_E32 =>
            Put ("e32");
         when Mode_I32 =>
            Put ("i32");
         when Mode_I64 =>
            Put ("i64");
         when Mode_F64 =>
            Put ("f64");
      end case;
   end Disp_Mode;

   procedure Disp_Value (Value : Value_Union; Mode : Mode_Type) is
   begin
      case Mode is
         when Mode_B1 =>
            if Value.B1 then
               Put ("T");
            else
               Put ("F");
            end if;
         when Mode_E8 =>
            Put_I32 (stdout, Ghdl_I32 (Value.E8));
         when Mode_E32 =>
            Put_I32 (stdout, Ghdl_I32 (Value.E32));
         when Mode_I32 =>
            Put_I32 (stdout, Value.I32);
         when Mode_I64 =>
            Put_I64 (stdout, Value.I64);
         when Mode_F64 =>
            Put_F64 (stdout, Value.F64);
      end case;
   end Disp_Value;
end Grt.Disp;