You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

144 lines
5.9 KiB

  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. *
  4. * Copyright (C) 2009 Jean-Pierre Charras, jp.charras at wanadoo.fr
  5. * Copyright (C) 2011 Wayne Stambaugh <stambaughw@verizon.net>
  6. * Copyright (C) 2009-2015 KiCad Developers, see change_log.txt for contributors.
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public License
  10. * as published by the Free Software Foundation; either version 2
  11. * of the License, or (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, you may find one here:
  20. * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
  21. * or you may search the http://www.gnu.org website for the version 2 license,
  22. * or you may write to the Free Software Foundation, Inc.,
  23. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
  24. */
  25. /**
  26. * @file erc.h
  27. */
  28. #ifndef _ERC_H
  29. #define _ERC_H
  30. class NETLIST_OBJECT;
  31. class NETLIST_OBJECT_LIST;
  32. class SCH_SHEET_LIST;
  33. /* For ERC markers: error types (used in diags, and to set the color):
  34. */
  35. enum errortype
  36. {
  37. OK = 0,
  38. WAR, // Error: severity = warning
  39. ERR, // Error: severity = error
  40. UNC // Error: unconnected pin
  41. };
  42. extern const wxString CommentERC_H[];
  43. extern const wxString CommentERC_V[];
  44. /// DRC error codes:
  45. enum ERCE_T
  46. {
  47. ERCE_UNSPECIFIED = 0,
  48. ERCE_DUPLICATE_SHEET_NAME, // duplicate sheet names within a given sheet
  49. ERCE_PIN_NOT_CONNECTED, // pin not connected and not no connect symbol
  50. ERCE_PIN_NOT_DRIVEN, // pin connected to some others pins but no pin to drive it
  51. ERCE_PIN_TO_PIN_WARNING, // pin connected to an other pin: warning level
  52. ERCE_PIN_TO_PIN_ERROR, // pin connected to an other pin: error level
  53. ERCE_HIERACHICAL_LABEL, // mismatch between hierarchical labels and pins sheets
  54. ERCE_NOCONNECT_CONNECTED, // a no connect symbol is connected to more than 1 pin
  55. ERCE_NOCONNECT_NOT_CONNECTED, // a no connect symbol is not connected to anything
  56. ERCE_LABEL_NOT_CONNECTED, // label not connected to anything
  57. ERCE_SIMILAR_LABELS, // 2 labels are equal fir case insensitive comparisons
  58. ERCE_SIMILAR_GLBL_LABELS, // 2 labels are equal fir case insensitive comparisons
  59. ERCE_DIFFERENT_UNIT_FP, // different units of the same component have different footprints assigned
  60. ERCE_DIFFERENT_UNIT_NET, // a shared pin in a multi-unit component is connected to more than one net
  61. ERCE_BUS_ALIAS_CONFLICT, // conflicting bus alias definitions across sheets
  62. ERCE_DRIVER_CONFLICT, // conflicting drivers (labels, etc) on a subgraph
  63. ERCE_BUS_ENTRY_CONFLICT, // a wire connected to a bus doesn't match the bus
  64. ERCE_BUS_LABEL_ERROR, // a label attached to a bus isn't in bus format
  65. ERCE_BUS_TO_BUS_CONFLICT, // a connection between bus objects doesn't share at least one net
  66. ERCE_BUS_TO_NET_CONFLICT, // a bus wire is graphically connected to a net port/pin (or vice versa)
  67. ERCE_GLOBLABEL, // a global label is unique
  68. };
  69. /* Minimal connection table */
  70. #define NPI 4 // Net with Pin isolated, this pin has type Not Connected and must be left N.C.
  71. #define DRV 3 // Net driven by a signal (a pin output for instance)
  72. #define NET_NC 2 // Net "connected" to a "NoConnect symbol"
  73. #define NOD 1 // Net not driven ( Such as 2 or more connected inputs )
  74. #define NOC 0 // initial state of a net: no connection
  75. /**
  76. * Function WriteDiagnosticERC
  77. * save the ERC errors to \a aFullFileName.
  78. *
  79. * @param aFullFileName A wxString object containing the file name and path.
  80. */
  81. bool WriteDiagnosticERC( EDA_UNITS_T aUnits, const wxString& aFullFileName );
  82. /**
  83. * Performs ERC testing and creates an ERC marker to show the ERC problem for aNetItemRef
  84. * or between aNetItemRef and aNetItemTst.
  85. * if MinConn < 0: this is an error on labels
  86. */
  87. void Diagnose( NETLIST_OBJECT* NetItemRef, NETLIST_OBJECT* NetItemTst,
  88. int MinConnexion, int Diag );
  89. /**
  90. * Perform ERC testing for electrical conflicts between \a NetItemRef and other items
  91. * (mainly pin) on the same net.
  92. * @param aList = a reference to the list of connected objects
  93. * @param aNetItemRef = index in list of the current object
  94. * @param aNetStart = index in list of net objects of the first item
  95. * @param aMinConnexion = a pointer to a variable to store the minimal connection
  96. * found( NOD, DRV, NPI, NET_NC)
  97. */
  98. void TestOthersItems( NETLIST_OBJECT_LIST* aList,
  99. unsigned aNetItemRef, unsigned aNetStart,
  100. int* aMinConnexion );
  101. /**
  102. * Function TestDuplicateSheetNames( )
  103. * inside a given sheet, one cannot have sheets with duplicate names (file
  104. * names can be duplicated).
  105. * @return the error count
  106. * @param aCreateMarker: true = create error markers in schematic,
  107. * false = calculate error count only
  108. */
  109. int TestDuplicateSheetNames( bool aCreateMarker );
  110. /**
  111. * Checks that there are not conflicting bus alias definitions in the schematic
  112. *
  113. * (for example, two hierarchical sub-sheets contain different definitions for
  114. * the same bus alias)
  115. *
  116. * @param aCreateMarker: true = create error markers in schematic,
  117. * false = calculate error count only
  118. * @return the error count
  119. */
  120. int TestConflictingBusAliases( bool aCreateMarker = true );
  121. /**
  122. * Test if all units of each multiunit component have the same footprint assigned.
  123. * @param aSheetList contains components to be validated.
  124. * @return The error count.
  125. */
  126. int TestMultiunitFootprints( SCH_SHEET_LIST& aSheetList );
  127. #endif // _ERC_H