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.

123 lines
5.0 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. #define ERCE_UNSPECIFIED 0
  46. #define ERCE_DUPLICATE_SHEET_NAME 1 // duplicate sheet names within a given sheet
  47. #define ERCE_PIN_NOT_CONNECTED 2 // pin not connected and not no connect symbol
  48. #define ERCE_PIN_NOT_DRIVEN 3 // pin connected to some others pins but no pin to drive it
  49. #define ERCE_PIN_TO_PIN_WARNING 4 // pin connected to another pin: warning level
  50. #define ERCE_PIN_TO_PIN_ERROR 5 // pin connected to another pin: error level
  51. #define ERCE_HIERACHICAL_LABEL 6 // mismatch between hierarchical labels and pins sheets
  52. #define ERCE_NOCONNECT_CONNECTED 7 // a no connect symbol is connected to more than 1 pin
  53. #define ERCE_GLOBLABEL 8 // global label not connected to any other global label
  54. #define ERCE_SIMILAR_LABELS 9 // 2 labels are equal fir case insensitive comparisons
  55. #define ERCE_SIMILAR_GLBL_LABELS 10 // 2 labels are equal fir case insensitive comparisons
  56. #define ERCE_DIFFERENT_UNIT_FP 11 // different units of the same component have different
  57. // footprints assigned
  58. #define ERCE_DIFFERENT_UNIT_NET 12 // a shared pin in a multi-unit component is connected
  59. // to more than one net
  60. /* Minimal connection table */
  61. #define NPI 4 // Net with Pin isolated, this pin has type Not Connected and must be left N.C.
  62. #define DRV 3 // Net driven by a signal (a pin output for instance)
  63. #define NET_NC 2 // Net "connected" to a "NoConnect symbol"
  64. #define NOD 1 // Net not driven ( Such as 2 or more connected inputs )
  65. #define NOC 0 // initial state of a net: no connection
  66. /**
  67. * Function WriteDiagnosticERC
  68. * save the ERC errors to \a aFullFileName.
  69. *
  70. * @param aFullFileName A wxString object containing the file name and path.
  71. */
  72. bool WriteDiagnosticERC( const wxString& aFullFileName );
  73. /**
  74. * Performs ERC testing and creates an ERC marker to show the ERC problem for aNetItemRef
  75. * or between aNetItemRef and aNetItemTst.
  76. * if MinConn < 0: this is an error on labels
  77. */
  78. void Diagnose( NETLIST_OBJECT* NetItemRef, NETLIST_OBJECT* NetItemTst,
  79. int MinConnexion, int Diag );
  80. /**
  81. * Perform ERC testing for electrical conflicts between \a NetItemRef and other items
  82. * (mainly pin) on the same net.
  83. * @param aList = a reference to the list of connected objects
  84. * @param aNetItemRef = index in list of the current object
  85. * @param aNetStart = index in list of net objects of the first item
  86. * @param aMinConnexion = a pointer to a variable to store the minimal connection
  87. * found( NOD, DRV, NPI, NET_NC)
  88. */
  89. void TestOthersItems( NETLIST_OBJECT_LIST* aList,
  90. unsigned aNetItemRef, unsigned aNetStart,
  91. int* aMinConnexion );
  92. /**
  93. * Function TestDuplicateSheetNames( )
  94. * inside a given sheet, one cannot have sheets with duplicate names (file
  95. * names can be duplicated).
  96. * @return the error count
  97. * @param aCreateMarker: true = create error markers in schematic,
  98. * false = calculate error count only
  99. */
  100. int TestDuplicateSheetNames( bool aCreateMarker );
  101. /**
  102. * Test if all units of each multiunit component have the same footprint assigned.
  103. * @param aSheetList contains components to be validated.
  104. * @return The error count.
  105. */
  106. int TestMultiunitFootprints( SCH_SHEET_LIST& aSheetList );
  107. #endif // _ERC_H