1--  Interpreter AMS simulation
2--  Copyright (C) 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
17with Simple_IO; use Simple_IO;
18with Vhdl.Utils; use Vhdl.Utils;
19with Vhdl.Prints;
20
21package body Simul.Debugger.AMS is
22   procedure Disp_Quantity_Name (Quantity : Quantity_Index_Type)
23   is
24      Obj : Scalar_Quantity renames Scalar_Quantities.Table (Quantity);
25   begin
26      Disp_Instance_Name (Obj.Instance, True);
27      Put ('.');
28      Put (Image_Identifier (Obj.Decl));
29      if Obj.Kind = Quantity_Reference then
30         Put ("'Ref");
31      end if;
32   end Disp_Quantity_Name;
33
34   procedure Disp_Term (Term : Ams_Term_Acc) is
35   begin
36      case Term.Sign is
37         when Op_Plus =>
38            Put (" + ");
39         when Op_Minus =>
40            Put (" - ");
41      end case;
42
43      case Term.Op is
44         when Op_Quantity =>
45            Disp_Quantity_Name (Term.Quantity);
46         when Op_Vhdl_Expr =>
47            Vhdl.Prints.Disp_Expression (Term.Vhdl_Expr);
48      end case;
49   end Disp_Term;
50
51   procedure Disp_Characteristic_Expression
52     (Ce : Characteristic_Expressions_Index)
53   is
54      Obj : Characteristic_Expr renames
55        Characteristic_Expressions.Table (Ce);
56      Expr : Ams_Term_Acc := Obj.Expr;
57   begin
58      case Obj.Kind is
59         when Explicit =>
60            Put ("Explic:");
61         when Contribution =>
62            Put ("Contri:");
63         when Structural =>
64            Put ("Struct:");
65      end case;
66
67      while Expr /= null loop
68         Disp_Term (Expr);
69         Expr := Expr.Next;
70      end loop;
71      New_Line;
72   end Disp_Characteristic_Expression;
73
74   procedure Disp_Characteristic_Expressions is
75   begin
76      Put_Line ("Characteristic expressions:");
77      for I in Characteristic_Expressions.First
78        .. Characteristic_Expressions.Last
79      loop
80         Disp_Characteristic_Expression (I);
81      end loop;
82   end Disp_Characteristic_Expressions;
83end Simul.Debugger.AMS;
84