{
FILE *infile;
char **tokens;
int line;
int i;
int error;
struct s_block *cur_blk;
infile = fopen(place_file, "r");
tokens = ReadLineTokens(infile, &line);
error = 0;
if(NULL == tokens)
{
error = 1;
}
for(i = 0; i < 6; ++i)
{
if(!error)
{
if(NULL == tokens[i])
{
error = 1;
}
}
}
if(!error)
{
if((0 != strcmp(tokens[0], "Netlist")) ||
(0 != strcmp(tokens[1], "file:")) ||
(0 != strcmp(tokens[3], "Architecture")) ||
(0 != strcmp(tokens[4], "file:")))
{
error = 1;
};
}
if(error)
{
printf(ERRTAG
"'%s' - Bad filename specification line in placement file\n",
place_file);
exit(1);
}
if(0 != strcmp(tokens[2], arch_file))
{
printf(ERRTAG
"'%s' - Architecture file that generated placement (%s) does "
"not match current architecture file (%s)\n", place_file,
tokens[2], arch_file);
exit(1);
}
if(0 != strcmp(tokens[5], net_file))
{
printf(ERRTAG
"'%s' - Netlist file that generated placement (%s) does "
"not match current netlist file (%s)\n", place_file,
tokens[5], net_file);
exit(1);
}
tokens = ReadLineTokens(infile, &line);
error = 0;
if(NULL == tokens)
{
error = 1;
}
for(i = 0; i < 7; ++i)
{
if(!error)
{
if(NULL == tokens[i])
{
error = 1;
}
}
}
if(!error)
{
if((0 != strcmp(tokens[0], "Array")) ||
(0 != strcmp(tokens[1], "size:")) ||
(0 != strcmp(tokens[3], "x")) ||
(0 != strcmp(tokens[5], "logic")) ||
(0 != strcmp(tokens[6], "blocks")))
{
error = 1;
};
}
if(error)
{
printf(ERRTAG
"'%s' - Bad fpga size specification line in placement file\n",
place_file);
exit(1);
}
if((my_atoi(tokens[2]) != nx) || (my_atoi(tokens[4]) != ny))
{
printf(ERRTAG
"'%s' - Current FPGA size (%d x %d) is different from "
"size when placement generated (%d x %d)\n", place_file,
nx, ny, my_atoi(tokens[2]), my_atoi(tokens[4]));
exit(1);
}
tokens = ReadLineTokens(infile, &line);
while(tokens)
{
cur_blk = NULL;
for(i = 0; i < num_blocks; ++i)
{
if(0 == strcmp(block_list[i].name, tokens[0]))
{
cur_blk = (block_list + i);
break;
}
}
if(NULL == cur_blk)
{
printf(ERRTAG "'%s':%d - Block in placement file does "
"not exist in netlist\n", place_file, line);
exit(1);
}
cur_blk->x = my_atoi(tokens[1]);
cur_blk->y = my_atoi(tokens[2]);
cur_blk->z = my_atoi(tokens[3]);
assert(*tokens);
free(*tokens);
free(tokens);
tokens = ReadLineTokens(infile, &line);
}
fclose(infile);
}