20#include <boost/test/unit_test.hpp>
43static const char*
DAISY_PCB_FILE =
"net_chains/net_chain_trunk_delay.kicad_pcb";
48std::unique_ptr<BOARD> loadBoard(
const char* aBoardFile )
51 std::unique_ptr<BOARD> board = std::make_unique<BOARD>();
53 board->BuildConnectivity();
59void tagChainNets(
BOARD* aBoard,
const wxString& aChain )
63 if( n && n->GetNetname().StartsWith( wxS(
"/NET_" ) ) )
64 n->SetNetChain( aChain );
71void setTerminals(
BOARD* aBoard,
const wxString& aChain )
78 if( fp->Pads().empty() )
94 if( n && n->GetNetChain() == aChain )
96 n->SetTerminalPad( 0, first->
Pads().front() );
97 n->SetTerminalPad( 1, last->
Pads().front() );
103std::set<BOARD_CONNECTED_ITEM*> collectChainItems(
BOARD* aBoard,
const wxString& aChain )
105 std::set<BOARD_CONNECTED_ITEM*> items;
109 if( t->GetNet() && t->GetNet()->GetNetChain() == aChain )
115 for(
PAD* p : fp->Pads() )
117 if( p->GetNet() && p->GetNet()->GetNetChain() == aChain )
137 tagChainNets( board.get(), wxS(
"DSY" ) );
138 setTerminals( board.get(), wxS(
"DSY" ) );
140 CHAIN_TOPOLOGY topo( board.get(), wxS(
"DSY" ), collectChainItems( board.get(), wxS(
"DSY" ) ),
144 BOOST_CHECK_CLOSE( topo.
TrunkLength(), 50.0e6, 5.0 );
147 BOOST_CHECK_CLOSE( topo.
TrunkDelay(), expectedDelayIU, 5.0 );
151 auto [bridgingLen, bridgingDelay] =
153 BOOST_CHECK_CLOSE( bridgingDelay, topo.
TrunkDelay(), 0.001 );
154 BOOST_CHECK_CLOSE( bridgingLen, 5.0e6, 0.001 );
165 tagChainNets( board.get(), wxS(
"DSY" ) );
168 CHAIN_TOPOLOGY topo( board.get(), wxS(
"DSY" ), collectChainItems( board.get(), wxS(
"DSY" ) ),
171 BOOST_CHECK( !topo.
IsValid() );
175 auto [bridgingLen, bridgingDelay] =
178 BOOST_CHECK_CLOSE( bridgingLen, 5.0e6, 0.001 );
181 BOOST_CHECK_CLOSE( bridgingDelay, expectedDelayIU, 0.001 );
constexpr EDA_IU_SCALE pcbIUScale
General utilities for PCB file IO for QA programs.
Information pertinent to a Pcbnew printed circuit board.
const NETINFO_LIST & GetNetInfo() const
const FOOTPRINTS & Footprints() const
const TRACKS & Tracks() const
Build a topological view of a single named net chain's routed copper.
double TrunkLength() const
double TrunkDelay() const
Handle the data for a net.
A #PLUGIN derivation for saving and loading Pcbnew s-expression formatted files.
BOARD * LoadBoard(const wxString &aFileName, BOARD *aAppendToMe, const std::map< std::string, UTF8 > *aProperties=nullptr, PROJECT *aProject=nullptr) override
Load information from some input file format that this PCB_IO implementation knows about into either ...
std::string GetPcbnewTestDataDir()
Utility which returns a path to the data directory where the test board files are stored.
std::tuple< double, double > BoardChainBridging(const BOARD *aBoard, const wxString &aNetChain, const double aDefaultBridgeUnitDelay)
Compute both the chain bridging length and its associated propagation delay (in internal delay IU,...
BOOST_AUTO_TEST_CASE(HorizontalAlignment)
BOOST_AUTO_TEST_SUITE(CadstarPartParser)
static const char * DAISY_PCB_FILE
BOOST_REQUIRE(intersection.has_value()==c.ExpectedIntersection.has_value())
BOOST_AUTO_TEST_SUITE_END()
constexpr double DEFAULT_PROPAGATION_DELAY_PS_PER_MM
BOOST_AUTO_TEST_CASE(DaisyTrunkDelayEqualsBridgeWithoutStackup)
BOOST_CHECK_EQUAL(result, "25.4")