machxo2: Initialize Arch context with device type and package.
This commit is contained in:
parent
6f6aaa4a97
commit
ec4a9685ab
@ -29,14 +29,6 @@
|
|||||||
|
|
||||||
NEXTPNR_NAMESPACE_BEGIN
|
NEXTPNR_NAMESPACE_BEGIN
|
||||||
|
|
||||||
// ---------------------------------------------------------------
|
|
||||||
|
|
||||||
Arch::Arch(ArchArgs args) : chipName("generic"), args(args)
|
|
||||||
{
|
|
||||||
// Dummy for empty decals
|
|
||||||
// decal_graphics[IdString()];
|
|
||||||
}
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------
|
// -----------------------------------------------------------------------
|
||||||
|
|
||||||
void IdString::initialize_arch(const BaseCtx *ctx) {
|
void IdString::initialize_arch(const BaseCtx *ctx) {
|
||||||
@ -74,8 +66,49 @@ static const ChipInfoPOD *get_chip_info(ArchArgs::ArchArgsTypes chip)
|
|||||||
return ptr->get();
|
return ptr->get();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------
|
||||||
|
|
||||||
|
Arch::Arch(ArchArgs args) : args(args)
|
||||||
|
{
|
||||||
|
chip_info = get_chip_info(args.type);
|
||||||
|
if (chip_info == nullptr)
|
||||||
|
log_error("Unsupported MachXO2 chip type.\n");
|
||||||
|
if (chip_info->const_id_count != DB_CONST_ID_COUNT)
|
||||||
|
log_error("Chip database 'bba' and nextpnr code are out of sync; please rebuild (or contact distribution "
|
||||||
|
"maintainer)!\n");
|
||||||
|
|
||||||
|
package_info = nullptr;
|
||||||
|
for (int i = 0; i < chip_info->num_packages; i++) {
|
||||||
|
if (args.package == chip_info->package_info[i].name.get()) {
|
||||||
|
package_info = &(chip_info->package_info[i]);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!package_info)
|
||||||
|
log_error("Unsupported package '%s' for '%s'.\n", args.package.c_str(), getChipName().c_str());
|
||||||
|
}
|
||||||
|
|
||||||
bool Arch::isAvailable(ArchArgs::ArchArgsTypes chip) { return get_chip_info(chip) != nullptr; }
|
bool Arch::isAvailable(ArchArgs::ArchArgsTypes chip) { return get_chip_info(chip) != nullptr; }
|
||||||
|
|
||||||
|
std::string Arch::getChipName() const
|
||||||
|
{
|
||||||
|
if (args.type == ArchArgs::LCMXO2_256HC) {
|
||||||
|
return "LCMXO2-256HC";
|
||||||
|
} else if (args.type == ArchArgs::LCMXO2_640HC) {
|
||||||
|
return "LCMXO2-640HC";
|
||||||
|
} else if (args.type == ArchArgs::LCMXO2_1200HC) {
|
||||||
|
return "LCMXO2-1200HC";
|
||||||
|
} else if (args.type == ArchArgs::LCMXO2_2000HC) {
|
||||||
|
return "LCMXO2-2000HC";
|
||||||
|
} else if (args.type == ArchArgs::LCMXO2_4000HC) {
|
||||||
|
return "LCMXO2-4000HC";
|
||||||
|
} else if (args.type == ArchArgs::LCMXO2_7000HC) {
|
||||||
|
return "LCMXO2-7000HC";
|
||||||
|
} else {
|
||||||
|
log_error("Unknown chip\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------
|
// ---------------------------------------------------------------
|
||||||
|
|
||||||
BelId Arch::getBelByName(IdString name) const
|
BelId Arch::getBelByName(IdString name) const
|
||||||
|
@ -255,7 +255,8 @@ struct CellTiming
|
|||||||
|
|
||||||
struct Arch : BaseCtx
|
struct Arch : BaseCtx
|
||||||
{
|
{
|
||||||
std::string chipName;
|
const ChipInfoPOD *chip_info;
|
||||||
|
const PackageInfoPOD *package_info;
|
||||||
|
|
||||||
// Placeholders to be removed.
|
// Placeholders to be removed.
|
||||||
std::unordered_map<Loc, BelId> bel_by_loc;
|
std::unordered_map<Loc, BelId> bel_by_loc;
|
||||||
@ -275,7 +276,7 @@ struct Arch : BaseCtx
|
|||||||
|
|
||||||
static bool isAvailable(ArchArgs::ArchArgsTypes chip);
|
static bool isAvailable(ArchArgs::ArchArgsTypes chip);
|
||||||
|
|
||||||
std::string getChipName() const { return chipName; }
|
std::string getChipName() const;
|
||||||
|
|
||||||
IdString archId() const { return id("machxo2"); }
|
IdString archId() const { return id("machxo2"); }
|
||||||
ArchArgs archArgs() const { return args; }
|
ArchArgs archArgs() const { return args; }
|
||||||
|
@ -68,7 +68,7 @@ set -ex
|
|||||||
${YOSYS:-yosys} -p "read_verilog blinky.v
|
${YOSYS:-yosys} -p "read_verilog blinky.v
|
||||||
synth_machxo2 -noiopad -json blinky.json
|
synth_machxo2 -noiopad -json blinky.json
|
||||||
show -format png -prefix blinky"
|
show -format png -prefix blinky"
|
||||||
${NEXTPNR:-../../nextpnr-machxo2} $NEXTPNR_MODE --1200 --no-iobs --json blinky.json --write ${1}blinky.json
|
${NEXTPNR:-../../nextpnr-machxo2} $NEXTPNR_MODE --1200 --package QFN32 --no-iobs --json blinky.json --write ${1}blinky.json
|
||||||
${YOSYS:-yosys} -p "read_verilog -lib +/machxo2/cells_sim.v
|
${YOSYS:-yosys} -p "read_verilog -lib +/machxo2/cells_sim.v
|
||||||
read_json ${1}blinky.json
|
read_json ${1}blinky.json
|
||||||
clean -purge
|
clean -purge
|
||||||
|
@ -26,7 +26,7 @@ set -ex
|
|||||||
${YOSYS:-yosys} -p "read_verilog blinky.v
|
${YOSYS:-yosys} -p "read_verilog blinky.v
|
||||||
synth_machxo2 -json blinky.json
|
synth_machxo2 -json blinky.json
|
||||||
show -format png -prefix blinky"
|
show -format png -prefix blinky"
|
||||||
${NEXTPNR:-../../nextpnr-machxo2} $NEXTPNR_MODE --1200 --no-iobs --json blinky.json --write ${1}blinky.json
|
${NEXTPNR:-../../nextpnr-machxo2} $NEXTPNR_MODE --1200 --package QFN32 --no-iobs --json blinky.json --write ${1}blinky.json
|
||||||
${YOSYS:-yosys} -p "read_verilog -lib +/machxo2/cells_sim.v
|
${YOSYS:-yosys} -p "read_verilog -lib +/machxo2/cells_sim.v
|
||||||
read_json ${1}blinky.json
|
read_json ${1}blinky.json
|
||||||
clean -purge
|
clean -purge
|
||||||
|
@ -26,7 +26,7 @@ set -ex
|
|||||||
${YOSYS:-yosys} -p "read_verilog blinky.v
|
${YOSYS:-yosys} -p "read_verilog blinky.v
|
||||||
synth_machxo2 -json blinky.json
|
synth_machxo2 -json blinky.json
|
||||||
show -format png -prefix blinky"
|
show -format png -prefix blinky"
|
||||||
${NEXTPNR:-../../nextpnr-machxo2} $NEXTPNR_MODE --1200 --no-iobs --json blinky.json --write ${1}blinky.json
|
${NEXTPNR:-../../nextpnr-machxo2} $NEXTPNR_MODE --1200 --package QFN32 --no-iobs --json blinky.json --write ${1}blinky.json
|
||||||
${YOSYS:-yosys} -p "read_verilog -lib +/machxo2/cells_sim.v
|
${YOSYS:-yosys} -p "read_verilog -lib +/machxo2/cells_sim.v
|
||||||
read_json ${1}blinky.json
|
read_json ${1}blinky.json
|
||||||
clean -purge
|
clean -purge
|
||||||
|
@ -58,7 +58,7 @@ po::options_description MachXO2CommandHandler::getArchOptions()
|
|||||||
if (Arch::isAvailable(ArchArgs::LCMXO2_7000HC))
|
if (Arch::isAvailable(ArchArgs::LCMXO2_7000HC))
|
||||||
specific.add_options()("7000", "set device type to LCMXO2-7000HC");
|
specific.add_options()("7000", "set device type to LCMXO2-7000HC");
|
||||||
|
|
||||||
specific.add_options()("package", po::value<std::string>(), "select device package (defaults to QFN32)");
|
specific.add_options()("package", po::value<std::string>(), "select device package");
|
||||||
specific.add_options()("speed", po::value<int>(), "select device speedgrade (1 to 6 inclusive)");
|
specific.add_options()("speed", po::value<int>(), "select device speedgrade (1 to 6 inclusive)");
|
||||||
|
|
||||||
specific.add_options()("override-basecfg", po::value<std::string>(),
|
specific.add_options()("override-basecfg", po::value<std::string>(),
|
||||||
@ -76,6 +76,22 @@ void MachXO2CommandHandler::customBitstream(Context *ctx) {}
|
|||||||
std::unique_ptr<Context> MachXO2CommandHandler::createContext(std::unordered_map<std::string, Property> &values)
|
std::unique_ptr<Context> MachXO2CommandHandler::createContext(std::unordered_map<std::string, Property> &values)
|
||||||
{
|
{
|
||||||
ArchArgs chipArgs;
|
ArchArgs chipArgs;
|
||||||
|
chipArgs.type = ArchArgs::NONE;
|
||||||
|
if (vm.count("256"))
|
||||||
|
chipArgs.type = ArchArgs::LCMXO2_256HC;
|
||||||
|
if (vm.count("640"))
|
||||||
|
chipArgs.type = ArchArgs::LCMXO2_640HC;
|
||||||
|
if (vm.count("1200"))
|
||||||
|
chipArgs.type = ArchArgs::LCMXO2_1200HC;
|
||||||
|
if (vm.count("2000"))
|
||||||
|
chipArgs.type = ArchArgs::LCMXO2_2000HC;
|
||||||
|
if (vm.count("4000"))
|
||||||
|
chipArgs.type = ArchArgs::LCMXO2_4000HC;
|
||||||
|
if (vm.count("7000"))
|
||||||
|
chipArgs.type = ArchArgs::LCMXO2_7000HC;
|
||||||
|
if (vm.count("package"))
|
||||||
|
chipArgs.package = vm["package"].as<std::string>();
|
||||||
|
|
||||||
if (values.find("arch.name") != values.end()) {
|
if (values.find("arch.name") != values.end()) {
|
||||||
std::string arch_name = values["arch.name"].as_string();
|
std::string arch_name = values["arch.name"].as_string();
|
||||||
if (arch_name != "machxo2")
|
if (arch_name != "machxo2")
|
||||||
|
Loading…
Reference in New Issue
Block a user