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:
parent
88729de685
commit
d9eaff1c99
|
@ -384,6 +384,7 @@ void NETLIST_EXPORTER_PSPICE::UpdateDirectives( unsigned aCtl )
|
||||||
|
|
||||||
m_directives.clear();
|
m_directives.clear();
|
||||||
bool controlBlock = false;
|
bool controlBlock = false;
|
||||||
|
bool circuitBlock = false;
|
||||||
|
|
||||||
for( unsigned i = 0; i < sheetList.size(); i++ )
|
for( unsigned i = 0; i < sheetList.size(); i++ )
|
||||||
{
|
{
|
||||||
|
@ -436,20 +437,9 @@ void NETLIST_EXPORTER_PSPICE::UpdateDirectives( unsigned aCtl )
|
||||||
m_title = line.AfterFirst( ' ' );
|
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
|
else if( line.StartsWith( '.' ) // one-line directives
|
||||||
|| controlBlock // .control .. .endc block
|
|| controlBlock // .control .. .endc block
|
||||||
|
|| circuitBlock // .subckt .. .ends block
|
||||||
|| couplingK.Matches( line ) // K## L## L## coupling constant
|
|| couplingK.Matches( line ) // K## L## L## coupling constant
|
||||||
|| ( directiveStarted && line.StartsWith( '+' ) ) ) // multiline directives
|
|| ( directiveStarted && line.StartsWith( '+' ) ) ) // multiline directives
|
||||||
{
|
{
|
||||||
|
@ -458,6 +448,21 @@ void NETLIST_EXPORTER_PSPICE::UpdateDirectives( unsigned aCtl )
|
||||||
m_directives.emplace_back( line + " " );
|
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
|
// Mark directive as started or continued in case it is a multi-line one
|
||||||
directiveStarted = line.StartsWith( '.' )
|
directiveStarted = line.StartsWith( '.' )
|
||||||
|| ( directiveStarted && line.StartsWith( '+' ) );
|
|| ( directiveStarted && line.StartsWith( '+' ) );
|
||||||
|
|
Loading…
Reference in New Issue