Skip to content

Commit 0646c05

Browse files
committed
icell_liberty: flop harder
1 parent fd344e4 commit 0646c05

File tree

1 file changed

+24
-9
lines changed

1 file changed

+24
-9
lines changed

passes/cmds/icell_liberty.cc

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,12 @@ struct LibertyStubber {
3232
void liberty_prefix(std::ostream& f)
3333
{
3434
f << "/*\n";
35-
f << stringf("Models interfaces of select Yosys internal cell.\n");
36-
f << stringf("Likely contains INCORRECT POLARITIES.\n");
37-
f << stringf("Impractical for any simulation, synthesis, or timing.\n");
38-
f << stringf("Intended purely for SDC expansion.\n");
39-
f << stringf("Do not microwave or tumble dry.\n");
40-
f << stringf("Generated by %s\n", yosys_maybe_version());
35+
f << stringf("\tModels interfaces of select Yosys internal cell.\n");
36+
f << stringf("\tLikely contains INCORRECT POLARITIES.\n");
37+
f << stringf("\tImpractical for any simulation, synthesis, or timing.\n");
38+
f << stringf("\tIntended purely for SDC expansion.\n");
39+
f << stringf("\tDo not microwave or tumble dry.\n");
40+
f << stringf("\tGenerated by %s\n", yosys_maybe_version());
4141
f << "*/\n";
4242
f << "library (yosys) {\n";
4343
f << "\tinput_threshold_pct_fall : 50;\n";
@@ -82,7 +82,13 @@ struct LibertyStubber {
8282
f << "\tcell (\"" << derived_name << "\") {\n";
8383
auto& base_type = ct.cell_types[base_name];
8484
i.indent = 3;
85-
for (auto x : derived->ports) {
85+
auto sorted_ports = derived->ports;
86+
// Hack for CLK and C coming before Q does
87+
auto cmp = [](IdString l, IdString r) { return l.str() < r.str(); };
88+
std::sort(sorted_ports.begin(), sorted_ports.end(), cmp);
89+
std::string clock_pin_name = "";
90+
for (auto x : sorted_ports) {
91+
std::string port_name = RTLIL::unescape_id(x);
8692
bool is_input = base_type.inputs.count(x);
8793
bool is_output = base_type.outputs.count(x);
8894
f << "\t\tpin (" << RTLIL::unescape_id(x.str()) << ") {\n";
@@ -93,10 +99,19 @@ struct LibertyStubber {
9399
} else {
94100
i.item("direction", "inout");
95101
}
96-
if (RTLIL::unescape_id(x) == "CLK" || RTLIL::unescape_id(x) == "C")
102+
if (port_name == "CLK" || port_name == "C") {
97103
i.item("clock", "true");
98-
if (RTLIL::unescape_id(x) == "Q")
104+
clock_pin_name = port_name;
105+
}
106+
if (port_name == "Q") {
99107
i.item("function", "IQ");
108+
f << "\t\t\ttiming () {\n";
109+
i.indent++;
110+
log_assert(clock_pin_name.size());
111+
i.item("related_pin", clock_pin_name);
112+
i.indent--;
113+
f << "\t\t\t}\n";
114+
}
100115
f << "\t\t}\n";
101116
}
102117

0 commit comments

Comments
 (0)