From 2446b6fbefc51a0f64e68c44cb44ac2d3b2d538a Mon Sep 17 00:00:00 2001 From: Ahmed Irfan Date: Tue, 2 Sep 2014 14:47:51 +0200 Subject: added $pmux cell translation --- backends/btor/btor.cc | 40 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 38 insertions(+), 2 deletions(-) (limited to 'backends/btor/btor.cc') diff --git a/backends/btor/btor.cc b/backends/btor/btor.cc index 03ef183a..2eac675e 100644 --- a/backends/btor/btor.cc +++ b/backends/btor/btor.cc @@ -638,7 +638,42 @@ struct BtorDumper fprintf(f, "%s\n", str.c_str()); line_ref[cell->name]=line_num; } - //registers + else if(cell->type == "$pmux") + { + log("writing pmux cell\n"); + int output_width = cell->parameters.at(RTLIL::IdString("\\WIDTH")).as_int(); + int select_width = cell->parameters.at(RTLIL::IdString("\\S_WIDTH")).as_int(); + int default_case = dump_sigspec(&cell->connections.at(RTLIL::IdString("\\A")), output_width); + int cases = dump_sigspec(&cell->connections.at(RTLIL::IdString("\\B")), output_width*select_width); + int select = dump_sigspec(&cell->connections.at(RTLIL::IdString("\\S")), select_width); + int *c = new int[select_width]; + + for (int i=0; i=0; --i) + { + ++line_num; + str = stringf ("%d cond 1 %d %d %d", line_num, c[i], c[i]+1, line_num-1); + fprintf(f, "%s\n", str.c_str()); + } + + line_ref[cell->name]=line_num; + } + //registers else if(cell->type == "$dff" || cell->type == "$adff" || cell->type == "$dffsr") { //TODO: remodelling fo adff cells @@ -767,7 +802,8 @@ struct BtorDumper assert(output->width == output_width); int offset = cell->parameters.at(RTLIL::IdString("\\OFFSET")).as_int(); ++line_num; - str = stringf("%d %s %d %d %d %d", line_num, cell_type_translation.at(cell->type).c_str(), output_width, input_line, output_width+offset-1, offset); + str = stringf("%d %s %d %d %d %d", line_num, cell_type_translation.at(cell->type).c_str(), + output_width, input_line, output_width+offset-1, offset); fprintf(f, "%s\n", str.c_str()); line_ref[cell->name]=line_num; } -- cgit v1.2.3 From b783dbe148e6d246ebd107c0913de2989ab5af48 Mon Sep 17 00:00:00 2001 From: ahmedirfan1983 Date: Thu, 18 Sep 2014 11:15:46 +0200 Subject: fixed memory next issue, when same memory is written in different case statement fixed reduce_xnor, logic_not bug translation bug --- backends/btor/btor.cc | 35 +++++++++++++++++++++++++++-------- 1 file changed, 27 insertions(+), 8 deletions(-) (limited to 'backends/btor/btor.cc') diff --git a/backends/btor/btor.cc b/backends/btor/btor.cc index 2eac675e..abe09943 100644 --- a/backends/btor/btor.cc +++ b/backends/btor/btor.cc @@ -75,7 +75,8 @@ struct BtorDumper std::string str;//temp string for writing file std::map basic_wires;//input wires and registers RTLIL::IdString curr_cell; //current cell being dumped - std::map cell_type_translation, s_cell_type_translation; //RTLIL to BTOR translation + std::set mem_next; //if memory (line_number) already has next + std::map cell_type_translation, s_cell_type_translation; //RTLIL to BTOR translation BtorDumper(FILE *f, RTLIL::Module *module, RTLIL::Design *design, BtorDumperConfig *config) : f(f), module(module), design(design), config(config), ct(design), sigmap(module) { @@ -414,7 +415,7 @@ struct BtorDumper line_ref[cell->name]=cell_line; } //unary cells - if(cell->type == "$not" || cell->type == "$neg" || cell->type == "$pos" || cell->type == "$reduce_and" || + else if(cell->type == "$not" || cell->type == "$neg" || cell->type == "$pos" || cell->type == "$reduce_and" || cell->type == "$reduce_or" || cell->type == "$reduce_xor" || cell->type == "$reduce_bool") { log("writing unary cell - %s\n", cstr(cell->type)); @@ -451,15 +452,17 @@ struct BtorDumper ++line_num; str = stringf ("%d %s %d %d", line_num, cell_type_translation.at("$reduce_or").c_str(), output_width, l); fprintf(f, "%s\n", str.c_str()); + l = line_num; } else if(cell->type == "$reduce_xnor") { ++line_num; str = stringf ("%d %s %d %d", line_num, cell_type_translation.at("$reduce_xor").c_str(), output_width, l); fprintf(f, "%s\n", str.c_str()); + l = line_num; } ++line_num; - str = stringf ("%d %s %d %d", line_num, cell_type_translation.at("$not").c_str(), output_width, line_num-1); + str = stringf ("%d %s %d %d", line_num, cell_type_translation.at("$not").c_str(), output_width, l); fprintf(f, "%s\n", str.c_str()); line_ref[cell->name]=line_num; } @@ -661,13 +664,13 @@ struct BtorDumper } ++line_num; - str = stringf ("%d cond 1 %d %d %d", line_num, c[select_width-1], c[select_width-1]+1, default_case); + str = stringf ("%d cond %d %d %d %d", line_num, output_width, c[select_width-1], c[select_width-1]+1, default_case); fprintf(f, "%s\n", str.c_str()); for (int i=select_width-2; i>=0; --i) { ++line_num; - str = stringf ("%d cond 1 %d %d %d", line_num, c[i], c[i]+1, line_num-1); + str = stringf ("%d cond %d %d %d %d", line_num, output_width, c[i], c[i]+1, line_num-1); fprintf(f, "%s\n", str.c_str()); } @@ -763,11 +766,26 @@ struct BtorDumper int enable = dump_sigspec(&cell->connections.at(RTLIL::IdString("\\EN")), 1); int address_width = cell->parameters.at(RTLIL::IdString("\\ABITS")).as_int(); int address = dump_sigspec(&cell->connections.at(RTLIL::IdString("\\ADDR")), address_width); - int data_width = cell->parameters.at(RTLIL::IdString("\\WIDTH")).as_int(); + int data_width = cell->parameters.at(RTLIL::IdString("\\WIDTH")).as_int(); int data = dump_sigspec(&cell->connections.at(RTLIL::IdString("\\DATA")), data_width); str = cell->parameters.at(RTLIL::IdString("\\MEMID")).decode_string(); int mem = dump_memory(module->memories.at(RTLIL::IdString(str.c_str()))); - ++line_num; + //check if the memory has already next + auto it = mem_next.find(mem); + if(it != std::end(mem_next)) + { + ++line_num; + str = cell->parameters.at(RTLIL::IdString("\\MEMID")).decode_string(); + RTLIL::Memory *memory = module->memories.at(RTLIL::IdString(str.c_str())); + int address_bits = ceil(log(memory->size)/log(2)); + str = stringf("%d array %d %d", line_num, memory->width, address_bits); + fprintf(f, "%s\n", str.c_str()); + ++line_num; + str = stringf("%d eq 1 %d %d", line_num, mem, line_num - 1); + fprintf(f, "%s\n", str.c_str()); + mem = line_num - 1; + } + ++line_num; if(polarity) str = stringf("%d one 1", line_num); else @@ -788,7 +806,8 @@ struct BtorDumper ++line_num; str = stringf("%d anext %d %d %d %d", line_num, data_width, address_width, mem, line_num-1); fprintf(f, "%s\n", str.c_str()); - line_ref[cell->name]=line_num; + mem_next.insert(mem); + line_ref[cell->name]=line_num; } else if(cell->type == "$slice") { -- cgit v1.2.3