-
Notifications
You must be signed in to change notification settings - Fork 408
/
Copy pathblif.c
81 lines (71 loc) · 1.55 KB
/
blif.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#include <stdio.h>
#include <string.h>
#include "ace.h"
#include "blif.h"
bool blif_clock_from_latch(char * latch_line, char * clk_name);
bool blif_clock_from_latch(char * latch_line, char * clk_name) {
char * pos;
pos = strtok(latch_line, " ");
pos = strtok(NULL, " ");
pos = strtok(NULL, " ");
pos = strtok(NULL, " ");
pos = strtok(NULL, " ");
if (pos) {
strncpy(clk_name, pos, ACE_CHAR_BUFFER_SIZE);
clk_name[ACE_CHAR_BUFFER_SIZE - 1] = '\0';
return TRUE;
} else {
return FALSE;
}
}
#if 0
void blif_clock_info(char * blif_file_name, int * num_clks, char * clk_name)
{
bool multiple_clocks = FALSE;
FILE * file_desc;
char line[ACE_CHAR_BUFFER_SIZE];
char clk_name_saved[ACE_CHAR_BUFFER_SIZE] = "";
char clk_name_temp[ACE_CHAR_BUFFER_SIZE];
char str_latch[] = ".latch";
file_desc = fopen(blif_file_name, "r");
while(fgets(line, ACE_CHAR_BUFFER_SIZE, file_desc))
{
char * start_pos = line;
while (start_pos[0] == ' ' || start_pos[0] == '\t')
{
start_pos++;
}
// Check for .latch
if ((start_pos == NULL) || (strncmp(start_pos, str_latch, 6) != 0))
{
continue;
}
// Extract and check clock name
if (blif_clock_from_latch(line, clk_name_temp))
{
if (strcmp(clk_name_saved, "") == 0)
{
strcpy(clk_name_saved, clk_name_temp);
}
else if (strcmp(clk_name_saved, clk_name_temp))
{
multiple_clocks = TRUE;
break;
}
}
}
if (multiple_clocks)
{
*num_clks = 2;
}
else if (strcmp(clk_name_saved, "") != 0)
{
*num_clks = 1;
strcpy(clk_name, clk_name_saved);
}
else
{
*num_clks = 0;
}
}
#endif