BSDL: attach-bsdl command + persist the attached model
New `attach-bsdl <module> <part> <file.bsd>` command: parse via BsdlModel, apply_bsdl() onto the part, store the path on Part::bsdl_path, report bound/ unbound. Persist a `B\t<path>` line under the part; on restore, re-parse and re-apply each attached model (the .bsd path is persisted, not the derived pin specs). Round-trip covered by test_bsdl_apply. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -4,6 +4,12 @@
|
||||
#include "system/parts.hpp"
|
||||
#include "system/pins.hpp"
|
||||
#include "system/pin_spec.hpp"
|
||||
#include "system/system.hpp"
|
||||
#include "system/modules.hpp"
|
||||
#include "system/persist.hpp"
|
||||
|
||||
#include <cstdio>
|
||||
#include <fstream>
|
||||
|
||||
// Minimal synthetic BSDL: 4 TAP pins, one bidir I/O, a power and a ground
|
||||
// linkage pin, each with a PIN_MAP ball.
|
||||
@@ -92,3 +98,46 @@ TEST_CASE("apply_bsdl falls back to the physical pad when names are balls") {
|
||||
CHECK(part.get("C1")->spec.function == PinFunction::Power); // VDD:C1
|
||||
CHECK(part.get("C2")->spec.function == PinFunction::Ground); // GND:C2
|
||||
}
|
||||
|
||||
TEST_CASE("attached BSDL path persists and re-applies on restore") {
|
||||
const char *bsd = "test_attach_demo.bsd";
|
||||
const char *snap = "test_attach_snap.essim";
|
||||
{ std::ofstream o(bsd); o << DEMO_BSDL; }
|
||||
|
||||
{
|
||||
System sys;
|
||||
Module *m = sys.modules()->merge("CARD");
|
||||
Part *u = new Part("U1");
|
||||
for (const char *n : {"TCK", "TDI", "TDO", "TMS", "IO1", "VDD", "GND"})
|
||||
u->add(new Pin(n));
|
||||
m->add(u);
|
||||
|
||||
BsdlModel model = BsdlModel::from_file(bsd);
|
||||
REQUIRE(model.valid());
|
||||
apply_bsdl(u, model);
|
||||
u->bsdl_path = bsd;
|
||||
|
||||
std::string err;
|
||||
REQUIRE(save_system(&sys, snap, err));
|
||||
}
|
||||
|
||||
{
|
||||
std::string err;
|
||||
System *sys = restore_system(snap, err);
|
||||
REQUIRE(sys != nullptr);
|
||||
|
||||
Part *u = sys->modules()->get("CARD")->get("U1");
|
||||
CHECK(u->bsdl_path == bsd);
|
||||
// spec re-derived from the model at restore, not stored in the snapshot
|
||||
CHECK(u->get("VDD")->spec.function == PinFunction::Power);
|
||||
CHECK(u->get("VDD")->spec.source == SpecSource::Bsdl);
|
||||
CHECK(u->get("VDD")->expected_signal_type() == SignalType::Power);
|
||||
CHECK(u->get("TCK")->spec.function == PinFunction::JtagTck);
|
||||
CHECK(u->get("TCK")->spec.pad == "A1");
|
||||
|
||||
delete sys;
|
||||
}
|
||||
|
||||
std::remove(bsd);
|
||||
std::remove(snap);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user