aboutsummaryrefslogtreecommitdiffstats
path: root/src/bug.adb
blob: 334717399e665c9bcefcdb776923a63ea72f3a3d (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
--  Bug handling
--  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 GHDL; see the file COPYING.  If not, write to the Free
--  Software Foundation, 59 Temple Place - Suite 330, Boston, MA
--  02111-1307, USA.

with Ada.Command_Line; use Ada.Command_Line;
with GNAT.Directory_Operations;
with Simple_IO; use Simple_IO;
with Version; use Version;

package body Bug is
   --  Declared in the files generated by gnatbind.
   --  Note: since the string is exported with C convension, there is no way
   --  to know the length (gnat1 crashes if the string is unconstrained).
   --  Hopefully, the format of the string seems to be fixed.
   --  We don't use GNAT.Compiler_Version because it doesn't exist
   --   in gnat 3.15p
   GNAT_Version : constant String (1 .. 31 + 15);
   pragma Import (C, GNAT_Version, "__gnat_version");

   function Get_Gnat_Version return String
   is
      C : Character;
   begin
      for I in GNAT_Version'Range loop
         C := GNAT_Version (I);
         case C is
            when ' '
              | 'A' .. 'Z'
              | 'a' .. 'z'
              | '0' .. '9'
              | ':'
              | '-'
              | '.'
              | '(' =>
               --  Accept only a few printable characters.
               --  Underscore is excluded since the next bytes after
               --  GNAT_Version is Ada_Main_Program_Name, which often starts
               --  with _ada_.
               null;
            when ')' =>
               return GNAT_Version (1 .. I);
            when others =>
               return GNAT_Version (1 .. I - 1);
         end case;
      end loop;
      return GNAT_Version;
   end Get_Gnat_Version;

   procedure Disp_Bug_Box (Except : Exception_Occurrence)
   is
      Id : Exception_Id;
   begin
      New_Line_Err;
      Put_Line_Err
        ("******************** GHDL Bug occurred ***************************");
      Put_Line_Err
        ("Please report this bug on https://github.com/ghdl/ghdl/issues");
      Put_Line_Err ("GHDL release: " & Ghdl_Ver & ' ' & Ghdl_Release);
      Put_Line_Err ("Compiled with " & Get_Gnat_Version);
      Put_Line_Err ("Target: " & Standard'Target_Name);
      Put_Line_Err (GNAT.Directory_Operations.Get_Current_Dir);
      --Put_Line
      --  ("Program name: " & Command_Name);
      --Put_Line
      --  ("Program arguments:");
      --for I in 1 .. Argument_Count loop
      --   Put_Line ("  " & Argument (I));
      --end loop;
      Put_Line_Err ("Command line:");
      Put_Err (Command_Name);
      for I in 1 .. Argument_Count loop
         Put_Err (' ');
         Put_Err (Argument (I));
      end loop;
      New_Line_Err;
      Id := Exception_Identity (Except);
      if Id /= Null_Id then
         Put_Line_Err ("Exception " & Exception_Name (Id) & " raised");
         --Put_Line ("exception message: " & Exception_Message (Except));
         Put_Line_Err ("Exception information:");
         Put_Err (Exception_Information (Except));
      end if;
      Put_Line_Err
        ("******************************************************************");
   end Disp_Bug_Box;
end Bug;
; // True if this FF has async load function — this includes D latches. // If this and has_clk are both set, has_arst and has_sr cannot be set. bool has_aload; // True if this FF has sync set/reset. Depends on has_clk, exclusive // with has_arst, has_sr, has_aload. bool has_srst; // True if this FF has async set/reset. Exclusive with has_srst, // has_sr. If this and has_clk are both set, has_aload cannot be set. bool has_arst; // True if this FF has per-bit async set + clear. Exclusive with // has_srst, has_arst. If this and has_clk are both set, has_aload // cannot be set. bool has_sr; // If has_ce and has_srst are both set, determines their relative // priorities: if true, inactive ce disables srst; if false, srst // operates independent of ce. bool ce_over_srst; // True if this FF is a fine cell, false if it is a coarse cell. // If true, width must be 1. bool is_fine; // Polarities, corresponding to sig_*. True means active-high, false // means active-low. bool pol_clk; bool pol_ce; bool pol_aload; bool pol_arst; bool pol_srst; bool pol_clr; bool pol_set; // The value loaded by sig_arst. Const val_arst; // The value loaded by sig_srst. Const val_srst; // The initial value at power-up. Const val_init; // The FF data width in bits. int width; dict<IdString, Const> attributes; FfData(Module *module = nullptr, FfInitVals *initvals = nullptr, IdString name = IdString()) : module(module), initvals(initvals), cell(nullptr), name(name) { width = 0; has_clk = false; has_gclk = false; has_ce = false; has_aload = false; has_srst = false; has_arst = false; has_sr = false; ce_over_srst = false; is_fine = false; pol_clk = false; pol_aload = false; pol_ce = false; pol_arst = false; pol_srst = false; pol_clr = false; pol_set = false; } FfData(FfInitVals *initvals, Cell *cell_); // Returns a FF identical to this one, but only keeping bit indices from the argument. FfData slice(const std::vector<int> &bits); void add_dummy_ce(); void add_dummy_srst(); void add_dummy_arst(); void add_dummy_aload(); void add_dummy_sr(); void add_dummy_clk(); void arst_to_aload(); void arst_to_sr(); void aload_to_sr(); // Given a FF with both has_ce and has_srst, sets ce_over_srst to the given value and // fixes up control signals appropriately to preserve semantics. void convert_ce_over_srst(bool val); void unmap_ce(); void unmap_srst(); void unmap_ce_srst() { unmap_ce(); unmap_srst(); } Cell *emit(); // Removes init attribute from the Q output, but keeps val_init unchanged. // It will be automatically reattached on emit. Use this before changing sig_q. void remove_init() { if (initvals) initvals->remove_init(sig_q); } void remove(); // Flip the sense of the given bit slices of the FF: insert inverters on data // inputs and output, flip the corresponding init/reset bits, swap clr/set // inputs with proper priority fix. void flip_bits(const pool<int> &bits); }; YOSYS_NAMESPACE_END #endif