Browse Source
Pcbnew: First draft to use a new netlist format ( containing the same info as the intermediate netlist, but using S expressions)
Pcbnew: First draft to use a new netlist format ( containing the same info as the intermediate netlist, but using S expressions)
* Eeschema can generate this netlist format. * Pcbnew can use (automatic identification) the current format or the new format. * Cvpcb does not use yet the new format.pull/1/head
15 changed files with 2346 additions and 1462 deletions
-
10CHANGELOG.txt
-
207INSTALL.txt
-
1283demos/interf_u/interf_u.net
-
196eeschema/netform.cpp
-
88eeschema/netlist_control.cpp
-
13eeschema/netlist_control.h
-
36include/wxEeschemaStruct.h
-
7include/wxPcbStruct.h
-
61license_for_documentation.txt
-
2pcbnew/CMakeLists.txt
-
16pcbnew/clean.cpp
-
954pcbnew/netlist.cpp
-
295pcbnew/netlist_reader.h
-
315pcbnew/netlist_reader_firstformat.cpp
-
325pcbnew/netlist_reader_kicad.cpp
@ -1,207 +0,0 @@ |
|||
KiCad installation |
|||
================== |
|||
|
|||
The parts of KiCad |
|||
------------------ |
|||
KiCad consists of 3 packages: |
|||
|
|||
kicad - KiCad programs and core files. |
|||
kicad-doc - Documentation and interactive help (optional package). |
|||
kicad-library - KiCad schematic, pcb & 3D-model libraries (optional package). |
|||
|
|||
|
|||
Installation from binary packages |
|||
--------------------------------- |
|||
|
|||
KiCad binary packages exist for Linux and Windows (XP, 2000). |
|||
|
|||
Data files (schematic, boards, libraries) are compatible with all platforms. |
|||
|
|||
*.zip - KiCad packages for Windows. |
|||
*.tbz2 - KiCad for Linux. |
|||
|
|||
|
|||
Installation from binary packages for Windows |
|||
--------------------------------------------- |
|||
|
|||
KiCad can be installed in 'C:\kicad', 'D:\kicad', 'C:\Program files\kicad', |
|||
'D:\Program files\kicad'. |
|||
|
|||
For example, for an installation in the folder 'C:\kicad', unzip KiCad |
|||
packages: |
|||
|
|||
kicad-{version}.zip |
|||
kicad-doc-{version}.zip |
|||
kicad-library-{version}.zip |
|||
|
|||
to the folder 'C:\kicad'. |
|||
|
|||
The main program is the project manager (kicad.exe) and from it you can run |
|||
the other programs (schematic editor - eeschema, pcb editor - pcbnew, |
|||
utilities: cvpcb and gerbview). |
|||
|
|||
You can create a shortcut to 'C:\kicad\bin\kicad.exe'. |
|||
|
|||
|
|||
Installation from binary packages for Linux |
|||
------------------------------------------- |
|||
|
|||
KiCad can be installed in '/usr' or '/usr/local'. |
|||
|
|||
You must have "root" access for installation. |
|||
|
|||
cd / |
|||
tar -xjf kicad-{version}.tbz2 |
|||
tar -xjf kicad-doc-{version}.tbz2 |
|||
tar -xjf kicad-library-{version}.tbz2 |
|||
|
|||
The main program is '/usr/bin/kicad'. |
|||
|
|||
|
|||
Windows KiCad tree |
|||
------------------ |
|||
|
|||
kicad/bin - Binaries (executable files). |
|||
kicad/doc - Various documentation. |
|||
kicad/doc/help - Interactive help. |
|||
kicad/share/demos - Sample schematics and printed boards. |
|||
kicad/share/internat - Interface localization files. |
|||
kicad/share/library - Libraries for schematic. |
|||
kicad/share/modules - Module libraries for printed boards. |
|||
kicad/share/modules/packages3d - 3D component models (.wrl and .wings format). |
|||
|
|||
Files '*.mod' are libraries, and files '*.brd' are printed boards you can |
|||
view with pcbnew. |
|||
Files *.brd show the existing modules (and 3D shapes) in libraries. |
|||
|
|||
|
|||
Linux KiCad tree |
|||
---------------- |
|||
|
|||
/usr/bin - Binaries (executable files). |
|||
/usr/share/doc/kicad/ - Various documentation. |
|||
/usr/share/doc/kicad/help - Interactive help. |
|||
/usr/share/kicad/demos - Sample schematics and printed boards. |
|||
/usr/share/kicad/internat - Dictionaries for interface localization. |
|||
/usr/share/kicad/library - Interface localization files. |
|||
/usr/share/kicad/modules - Module libraries for printed boards. |
|||
/usr/share/kicad/modules/packages3d - 3D component models (.wrl and .wings format). |
|||
|
|||
if not found search kicad in |
|||
/usr/local/ |
|||
and if found, kicad uses the same tree as the Windows KiCad tree above |
|||
|
|||
Files '*.mod' are the libraries, and files '*.brd' are printed boards you can |
|||
view with pcbnew. |
|||
Files *.brd show the existing modules (and 3D shapes) in libraries. |
|||
|
|||
Warning: |
|||
Do not change the KiCad tree, or the location of binary files, |
|||
else KiCad will not be able to find its required files (configuration, |
|||
libraries, etc.). |
|||
|
|||
Mac OS X KiCad tree |
|||
------------------- |
|||
|
|||
System wide files |
|||
|
|||
/Library/Application Support/kicad/demos |
|||
/Library/Application Support/kicad/internat |
|||
/Library/Application Support/kicad/library |
|||
/Library/Application Support/kicad/modules |
|||
/Library/Application Support/kicad/modules/packages3d |
|||
|
|||
User files can be the same as the system wide files but only inside the users home directory. |
|||
|
|||
$HOME/Library/Application Support/kicad |
|||
|
|||
Warning: |
|||
These paths are hardcoded into KiCad, if you put them somewhere else KiCad will not find them when a new |
|||
project is created. |
|||
|
|||
Installation from source code |
|||
----------------------------- |
|||
|
|||
Some dependencies must be satisfied for the correct installation of KiCad: |
|||
|
|||
wxWidgets >= 2.8.11 http://www.wxwidgets.org/ |
|||
CMake >= 2.6.4 http://www.cmake.org/ |
|||
Boost C++ Libraries (files used by kicad are provided in kicad sources) http://www.boost.org/ |
|||
OpenGL |
|||
Linux: Mesa 3D Graphics Library http://www.mesa3d.org/ |
|||
Windows: built-in |
|||
Zlib Compression Library http://www.zlib.net/ |
|||
|
|||
In source-tree-build are mostly unwanted, so make a subdir called "build" and |
|||
change to it. |
|||
|
|||
Call cmake with the path to KiCad. E.g., when your build-folder is "build" |
|||
within source-tree, type "cmake ../". |
|||
|
|||
Now your system get checked if it is able compiling KiCad and cmake generates |
|||
the Makefiles. |
|||
|
|||
After calling cmake just type "make" and build begins. |
|||
|
|||
It is easy to build only a specific binary such as pcbnew alone: |
|||
make pcbnew |
|||
|
|||
After "make" type "make install" and install begins. |
|||
|
|||
You may install to a temporary-root with |
|||
make install DESTDIR=<temproot> |
|||
|
|||
If you want to uninstall KiCad again type "make uninstall" from within the |
|||
build directory. |
|||
|
|||
|
|||
Important parameters to cmake |
|||
----------------------------- |
|||
|
|||
-DCMAKE_BUILD_TYPE=<buildtype> |
|||
<buildtype> may current one of "Debug" and "Release". |
|||
|
|||
-DCMAKE_INSTALL_PREFIX=<prefix> |
|||
Default to "/usr/local". |
|||
|
|||
-DwxWidgets_ROOT_DIR=<wxInstallDir> |
|||
Required for Windows platform. |
|||
|
|||
-DwxWidgets_USE_DEBUG=ON |
|||
Can be used only with -DCMAKE_BUILD_TYPE=Debug |
|||
|
|||
-DwxWidgets_USE_STATIC=ON |
|||
For building statically linked executables. Can be used only if wxWidgets |
|||
configured and builded with "--enable-monolithic --disable-shared" parameters. |
|||
|
|||
-DwxWidgets_USE_STATIC=OFF |
|||
For building dinamically linked executables. Can be used only if wxWidgets |
|||
configured and builded with "--disable-monolithic --enable-shared" parameters. |
|||
|
|||
-DwxUSE_UNICODE=ON |
|||
Require on locale utf8 for build the KiCad with cyrillic fonts support. |
|||
|
|||
-DKICAD_GOST=ON |
|||
Build the KiCad with russian GOST support. |
|||
|
|||
-DKICAD_KEEPCASE=ON |
|||
Build the KiCad with no component name conversion to uppercase (if you want your |
|||
ADuC.../Si.../bq... components named as just so). |
|||
|
|||
-DCMAKE_CXX_FLAGS=<some extra flags> |
|||
Extra flags for the c++ compiler for your system required. |
|||
|
|||
-DCMAKE_VERBOSE_MAKEFILE=ON |
|||
When more output is wanted use this cmake parameter or call "make VERBOSE=1". |
|||
|
|||
|
|||
Extra CFLAGS and linker flags |
|||
----------------------------- |
|||
|
|||
If you require extra flags for compiler and linker you may give them via |
|||
environment variables |
|||
"CXXFLAGS" (c++ compiler) |
|||
"LDFLAGS" (for linker) |
|||
"CFLAGS" (for c-compiler, not needed in kdesvn build) |
|||
|
|||
eg., it may usefull on 64bit systems "-m64" to CXXFLAGS and LDFLAGS. |
1283
demos/interf_u/interf_u.net
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
@ -0,0 +1,61 @@ |
|||
KiCad Free Documentation Licence |
|||
================================ |
|||
|
|||
Copyright (c) jean-pierre Charras |
|||
Copyright (C) KiCad Developers |
|||
|
|||
Everyone is permitted to copy and distribute verbatim copies |
|||
of this licence document, but changing it is not allowed. |
|||
|
|||
KICAD FREE DOCUMENTATION LICENCE |
|||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION |
|||
|
|||
1. Permission is granted to make and distribute verbatim copies of this |
|||
manual or piece of documentation provided any copyright notice and this |
|||
permission notice are preserved on all copies. |
|||
|
|||
2. Permission is granted to process this file or document through a |
|||
document processing system and, at your option and the option of any third |
|||
party, print the results, provided a printed document carries a copying |
|||
permission notice identical to this one. |
|||
|
|||
3. Permission is granted to copy and distribute modified versions of this |
|||
manual or piece of documentation under the conditions for verbatim |
|||
copying, provided also that any sections describing licensing conditions |
|||
for this manual, such as, in particular, the GNU General Public Licence, |
|||
the GNU Library General Public Licence, and any wxWindows Licence are |
|||
included exactly as in the original, and provided that the entire |
|||
resulting derived work is distributed under the terms of a permission |
|||
notice identical to this one. |
|||
|
|||
4. Permission is granted to copy and distribute translations of this |
|||
manual or piece of documentation into another language, under the above |
|||
conditions for modified versions, except that sections related to |
|||
licensing, including this paragraph, may also be included in translations |
|||
approved by the copyright holders of the respective licence documents in |
|||
addition to the original French or English. |
|||
|
|||
WARRANTY DISCLAIMER |
|||
|
|||
5. BECAUSE THIS MANUAL OR PIECE OF DOCUMENTATION IS LICENSED FREE OF CHARGE, |
|||
THERE IS NO WARRANTY FOR IT, TO THE EXTENT PERMITTED BY APPLICABLE LAW. |
|||
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER |
|||
PARTIES PROVIDE THIS MANUAL OR PIECE OF DOCUMENTATION "AS IS" WITHOUT |
|||
WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT |
|||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A |
|||
PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF |
|||
THE MANUAL OR PIECE OF DOCUMENTATION IS WITH YOU. SHOULD THE MANUAL OR |
|||
PIECE OF DOCUMENTATION PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL |
|||
NECESSARY SERVICING, REPAIR OR CORRECTION. |
|||
|
|||
6. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL |
|||
ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR |
|||
REDISTRIBUTE THE MANUAL OR PIECE OF DOCUMENTATION AS PERMITTED ABOVE, BE |
|||
LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR |
|||
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE |
|||
MANUAL OR PIECE OF DOCUMENTATION (INCLUDING BUT NOT LIMITED TO LOSS OF |
|||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD |
|||
PARTIES OR A FAILURE OF A PROGRAM BASED ON THE MANUAL OR PIECE OF |
|||
DOCUMENTATION TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR |
|||
OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. |
|||
|
954
pcbnew/netlist.cpp
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
@ -0,0 +1,295 @@ |
|||
#ifndef NETLIST_READER_H |
|||
#define NETLIST_READER_H |
|||
|
|||
/** |
|||
* @file netlist_reader.h |
|||
*/ |
|||
|
|||
/* |
|||
* This program source code file is part of KiCad, a free EDA CAD application. |
|||
* |
|||
* Copyright (C) 2012 Jean-Pierre Charras. |
|||
* Copyright (C) 2012 KiCad Developers, see CHANGELOG.TXT for contributors. |
|||
* |
|||
* 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, you may find one here: |
|||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html |
|||
* or you may search the http://www.gnu.org website for the version 2 license, |
|||
* or you may write to the Free Software Foundation, Inc., |
|||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA |
|||
*/ |
|||
|
|||
#include <algorithm> |
|||
|
|||
#include <fctsys.h> |
|||
#include <kicad_string.h> |
|||
#include <wxPcbStruct.h> |
|||
#include <richio.h> |
|||
#include <macros.h> |
|||
|
|||
#include <class_board.h> |
|||
#include <class_module.h> |
|||
#include <pcbnew.h> |
|||
|
|||
|
|||
/* |
|||
* Helper class, to store new footprints info found in netlist. |
|||
* New footprints are footprints relative to new components found in netlist |
|||
*/ |
|||
class MODULE_INFO |
|||
{ |
|||
public: |
|||
wxString m_Footprint; |
|||
wxString m_Reference; |
|||
wxString m_Value; |
|||
wxString m_TimeStamp; |
|||
|
|||
public: MODULE_INFO( const wxString& libname, |
|||
const wxString& cmpname, |
|||
const wxString& value, |
|||
const wxString& timestamp ) |
|||
{ |
|||
m_Footprint = libname; |
|||
m_Reference = cmpname; |
|||
m_Value = value; |
|||
m_TimeStamp = timestamp; |
|||
} |
|||
|
|||
~MODULE_INFO() { }; |
|||
}; |
|||
|
|||
|
|||
/* |
|||
* Helper class, to read a netlist. |
|||
*/ |
|||
class NETLIST_READER |
|||
{ |
|||
private: |
|||
PCB_EDIT_FRAME* m_pcbframe; // the main Pcbnew frame |
|||
wxTextCtrl* m_messageWindow; // a textctrl to show messages (can be NULL) |
|||
wxString m_netlistFullName; // The full netlist filename |
|||
wxString m_cmplistFullName; // The full component/footprint association filename |
|||
MODULE* m_currModule; // The footprint currently being read in netlist |
|||
std::vector <MODULE_INFO*> m_modulesInNetlist; // The list of footprints, found in netlist |
|||
// (must be loaded from libraries) |
|||
std::vector <MODULE_INFO*> m_newModulesList; // The list of new footprints, |
|||
// found in netlist, but not on board |
|||
// (must be loaded from libraries) |
|||
bool m_BuildModuleListOnly; // if true read netlist, populates m_modulesInNetlist |
|||
// but do not read and change nets and modules on board |
|||
|
|||
public: |
|||
bool m_UseCmpFile; // true to use .cmp files as component/footprint file link |
|||
// false to use netlist only to know component/footprint link |
|||
bool m_UseTimeStamp; // Set to true to identify footprints by time stamp |
|||
// false to use schematic reference |
|||
bool m_ChangeFootprints; // Set to true to change existing footprints to new ones |
|||
// when netlist gives a different footprint name |
|||
|
|||
public: NETLIST_READER( PCB_EDIT_FRAME* aFrame, wxTextCtrl* aMessageWindow = NULL ) |
|||
{ |
|||
m_pcbframe = aFrame; |
|||
m_messageWindow = aMessageWindow; |
|||
m_UseTimeStamp = false; |
|||
m_ChangeFootprints = false; |
|||
m_UseCmpFile = true; |
|||
m_BuildModuleListOnly = false; |
|||
} |
|||
|
|||
~NETLIST_READER() |
|||
{ |
|||
// Free modules info list: |
|||
for( unsigned ii = 0; ii < m_newModulesList.size(); ii++ ) |
|||
delete m_modulesInNetlist[ii]; |
|||
|
|||
m_modulesInNetlist.clear(); |
|||
m_newModulesList.clear(); |
|||
} |
|||
|
|||
std::vector <MODULE_INFO*>& GetModuleInfoList() |
|||
{ |
|||
return m_modulesInNetlist; |
|||
} |
|||
|
|||
/** |
|||
* Function AddModuleInfo |
|||
* Add a new module info to the main list of modules ifo |
|||
* @param aModInfo = a reference to the item to add |
|||
*/ |
|||
void AddModuleInfo( MODULE_INFO* aModInfo ) |
|||
{ |
|||
m_modulesInNetlist.push_back( aModInfo ); |
|||
} |
|||
|
|||
/** |
|||
* Function BuildModuleListOnly |
|||
* Set to true or false the Build Module List Only option |
|||
* When this option is false, a full netlist read is made, |
|||
* and modules are added/modified |
|||
* When this option is true, a partial netlist read is made |
|||
* and only the list of modules found in netlist is built |
|||
* @param aOpt = the value of option |
|||
*/ |
|||
void BuildModuleListOnly( bool aOpt ) |
|||
{ |
|||
m_BuildModuleListOnly = aOpt; |
|||
} |
|||
|
|||
/** |
|||
* Function BuildModuleListOnly |
|||
* Get the Build Module List Only option state |
|||
* @return the state of option (true/false) |
|||
*/ |
|||
bool BuildModuleListOnly() |
|||
{ |
|||
return m_BuildModuleListOnly; |
|||
} |
|||
|
|||
/** |
|||
* Function InitializeModules |
|||
* Called when reading a netlist and after the module info list is populated |
|||
* Load new module and clear pads netnames |
|||
* return true if all modules are loaded, false if some are missing |
|||
*/ |
|||
bool InitializeModules(); |
|||
|
|||
/** |
|||
* Function TestFootprintsMatchingAndExchange |
|||
* Called when reading a netlist, after the module info list is populated |
|||
* module reference updated (after a call to InitializeModules) |
|||
* Test, for each module, if the current footprint matches the footprint |
|||
* given by the netlist (or the cmp file, if used) |
|||
* print a list of mismatches od exchange footprints i |
|||
* m_ChangeFootprints == true |
|||
*/ |
|||
void TestFootprintsMatchingAndExchange(); |
|||
|
|||
|
|||
/** |
|||
* Function SetFilesnames |
|||
* initialize filenames |
|||
* @param aNetlistFileName = full filename of netlist |
|||
* @param aCmplistFileName = full filename of components file (can be empty) |
|||
* and the components file will be non used |
|||
*/ |
|||
void SetFilesnames( const wxString& aNetlistFileName, |
|||
const wxString& aCmplistFileName ) |
|||
{ |
|||
m_netlistFullName = aNetlistFileName; |
|||
m_cmplistFullName = aCmplistFileName; |
|||
} |
|||
|
|||
/** |
|||
* Function ReadNetList |
|||
* The main function to detect a netlist format, read the netlist, |
|||
* and update the board |
|||
* depending on the detected format, calls ReadOldFmtdNetList or ReadKicadNetList |
|||
* @param aFile = the already opened file (will be closed by the netlist reader) |
|||
* @return true if success |
|||
*/ |
|||
bool ReadNetList( FILE* aFile ); |
|||
|
|||
/** |
|||
* Function ReadOldFmtdNetList |
|||
* The main function to read a netlist (old netlist format), |
|||
* and update the board |
|||
* @param aFile = the already opened file (will be closed by ReadOldFmtdNetList) |
|||
* @return true if success |
|||
*/ |
|||
bool ReadOldFmtdNetList( FILE* aFile ); |
|||
|
|||
/** |
|||
* Function ReadKicadNetList |
|||
* The main function to read a netlist (new netlist format, using S expressions), |
|||
* and update the board |
|||
* @param aFile = the already opened file (will be closed by ReadKicadNetList) |
|||
* @return true if success |
|||
*/ |
|||
bool ReadKicadNetList( FILE* aFile ); |
|||
|
|||
/** |
|||
* function RemoveExtraFootprints |
|||
* Remove (delete) not locked footprints found on board, but not in netlist |
|||
* The netlist is expected to be read, and the main module list info up to date |
|||
*/ |
|||
void RemoveExtraFootprints( ); |
|||
|
|||
/** |
|||
* Function SetPadNetName |
|||
* Update a pad netname |
|||
* @param aModule = module reference |
|||
* @param aPadname = pad name (pad num) |
|||
* @param aNetname = new net name of the pad |
|||
* @return a pointer to the pad or NULL if the pad is not found |
|||
*/ |
|||
D_PAD* SetPadNetName( const wxString & aModule, const wxString & aPadname, |
|||
const wxString & aNetname ); |
|||
|
|||
private: |
|||
|
|||
/** |
|||
* Function FindModule |
|||
* search for a module id the modules existing in the current BOARD. |
|||
* @param aId = the key to identify the module to find: |
|||
* The reference or the full time stamp, according to m_UseTimeStamp |
|||
* @return the module found, or NULL. |
|||
*/ |
|||
MODULE* FindModule( const wxString& aId ); |
|||
|
|||
/** |
|||
* Function SetPadNetName |
|||
* Update a pad netname using the current footprint |
|||
* from the netlist (line format: ( \<pad number\> \<net name\> ) ) |
|||
* @param aText = current line read from netlist |
|||
*/ |
|||
bool SetPadNetName( char* aText ); |
|||
|
|||
/** |
|||
* Function ReadOldFmtNetlistModuleDescr |
|||
* Read the full description of a footprint, from the netlist |
|||
* and update the corresponding module. |
|||
* @param aBuildList bool to switch between 2 modes: |
|||
* aBuildList = true: |
|||
* add module info added to m_newModulesList |
|||
* aBuildList = false: |
|||
* The module is searched in the board modules list |
|||
* @param aText contains the first line of description |
|||
* This function uses m_useFichCmp as a flag to know the footprint name: |
|||
* If true: component file *.cmp is used |
|||
* If false: the netlist only is used |
|||
* This flag is reset to false if the .cmp file is not found |
|||
* @return a reference to the corresponding module on board (NULL if not found) |
|||
*/ |
|||
MODULE* ReadOldFmtNetlistModuleDescr( char* aText, bool aBuildList ); |
|||
|
|||
/** |
|||
* Function loadNewModules |
|||
* Load from libraries new modules found in netlist and add them to the current Board. |
|||
* modules to load come from m_newModulesList |
|||
* @return false if a footprint is not found, true if all footprints are loaded |
|||
*/ |
|||
bool loadNewModules(); |
|||
|
|||
/** |
|||
* function readModuleComponentLinkfile |
|||
* read the *.cmp file ( filename in m_cmplistFullName ) |
|||
* and initialize the m_Footprint member of each item in m_modulesInNetlist, |
|||
* when it is found in file, and with a non empty footprint value |
|||
* giving the equivalence between footprint names and components |
|||
* to find the footprint name corresponding to aCmpIdent |
|||
* @return true and the file can be read |
|||
*/ |
|||
bool readModuleComponentLinkfile(); |
|||
}; |
|||
|
|||
#endif // NETLIST_READER_H |
@ -0,0 +1,315 @@ |
|||
/**
|
|||
* @file pcbnew/netlist_reader_firstformat.cpp |
|||
*/ |
|||
/*
|
|||
* This program source code file is part of KiCad, a free EDA CAD application. |
|||
* |
|||
* Copyright (C) 1992-2011 Jean-Pierre Charras. |
|||
* Copyright (C) 1992-2011 KiCad Developers, see change_log.txt for contributors. |
|||
* |
|||
* 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, you may find one here: |
|||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|||
* or you may search the http://www.gnu.org website for the version 2 license,
|
|||
* or you may write to the Free Software Foundation, Inc., |
|||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA |
|||
*/ |
|||
|
|||
|
|||
/*
|
|||
* Netlist reader using the first format of pcbnew netlist. |
|||
* This netlist reader build the list of modules found in netlist |
|||
* (list in m_modulesInNetlist) |
|||
* and update pads netnames |
|||
*/ |
|||
|
|||
#include <fctsys.h>
|
|||
#include <kicad_string.h>
|
|||
#include <wxPcbStruct.h>
|
|||
#include <richio.h>
|
|||
|
|||
#include <class_board.h>
|
|||
#include <class_module.h>
|
|||
#include <pcbnew.h>
|
|||
|
|||
#include <netlist_reader.h>
|
|||
|
|||
// constants used by ReadOldFmtNetlistModuleDescr():
|
|||
#define BUILDLIST true
|
|||
#define READMODULE false
|
|||
|
|||
|
|||
/*
|
|||
* Function ReadOldFmtdNetList |
|||
* Update footprints (load missing footprints and delete on request extra |
|||
* footprints) |
|||
* Update References, values, "TIME STAMP" and connectivity data |
|||
* return true if Ok |
|||
* |
|||
* the format of the netlist is something like: |
|||
* # EESchema Netlist Version 1.0 generee le 18/5/2005-12:30:22 |
|||
* ( |
|||
* ( 40C08647 $noname R20 4,7K {Lib=R} |
|||
* ( 1 VCC ) |
|||
* ( 2 MODB_1 ) |
|||
* ) |
|||
* ( 40C0863F $noname R18 4,7_k {Lib=R} |
|||
* ( 1 VCC ) |
|||
* ( 2 MODA_1 ) |
|||
* ) |
|||
* } |
|||
* #End |
|||
*/ |
|||
bool NETLIST_READER::ReadOldFmtdNetList( FILE* aFile ) |
|||
{ |
|||
int state = 0; |
|||
bool is_comment = false; |
|||
|
|||
/* First, read the netlist: Build the list of footprints found in netlist
|
|||
*/ |
|||
// netlineReader dtor will close aFile
|
|||
FILE_LINE_READER netlineReader( aFile, m_netlistFullName ); |
|||
|
|||
while( netlineReader.ReadLine() ) |
|||
{ |
|||
char* line = StrPurge( netlineReader.Line() ); |
|||
|
|||
if( is_comment ) // Comments in progress
|
|||
{ |
|||
// Test for end of the current comment
|
|||
if( ( line = strchr( line, '}' ) ) == NULL ) |
|||
continue; |
|||
|
|||
is_comment = false; |
|||
} |
|||
if( *line == '{' ) // Start Comment
|
|||
{ |
|||
is_comment = true; |
|||
|
|||
if( ( line = strchr( line, '}' ) ) == NULL ) |
|||
continue; |
|||
} |
|||
|
|||
if( *line == '(' ) |
|||
state++; |
|||
|
|||
if( *line == ')' ) |
|||
state--; |
|||
|
|||
if( state == 2 ) |
|||
{ |
|||
ReadOldFmtNetlistModuleDescr( line, BUILDLIST ); |
|||
continue; |
|||
} |
|||
|
|||
if( state >= 3 ) // First pass: pad descriptions are not read here.
|
|||
{ |
|||
state--; |
|||
} |
|||
} |
|||
|
|||
if( BuildModuleListOnly() ) |
|||
return true; // at this point, the module list is read and built.
|
|||
|
|||
// Load new footprints
|
|||
bool success = InitializeModules(); |
|||
|
|||
if( ! success ) |
|||
wxMessageBox( _("Some footprints are not found in libraries") ); |
|||
|
|||
TestFootprintsMatchingAndExchange(); |
|||
|
|||
/* Second read , All footprints are on board.
|
|||
* Update the schematic info (pad netnames) |
|||
*/ |
|||
netlineReader.Rewind(); |
|||
m_currModule = NULL; |
|||
state = 0; |
|||
is_comment = false; |
|||
|
|||
while( netlineReader.ReadLine() ) |
|||
{ |
|||
char* line = StrPurge( netlineReader.Line() ); |
|||
|
|||
if( is_comment ) // we are reading a comment
|
|||
{ |
|||
// Test for end of the current comment
|
|||
if( ( line = strchr( line, '}' ) ) == NULL ) |
|||
continue; |
|||
is_comment = false; |
|||
} |
|||
|
|||
if( *line == '{' ) // this is the beginning of a comment
|
|||
{ |
|||
is_comment = true; |
|||
|
|||
if( ( line = strchr( line, '}' ) ) == NULL ) |
|||
continue; |
|||
} |
|||
|
|||
if( *line == '(' ) |
|||
state++; |
|||
|
|||
if( *line == ')' ) |
|||
state--; |
|||
|
|||
if( state == 2 ) |
|||
{ |
|||
m_currModule = ReadOldFmtNetlistModuleDescr( line, READMODULE ); |
|||
continue; |
|||
} |
|||
|
|||
if( state >= 3 ) |
|||
{ |
|||
if( m_currModule ) |
|||
SetPadNetName( line ); |
|||
state--; |
|||
} |
|||
} |
|||
|
|||
return true; |
|||
} |
|||
|
|||
|
|||
/* Function ReadOldFmtNetlistModuleDescr
|
|||
* Read the beginning of a footprint description, from the netlist |
|||
* and add a module info to m_modulesInNetlist |
|||
* Analyze lines like: |
|||
* ( /40C08647 $noname R20 4.7K {Lib=R} |
|||
* (1 VCC) |
|||
* (2 MODB_1) |
|||
* ) |
|||
*/ |
|||
MODULE* NETLIST_READER::ReadOldFmtNetlistModuleDescr( char* aText, bool aBuildList ) |
|||
{ |
|||
char* text; |
|||
wxString timeStampPath; // the full time stamp read from netlist
|
|||
wxString footprintName; // the footprint name read from netlist
|
|||
wxString cmpValue; // the component value read from netlist
|
|||
wxString cmpReference; // the component schematic reference read from netlist
|
|||
bool error = false; |
|||
char line[1024]; |
|||
|
|||
strcpy( line, aText ); |
|||
|
|||
cmpValue = wxT( "~" ); |
|||
|
|||
// Read descr line like /40C08647 $noname R20 4.7K {Lib=R}
|
|||
|
|||
// Read time stamp (first word)
|
|||
if( ( text = strtok( line, " ()\t\n" ) ) == NULL ) |
|||
error = true; |
|||
else |
|||
timeStampPath = FROM_UTF8( text ); |
|||
|
|||
// Read footprint name (second word)
|
|||
if( ( text = strtok( NULL, " ()\t\n" ) ) == NULL ) |
|||
error = true; |
|||
else |
|||
footprintName = FROM_UTF8( text ); |
|||
|
|||
// Read schematic reference (third word)
|
|||
if( ( text = strtok( NULL, " ()\t\n" ) ) == NULL ) |
|||
error = true; |
|||
else |
|||
cmpReference = FROM_UTF8( text ); |
|||
|
|||
// Read schematic value (forth word)
|
|||
if( ( text = strtok( NULL, " ()\t\n" ) ) == NULL ) |
|||
error = true; |
|||
else |
|||
cmpValue = FROM_UTF8( text ); |
|||
|
|||
if( error ) |
|||
return NULL; |
|||
|
|||
if( aBuildList ) |
|||
{ |
|||
MODULE_INFO* mod_info = new MODULE_INFO( footprintName, cmpReference, |
|||
cmpValue, timeStampPath ); |
|||
AddModuleInfo( mod_info ); |
|||
return NULL; |
|||
} |
|||
|
|||
// search the module loaded on board
|
|||
// reference and time stamps are already updated so we can used search by reference
|
|||
MODULE* module = m_pcbframe->GetBoard()->FindModuleByReference( cmpReference ); |
|||
if( module == NULL ) |
|||
{ |
|||
if( m_messageWindow ) |
|||
{ |
|||
wxString msg; |
|||
msg.Printf( _( "Component [%s] not found" ), GetChars( cmpReference ) ); |
|||
m_messageWindow->AppendText( msg + wxT( "\n" ) ); |
|||
} |
|||
} |
|||
|
|||
return module; |
|||
} |
|||
|
|||
|
|||
/*
|
|||
* Function SetPadNetName |
|||
* Update a pad netname using the current footprint |
|||
* Line format: ( <pad number> = <net name> ) |
|||
* Param aText = current line read from netlist |
|||
*/ |
|||
bool NETLIST_READER::SetPadNetName( char* aText ) |
|||
{ |
|||
char* p; |
|||
char line[256]; |
|||
|
|||
if( m_currModule == NULL ) |
|||
return false; |
|||
|
|||
strncpy( line, aText, sizeof(line) ); |
|||
|
|||
if( ( p = strtok( line, " ()\t\n" ) ) == NULL ) |
|||
return false; |
|||
|
|||
wxString pinName = FROM_UTF8( p ); |
|||
|
|||
if( ( p = strtok( NULL, " ()\t\n" ) ) == NULL ) |
|||
return false; |
|||
|
|||
wxString netName = FROM_UTF8( p ); |
|||
|
|||
bool found = false; |
|||
for( D_PAD* pad = m_currModule->m_Pads; pad; pad = pad->Next() ) |
|||
{ |
|||
wxString padName = pad->GetPadName(); |
|||
|
|||
if( padName == pinName ) |
|||
{ |
|||
found = true; |
|||
if( (char) netName[0] != '?' ) |
|||
pad->SetNetname( netName ); |
|||
else |
|||
pad->SetNetname( wxEmptyString ); |
|||
} |
|||
} |
|||
|
|||
if( !found ) |
|||
{ |
|||
if( m_messageWindow ) |
|||
{ |
|||
wxString msg; |
|||
msg.Printf( _( "Module [%s]: Pad [%s] not found" ), |
|||
GetChars( m_currModule->m_Reference->m_Text ), |
|||
GetChars( pinName ) ); |
|||
m_messageWindow->AppendText( msg + wxT( "\n" ) ); |
|||
} |
|||
} |
|||
|
|||
return found; |
|||
} |
@ -0,0 +1,325 @@ |
|||
/**
|
|||
* @file pcbnew/netlist_reader_kicad.cpp |
|||
*/ |
|||
/*
|
|||
* This program source code file is part of KiCad, a free EDA CAD application. |
|||
* |
|||
* Copyright (C) 1992-2011 Jean-Pierre Charras. |
|||
* Copyright (C) 1992-2011 KiCad Developers, see change_log.txt for contributors. |
|||
* |
|||
* 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, you may find one here: |
|||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|||
* or you may search the http://www.gnu.org website for the version 2 license,
|
|||
* or you may write to the Free Software Foundation, Inc., |
|||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA |
|||
*/ |
|||
|
|||
#include <wx/wx.h>
|
|||
#include <netlist_lexer.h> // netlist_lexer is common to Eeschema and Pcbnew
|
|||
#include <netlist_reader.h>
|
|||
|
|||
using namespace NL_T; |
|||
|
|||
/**
|
|||
* Class PCB_PLOT_PARAMS_PARSER |
|||
* is the parser class for PCB_PLOT_PARAMS. |
|||
*/ |
|||
class NETLIST_READER_KICAD_PARSER : public NETLIST_LEXER |
|||
{ |
|||
private: |
|||
T token; |
|||
NETLIST_READER * netlist_reader; |
|||
|
|||
public: |
|||
NETLIST_READER_KICAD_PARSER( FILE_LINE_READER* aReader, NETLIST_READER *aNetlistReader ); |
|||
|
|||
/**
|
|||
* Function Parse |
|||
* parse the full netlist |
|||
*/ |
|||
void Parse( BOARD * aBrd ) throw( IO_ERROR, PARSE_ERROR ); |
|||
|
|||
/**
|
|||
* Function ParseComp |
|||
* parse the comp description like |
|||
* (comp (ref P1) |
|||
* (value DB25FEMELLE) |
|||
* (footprint DB25FC) |
|||
* (libsource (lib conn) (part DB25)) |
|||
* (sheetpath (names /) (tstamps /)) |
|||
* (tstamp 3256759C)) |
|||
*/ |
|||
MODULE_INFO* ParseComp() throw( IO_ERROR, PARSE_ERROR ); |
|||
|
|||
void ParseNet( BOARD * aBrd ) throw( IO_ERROR, PARSE_ERROR ); |
|||
|
|||
/**
|
|||
* Function SkipCurrent |
|||
* Skip the current token level, i.e |
|||
* search for the RIGHT parenthesis which closes the current description |
|||
*/ |
|||
void SkipCurrent() throw( IO_ERROR, PARSE_ERROR ); |
|||
|
|||
// Useful for debug only:
|
|||
const char* getTokenName( T aTok ) |
|||
{ |
|||
return NETLIST_LEXER::TokenName( aTok ); |
|||
} |
|||
}; |
|||
|
|||
|
|||
bool NETLIST_READER::ReadKicadNetList( FILE* aFile ) |
|||
{ |
|||
bool success = true; |
|||
BOARD * brd = m_pcbframe->GetBoard(); |
|||
|
|||
// netlineReader dtor will close aFile
|
|||
FILE_LINE_READER netlineReader( aFile, m_netlistFullName ); |
|||
NETLIST_READER_KICAD_PARSER netlist_parser( &netlineReader, this ); |
|||
|
|||
netlist_parser.Parse( brd ); |
|||
|
|||
return success; |
|||
} |
|||
|
|||
|
|||
|
|||
// NETLIST_READER_KICAD_PARSER
|
|||
NETLIST_READER_KICAD_PARSER::NETLIST_READER_KICAD_PARSER( FILE_LINE_READER* aReader, |
|||
NETLIST_READER *aNetlistReader ) : |
|||
NETLIST_LEXER( aReader ) |
|||
{ |
|||
netlist_reader = aNetlistReader; |
|||
} |
|||
|
|||
/**
|
|||
* Function SkipCurrent |
|||
* Skip the current token level, i.e |
|||
* search for the RIGHT parenthesis which closes the current description |
|||
*/ |
|||
void NETLIST_READER_KICAD_PARSER::SkipCurrent() throw( IO_ERROR, PARSE_ERROR ) |
|||
{ |
|||
int curr_level = 0; |
|||
while( ( token = NextTok() ) != T_EOF ) |
|||
{ |
|||
if( token == T_LEFT ) |
|||
curr_level--; |
|||
if( token == T_RIGHT ) |
|||
{ |
|||
curr_level++; |
|||
if( curr_level > 0 ) |
|||
return; |
|||
} |
|||
} |
|||
} |
|||
|
|||
|
|||
void NETLIST_READER_KICAD_PARSER::Parse( BOARD * aBrd ) |
|||
throw( IO_ERROR, PARSE_ERROR ) |
|||
{ |
|||
wxString text; |
|||
while( ( token = NextTok() ) != T_EOF ) |
|||
{ |
|||
if( token == T_LEFT ) |
|||
token = NextTok(); |
|||
if( token == T_components ) |
|||
{ |
|||
// The section comp starts here.
|
|||
while( ( token = NextTok() ) != T_RIGHT ) |
|||
{ |
|||
if( token == T_LEFT ) |
|||
token = NextTok(); |
|||
if( token == T_comp ) |
|||
{ |
|||
// A comp section if found. Read it
|
|||
MODULE_INFO* mod_info = ParseComp(); |
|||
netlist_reader->AddModuleInfo( mod_info ); |
|||
} |
|||
} |
|||
if( netlist_reader->BuildModuleListOnly() ) |
|||
return; // at this point, the module list is read and built.
|
|||
// Load new footprints
|
|||
netlist_reader->InitializeModules(); |
|||
netlist_reader->TestFootprintsMatchingAndExchange(); |
|||
} |
|||
|
|||
if( token == T_nets ) |
|||
{ |
|||
// The section nets starts here.
|
|||
while( ( token = NextTok() ) != T_RIGHT ) |
|||
{ |
|||
if( token == T_LEFT ) |
|||
token = NextTok(); |
|||
if( token == T_net ) |
|||
{ |
|||
// A net section if found. Read it
|
|||
ParseNet( aBrd ); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
} |
|||
|
|||
void NETLIST_READER_KICAD_PARSER::ParseNet( BOARD * aBrd ) |
|||
throw( IO_ERROR, PARSE_ERROR ) |
|||
{ |
|||
/* Parses a section like
|
|||
* (net (code 20) (name /PC-A0) |
|||
* (node (ref BUS1) (pin 62)) |
|||
* (node (ref U3) (pin 3)) |
|||
* (node (ref U9) (pin M6))) |
|||
*/ |
|||
|
|||
wxString code; |
|||
wxString name; |
|||
wxString cmpref; |
|||
wxString pin; |
|||
D_PAD * pad = NULL; |
|||
int nodecount = 0; |
|||
// The token net was read, so the next data is (code <number>)
|
|||
while( (token = NextTok()) != T_RIGHT ) |
|||
{ |
|||
if( token == T_LEFT ) |
|||
token = NextTok(); |
|||
switch( token ) |
|||
{ |
|||
case T_code: |
|||
NeedSYMBOLorNUMBER(); |
|||
code = FROM_UTF8( CurText() ); |
|||
NeedRIGHT(); |
|||
break; |
|||
|
|||
case T_name: |
|||
NeedSYMBOLorNUMBER(); |
|||
name = FROM_UTF8( CurText() ); |
|||
NeedRIGHT(); |
|||
if( name.IsEmpty() ) // Give a dummy net name like N-000109
|
|||
name = wxT("N-00000") + code; |
|||
break; |
|||
|
|||
case T_node: |
|||
while( (token = NextTok()) != T_RIGHT ) |
|||
{ |
|||
if( token == T_LEFT ) |
|||
token = NextTok(); |
|||
switch( token ) |
|||
{ |
|||
case T_ref: |
|||
NeedSYMBOLorNUMBER(); |
|||
cmpref = FROM_UTF8( CurText() ); |
|||
NeedRIGHT(); |
|||
break; |
|||
|
|||
case T_pin: |
|||
NeedSYMBOLorNUMBER(); |
|||
pin = FROM_UTF8( CurText() ); |
|||
NeedRIGHT(); |
|||
break; |
|||
|
|||
default: |
|||
SkipCurrent(); |
|||
break; |
|||
} |
|||
} |
|||
pad = netlist_reader->SetPadNetName( cmpref, pin, name ); |
|||
nodecount++; |
|||
break; |
|||
|
|||
default: |
|||
SkipCurrent(); |
|||
break; |
|||
} |
|||
} |
|||
|
|||
// When there is onlu one item in net, clear pad netname
|
|||
if( nodecount < 2 && pad ) |
|||
pad->SetNetname( wxEmptyString ); |
|||
} |
|||
|
|||
|
|||
MODULE_INFO* NETLIST_READER_KICAD_PARSER::ParseComp() |
|||
throw( IO_ERROR, PARSE_ERROR ) |
|||
{ |
|||
/* Parses a section like
|
|||
* (comp (ref P1) |
|||
* (value DB25FEMELLE) |
|||
* (footprint DB25FC) |
|||
* (libsource (lib conn) (part DB25)) |
|||
* (sheetpath (names /) (tstamps /)) |
|||
* (tstamp 3256759C)) |
|||
* |
|||
* other fields (unused) are skipped |
|||
* A component need a reference, value, foorprint name and a full time stamp |
|||
* The full time stamp is the sheetpath time stamp + the component time stamp |
|||
*/ |
|||
wxString ref; |
|||
wxString value; |
|||
wxString footprint; |
|||
wxString pathtimestamp, timestamp; |
|||
// The token comp was read, so the next data is (ref P1)
|
|||
|
|||
while( (token = NextTok()) != T_RIGHT ) |
|||
{ |
|||
if( token == T_LEFT ) |
|||
token = NextTok(); |
|||
switch( token ) |
|||
{ |
|||
case T_ref: |
|||
NeedSYMBOLorNUMBER(); |
|||
ref = FROM_UTF8( CurText() ); |
|||
NeedRIGHT(); |
|||
break; |
|||
|
|||
case T_value: |
|||
NeedSYMBOLorNUMBER(); |
|||
value = FROM_UTF8( CurText() ); |
|||
NeedRIGHT(); |
|||
break; |
|||
|
|||
case T_footprint: |
|||
NeedSYMBOLorNUMBER(); |
|||
footprint = FROM_UTF8( CurText() ); |
|||
NeedRIGHT(); |
|||
break; |
|||
|
|||
case T_libsource: |
|||
// Currently not used data, skip it
|
|||
SkipCurrent(); |
|||
break; |
|||
|
|||
case T_sheetpath: |
|||
while( ( token = NextTok() ) != T_tstamps ); |
|||
NeedSYMBOLorNUMBER(); |
|||
pathtimestamp = FROM_UTF8( CurText() ); |
|||
NeedRIGHT(); |
|||
NeedRIGHT(); |
|||
break; |
|||
|
|||
case T_tstamp: |
|||
NeedSYMBOLorNUMBER(); |
|||
timestamp = FROM_UTF8( CurText() ); |
|||
NeedRIGHT(); |
|||
break; |
|||
|
|||
default: |
|||
// Skip not used data (i.e all other tokens)
|
|||
SkipCurrent(); |
|||
break; |
|||
} |
|||
} |
|||
pathtimestamp += timestamp; |
|||
MODULE_INFO* mod_info = new MODULE_INFO( footprint, ref, value, pathtimestamp ); |
|||
|
|||
return mod_info; |
|||
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue