aboutsummaryrefslogtreecommitdiffstats
path: root/src/synth/elab-vhdl_values-debug.adb
blob: a7cf2f9a3ce69a11ab6a690519af3f298b579307 (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
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318pre { line-height: 125%; margin: 0; 
--  Values in synthesis.
--  Copyright (C) 2017 Tristan Gingold
--
--  This file is part of GHDL.
--
--  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>.

with Simple_IO; use Simple_IO;
with Utils_IO; use Utils_IO;

with Vhdl.Nodes; use Vhdl.Nodes;

package body Elab.Vhdl_Values.Debug is
   procedure Put_Dir (Dir : Direction_Type) is
   begin
      case Dir is
         when Dir_To =>
            Put ("to");
         when Dir_Downto =>
            Put ("downto");
      end case;
   end Put_Dir;

   procedure Debug_Bound (Bnd : Bound_Type; Verbose : Boolean) is
   begin
      Put_Int32 (Bnd.Left);
      Put (' ');
      Put_Dir (Bnd.Dir);
      Put (' ');
      Put_Int32 (Bnd.Right);
      if Verbose then
         Put (" [l=");
         Put_Uns32 (Bnd.Len);
         Put (']');
      end if;
   end Debug_Bound;

   procedure Debug_Typ_Phys (T : Type_Acc) is
   begin
      Put ("[al=");
      Put_Int32 (Int32 (T.Al));
      Put (" sz=");
      Put_Uns32 (Uns32 (T.Sz));
      Put (" w=");
      Put_Uns32 (T.W);
      Put (']');
   end Debug_Typ_Phys;

   procedure Debug_Typ1 (T : Type_Acc) is
   begin
      case T.Kind is
         when Type_Bit =>
            Put ("bit");
            Debug_Typ_Phys (T);
         when Type_Logic =>
            Put ("bit/logic");
            Debug_Typ_Phys (T);
         when Type_Vector =>
            Put ("vector ");
            Debug_Typ_Phys (T);
            Put (" (");
            Debug_Bound (T.Abound, True);
            Put (") of ");
            Debug_Typ1 (T.Arr_El);
         when Type_Array =>
            Put ("arr ");
            Debug_Typ_Phys (T);
            Put (" (");
            declare
               It : Type_Acc;
            begin
               It := T;
               loop
                  Debug_Bound (It.Abound, True);
                  exit when It.Alast;
                  Put (", ");
                  It := It.Arr_El;
               end loop;
               Put (") of ");
               Debug_Typ1 (It.Arr_El);
            end;
         when Type_Record =>
            Put ("rec ");
            Debug_Typ_Phys (T);
            Put (" (");
            for I in T.Rec.E'Range loop
               if I /= 1 then
                  Put (", ");
               end if;
               Put ("[noff=");
               Put_Uns32 (T.Rec.E (I).Offs.Net_Off);
               Put (", moff=");
               Put_Uns32 (Uns32 (T.Rec.E (I).Offs.Mem_Off));
               Put ("] ");
               Debug_Typ1 (T.Rec.E (I).Typ);
            end loop;
            Put (")");
         when Type_Unbounded_Record =>
            Put ("unbounded record");
         when Type_Discrete =>
            Put ("discrete ");
            Debug_Typ_Phys (T);
            Put (": ");
            Put_Int64 (T.Drange.Left);
            Put (' ');
            Put_Dir (T.Drange.Dir);
            Put (' ');
            Put_Int64 (T.Drange.Right);
            if T.Drange.Is_Signed then
               Put (" [signed]");
            else
               Put (" [unsigned]");
            end if;
         when Type_Access =>
            Put ("access");
         when Type_File =>
            Put ("file");
         when Type_Float =>
            Put ("float");
         when Type_Slice =>
            Put ("slice");
         when Type_Unbounded_Vector =>
            Put ("unbounded vector");
         when Type_Unbounded_Array =>
            Put ("unbounded arr (");
            declare
               It : Type_Acc;
            begin
               It := T;
               loop
                  Put ("<>");
                  exit when It.Ulast;
                  Put (", ");
                  It := It.Uarr_El;
               end loop;
               Put (") of ");
               Debug_Typ1 (It.Uarr_El);
            end;
         when Type_Protected =>
            Put ("protected");
      end case;
   end Debug_Typ1;

   procedure Debug_Typ (T : Type_Acc) is
   begin
      Debug_Typ1 (T);
      New_Line;
   end Debug_Typ;

   procedure Debug_Type_Short (T : Type_Acc) is
   begin
      case T.Kind is
         when Type_Bit =>
            Put ("bit");
         when Type_Logic =>
            Put ("logic");
         when Type_Vector =>
            Debug_Type_Short (T.Arr_El);
            Put ("_vec(");
            Debug_Bound (T.Abound, False);
            Put (")");
         when Type_Array =>
            declare
               It : Type_Acc;
            begin
               Put ("arr (");
               It := T;
               loop
                  Debug_Bound (It.Abound, False);
                  exit when It.Alast;
                  It := It.Arr_El;
                  Put (", ");
               end loop;
               Put (")");
            end;
         when Type_Record =>
            Put ("rec: (");
            Put (")");
         when Type_Unbounded_Record =>
            Put ("unbounded record");
         when Type_Discrete =>
            Put ("discrete");
         when Type_Access =>
            Put ("access");
         when Type_File =>
            Put ("file");
         when Type_Float =>
            Put ("float");
         when Type_Slice =>
            Put ("slice");
         when Type_Unbounded_Vector =>
            Put ("unbounded vector");
         when Type_Unbounded_Array =>
            Put ("unbounded array");
         when Type_Protected =>
            Put ("protected");
      end case;
   end Debug_Type_Short;

   procedure Debug_Memtyp (M : Memtyp) is
   begin
      case M.Typ.Kind is
         when Type_Bit
           | Type_Logic =>
            Put ("bit/logic: ");
            Put_Uns32 (Uns32 (Read_U8 (M.Mem)));
         when Type_Vector =>
            Put ("vector (");
            Debug_Bound (M.Typ.Abound, True);
            Put ("): ");
            for I in 1 .. M.Typ.Abound.Len loop
               Put_Uns32 (Uns32 (Read_U8 (M.Mem + Size_Type (I - 1))));
            end loop;
         when Type_Array =>
            declare
               T : Type_Acc;
               El : Type_Acc;
               Len : Uns32;
            begin
               Put ("arr (");
               T := M.Typ;
               Len := 1;
               loop
                  Debug_Bound (T.Abound, True);
                  Len := Len * T.Abound.Len;
                  El := T.Arr_El;
                  exit when T.Alast;
                  T := El;
                  Put (", ");
               end loop;
               Put ("): ");
               for I in 1 .. Len loop
                  if I > 1 then
                     Put (", ");
                  end if;
                  Debug_Memtyp ((El, M.Mem + Size_Type (I - 1) * El.Sz));
               end loop;
            end;
         when Type_Record =>
            Put ("rec: (");
            for I in M.Typ.Rec.E'Range loop
               if I > 1 then
                  Put (", ");
               end if;
               Debug_Memtyp
                 ((M.Typ.Rec.E (I).Typ, M.Mem + M.Typ.Rec.E (I).Offs.Mem_Off));
            end loop;
            Put (")");
         when Type_Discrete =>
            Put ("discrete: ");
            Put_Int64 (Read_Discrete (M));
         when Type_Access =>
            Put ("access");
         when Type_File =>
            Put ("file");
         when Type_Float =>
            Put ("float");
         when Type_Slice =>
            Put ("slice");
         when Type_Unbounded_Vector =>
            Put ("unbounded vector");
         when Type_Unbounded_Array =>
            Put ("unbounded array");
         when Type_Unbounded_Record =>
            Put ("unbounded record");
         when Type_Protected =>
            Put ("protected");
      end case;
      New_Line;
   end Debug_Memtyp;

   procedure Debug_Valtyp (V : Valtyp) is
   begin
      case V.Val.Kind is
         when Value_Memory
           | Value_Const =>
            Debug_Memtyp (Get_Memtyp (V));
         when Value_Net =>
            Put ("net ");
            Put_Uns32 (V.Val.N);
            Put (' ');
            Debug_Typ1 (V.Typ);
            New_Line;
         when Value_Signal =>
            Put ("signal ");
            Put_Uns32 (Uns32 (V.Val.S));
            Put (": ");
            Debug_Typ1 (V.Typ);
            New_Line;
         when Value_Wire =>
            Put ("wire ");
            Put_Uns32 (V.Val.N);
            New_Line;
         when Value_File =>
            Put_Line ("a file");
         when Value_Alias =>
            Put ("an alias: ");
            Debug_Typ1 (V.Typ);
            Put (" of ");
            Debug_Valtyp ((V.Typ, V.Val.A_Obj));
         when Value_Dyn_Alias =>
            Put ("dyn alias: ");
            Debug_Typ1 (V.Typ);
      end case;
   end Debug_Valtyp;

end Elab.Vhdl_Values.Debug;
00000000000000000000000000000; parameter INIT_3A = 256'h0000000000000000000000000000000000000000000000000000000000000000; parameter INIT_3B = 256'h0000000000000000000000000000000000000000000000000000000000000000; parameter INIT_3C = 256'h0000000000000000000000000000000000000000000000000000000000000000; parameter INIT_3D = 256'h0000000000000000000000000000000000000000000000000000000000000000; parameter INIT_3E = 256'h0000000000000000000000000000000000000000000000000000000000000000; parameter INIT_3F = 256'h0000000000000000000000000000000000000000000000000000000000000000; parameter INIT_40 = 256'h0000000000000000000000000000000000000000000000000000000000000000; parameter INIT_41 = 256'h0000000000000000000000000000000000000000000000000000000000000000; parameter INIT_42 = 256'h0000000000000000000000000000000000000000000000000000000000000000; parameter INIT_43 = 256'h0000000000000000000000000000000000000000000000000000000000000000; parameter INIT_44 = 256'h0000000000000000000000000000000000000000000000000000000000000000; parameter INIT_45 = 256'h0000000000000000000000000000000000000000000000000000000000000000; parameter INIT_46 = 256'h0000000000000000000000000000000000000000000000000000000000000000; parameter INIT_47 = 256'h0000000000000000000000000000000000000000000000000000000000000000; parameter INIT_48 = 256'h0000000000000000000000000000000000000000000000000000000000000000; parameter INIT_49 = 256'h0000000000000000000000000000000000000000000000000000000000000000; parameter INIT_4A = 256'h0000000000000000000000000000000000000000000000000000000000000000; parameter INIT_4B = 256'h0000000000000000000000000000000000000000000000000000000000000000; parameter INIT_4C = 256'h0000000000000000000000000000000000000000000000000000000000000000; parameter INIT_4D = 256'h0000000000000000000000000000000000000000000000000000000000000000; parameter INIT_4E = 256'h0000000000000000000000000000000000000000000000000000000000000000; parameter INIT_4F = 256'h0000000000000000000000000000000000000000000000000000000000000000; parameter INIT_50 = 256'h0000000000000000000000000000000000000000000000000000000000000000; parameter INIT_51 = 256'h0000000000000000000000000000000000000000000000000000000000000000; parameter INIT_52 = 256'h0000000000000000000000000000000000000000000000000000000000000000; parameter INIT_53 = 256'h0000000000000000000000000000000000000000000000000000000000000000; parameter INIT_54 = 256'h0000000000000000000000000000000000000000000000000000000000000000; parameter INIT_55 = 256'h0000000000000000000000000000000000000000000000000000000000000000; parameter INIT_56 = 256'h0000000000000000000000000000000000000000000000000000000000000000; parameter INIT_57 = 256'h0000000000000000000000000000000000000000000000000000000000000000; parameter INIT_58 = 256'h0000000000000000000000000000000000000000000000000000000000000000; parameter INIT_59 = 256'h0000000000000000000000000000000000000000000000000000000000000000; parameter INIT_5A = 256'h0000000000000000000000000000000000000000000000000000000000000000; parameter INIT_5B = 256'h0000000000000000000000000000000000000000000000000000000000000000; parameter INIT_5C = 256'h0000000000000000000000000000000000000000000000000000000000000000; parameter INIT_5D = 256'h0000000000000000000000000000000000000000000000000000000000000000; parameter INIT_5E = 256'h0000000000000000000000000000000000000000000000000000000000000000; parameter INIT_5F = 256'h0000000000000000000000000000000000000000000000000000000000000000; parameter INIT_60 = 256'h0000000000000000000000000000000000000000000000000000000000000000; parameter INIT_61 = 256'h0000000000000000000000000000000000000000000000000000000000000000; parameter INIT_62 = 256'h0000000000000000000000000000000000000000000000000000000000000000; parameter INIT_63 = 256'h0000000000000000000000000000000000000000000000000000000000000000; parameter INIT_64 = 256'h0000000000000000000000000000000000000000000000000000000000000000; parameter INIT_65 = 256'h0000000000000000000000000000000000000000000000000000000000000000; parameter INIT_66 = 256'h0000000000000000000000000000000000000000000000000000000000000000; parameter INIT_67 = 256'h0000000000000000000000000000000000000000000000000000000000000000; parameter INIT_68 = 256'h0000000000000000000000000000000000000000000000000000000000000000; parameter INIT_69 = 256'h0000000000000000000000000000000000000000000000000000000000000000; parameter INIT_6A = 256'h0000000000000000000000000000000000000000000000000000000000000000; parameter INIT_6B = 256'h0000000000000000000000000000000000000000000000000000000000000000; parameter INIT_6C = 256'h0000000000000000000000000000000000000000000000000000000000000000; parameter INIT_6D = 256'h0000000000000000000000000000000000000000000000000000000000000000; parameter INIT_6E = 256'h0000000000000000000000000000000000000000000000000000000000000000; parameter INIT_6F = 256'h0000000000000000000000000000000000000000000000000000000000000000; parameter INIT_70 = 256'h0000000000000000000000000000000000000000000000000000000000000000; parameter INIT_71 = 256'h0000000000000000000000000000000000000000000000000000000000000000; parameter INIT_72 = 256'h0000000000000000000000000000000000000000000000000000000000000000; parameter INIT_73 = 256'h0000000000000000000000000000000000000000000000000000000000000000; parameter INIT_74 = 256'h0000000000000000000000000000000000000000000000000000000000000000; parameter INIT_75 = 256'h0000000000000000000000000000000000000000000000000000000000000000; parameter INIT_76 = 256'h0000000000000000000000000000000000000000000000000000000000000000; parameter INIT_77 = 256'h0000000000000000000000000000000000000000000000000000000000000000; parameter INIT_78 = 256'h0000000000000000000000000000000000000000000000000000000000000000; parameter INIT_79 = 256'h0000000000000000000000000000000000000000000000000000000000000000; parameter INIT_7A = 256'h0000000000000000000000000000000000000000000000000000000000000000; parameter INIT_7B = 256'h0000000000000000000000000000000000000000000000000000000000000000; parameter INIT_7C = 256'h0000000000000000000000000000000000000000000000000000000000000000; parameter INIT_7D = 256'h0000000000000000000000000000000000000000000000000000000000000000; parameter INIT_7E = 256'h0000000000000000000000000000000000000000000000000000000000000000; parameter INIT_7F = 256'h0000000000000000000000000000000000000000000000000000000000000000; parameter IS_CLKARDCLK_INVERTED = 1'b0; parameter IS_CLKBWRCLK_INVERTED = 1'b0; parameter IS_ENARDEN_INVERTED = 1'b0; parameter IS_ENBWREN_INVERTED = 1'b0; parameter IS_RSTRAMARSTRAM_INVERTED = 1'b0; parameter IS_RSTRAMB_INVERTED = 1'b0; parameter IS_RSTREGARSTREG_INVERTED = 1'b0; parameter IS_RSTREGB_INVERTED = 1'b0; parameter RAM_MODE = "TDP"; parameter integer DOA_REG = 0; parameter integer DOB_REG = 0; parameter integer READ_WIDTH_A = 0; parameter integer READ_WIDTH_B = 0; parameter integer WRITE_WIDTH_A = 0; parameter integer WRITE_WIDTH_B = 0; parameter WRITE_MODE_A = "WRITE_FIRST"; parameter WRITE_MODE_B = "WRITE_FIRST"; parameter SIM_DEVICE = "VIRTEX6"; endmodule