mirror of
https://github.com/YosysHQ/yosys
synced 2025-05-13 10:44:45 +00:00
add qlf_k6n10f architecture + bram inference
(Copied from QuickLogic Yosys plugin repo)
This commit is contained in:
parent
e230a871be
commit
688455ef69
13 changed files with 90322 additions and 21 deletions
|
@ -2,6 +2,7 @@
|
|||
* yosys -- Yosys Open SYnthesis Suite
|
||||
*
|
||||
* Copyright (C) 2021 QuickLogic Corp.
|
||||
* Copyright 2020-2022 F4PGA Authors
|
||||
*
|
||||
* Permission to use, copy, modify, and/or distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
|
@ -30,6 +31,7 @@ struct SynthQuickLogicPass : public ScriptPass {
|
|||
|
||||
void help() override
|
||||
{
|
||||
// |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|
|
||||
log("\n");
|
||||
log(" synth_quicklogic [options]\n");
|
||||
log("This command runs synthesis for QuickLogic FPGAs\n");
|
||||
|
@ -42,6 +44,17 @@ struct SynthQuickLogicPass : public ScriptPass {
|
|||
log(" generate the synthesis netlist for the specified family.\n");
|
||||
log(" supported values:\n");
|
||||
log(" - pp3: PolarPro 3 \n");
|
||||
log(" - qlf_k6n10f: K6N10f\n");
|
||||
log("\n");
|
||||
log(" -nocarry\n");
|
||||
log(" do not use adder_carry cells in output netlist.\n");
|
||||
log("\n");
|
||||
log(" -nobram\n");
|
||||
log(" do not use block RAM cells in output netlist.\n");
|
||||
log("\n");
|
||||
log(" -bramtypes\n");
|
||||
log(" Emit specialized BRAM cells for particular address and data width\n");
|
||||
log(" configurations.\n");
|
||||
log("\n");
|
||||
log(" -blif <file>\n");
|
||||
log(" write the design to the specified BLIF file. writing of an output file\n");
|
||||
|
@ -61,7 +74,7 @@ struct SynthQuickLogicPass : public ScriptPass {
|
|||
}
|
||||
|
||||
string top_opt, blif_file, edif_file, family, currmodule, verilog_file, lib_path;
|
||||
bool abc9;
|
||||
bool abc9, inferAdder, nobram, bramTypes;
|
||||
|
||||
void clear_flags() override
|
||||
{
|
||||
|
@ -72,12 +85,26 @@ struct SynthQuickLogicPass : public ScriptPass {
|
|||
currmodule = "";
|
||||
family = "pp3";
|
||||
abc9 = true;
|
||||
inferAdder = true;
|
||||
nobram = false;
|
||||
bramTypes = false;
|
||||
lib_path = "+/quicklogic/";
|
||||
}
|
||||
|
||||
void set_scratchpad_defaults(RTLIL::Design *design) {
|
||||
lib_path = design->scratchpad_get_string("ql.lib_path", lib_path);
|
||||
if (lib_path.back() != '/')
|
||||
lib_path += "/";
|
||||
inferAdder = !design->scratchpad_get_bool("ql.nocarry", false);
|
||||
nobram = design->scratchpad_get_bool("ql.nobram", false);
|
||||
bramTypes = design->scratchpad_get_bool("ql.bramtypes", false);
|
||||
}
|
||||
|
||||
void execute(std::vector<std::string> args, RTLIL::Design *design) override
|
||||
{
|
||||
string run_from, run_to;
|
||||
clear_flags();
|
||||
set_scratchpad_defaults(design);
|
||||
|
||||
size_t argidx;
|
||||
for (argidx = 1; argidx < args.size(); argidx++)
|
||||
|
@ -114,6 +141,18 @@ struct SynthQuickLogicPass : public ScriptPass {
|
|||
abc9 = false;
|
||||
continue;
|
||||
}
|
||||
if (args[argidx] == "-nocarry") {
|
||||
inferAdder = false;
|
||||
continue;
|
||||
}
|
||||
if (args[argidx] == "-nobram") {
|
||||
nobram = true;
|
||||
continue;
|
||||
}
|
||||
if (args[argidx] == "-bramtypes") {
|
||||
bramTypes = true;
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
extra_args(args, argidx, design);
|
||||
|
@ -121,7 +160,7 @@ struct SynthQuickLogicPass : public ScriptPass {
|
|||
if (!design->full_selection())
|
||||
log_cmd_error("This command only operates on fully selected designs!\n");
|
||||
|
||||
if (family != "pp3")
|
||||
if (family != "pp3" && family != "qlf_k6n10f")
|
||||
log_cmd_error("Invalid family specified: '%s'\n", family.c_str());
|
||||
|
||||
if (abc9 && design->scratchpad_get_int("abc9.D", 0) == 0) {
|
||||
|
@ -144,14 +183,22 @@ struct SynthQuickLogicPass : public ScriptPass {
|
|||
}
|
||||
|
||||
if (check_label("begin")) {
|
||||
run(stringf("read_verilog -lib -specify +/quicklogic/common/cells_sim.v +/quicklogic/%s/cells_sim.v", family.c_str()));
|
||||
std::string read_simlibs = stringf("read_verilog -lib -specify %scommon/cells_sim.v %s%s/cells_sim.v", lib_path.c_str(), lib_path.c_str(), family.c_str());
|
||||
if (family == "qlf_k6n10f") {
|
||||
read_simlibs += stringf(" %sqlf_k6n10f/brams_sim.v", lib_path.c_str());
|
||||
if (bramTypes)
|
||||
read_simlibs += stringf(" %sqlf_k6n10f/bram_types_sim.v", lib_path.c_str());
|
||||
}
|
||||
run(read_simlibs);
|
||||
run(stringf("hierarchy -check %s", help_mode ? "-top <top>" : top_opt.c_str()));
|
||||
}
|
||||
|
||||
if (check_label("prepare")) {
|
||||
run("proc");
|
||||
run("flatten");
|
||||
run("tribuf -logic");
|
||||
if (help_mode || family == "pp3") {
|
||||
run("tribuf -logic", " (for pp3)");
|
||||
}
|
||||
run("deminout");
|
||||
run("opt_expr");
|
||||
run("opt_clean");
|
||||
|
@ -176,6 +223,71 @@ struct SynthQuickLogicPass : public ScriptPass {
|
|||
run("opt_clean");
|
||||
}
|
||||
|
||||
if (check_label("map_bram", "(for qlf_k6n10f, skip if -no_bram)") && (help_mode || family == "qlf_k6n10f")) {
|
||||
run("memory_libmap -lib " + lib_path + family + "/libmap_brams.txt");
|
||||
run("ql_bram_merge");
|
||||
run("techmap -map " + lib_path + family + "/libmap_brams_map.v");
|
||||
run("techmap -autoproc -map " + lib_path + family + "/brams_map.v");
|
||||
run("techmap -map " + lib_path + family + "/brams_final_map.v");
|
||||
|
||||
if (help_mode) {
|
||||
run("chtype -set TDP36K_<mode> t:TDP36K a:<mode>", "(if -bram_types)");
|
||||
}
|
||||
else if (bramTypes) {
|
||||
for (int a_dwidth : {1, 2, 4, 9, 18, 36})
|
||||
for (int b_dwidth: {1, 2, 4, 9, 18, 36}) {
|
||||
run(stringf("chtype -set TDP36K_BRAM_A_X%d_B_X%d_nonsplit t:TDP36K a:is_inferred=0 %%i "
|
||||
"a:is_fifo=0 %%i a:port_a_dwidth=%d %%i a:port_b_dwidth=%d %%i",
|
||||
a_dwidth, b_dwidth, a_dwidth, b_dwidth));
|
||||
|
||||
run(stringf("chtype -set TDP36K_FIFO_ASYNC_A_X%d_B_X%d_nonsplit t:TDP36K a:is_inferred=0 %%i "
|
||||
"a:is_fifo=1 %%i a:sync_fifo=0 %%i a:port_a_dwidth=%d %%i a:port_b_dwidth=%d %%i",
|
||||
a_dwidth, b_dwidth, a_dwidth, b_dwidth));
|
||||
|
||||
run(stringf("chtype -set TDP36K_FIFO_SYNC_A_X%d_B_X%d_nonsplit t:TDP36K a:is_inferred=0 %%i "
|
||||
"a:is_fifo=1 %%i a:sync_fifo=1 %%i a:port_a_dwidth=%d %%i a:port_b_dwidth=%d %%i",
|
||||
a_dwidth, b_dwidth, a_dwidth, b_dwidth));
|
||||
}
|
||||
|
||||
for (int a1_dwidth : {1, 2, 4, 9, 18})
|
||||
for (int b1_dwidth: {1, 2, 4, 9, 18})
|
||||
for (int a2_dwidth : {1, 2, 4, 9, 18})
|
||||
for (int b2_dwidth: {1, 2, 4, 9, 18}) {
|
||||
run(stringf("chtype -set TDP36K_BRAM_A1_X%d_B1_X%d_A2_X%d_B2_X%d_split t:TDP36K a:is_inferred=0 %%i "
|
||||
"a:is_split=1 %%i a:is_fifo=0 %%i "
|
||||
"a:port_a1_dwidth=%d %%i a:port_b1_dwidth=%d %%i a:port_a2_dwidth=%d %%i a:port_b2_dwidth=%d %%i",
|
||||
a1_dwidth, b1_dwidth, a2_dwidth, b2_dwidth, a1_dwidth, b1_dwidth, a2_dwidth, b2_dwidth));
|
||||
|
||||
run(stringf("chtype -set TDP36K_FIFO_ASYNC_A1_X%d_B1_X%d_A2_X%d_B2_X%d_split t:TDP36K a:is_inferred=0 %%i "
|
||||
"a:is_split=1 %%i a:is_fifo=1 %%i a:sync_fifo=0 %%i "
|
||||
"a:port_a1_dwidth=%d %%i a:port_b1_dwidth=%d %%i a:port_a2_dwidth=%d %%i a:port_b2_dwidth=%d %%i",
|
||||
a1_dwidth, b1_dwidth, a2_dwidth, b2_dwidth, a1_dwidth, b1_dwidth, a2_dwidth, b2_dwidth));
|
||||
|
||||
run(stringf("chtype -set TDP36K_FIFO_SYNC_A1_X%d_B1_X%d_A2_X%d_B2_X%d_split t:TDP36K a:is_inferred=0 %%i "
|
||||
"a:is_split=1 %%i a:is_fifo=1 %%i a:sync_fifo=1 %%i "
|
||||
"a:port_a1_dwidth=%d %%i a:port_b1_dwidth=%d %%i a:port_a2_dwidth=%d %%i a:port_b2_dwidth=%d %%i",
|
||||
a1_dwidth, b1_dwidth, a2_dwidth, b2_dwidth, a1_dwidth, b1_dwidth, a2_dwidth, b2_dwidth));
|
||||
}
|
||||
|
||||
|
||||
for (int a_width : {1, 2, 4, 9, 18, 36})
|
||||
for (int b_width: {1, 2, 4, 9, 18, 36}) {
|
||||
run(stringf("chtype -set TDP36K_BRAM_A_X%d_B_X%d_nonsplit t:TDP36K a:is_inferred=1 %%i "
|
||||
"a:port_a_width=%d %%i a:port_b_width=%d %%i",
|
||||
a_width, b_width, a_width, b_width));
|
||||
}
|
||||
|
||||
for (int a1_width : {1, 2, 4, 9, 18})
|
||||
for (int b1_width: {1, 2, 4, 9, 18})
|
||||
for (int a2_width : {1, 2, 4, 9, 18})
|
||||
for (int b2_width: {1, 2, 4, 9, 18}) {
|
||||
run(stringf("chtype -set TDP36K_BRAM_A1_X%d_B1_X%d_A2_X%d_B2_X%d_split t:TDP36K a:is_inferred=1 %%i "
|
||||
"a:port_a1_width=%d %%i a:port_b1_width=%d %%i a:port_a2_width=%d %%i a:port_b2_width=%d %%i",
|
||||
a1_width, b1_width, a2_width, b2_width, a1_width, b1_width, a2_width, b2_width));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (check_label("map_ffram")) {
|
||||
run("opt -fast -mux_undef -undriven -fine");
|
||||
run("memory_map -iattr -attr !ram_block -attr !rom_block -attr logic_block "
|
||||
|
@ -185,36 +297,65 @@ struct SynthQuickLogicPass : public ScriptPass {
|
|||
}
|
||||
|
||||
if (check_label("map_gates")) {
|
||||
run("techmap");
|
||||
if (inferAdder && family == "qlf_k6n10f") {
|
||||
run("techmap -map +/techmap.v -map " + lib_path + family + "/arith_map.v", "(unless -no_adder)");
|
||||
} else {
|
||||
run("techmap");
|
||||
}
|
||||
run("opt -fast");
|
||||
run("muxcover -mux8 -mux4");
|
||||
if (help_mode || family == "pp3") {
|
||||
run("muxcover -mux8 -mux4", "(for pp3)");
|
||||
}
|
||||
}
|
||||
|
||||
if (check_label("map_ffs")) {
|
||||
run("opt_expr");
|
||||
run("dfflegalize -cell $_DFFSRE_PPPP_ 0 -cell $_DLATCH_?_ x");
|
||||
|
||||
run(stringf("techmap -map +/quicklogic/%s/cells_map.v -map +/quicklogic/%s/ffs_map.v", family.c_str(), family.c_str()));
|
||||
|
||||
run("opt_expr -mux_undef");
|
||||
if (help_mode) {
|
||||
run("shregmap -minlen <min> -maxlen <max>", "(for qlf_k6n10f)");
|
||||
run("dfflegalize -cell <supported FF types>");
|
||||
run("techmap -map " + lib_path + family + "/cells_map.v", "(for pp3)");
|
||||
}
|
||||
if (family == "pp3") {
|
||||
run("dfflegalize -cell $_DFFSRE_PPPP_ 0 -cell $_DLATCH_?_ x");
|
||||
run("techmap -map " + lib_path + family + "/cells_map.v -map " + lib_path + family + "/ffs_map.v");
|
||||
run("opt_expr -mux_undef");
|
||||
} else if (family == "qlf_k6n10f") {
|
||||
run("shregmap -minlen 8 -maxlen 20");
|
||||
// FIXME: Apparently dfflegalize leaves around $_DLATCH_[NP]_ even if
|
||||
// not in the allowed set. As a workaround we put them in the allowed
|
||||
// set explicitly and map them later to $_DLATCHSR_[NP]NN_.
|
||||
run("dfflegalize -cell $_DFFSRE_?NNP_ 0 -cell $_DLATCHSR_?NN_ 0 -cell $_DLATCH_?_ 0" " -cell $_SDFFE_?N?P_ 0");
|
||||
}
|
||||
run("opt");
|
||||
}
|
||||
|
||||
if (check_label("map_luts")) {
|
||||
run(stringf("techmap -map +/quicklogic/%s/latches_map.v", family.c_str()));
|
||||
if (check_label("map_luts", "(for pp3)") && (help_mode || family == "pp3")) {
|
||||
run("techmap -map " + lib_path + family + "/latches_map.v");
|
||||
if (abc9) {
|
||||
run(stringf("read_verilog -lib -specify -icells +/quicklogic/%s/abc9_model.v", family.c_str()));
|
||||
run(stringf("techmap -map +/quicklogic/%s/abc9_map.v", family.c_str()));
|
||||
run("read_verilog -lib -specify -icells " + lib_path + family + "/abc9_model.v");
|
||||
run("techmap -map " + lib_path + family + "/abc9_map.v");
|
||||
run("abc9 -maxlut 4 -dff");
|
||||
run(stringf("techmap -map +/quicklogic/%s/abc9_unmap.v", family.c_str()));
|
||||
run("techmap -map " + lib_path + family + "/abc9_unmap.v");
|
||||
} else {
|
||||
run("abc -luts 1,2,2,4 -dress");
|
||||
}
|
||||
run("clean");
|
||||
}
|
||||
|
||||
if (check_label("map_cells")) {
|
||||
run(stringf("techmap -map +/quicklogic/%s/lut_map.v", family.c_str()));
|
||||
if (check_label("map_luts", "(for qlf_k6n10f)") && (help_mode || family == "qlf_k6n10f")) {
|
||||
if (abc9) {
|
||||
run("abc9 -maxlut 6");
|
||||
} else {
|
||||
run("abc -lut 6 -dress");
|
||||
}
|
||||
run("clean");
|
||||
run("opt_lut");
|
||||
}
|
||||
|
||||
if (check_label("map_cells", "(for pp3)") && (help_mode || family == "pp3")) {
|
||||
run("techmap -map " + lib_path + family + "/lut_map.v");
|
||||
run("clean");
|
||||
run("opt_lut");
|
||||
}
|
||||
|
||||
if (check_label("check")) {
|
||||
|
@ -224,14 +365,18 @@ struct SynthQuickLogicPass : public ScriptPass {
|
|||
run("check -noinit");
|
||||
}
|
||||
|
||||
if (check_label("iomap")) {
|
||||
if (check_label("iomap", "(for pp3)") && (family == "pp3" || help_mode)) {
|
||||
run("clkbufmap -inpad ckpad Q:P");
|
||||
run("iopadmap -bits -outpad outpad A:P -inpad inpad Q:P -tinoutpad bipad EN:Q:A:P A:top");
|
||||
}
|
||||
|
||||
if (check_label("finalize")) {
|
||||
run("setundef -zero -params -undriven");
|
||||
run("hilomap -hicell logic_1 A -locell logic_0 A -singleton A:top");
|
||||
if (help_mode || family == "pp3") {
|
||||
run("setundef -zero -params -undriven", "(for pp3)");
|
||||
}
|
||||
if (family == "pp3" || !edif_file.empty()) {
|
||||
run("hilomap -hicell logic_1 A -locell logic_0 A -singleton A:top", "(for pp3 or if -edif)");
|
||||
}
|
||||
run("opt_clean -purge");
|
||||
run("check");
|
||||
run("blackbox =A:whitebox");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue