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.
This commit is contained in:
Seth Hillbrand 2020-01-17 18:56:30 -08:00
parent 88729de685
commit d9eaff1c99
1 changed files with 17 additions and 12 deletions

View File

@ -384,6 +384,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++ )
{
@ -436,20 +437,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
{
@ -458,6 +448,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( '+' ) );