29#include <wx/tokenzr.h>
35 auto base = std::make_unique<SIM_MODEL_SUBCKT>();
36 base->AddPin( {
"+IN",
"1" } );
37 base->AddPin( {
"-IN",
"2" } );
38 base->AddPin( {
"VCC",
"3" } );
39 base->AddPin( {
"VEE",
"4" } );
40 base->AddPin( {
"OUT",
"5" } );
49 { 1, { { wxS(
"3" ), wxS(
"+IN" ) }, { wxS(
"2" ), wxS(
"-IN" ) }, { wxS(
"1" ), wxS(
"OUT" ) } } },
50 { 2, { { wxS(
"5" ), wxS(
"+IN" ) }, { wxS(
"6" ), wxS(
"-IN" ) }, { wxS(
"7" ), wxS(
"OUT" ) } } },
51 { 3, { { wxS(
"4" ), wxS(
"VEE" ) }, { wxS(
"8" ), wxS(
"VCC" ) } } },
56static std::vector<wxString>
splitTokens(
const wxString& aLine )
58 std::vector<wxString> tokens;
59 wxStringTokenizer tokenizer( aLine, wxS(
" \t" ), wxTOKEN_STRTOK );
61 while( tokenizer.HasMoreTokens() )
62 tokens.push_back( tokenizer.GetNextToken() );
73 std::vector<std::pair<wxString, wxString>> pairs =
76 const std::vector<std::pair<wxString, wxString>>
expected = {
77 { wxS(
"3" ), wxS(
"+IN" ) }, { wxS(
"2" ), wxS(
"-IN" ) }, { wxS(
"1" ), wxS(
"OUT" ) } };
92 std::vector<std::pair<wxString, wxString>> pairs =
95 BOOST_REQUIRE_EQUAL( pairs.size(), 1 );
130 { wxS(
"VCC" ), wxS(
"VEE" ) } );
133 BOOST_REQUIRE_EQUAL(
wrapper.GetPinCount(), 8 );
135 std::set<wxString> symbolPins;
136 std::set<std::string> nodeNames;
140 symbolPins.insert(
pin.symbolPinNumber );
141 nodeNames.insert(
pin.modelPinName );
147 for(
int ii = 1; ii <= 8; ++ii )
149 "missing outer pin for symbol pin " << ii );
157 { wxS(
"VCC" ), wxS(
"VEE" ) } );
162 wxString modelLine(
wrapper.SpiceGenerator().ModelLine( item ) );
163 wxArrayString lines = wxStringTokenize( modelLine, wxS(
"\n" ), wxTOKEN_STRTOK );
165 BOOST_REQUIRE_EQUAL( lines.size(), 4 );
169 BOOST_REQUIRE_GE(
header.size(), 2 );
173 const std::vector<wxString> expectedNodes = { wxS(
"n3" ), wxS(
"n2" ), wxS(
"n1" ),
174 wxS(
"n5" ), wxS(
"n6" ), wxS(
"n7" ),
175 wxS(
"n8" ), wxS(
"n4" ) };
176 std::vector<wxString> headerNodes(
header.begin() + 2,
header.end() );
177 BOOST_CHECK( headerNodes == expectedNodes );
193 { wxS(
"VCC" ), wxS(
"VEE" ) } );
195 { wxS(
"VCC" ), wxS(
"VEE" ) } );
202 { wxS(
"VCC" ), wxS(
"VEE" ) } );
203 BOOST_CHECK( a.GetSignature() != c.GetSignature() );
211 { wxS(
"VCC" ), wxS(
"VEE" ) } );
216 std::vector<std::string> names =
wrapper.SpiceGenerator().CurrentNames( item );
221 for(
const std::string&
name : names )
241 std::vector<UNIT_PIN_MAP> maps = {
242 { 1, { { wxS(
"3" ), wxS(
"+IN" ) }, { wxS(
"2" ), wxS(
"-IN" ) } } },
243 { 2, { { wxS(
"5" ), wxS(
"+IN" ) }, { wxS(
"6" ), wxS(
"-IN" ) } } },
244 { 3, { { wxS(
"4" ), wxS(
"VEE" ) }, { wxS(
"8" ), wxS(
"VCC" ) } } },
248 { wxS(
"VCC" ), wxS(
"VEE" ) } ),
258 std::vector<UNIT_PIN_MAP> maps = {
259 { 1, { { wxS(
"3" ), wxS(
"+IN" ) }, { wxS(
"2" ), wxS(
"-IN" ) }, { wxS(
"1" ), wxS(
"OUT" ) } } },
260 { 2, { { wxS(
"5" ), wxS(
"+IN" ) }, { wxS(
"6" ), wxS(
"-IN" ) }, { wxS(
"7" ), wxS(
"OUT" ) } } },
261 { 3, { { wxS(
"4" ), wxS(
"VEE" ) } } },
265 { wxS(
"VCC" ), wxS(
"VEE" ) } ),
275 std::vector<UNIT_PIN_MAP> maps = {
276 { 1, { { wxS(
"3" ), wxS(
"+IN" ) }, { wxS(
"2" ), wxS(
"-IN" ) }, { wxS(
"1" ), wxS(
"OUT" ) },
277 { wxS(
"4" ), wxS(
"VCC" ) } } },
278 { 2, { { wxS(
"5" ), wxS(
"+IN" ) }, { wxS(
"6" ), wxS(
"-IN" ) }, { wxS(
"7" ), wxS(
"OUT" ) } } },
279 { 3, { { wxS(
"9" ), wxS(
"VEE" ) }, { wxS(
"8" ), wxS(
"VCC" ) } } },
283 { wxS(
"VCC" ), wxS(
"VEE" ) } ),
291 auto base = std::make_unique<SIM_MODEL_SUBCKT>();
292 base->AddPin( {
"A",
"1" } );
293 base->AddPin( {
"B",
"2" } );
294 base->AddPin( {
"Y",
"3" } );
295 base->AddPin( {
"VCC",
"4" } );
296 base->AddPin( {
"GND",
"5" } );
298 std::vector<UNIT_PIN_MAP> maps = {
299 { 1, { { wxS(
"1" ), wxS(
"A" ) }, { wxS(
"2" ), wxS(
"B" ) }, { wxS(
"3" ), wxS(
"Y" ) } } },
300 { 2, { { wxS(
"4" ), wxS(
"A" ) }, { wxS(
"5" ), wxS(
"B" ) }, { wxS(
"6" ), wxS(
"Y" ) } } },
301 { 3, { { wxS(
"9" ), wxS(
"A" ) }, { wxS(
"10" ), wxS(
"B" ) }, { wxS(
"8" ), wxS(
"Y" ) } } },
302 { 4, { { wxS(
"12" ), wxS(
"A" ) }, { wxS(
"13" ), wxS(
"B" ) }, { wxS(
"11" ), wxS(
"Y" ) } } },
303 { 5, { { wxS(
"14" ), wxS(
"VCC" ) }, { wxS(
"7" ), wxS(
"GND" ) } } },
313 wxArrayString lines = wxStringTokenize( wxString(
wrapper.SpiceGenerator().ModelLine( item ) ),
314 wxS(
"\n" ), wxTOKEN_STRTOK );
316 std::vector<std::vector<wxString>> innerLines;
318 for(
const wxString& line : lines )
320 if( line.EndsWith( wxS(
"nand_single" ) ) )
324 BOOST_REQUIRE_EQUAL( innerLines.size(), 4u );
328 for(
const std::vector<wxString>& inner : innerLines )
330 BOOST_REQUIRE_EQUAL( inner.size(), 7u );
341 auto base = std::make_unique<SIM_MODEL_SUBCKT>();
342 base->AddPin( {
"+IN",
"1" } );
343 base->AddPin( {
"-IN",
"2" } );
344 base->AddPin( {
"VCC",
"3" } );
345 base->AddPin( {
"VEE",
"4" } );
346 base->AddPin( {
"OUT",
"5" } );
347 base->AddPin( {
"EN",
"6" } );
349 std::vector<UNIT_PIN_MAP> maps = {
350 { 1, { { wxS(
"3" ), wxS(
"+IN" ) }, { wxS(
"2" ), wxS(
"-IN" ) }, { wxS(
"1" ), wxS(
"OUT" ) },
351 { wxS(
"9" ), wxS(
"EN" ) } } },
352 { 2, { { wxS(
"5" ), wxS(
"+IN" ) }, { wxS(
"6" ), wxS(
"-IN" ) }, { wxS(
"7" ), wxS(
"OUT" ) } } },
353 { 3, { { wxS(
"4" ), wxS(
"VEE" ) }, { wxS(
"8" ), wxS(
"VCC" ) } } },
357 { wxS(
"VCC" ), wxS(
"VEE" ) } );
363 wxString modelLine(
wrapper.SpiceGenerator().ModelLine( item ) );
367 "expected a not-connected node for the unmapped private pin" );
Hold an error message and may be used when throwing exceptions containing meaningful error messages.
Wraps a resolved single-unit base model and presents it as one component-level SPICE device.
std::vector< std::pair< wxString, wxString > > ParseSimPinsTokens(const wxString &aPins, const wxString &aRef)
Parse one unit's Sim.Pins text into (symbolPinNumber -> modelPinName) pairs, preserving the written o...
BOOST_AUTO_TEST_CASE(HorizontalAlignment)
BOOST_AUTO_TEST_SUITE(CadstarPartParser)
BOOST_AUTO_TEST_SUITE_END()
VECTOR3I expected(15, 30, 45)
std::vector< std::string > header
BOOST_CHECK_MESSAGE(totalMismatches==0, std::to_string(totalMismatches)+" board(s) with strategy disagreements")
BOOST_AUTO_TEST_CASE(ParsePinsPreservesOrder)
static std::vector< UNIT_PIN_MAP > dualOpampMaps()
static std::unique_ptr< SIM_MODEL_SUBCKT > makeBaseOpamp()
static std::vector< wxString > splitTokens(const wxString &aLine)
BOOST_CHECK_EQUAL(result, "25.4")