Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dump memory property info in netlit info json file for EDA-2594 #312

Merged
merged 1 commit into from
Apr 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 55 additions & 3 deletions src/synth_rapidsilicon.cc
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,10 @@ struct SynthRapidSiliconPass : public ScriptPass {
std::set<std::string> pp_activeLow;
std::set<std::string> pp_fake;

// Special cells
//
dict<std::string, pair<int, int>> pp_memories;

void clear_flags() override
{
top_opt = "-auto-top";
Expand Down Expand Up @@ -3142,7 +3146,7 @@ static void show_sig(const RTLIL::SigSpec &sig)
return 1;
}

void writePortProperties(string jsonFileName)
void writeNetlistInfo(string jsonFileName)
{
run("design -save original");

Expand Down Expand Up @@ -3260,6 +3264,36 @@ static void show_sig(const RTLIL::SigSpec &sig)
}

json_file << "\n ]\n";

if (pp_memories.size()) {

dict<std::string, pair<int, int>>::iterator it;

json_file << " \"memories\" : [\n";

firstLine = true;

for (it = pp_memories.begin(); it != pp_memories.end(); ++it) {

if (firstLine) {
firstLine = false;
} else {
json_file << ",\n";
}

json_file << " {\n";
std::string name = it->first;
pair<int, int> wd = it->second;

json_file << " \"name\" : \"" << name.substr(1) << "\",\n";
json_file << " \"width\" : \"" << wd.first << "\",\n";
json_file << " \"depth\" : \"" << wd.second << "\"\n";
json_file << " }";
}

json_file << "\n ]\n";
}

json_file << "}\n";

json_file.close();
Expand Down Expand Up @@ -3812,6 +3846,7 @@ static void show_sig(const RTLIL::SigSpec &sig)
continue;
}
}

continue;
}

Expand Down Expand Up @@ -3839,6 +3874,7 @@ static void show_sig(const RTLIL::SigSpec &sig)
continue;
}
}

continue;
}

Expand Down Expand Up @@ -3874,6 +3910,18 @@ static void show_sig(const RTLIL::SigSpec &sig)
run("design -load original");
}

void collectMemProperties()
{
for (auto &mem : Mem::get_all_memories(_design->top_module())) {

std::string mem_id = id(mem.memid);

int width = mem.width;
int depth = mem.size;

pp_memories[mem_id] = std::make_pair(width, depth);
}
}

void script() override
{
Expand Down Expand Up @@ -3999,6 +4047,8 @@ static void show_sig(const RTLIL::SigSpec &sig)
run("opt_expr");
run("opt_clean");

collectMemProperties();

if (cec) {
run("write_verilog -noattr -nohex after_opt_clean1.v");
}
Expand Down Expand Up @@ -4535,6 +4585,8 @@ static void show_sig(const RTLIL::SigSpec &sig)
transform(1 /* bmuxmap*/); // we can map $bmux now because
// "memory" has been called

collectPortProperties();

if (check_label("map_luts") && effort != EffortLevel::LOW && !fast) {

map_luts(effort, "after_map_lut_1");
Expand Down Expand Up @@ -4738,6 +4790,8 @@ static void show_sig(const RTLIL::SigSpec &sig)

sec_check("final_netlist", true);

writeNetlistInfo("netlist_info.json");

run("stat");

// Note that numbers extractions are specific to GENESIS3
Expand All @@ -4750,8 +4804,6 @@ static void show_sig(const RTLIL::SigSpec &sig)

reportCarryChains();

writePortProperties("port_info.json");

if ((max_lut != -1) && (nbLUTx > max_lut)) {
log("\n");
log_cmd_error("Final netlist LUTs number [%d] exceeds '-max_lut' specified value [%d].\n", nbLUTx, max_lut);
Expand Down
Loading