Add ice40 --test mode
Signed-off-by: Clifford Wolf <clifford@clifford.at>
This commit is contained in:
parent
9afa6a2016
commit
f07682f515
@ -211,6 +211,9 @@ struct BelId
|
|||||||
bool nil() const {
|
bool nil() const {
|
||||||
return index < 0;
|
return index < 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool operator==(const BelId &other) const { return index == other.index; }
|
||||||
|
bool operator!=(const BelId &other) const { return index != other.index; }
|
||||||
};
|
};
|
||||||
|
|
||||||
struct WireId
|
struct WireId
|
||||||
@ -220,6 +223,9 @@ struct WireId
|
|||||||
bool nil() const {
|
bool nil() const {
|
||||||
return index < 0;
|
return index < 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool operator==(const WireId &other) const { return index == other.index; }
|
||||||
|
bool operator!=(const WireId &other) const { return index != other.index; }
|
||||||
};
|
};
|
||||||
|
|
||||||
struct PipId
|
struct PipId
|
||||||
@ -229,6 +235,9 @@ struct PipId
|
|||||||
bool nil() const {
|
bool nil() const {
|
||||||
return index < 0;
|
return index < 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool operator==(const PipId &other) const { return index == other.index; }
|
||||||
|
bool operator!=(const PipId &other) const { return index != other.index; }
|
||||||
};
|
};
|
||||||
|
|
||||||
struct BelPin
|
struct BelPin
|
||||||
|
@ -32,7 +32,7 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
po::options_description options("Allowed options");
|
po::options_description options("Allowed options");
|
||||||
options.add_options()("help,h","show help");
|
options.add_options()("help,h","show help");
|
||||||
options.add_options()("debug","just a check");
|
options.add_options()("test","just a check");
|
||||||
options.add_options()("gui","start gui");
|
options.add_options()("gui","start gui");
|
||||||
options.add_options()("file", po::value<std::string>(), "python file to execute");
|
options.add_options()("file", po::value<std::string>(), "python file to execute");
|
||||||
options.add_options()("version,v","show version");
|
options.add_options()("version,v","show version");
|
||||||
@ -80,14 +80,66 @@ int main(int argc, char *argv[])
|
|||||||
return a.exec();
|
return a.exec();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (vm.count("debug"))
|
if (vm.count("test"))
|
||||||
{
|
{
|
||||||
ChipArgs chipArgs;
|
ChipArgs chipArgs;
|
||||||
chipArgs.type = ChipArgs::LP384;
|
chipArgs.type = ChipArgs::LP384;
|
||||||
|
|
||||||
Design design(chipArgs);
|
Design design(chipArgs);
|
||||||
for (auto bel : design.chip.getBels())
|
int bel_count = 0, wire_count = 0, pip_count = 0;
|
||||||
printf("%s\n", design.chip.getBelName(bel).c_str());
|
|
||||||
|
std::cout << "Checking bel names.\n";
|
||||||
|
for (auto bel : design.chip.getBels()) {
|
||||||
|
auto name = design.chip.getBelName(bel);
|
||||||
|
assert(bel == design.chip.getBelByName(name));
|
||||||
|
bel_count++;
|
||||||
|
}
|
||||||
|
std::cout << " checked " << bel_count << " bels.\n";
|
||||||
|
|
||||||
|
std::cout << "Checking wire names.\n";
|
||||||
|
for (auto wire : design.chip.getWires()) {
|
||||||
|
auto name = design.chip.getWireName(wire);
|
||||||
|
assert(wire == design.chip.getWireByName(name));
|
||||||
|
wire_count++;
|
||||||
|
}
|
||||||
|
std::cout << " checked " << wire_count << " wires.\n";
|
||||||
|
|
||||||
|
std::cout << "Checking pip names.\n";
|
||||||
|
for (auto pip : design.chip.getPips()) {
|
||||||
|
auto name = design.chip.getPipName(pip);
|
||||||
|
assert(pip == design.chip.getPipByName(name));
|
||||||
|
pip_count++;
|
||||||
|
}
|
||||||
|
std::cout << " checked " << pip_count << " pips.\n";
|
||||||
|
|
||||||
|
std::cout << "Checking uphill -> downhill consistency.\n";
|
||||||
|
for (auto dst : design.chip.getWires()) {
|
||||||
|
for (auto uphill_pip : design.chip.getPipsUphill(dst)) {
|
||||||
|
bool found_downhill = false;
|
||||||
|
for (auto downhill_pip : design.chip.getPipsDownhill(design.chip.getPipSrcWire(uphill_pip))) {
|
||||||
|
if (uphill_pip == downhill_pip) {
|
||||||
|
assert(!found_downhill);
|
||||||
|
found_downhill = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
assert(found_downhill);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
std::cout << "Checking downhill -> uphill consistency.\n";
|
||||||
|
for (auto dst : design.chip.getWires()) {
|
||||||
|
for (auto downhill_pip : design.chip.getPipsDownhill(dst)) {
|
||||||
|
bool found_uphill = false;
|
||||||
|
for (auto uphill_pip : design.chip.getPipsUphill(design.chip.getPipDstWire(downhill_pip))) {
|
||||||
|
if (uphill_pip == downhill_pip) {
|
||||||
|
assert(!found_uphill);
|
||||||
|
found_uphill = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
assert(found_uphill);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user