aboutsummaryrefslogtreecommitdiffstats
path: root/backends/aiger/xaiger.cc
diff options
context:
space:
mode:
authorEddie Hung <eddie@fpgeh.com>2020-01-11 17:26:25 -0800
committerEddie Hung <eddie@fpgeh.com>2020-01-11 17:26:25 -0800
commit79db12f238b2f8c5d547ea731a056f98d89bc4b9 (patch)
tree777a7b6e595ea9bdc97094380abcbb80b4cacf10 /backends/aiger/xaiger.cc
parent11128dccb53983e7bb784cf2514edcaa6eb822fb (diff)
parent04a2eb82045a658de22cea610a3ac8c5dee9333c (diff)
downloadyosys-79db12f238b2f8c5d547ea731a056f98d89bc4b9.tar.gz
yosys-79db12f238b2f8c5d547ea731a056f98d89bc4b9.tar.bz2
yosys-79db12f238b2f8c5d547ea731a056f98d89bc4b9.zip
Merge remote-tracking branch 'origin/master' into eddie/abc9_refactor
Diffstat (limited to 'backends/aiger/xaiger.cc')
-rw-r--r--backends/aiger/xaiger.cc45
1 files changed, 27 insertions, 18 deletions
diff --git a/backends/aiger/xaiger.cc b/backends/aiger/xaiger.cc
index beaed696d..212e1e561 100644
--- a/backends/aiger/xaiger.cc
+++ b/backends/aiger/xaiger.cc
@@ -386,7 +386,8 @@ struct XAigerWriter
if (holes_mode) {
struct sort_by_port_id {
bool operator()(const RTLIL::SigBit& a, const RTLIL::SigBit& b) const {
- return a.wire->port_id < b.wire->port_id;
+ return a.wire->port_id < b.wire->port_id ||
+ (a.wire->port_id == b.wire->port_id && a.offset < b.offset);
}
};
input_bits.sort(sort_by_port_id());
@@ -526,7 +527,7 @@ struct XAigerWriter
RTLIL::Module *holes_module = module->design->module(stringf("%s$holes", module->name.c_str()));
log_assert(holes_module);
- dict<IdString, Cell*> cell_cache;
+ dict<IdString, std::tuple<int,int,int>> cell_cache;
int box_count = 0;
for (auto cell : box_list) {
@@ -535,24 +536,32 @@ struct XAigerWriter
RTLIL::Module* box_module = module->design->module(cell->type);
log_assert(box_module);
- int box_inputs = 0, box_outputs = 0;
- for (auto port_name : box_module->ports) {
- RTLIL::Wire *w = box_module->wire(port_name);
- log_assert(w);
- if (w->port_input)
- box_inputs += GetSize(w);
- if (w->port_output)
- box_outputs += GetSize(w);
- }
+ auto r = cell_cache.insert(cell->type);
+ auto &v = r.first->second;
+ if (r.second) {
+ int box_inputs = 0, box_outputs = 0;
+ for (auto port_name : box_module->ports) {
+ RTLIL::Wire *w = box_module->wire(port_name);
+ log_assert(w);
+ if (w->port_input)
+ box_inputs += GetSize(w);
+ if (w->port_output)
+ box_outputs += GetSize(w);
+ }
- // For flops only, create an extra 1-bit input that drives a new wire
- // called "<cell>.abc9_ff.Q" that is used below
- if (box_module->get_bool_attribute("\\abc9_flop"))
- box_inputs++;
+ // For flops only, create an extra 1-bit input that drives a new wire
+ // called "<cell>.abc9_ff.Q" that is used below
+ if (box_module->get_bool_attribute("\\abc9_flop"))
+ box_inputs++;
+
+ std::get<0>(v) = box_inputs;
+ std::get<1>(v) = box_outputs;
+ std::get<2>(v) = box_module->attributes.at("\\abc9_box_id").as_int();
+ }
- write_h_buffer(box_inputs);
- write_h_buffer(box_outputs);
- write_h_buffer(box_module->attributes.at("\\abc9_box_id").as_int());
+ write_h_buffer(std::get<0>(v));
+ write_h_buffer(std::get<1>(v));
+ write_h_buffer(std::get<2>(v));
write_h_buffer(box_count++);
}