Skip to content

Commit a2a0e60

Browse files
committed
[Yosys+Odin]: - pass user-defined DSPs untouched to the partial mapping phase
- create a fake ast node for user-defined DSPs in the BLIF Reader Signed-off-by: Seyed Alireza Damghani <[email protected]>
1 parent 88ad9b7 commit a2a0e60

File tree

3 files changed

+17
-9
lines changed

3 files changed

+17
-9
lines changed

ODIN_II/SRC/BLIFElaborate.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,7 @@ void blif_elaborate_node(nnode_t* node, short traverse_number, netlist_t* netlis
301301
case PAD_NODE: //fallthrough
302302
case INPUT_NODE: //fallthrough
303303
case OUTPUT_NODE: //fallthrough
304+
case HARD_IP: //fallthrough
304305
case BUF_NODE: //fallthrough
305306
case BITWISE_NOT: //fallthrough
306307
case BITWISE_AND: //fallthrough
@@ -312,7 +313,6 @@ void blif_elaborate_node(nnode_t* node, short traverse_number, netlist_t* netlis
312313
/* some are already resolved for this phase */
313314
break;
314315
}
315-
case HARD_IP:
316316
case ADDER_FUNC:
317317
case CARRY_FUNC:
318318
case CLOCK_NODE:

ODIN_II/SRC/BLIFReader.cpp

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -358,22 +358,27 @@ void BLIF::Reader::create_hard_block_nodes(hard_block_models* models) {
358358
char new_name[READ_BLIF_BUFFER];
359359
vtr::free(new_node->name);
360360
/* in case of weird names, need to add memories manually */
361-
if (ports->count == 5) {
361+
int sc_spot = -1;
362+
if (std::string(subcircuit_stripped_name).find(SINGLE_PORT_RAM_string, 0) != std::string::npos) {
362363
/* specify node type */
363364
new_node->type = yosys_subckt_strmap[SINGLE_PORT_RAM_string];
364365
/* specify node name */
365366
odin_sprintf(new_name, "\\%s~%ld", SINGLE_PORT_RAM_string, hard_block_number - 1);
366-
new_node->name = make_full_ref_name(new_name, NULL, NULL, NULL, -1);
367-
} else if (ports->count == 9) {
367+
} else if (std::string(subcircuit_stripped_name).find(DUAL_PORT_RAM_string, 0) != std::string::npos) {
368368
/* specify node type */
369369
new_node->type = yosys_subckt_strmap[DUAL_PORT_RAM_string];
370370
/* specify node name */
371371
odin_sprintf(new_name, "\\%s~%ld", DUAL_PORT_RAM_string, hard_block_number - 1);
372-
new_node->name = make_full_ref_name(new_name, NULL, NULL, NULL, -1);
372+
} else if ((sc_spot = sc_lookup_string(hard_block_names, subcircuit_stripped_name)) != -1) {
373+
/* specify node type */
374+
new_node->type = HARD_IP;
375+
/* specify node name */
376+
odin_sprintf(new_name, "\\%s~%ld", subcircuit_stripped_name, hard_block_number - 1);
373377
} else {
374378
error_message(PARSE_BLIF, unknown_location,
375-
"Unsupported sub-circuit type (%s) in BLIF file.\n", subcircuit_name);
379+
"Unsupported subcircuit type (%s) in BLIF file.\n", subcircuit_name);
376380
}
381+
new_node->name = make_full_ref_name(new_name, NULL, NULL, NULL, -1);
377382
}
378383

379384
if (new_node->type == BRAM) {
@@ -410,7 +415,7 @@ void BLIF::Reader::create_hard_block_nodes(hard_block_models* models) {
410415

411416
if (!model)
412417
error_message(PARSE_BLIF, unknown_location,
413-
"Failed to retrieve sub-circuit model (%s)\n", subcircuit_name);
418+
"Failed to retrieve subcircuit model (%s)\n", subcircuit_name);
414419

415420
/* Add input and output ports to the new node. */
416421
else {
@@ -481,7 +486,7 @@ void BLIF::Reader::create_hard_block_nodes(hard_block_models* models) {
481486
}
482487

483488
// Create a fake ast node.
484-
if (!configuration.coarsen) {
489+
if (!configuration.coarsen || new_node->type == HARD_IP) {
485490
new_node->related_ast_node = create_node_w_type(HARD_BLOCK, my_location);
486491
new_node->related_ast_node->children = (ast_node_t**)vtr::calloc(1, sizeof(ast_node_t*));
487492
new_node->related_ast_node->identifier_node = create_tree_node_id(vtr::strdup(subcircuit_name), my_location);

ODIN_II/SRC/VerilogWriter.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,10 @@ Verilog::Writer::Writer()
4040
this->models_declaration = sc_new_string_cache();
4141
}
4242

43-
Verilog::Writer::~Writer() = default;
43+
Verilog::Writer::~Writer() {
44+
if (this->models_declaration)
45+
sc_free_string_cache(this->models_declaration);
46+
}
4447

4548
inline void Verilog::Writer::_create_file(const char* file_name, const file_type_e file_type) {
4649
// validate the file_name pointer

0 commit comments

Comments
 (0)