Skip to content

Commit 8550378

Browse files
authored
Merge pull request #938 from CAS-Atlantic/readblif_bugfix
ODIN_II: read_blif bug fix
2 parents 7ca19f0 + 6590357 commit 8550378

File tree

1 file changed

+20
-17
lines changed

1 file changed

+20
-17
lines changed

ODIN_II/SRC/read_blif.cpp

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1380,7 +1380,7 @@ hard_block_model *read_hard_block_model(char *name_subckt, hard_block_ports *por
13801380
while (vtr::fgets(buffer, READ_BLIF_BUFFER, file))
13811381
{
13821382
char *token = vtr::strtok(buffer,TOKENS, file, buffer);
1383-
// match .model followed buy the subcircuit name.
1383+
// match .model followed by the subcircuit name.
13841384
if (token && !strcmp(token,".model") && !strcmp(vtr::strtok(NULL,TOKENS, file, buffer), name_subckt))
13851385
{
13861386
model = (hard_block_model *)vtr::calloc(1, sizeof(hard_block_model));
@@ -1397,28 +1397,31 @@ hard_block_model *read_hard_block_model(char *name_subckt, hard_block_ports *por
13971397
while (vtr::fgets(buffer, READ_BLIF_BUFFER, file))
13981398
{
13991399
char *first_word = vtr::strtok(buffer, TOKENS, file, buffer);
1400-
if(!strcmp(first_word, ".inputs"))
1400+
if(first_word)
14011401
{
1402-
char *name;
1403-
while ((name = vtr::strtok(NULL, TOKENS, file, buffer)))
1402+
if(!strcmp(first_word, ".inputs"))
14041403
{
1405-
model->inputs->names = (char **)vtr::realloc(model->inputs->names, sizeof(char *) * (model->inputs->count + 1));
1406-
model->inputs->names[model->inputs->count++] = vtr::strdup(name);
1404+
char *name;
1405+
while ((name = vtr::strtok(NULL, TOKENS, file, buffer)))
1406+
{
1407+
model->inputs->names = (char **)vtr::realloc(model->inputs->names, sizeof(char *) * (model->inputs->count + 1));
1408+
model->inputs->names[model->inputs->count++] = vtr::strdup(name);
1409+
}
14071410
}
1408-
}
1409-
else if(!strcmp(first_word, ".outputs"))
1410-
{
1411-
char *name;
1412-
while ((name = vtr::strtok(NULL, TOKENS, file, buffer)))
1411+
else if(!strcmp(first_word, ".outputs"))
1412+
{
1413+
char *name;
1414+
while ((name = vtr::strtok(NULL, TOKENS, file, buffer)))
1415+
{
1416+
model->outputs->names = (char **)vtr::realloc(model->outputs->names, sizeof(char *) * (model->outputs->count + 1));
1417+
model->outputs->names[model->outputs->count++] = vtr::strdup(name);
1418+
}
1419+
}
1420+
else if(!strcmp(first_word, ".end"))
14131421
{
1414-
model->outputs->names = (char **)vtr::realloc(model->outputs->names, sizeof(char *) * (model->outputs->count + 1));
1415-
model->outputs->names[model->outputs->count++] = vtr::strdup(name);
1422+
break;
14161423
}
14171424
}
1418-
else if(!strcmp(first_word, ".end"))
1419-
{
1420-
break;
1421-
}
14221425
}
14231426
break;
14241427
}

0 commit comments

Comments
 (0)