From ac39e32bc9cc02d6260167476ada8671a1f38874 Mon Sep 17 00:00:00 2001 From: Seth Hillbrand Date: Fri, 17 Jan 2020 18:56:30 -0800 Subject: [PATCH] Recognize subckt blocks in spice Spice lines defining circuit elements are contained in a .subckt .. .ends block. The intervening lines should be exported to the netlist as well as the control lines. (cherry picked from commit d9eaff1c99f4c6664e23f8995062cf34f92dbc6c) --- .../netlist_exporter_pspice.cpp | 29 +++++++++++-------- 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/eeschema/netlist_exporters/netlist_exporter_pspice.cpp b/eeschema/netlist_exporters/netlist_exporter_pspice.cpp index 8aa235c8c9..406da8795d 100644 --- a/eeschema/netlist_exporters/netlist_exporter_pspice.cpp +++ b/eeschema/netlist_exporters/netlist_exporter_pspice.cpp @@ -382,6 +382,7 @@ void NETLIST_EXPORTER_PSPICE::UpdateDirectives( unsigned aCtl ) m_directives.clear(); bool controlBlock = false; + bool circuitBlock = false; for( unsigned i = 0; i < sheetList.size(); i++ ) { @@ -437,20 +438,9 @@ void NETLIST_EXPORTER_PSPICE::UpdateDirectives( unsigned aCtl ) m_title = line.AfterFirst( ' ' ); } - // Handle .control .. .endc blocks - else if( lowercaseline.IsSameAs( ".control" ) && ( !controlBlock ) ) - { - controlBlock = true; - m_directives.push_back( line ); - } - else if( lowercaseline.IsSameAs( ".endc" ) && controlBlock ) - { - controlBlock = false; - m_directives.push_back( line ); - } - else if( line.StartsWith( '.' ) // one-line directives || controlBlock // .control .. .endc block + || circuitBlock // .subckt .. .ends block || couplingK.Matches( line ) // K## L## L## coupling constant || ( directiveStarted && line.StartsWith( '+' ) ) ) // multiline directives { @@ -459,6 +449,21 @@ void NETLIST_EXPORTER_PSPICE::UpdateDirectives( unsigned aCtl ) m_directives.emplace_back( line + " " ); } + + // Handle .control .. .endc blocks + if( lowercaseline.IsSameAs( ".control" ) && ( !controlBlock ) ) + controlBlock = true; + + if( lowercaseline.IsSameAs( ".endc" ) && controlBlock ) + controlBlock = false; + + // Handle .subckt .. .ends blocks + if( lowercaseline.StartsWith( ".subckt" ) && ( !circuitBlock ) ) + circuitBlock = true; + + if( lowercaseline.IsSameAs( ".ends" ) && circuitBlock ) + circuitBlock = false; + // Mark directive as started or continued in case it is a multi-line one directiveStarted = line.StartsWith( '.' ) || ( directiveStarted && line.StartsWith( '+' ) );