73#define INSTRUCTION(x) (0 == strcmp(instruction, x))
74#define NOT_INSTRUCTION(x) (0 != strcmp(instruction, x))
80static long pseudonode;
84static unsigned long mline[
MAXDEPTH+1L];
85static unsigned long mfile[
MAXDEPTH+1L];
120 unsigned long nl = 0UL;
121 char *p = (
char*) NULL;
122 char *s = (
char*) NULL;
123 char *t = (
char*) NULL;
124 char *
string = (
char*) NULL;
125 char brc[3] = {
'\0'};
129 char old_instruction[
STRLENGTH] = {
'\0'};
135 (void) strcpy(instruction,
"");
136 (void) strcpy(old_instruction,
"");
144 data_flag[0] =
false;
149 (void) fprintf(
STDERR,
"\nNAPA File Expansion:\n");
150 (void) fprintf(
STDERR,
" Input files are expanded as requested.\n");
151 (void) fprintf(
STDERR,
" No C file has been created.\n\n");
153 (void) fprintf(
STDERR,
"\n********* EXPANSION *************");
154 n =
MAX(117L - n, 0L);
156 (void) fprintf(
STDOUT,
" START *******\n\n\n");
157 (void) fprintf(
STDERR,
" START *******\n\n");
161 if ((FILE*) NULL == fhandle[0]) {
163 (void) fprintf(
STDERR,
" OUCH!- can't find or access main netlist file <\"%s\">\n",
Cur_Fil_Name[0]);
174 p =
get_a_line(buffer1, &nl, fhandle[0], mline, mfile);
175 if ((
char*) NULL == p) {
177 (void) fprintf(
STDERR,
" main netlist file <\"%s\"> is empty or corrupted\n",
Cur_Fil_Name[0]);
183 while ((
char*) NULL != p) {
188 (void) strcpy(buffer3, buffer1);
192 string =
get_token(
string, instruction,
false);
201 string =
get_node(
string, token, &pseudonode);
205 (void) snprintf(buffer2, (
size_t) (
LINLENGTH-1L),
"void itool %s",
string);
207 string =
get_node(t, token, &pseudonode);
287 (void) fprintf(
STDERR,
" 'num_initial' is deprecated, replaced by 'interlude' instruction\n");
312 get_data(
string, buffer1, cell_name);
390 (void) fprintf(
STDERR,
"\n");
392 (void) fprintf(
STDERR,
"\n USER's MESSAGE collected during parsing:");
396 (void) fprintf(
STDERR,
" < %s >\n\n", token);
400 (void) fprintf(
STDERR,
"\n The parser is instructed by the user to prevent the\n");
401 (void) fprintf(
STDERR,
" simulation of this NAPA netlist in its current state:\n\n");
404 (void) fprintf(
STDERR,
" < %s >\n\n", token);
409 (void) fprintf(
STDERR,
" cell interface is only allowed as head line of a cell\n");
414 (void) fprintf(
STDERR,
" token <%s> is not a NAPA instruction\n", instruction);
416 (void) fprintf(
STDERR,
", nor a well-formed NAPA identifier\n");
429 if ((0 != strcmp(old_instruction, instruction)) && (0 != strcmp(old_instruction,
""))) {
430 (void) fprintf(
STDOUT,
"\n");
433 for (j = 0L; j < depth; j++) {
434 (void) fprintf(
STDOUT,
" ");
436 (void) fprintf(
STDOUT,
"%s\n", buffer3);
437 (void) strcpy(old_instruction, instruction);
439 (void) fprintf(
STDOUT,
"\n#* ");
440 (void) fprintf(
STDERR,
" ");
441 for (j = 0L; j < depth; j++) {
444 (void) fprintf(
STDOUT,
">> %s\n\n", buffer3);
445 (void) fprintf(
STDERR,
">> ");
446 (void) strcpy(old_instruction,
"");
447 }
else if (
GEN_KIND == pseudonode) {
448 (void) fprintf(
STDOUT,
"\n#* ");
449 (void) fprintf(
STDERR,
" ");
450 for (j = 0L; j < depth; j++) {
453 (void) fprintf(
STDOUT,
">> %s\n\n", buffer3);
454 (void) fprintf(
STDERR,
">> ");
455 (void) strcpy(old_instruction,
"");
457 (void) strcpy(old_instruction,
"");
464 string =
process_gen(
string, &pseudonode, cell_name);
466 (void) fprintf(
STDOUT,
"#* changed in ... cell %s\n\n",
string);
475 if (0 != strcmp(instruction,
"")) {
479 p =
get_a_line(buffer1, &nl, fhandle[depth], mline, mfile);
480 while (((
char*) NULL == p) && (0L < depth)) {
482 if (EOF == fclose(fhandle[depth])) {
484 (void) fprintf(
STDERR,
" OUCH!- can't close cell or data file opened during parsing\n");
488 (void) fprintf(
STDOUT,
"\n#* ");
489 (void) fprintf(
STDERR,
" ");
490 for (j = 0L; j < (depth-1L); j++) {
494 (void) strcpy(old_instruction,
"");
497 p =
get_a_line(buffer1, &nl, fhandle[depth], mline, mfile);
503 if (EOF == fclose(fhandle[depth])) {
505 (void) fprintf(
STDERR,
" OUCH!- can't close main netlist file opened during parsing\n");
533 (void)
f2printf(
STDERR, NULL,
"[ Trivial case as the NAPA main netlist has no hierarchy ]\n\n");
535 (void) fprintf(
STDOUT,
"\n\n");
537 (void) fprintf(
STDERR,
"*********************************");
538 n =
MAX(117L - n, 0L);
553 char file_version[7] = {
'\0'};
554 char napa_version[7] = {
'\0'};
555 double file_version_id;
556 double napa_version_id;
557 (void) snprintf(file_version, (
size_t) 6,
"%s", str);
559 if (2 != sscanf(file_version,
"%c%lf", &ch, &file_version_id)) {
561 (void) fprintf(
STDERR,
"\n Version of file is not coded correctly\n");
562 (void) fprintf(
STDERR,
" file version: < %s > ?\n", str);
565 if ((
'V' != ch) && (
'X' != ch)) {
567 (void) fprintf(
STDERR,
"\n Version of file is not coded correctly\n");
568 (void) fprintf(
STDERR,
" file version: < %s > ?\n", str);
571 if (2 != sscanf(napa_version,
"%c%lf", &ch, &napa_version_id)) {
573 (void) fprintf(
STDERR,
"\n Version of NAPA compiler is not coded correctly\n");
577 if ((
'V' != ch) && (
'X' != ch)) {
579 (void) fprintf(
STDERR,
"\n Version of NAPA compiler is not coded correctly\n");
583 if (file_version_id < napa_version_id) {
585 (void) fprintf(
STDERR,
"\n Version of file is older than current version of NAPA compiler\n");
586 (void) fprintf(
STDERR,
" file version: < %s >\n", str);
590 if (file_version_id > napa_version_id) {
592 (void) fprintf(
STDERR,
"\n Version of file is newer than current version of NAPA compiler\n");
593 (void) fprintf(
STDERR,
" file version: < %s >\n", str);
600char *
get_node(
char *str,
char *nodnam,
long *pseudo) {
625 char brc[3] = {
'\0'};
626 char sgn[2] = {
'\0'};
627 char *t = (
char*) NULL;
628 char *str1 = (
char*) NULL;
629 char *str2 = (
char*) NULL;
630 char *str3 = (
char*) NULL;
631 char *str4 = (
char*) NULL;
639 if (data_flag[depth]) {
641 (void) fprintf(
STDERR,
" nodes definitions are not allowed in a data cell file\n");
645 if (0 == strcmp(brc,
"")) {
647 }
else if (0 == strcmp(brc,
"()")) {
652 }
else if (0 == strcmp(brc,
"[]")) {
653 if (1 != sscanf(tok2,
"%li", &w)) {
656 (void) fprintf(
STDERR,
" invalid width in declaration <node[%s]>\n", tok2);
662 (void) fprintf(
STDERR,
" node width <%ld> must be strictly positive\n", w);
665 (void) strcpy(tok4, str1);
667 n = (long) fprintf(
STDOUT,
"\n#* node[%ld] %s ", w, str1);
668 for (i = 0L; i <
MAX(77L-n, 0L); i++) {
669 (void) fprintf(
STDOUT,
".");
671 (void) fprintf(
STDOUT,
"...\n");
673 for (i = 0L; i < w; i++) {
674 (void) strcpy(tok5, tok4);
678 (void) fprintf(
STDOUT,
" node %s\n", str2);
684 (void) fprintf(
STDERR,
" a cell or a generator cannot be associated in a nodeset\n");
689 (void) fprintf(
STDOUT,
"#* ");
690 for (i = 0L; i <
MAX(n-5L, 72L); i++) {
691 (void) fprintf(
STDOUT,
".");
693 (void) fprintf(
STDOUT,
"...\n\n");
698 (void) fprintf(
STDERR,
" brackets, if any, around node cannot be < %s > but parenthesis\n", brc);
703 (void) fprintf(
STDERR,
" node name is missing\n");
708 (void) fprintf(
STDERR,
" node name <%s> is not a NAPA identifier\n", tok1);
711 if ((0 == strcmp(tok1,
"One")) || (0 == strcmp(tok1,
"Zero")) || (0 == strcmp(tok1,
"Ground"))) {
713 (void) fprintf(
STDERR,
" automatic node <%s> cannot be redefined by user\n", tok1);
716 if ((
char*) NULL != strchr(tok1,
':')) {
718 (void) fprintf(
STDERR,
" definition of node <%s> cannot include a bit field\n", tok1);
723 (void) fprintf(
STDERR,
" no sign expected in front of the node identifier <%s>\n", tok1);
733 (void) fprintf(
STDERR,
" duplicate node definition, <%s> is already defined\n", tok1);
742 (void) fprintf(
STDERR,
" definition <%s> is colliding an alias defined\n", tok1);
749 (void) fprintf(
STDERR,
" definition <%s> is colliding a variable defined\n", tok1);
756 (void) fprintf(
STDERR,
" definition <%s> is colliding a record defined\n", tok1);
763 (void) fprintf(
STDERR,
" definition <%s> is colliding an array defined\n", tok1);
770 (void) fprintf(
STDERR,
" definition <%s> is colliding a directive defined\n", tok1);
774 if (0 == strcmp(tok1,
"fs")) {
776 (void) fprintf(
STDERR,
" node identifier cannot be the <fs> identifier\n");
782 (void) fprintf(
STDERR,
" keyword <%s> cannot be used as node name\n", tok1);
787 (void) fprintf(
STDERR,
" keyword <%s> is not recommended to be used as node name\n", tok1);
790 if ((0 == strcmp(sgn,
"+")) || (0 == strcmp(sgn,
"-"))) {
792 (void) fprintf(
STDERR,
" no sign is expected before the node kind\n");
795 if (0 == strcmp(tok2,
"[")) {
797 (void) fprintf(
STDERR,
" this is not a nodeset, brackets [] are not expected\n");
802 (void) fprintf(
STDERR,
" node kind <%s> is not a NAPA identifier\n", tok2);
808 (void) fprintf(
STDERR,
" node <%s>, node kind is missing\n", tok1);
814 (void) fprintf(
STDERR,
" unknown node kind <%s>\n", tok2);
836 (void) strcpy(nodnam, tok1);
841 if (0 == strcmp(tok1,
"void")) {
846 (void) strcpy(tok3, tok1);
851 (void) fprintf(
STDERR,
" parameters of node <%s> are missing\n", tok3);
855 t = strstr(str,
"&delayed");
856 if ((
char*) NULL != t) {
858 for (i = 0; i < 7; i++) {
870 }
else if (0 == strcmp(tok1,
"void")) {
874 (void) snprintf(tok11, (
size_t) (
LINLENGTH-1L),
"%s delayed_node$", str);
880 (void) snprintf(tok9, (
size_t) (
LINLENGTH-1L),
"%s_intern", tok3);
884 (void) snprintf(tok11, (
size_t) (
LINLENGTH-1L),
"%s delayed_node$", str);
904 ((0 != strncmp(
Node_List[
Num_Nodes].name1,
"_void", (
size_t) 5)) && (!flag)) ?
false :
true;
919 (void) fprintf(
STDERR,
" <%s> : self-reference is not allowed in a node definition,\n",
Node_List[
Num_Nodes].name1);
920 (void) fprintf(
STDERR,
" unless the node is delayed with '&delayed' short form\n");
928 (void) fprintf(
STDERR,
" delay node <%s> cannot be delayed with '&delayed' short form\n",
Node_List[
Num_Nodes-1].name1);
935 (void) snprintf(tok10, (
size_t) (
LINLENGTH-1L),
"1 %s", tok9);
950 ((0 != strncmp(
Node_List[
Num_Nodes].name1,
"_void", (
size_t) 5)) && (!flag)) ?
false :
true;
965void get_var(
char *str,
const char *instruction) {
983 char brc[3] = {
'\0'};
984 char sgn[2] = {
'\0'};
985 char *s = (
char*) NULL;
986 char *t = (
char*) NULL;
989 int flag, cflag, eflag, uflag;
996 if (0 == strcmp(brc,
"")) {
998 }
else if (0 == strcmp(brc,
"()")) {
1005 (void) fprintf(
STDERR,
" brackets, if any, around variable name cannot be < %s > but parenthesis\n", brc);
1010 (void) fprintf(
STDERR,
" %s name <%s> is not a NAPA identifier\n", instruction, tok1);
1015 (void) fprintf(
STDERR,
" no sign expected in front of the %s identifier <%s>\n", instruction, tok1);
1020 (void) fprintf(
STDERR,
" %s name is missing\n", instruction);
1023 if ((
char*) NULL != strchr(tok1,
':')) {
1025 (void) fprintf(
STDERR,
" definition of %s <%s> cannot include a bit field\n", instruction, tok1);
1028 if (0 == strcmp(tok1,
"fs")) {
1030 (void) fprintf(
STDERR,
" %s identifier cannot be the <fs> identifier\n", instruction );
1033 if (0 == strcmp(tok1,
"void")) {
1035 (void) fprintf(
STDERR,
" %s identifier cannot be the <void> identifier\n", instruction );
1041 (void) fprintf(
STDERR,
" keyword <%s> cannot be used as %s identifier\n", tok1, instruction);
1046 (void) fprintf(
STDERR,
" keyword <%s> is not recommended to be used as %s name\n", tok1, instruction);
1051 (void) fprintf(
STDERR,
" %s variable definition!<%s> is already defined\n", instruction, tok1);
1058 (void) fprintf(
STDERR,
" %s definition <%s> is colliding an alias defined\n", instruction, tok1);
1065 (void) fprintf(
STDERR,
" %s definition <%s> is colliding a node defined\n", instruction, tok1);
1072 (void) fprintf(
STDERR,
" %s definition <%s> is colliding a record defined\n", instruction, tok1);
1079 (void) fprintf(
STDERR,
" %s definition <%s> is colliding an array defined\n", instruction, tok1);
1086 (void) fprintf(
STDERR,
" %s definition <%s> is colliding a directive defined\n", instruction, tok1);
1090 t = strstr(str,
"&update");
1091 if ((
char*) NULL != t) {
1093 for (i = 0L; i < 6L; i++) {
1098 t = strstr(str,
"&constant");
1099 if ((
char*) NULL != t) {
1101 for (i = 0; i < 8; i++) {
1106 t = strstr(str,
"&export");
1107 if ((
char*) NULL != t) {
1109 for (i = 0L; i < 6L; i++) {
1114 (void) strcpy(tok4, str);
1115 for (j = 0L; j <=
LENGTH(tok4); j++) {
1116 if (
'"' == tok4[j]) {
1122 if (0 == strcmp(
"Space", tok1)) {
1124 (void) fprintf(
STDERR,
" variable <%s> must be a string and cannot being defined as analog\n", tok1);
1135 (void) snprintf(tok6, (
size_t) (
STRLENGTH-1L),
" (constant) %s ", tok1);
1145 (void) fprintf(
STDERR,
" variable <%s>, being analog, cannot be width limited\n", tok1);
1151 if (0 == strcmp(
"Space", tok1)) {
1153 (void) fprintf(
STDERR,
" variable <%s> must be a string and cannot being defined as digital\n", tok1);
1164 (void) snprintf(tok6, (
size_t) (
STRLENGTH-1L),
" (constant) %s ", tok1);
1175 if (0 == strcmp(
"Space", tok1)) {
1177 (void) fprintf(
STDERR,
" variable <%s> must be a string and cannot being defined as an event\n", tok1);
1186 (void) fprintf(
STDERR,
" redundant update, an event is automatically updated by definition\n");
1191 (void) fprintf(
STDERR,
" an event variable cannot be constant\n");
1196 (void) strcpy(tok7, str);
1198 if ((0 == strcmp(brc,
"()")) && (0 == strcmp(tok5,
"new"))) {
1202 (void) strcpy(s, tok7);
1204 (void) strcpy(tok3,
"(I_TYPE) (");
1205 (void) strcat(tok3, s);
1206 (void) strcat(tok3,
")");
1207 (void) strcpy(str, tok3);
1212 (void) fprintf(
STDERR,
" event variable <%s> cannot be width limited\n", tok1);
1225 (void) fprintf(
STDERR,
" a string cannot be updated\n");
1230 (void) fprintf(
STDERR,
" redundant declaration as a string is always constant\n");
1234 (void) strcat(str,
"\" \"");
1237 (void) strcpy(str, tok2);
1242 if (
'"' == str[0]) {
1251 (void) fprintf(
STDERR,
" identifier <%s> is not defined previously as a string variable\n", tok2);
1260 (void) fprintf(
STDERR,
" string variable <%s> cannot be width limited\n", tok1);
1289 (void) fprintf(
STDERR,
" <%s> self-reference is not allowed in a %s definition\n",
Var_List[
Num_Vars].name1, instruction);
1307 char *str1 = (
char*) NULL;
1308 char *str2 = (
char*) NULL;
1309 (void) strcpy(buf1, str);
1310 (void) strcpy(buf2, str);
1326 static long counter = -2;
1334 char sgn[2] = {
'\0'};
1335 char *s = (
char*) NULL;
1337 long label, existing;
1339 static long start = 0L;
1340 static long prev_num_groups = -1L;
1351 if (data_flag[depth]) {
1353 (void) fprintf(
STDERR,
" instruction 'post' is not allowed in a data cell file\n");
1358 (void) fprintf(
STDERR,
" bit width declaration <%ld> has no meaning here\n", width);
1361 (void) snprintf(tok2, (
size_t) (
STRLENGTH-1L),
"%s%s", sgn, tok1);
1362 if (1 != sscanf(tok2,
"%li", &label)) {
1368 (void) fprintf(
STDERR,
" label is not a strictly positive integer <%s>\n", tok2);
1375 (void) fprintf(
STDERR,
" no sign expected in front of the function identifier <%s>\n", tok1);
1380 (void) fprintf(
STDERR,
" function identifier is missing\n");
1383 (void) snprintf(tok2, (
size_t) (
STRLENGTH-1L),
"post_%s", tok1);
1387 (void) strcpy(tok3,
"");
1388 (void) strcpy(tok4,
"");
1394 if (
'$' == tok5[(
LENGTH(tok5)) - 1L]) {
1395 tok5[(
LENGTH(tok5)) - 1L] =
'\0';
1396 (void) strcat(tok3, tok5);
1397 (void) strcat(tok3,
" ");
1399 (void) strcat(tok4, tok5);
1400 (void) strcat(tok4,
" ");
1407 if (0 == strcmp(tok2,
Post_List[i].function)) {
1434 if (-1L == existing) {
1439 (void) fprintf(
STDERR,
" this instruction must immediately follow another postprocess, a tool or an output\n");
1457 (void) strcpy(ifil,
"");
1459 (void) strcpy(ifil, tok1);
1462 (void) fprintf(
STDERR,
" there is no file from tool node to postprocess\n");
1484 (void) fprintf(
STDERR,
" this instruction must follow immediately another postprocess, a tool or an output\n");
1495 (void) strcpy(ifil,
Group_List[existing].ofname);
1498 (void) fprintf(
STDERR,
" there is no file to postprocess\n");
1506 if ((0 == strcmp(ifil,
"\"stdout\""))|| (0 == strcmp(ifil,
"\"stderr\"")) || (0 == strcmp(ifil,
"\"stdin\"" ))) {
1508 (void) fprintf(
STDERR,
" standard IO stream <%s> cannot be postprocessed\n", ifil);
1525 (void) strcpy(ofil,
"");
1529 (void) strcpy(ofil, tok1);
1536 (void) fprintf(
STDERR,
" a void post instruction must have a label\n");
1551 (void) fprintf(
STDERR,
" file <%s> cannot be postprocessed\n", ofil);
1556 if (-1L == existing) {
1570 if (-1L == existing) {
1587 char brc[3] = {
'\0'};
1593 (void) snprintf(tok1, (
size_t) (
STRLENGTH-1L),
"%s%s", tok4, tok3);
1596 (void) fprintf(
STDERR,
" bit width declaration <%ld> has no meaning here\n", width);
1600 (void) fprintf(
STDERR,
" file name is missing\n");
1604 (void) strcpy(tok2, tok1);
1606 if ((
char*) NULL == strstr(tok2,
".")) {
1607 (void) strcat(tok2,
".hdr");
1609 if (((0 != strncmp(tok2,
"napa", (
size_t) 4))
1610 || (0 != strcmp(tok2 + ((
int) strlen(tok2)) - 4,
".hdr"))) && (0 ==
Error_Flag)) {
1612 (void) fprintf(
STDERR,
" Very first header in netlist must be the header file <napa.hdr>.\n");
1613 (void) fprintf(
STDERR,
" This header contains essential informations for compilation.\n");
1614 (void) fprintf(
STDERR,
" If needed, it can be replaced by a customized version,\n");
1615 (void) fprintf(
STDERR,
" file name must be prefixed by <napa> and suffixed with <.hdr>\n");
1621 (void) strcpy(tok2,
"noexpand");
1623 if ((0 != strcmp(tok2,
"expand")) && (0 != strcmp(tok2,
"noexpand"))) {
1626 (void) fprintf(
STDERR,
" (%s) is not a valid header qualifier\n\n", tok2);
1627 (void) fprintf(
STDERR,
" valid qualifiers are:\n");
1628 (void) fprintf(
STDERR,
" (noexpand)\n");
1629 (void) fprintf(
STDERR,
" (expand)\n");
1630 (void) strcpy(tok2,
"noexpand");
1635 (void) fprintf(
STDERR,
" invalid string <%s> after header qualifier (%s)", str, tok2);
1638 if ((
char*) NULL == strstr(tok1,
".")) {
1639 (void) strcat(tok1,
".hdr");
1676 char brc[3] = {
'\0'};
1677 char sgn[2] = {
'\0'};
1678 char *str2 = (
char*) NULL;
1684 (void) fprintf(
STDERR,
" bit width declaration <%ld> has no meaning here\n", width);
1688 if (0 == strcmp(brc,
"()")) {
1695 (void) fprintf(
STDERR,
" no sign expected\n");
1701 (void) fprintf(
STDERR,
" directive identifier is missing\n");
1706 (void) fprintf(
STDERR,
" directive identifier <%s> is not a NAPA identifier\n", tok1);
1711 (void) fprintf(
STDERR,
" directive identifier <%s> is a reserved NAPA keyword\n", tok1);
1718 (void) fprintf(
STDERR,
" <%s> is redefining a directive previously defined\n", tok1);
1729 (void) fprintf(
STDERR,
" definition <%s> is colliding an alias defined\n", tok1);
1736 (void) fprintf(
STDERR,
" definition <%s> is colliding a node defined\n", tok1);
1744 (void) fprintf(
STDERR,
" definition <%s> is colliding a variable defined\n", tok1);
1752 (void) fprintf(
STDERR,
" definition <%s> is colliding a record defined\n", tok1);
1760 (void) fprintf(
STDERR,
" definition <%s> is colliding an array defined\n", tok1);
1768 if (0 == strcmp(brc,
"()")) {
1770 (void) strcpy(tok3,
"(");
1771 (void) strcat(tok3, tok2);
1772 (void) strcat(tok3,
")");
1779 (void) strcpy(tok2, str1);
1801 char sgn[2] = {
'\0'};
1804 if (data_flag[depth]) {
1806 (void) fprintf(
STDERR,
" instruction 'nominal' is not allowed in a data cell file\n");
1811 (void) fprintf(
STDERR,
" bit width declaration <%ld> has no meaning here\n", width);
1814 if (0 != strcmp(tok1,
"fs")) {
1816 (void) fprintf(
STDERR,
" syntax error, keyword 'fs' is missing\n");
1845 char sgn[2] = {
'\0'};
1850 if (data_flag[depth]) {
1852 (void) fprintf(
STDERR,
" instruction 'decimate' is not allowed in a data cell file\n");
1857 (void) fprintf(
STDERR,
" bit width declaration <%ld> has no meaning here\n", width);
1862 (void) fprintf(
STDERR,
" decimation value is missing\n");
1865 if (0 == strcmp(tok1,
"fs")) {
1872 (void) snprintf(tok2, (
size_t) (
STRLENGTH-1L),
"%s%s", sgn, tok1);
1875 (void) strcpy(tok2,
Var_List[v].value);
1879 if (1 != sscanf(tok2,
"%li", <emp)) {
1881 (void) fprintf(
STDERR,
" rate is not a well-formed positive C integer <%s>,\n", tok2);
1882 (void) fprintf(
STDERR,
" if <%s> is a variable, it should be defined as a number before this instruction\n", tok2);
1887 (void) fprintf(
STDERR,
" rate is not a positive integer <%s>\n", tok2);
1892 (void) snprintf(tok2, (
size_t) (
STRLENGTH-1L),
"%s%s", sgn, tok1);
1896 (void) strcpy(tok2,
Var_List[v].value);
1900 if (1 != sscanf(tok2,
"%li", <emp)) {
1902 (void) fprintf(
STDERR,
" the decimation offset is not a well-formed positive C integer <%s>,\n", tok2);
1903 (void) fprintf(
STDERR,
" if <%s> is a variable, it should be defined as a number before this instruction\n", tok2);
1908 (void) fprintf(
STDERR,
" the decimation offset is not a positive integer <%s>\n", tok2);
1948 char sgn[2] = {
'\0'};
1953 if (data_flag[depth]) {
1955 (void) fprintf(
STDERR,
" instruction 'interpolate' is not allowed in a data cell file\n");
1960 (void) fprintf(
STDERR,
" bit width declaration <%ld> has no meaning here\n", width);
1965 (void) fprintf(
STDERR,
" interpolation value is missing\n");
1968 if (0 == strcmp(tok1,
"fs")) {
1975 (void) snprintf(tok2, (
size_t) (
STRLENGTH-1L),
"%s%s", sgn, tok1);
1978 (void) strcpy(tok2,
Var_List[v].value);
1982 if (1 != sscanf(tok2,
"%li", &(ltemp))) {
1984 (void) fprintf(
STDERR,
" rate is not a well-formed positive C integer <%s>,\n", tok2);
1985 (void) fprintf(
STDERR,
" if <%s> is a variable, it should be defined as a number before this instruction\n", tok2);
1990 (void) fprintf(
STDERR,
" rate is not a positive integer <%s>\n", tok2);
2023 char *s = (
char*) NULL;
2027 if (data_flag[depth]) {
2029 (void) fprintf(
STDERR,
" instruction 'drop' is not allowed in a data cell file\n");
2034 (void) fprintf(
STDERR,
" bit width declaration <%ld> has no meaning here\n", width);
2038 (void) fprintf(
STDERR,
" C conditional expression is missing\n");
2043 if (0 == strcmp(tok1,
"fs")) {
2075 char sgn[2] = {
'\0'};
2080 (void) fprintf(
STDERR,
" bit width declaration <%ld> has no meaning here\n", width);
2098 (void) fprintf(
STDERR,
" no sign expected in front of a command_line parameter <%s>\n", tok);
2102 if ((
UNDEFINED != i) && (0 != strcmp(tok,
"void"))) {
2104 (void) fprintf(
STDERR,
" duplication of command_line parameter <%s>\n", tok);
2111 (void) fprintf(
STDERR,
" parameter <%s> is not a NAPA identifier\n", tok);
2138 char brc[3] = {
'\0'};
2139 char sgn[2] = {
'\0'};
2140 char *s = (
char*) NULL;
2148 (void) fprintf(
STDERR,
" redeclaration of width limitation is not allowed when updating a variable\n");
2154 (void) fprintf(
STDERR,
" variable name <%s> is not a NAPA identifier\n", tok1);
2159 (void) fprintf(
STDERR,
" variable name is missing\n");
2162 if ((
char*) NULL != strchr(tok1,
':')) {
2164 (void) fprintf(
STDERR,
" %s <%s> cannot include a bit field\n", instruction, tok1);
2169 (void) fprintf(
STDERR,
" no sign expected in front of the variable identifier <%s>\n", tok1);
2174 (void) fprintf(
STDERR,
" a node cannot be updated <%s>\n", tok1);
2181 if ((0 == strcmp(brc,
"()")) && (0 == strcmp(tok2,
"new"))) {
2182 (void) strcpy(tok3,
"(I_TYPE) (");
2183 (void) strcat(tok3, s);
2184 (void) strcat(tok3,
")");
2185 (void) strcpy(str, tok3);
2188 (void) strcpy(tok3,
"(I_TYPE) (");
2189 (void) strcat(tok3, str);
2190 (void) strcat(tok3,
")");
2191 (void) strcpy(str, tok3);
2233 if (data_flag[depth]) {
2235 (void) fprintf(
STDERR,
" instruction 'output' is not allowed in a data cell file\n");
2240 (void) fprintf(
STDERR,
" output cannot be width limited\n");
2246 (void) fprintf(
STDERR,
" output stream is missing\n");
2251 (void) fprintf(
STDERR,
" output list is missing\n");
2257 for (i = 0; i <
Num_IOs; i++) {
2260 (void) fprintf(
STDERR,
" collision between I/O streams, <%s> is already defined", tok2);
2262 (void) fprintf(
STDERR,
" as input\n");
2265 (void) fprintf(
STDERR,
" as output\n");
2272 (void) fprintf(
STDERR,
" collision with I/O streams, <%s> is already defined as a dump file", tok2);
2304 if (data_flag[depth]) {
2306 (void) fprintf(
STDERR,
" instruction 'input' is not allowed in a data cell file\n");
2311 (void) fprintf(
STDERR,
" input cannot be width limited\n");
2317 (void) fprintf(
STDERR,
" stream input is missing\n");
2322 (void) fprintf(
STDERR,
" list of variables is missing\n");
2328 for (i = 0; i <
Num_IOs; i++) {
2331 (void) fprintf(
STDERR,
" collision between I/O streams, <%s> is already defined", tok2);
2333 (void) fprintf(
STDERR,
" as input\n");
2336 (void) fprintf(
STDERR,
" as output\n");
2343 (void) fprintf(
STDERR,
" collision with I/O streams, <%s> is already defined as a dump file", tok2);
2371 char brc[3] = {
'\0'};
2372 char *p = (
char*) NULL;
2373 if (data_flag[depth]) {
2375 (void) fprintf(
STDERR,
" instruction 'void' is not allowed in a data cell file\n");
2380 (void) fprintf(
STDERR,
" this instruction cannot be width limited\n");
2385 (void) fprintf(
STDERR,
" file name is missing\n");
2391 (void) snprintf(tok1, (
size_t) (
STRLENGTH-1L),
"%s%s", tok3, tok2);
2394 (void) fprintf(
STDERR,
" too many parameters <%s %s> for this instruction\n", tok1, str);
2411 char sgn[2] = {
'\0'};
2414 if (data_flag[depth]) {
2416 (void) fprintf(
STDERR,
" instruction 'alias' is not allowed in a data cell file\n");
2421 (void) fprintf(
STDERR,
" this instruction cannot be width limited\n");
2424 if (0 == strcmp(
"(", tok1)) {
2426 (void) fprintf(
STDERR,
" no braces are expected around the alias identifier\n");
2431 (void) fprintf(
STDERR,
" no sign expected in front of the alias identifier <%s>\n", tok1);
2436 (void) fprintf(
STDERR,
" alias name <%s> is not a NAPA identifier\n", tok1);
2441 (void) fprintf(
STDERR,
" alias name is missing\n");
2447 (void) fprintf(
STDERR,
" duplicate alias definition, <%s> is already defined\n", tok1);
2454 (void) fprintf(
STDERR,
" definition <%s> is colliding a node defined\n", tok1);
2461 (void) fprintf(
STDERR,
" definition <%s> is colliding a variable defined\n", tok1);
2468 (void) fprintf(
STDERR,
" definition <%s> is colliding a record defined\n", tok1);
2475 (void) fprintf(
STDERR,
" definition <%s> is colliding an array defined\n", tok1);
2482 (void) fprintf(
STDERR,
" definition <%s> is colliding a directive defined\n", tok1);
2486 if (0 == strcmp(tok1,
"fs")) {
2488 (void) fprintf(
STDERR,
" identifier cannot be the <fs> identifier\n");
2494 (void) fprintf(
STDERR,
" keyword <%s> cannot be used as alias name\n", tok1);
2499 (void) fprintf(
STDERR,
" keyword <%s> is not recommended to be used as alias name\n", tok1);
2504 (void) fprintf(
STDERR,
" alias target is missing\n");
2510 (void) fprintf(
STDERR,
" alias name <%s> is not a NAPA identifier\n", tok2);
2515 (void) fprintf(
STDERR,
" no sign expected in front of the alias target <%s>\n", tok2);
2520 (void) fprintf(
STDERR,
" a NAPA keyword cannot be an alias target: <%s>\n", tok2);
2523 if (0 == strcmp(tok2,
"Ground")) {
2525 (void) fprintf(
STDERR,
" node <Ground> cannot be an alias target\n");
2528 if (0 == strcmp(tok2,
"Zero")) {
2530 (void) fprintf(
STDERR,
" node <Zero> cannot be an alias target\n");
2533 if (0 == strcmp(tok2,
"One")) {
2535 (void) fprintf(
STDERR,
" node <One> cannot be an alias target\n");
2538 if (0 == strcmp(tok2,
"void")) {
2540 (void) fprintf(
STDERR,
" <void> cannot be an alias target\n");
2545 (void) fprintf(
STDERR,
" too many parameters for this instruction <%s ?>\n", str);
2566 if (data_flag[depth]) {
2568 (void) fprintf(
STDERR,
" instruction 'terminate' is not allowed in a data cell file\n");
2573 (void) fprintf(
STDERR,
" bit width declaration <%ld> has no meaning here\n", width);
2577 (void) fprintf(
STDERR,
" only one instruction 'terminate' is allowed in a netlist\n");
2584 (void) strcpy(str,
"true");
2586 if (0 == strcmp(str,
"true")) {
2607 char brck[3] = {
'\0'};
2609 if (data_flag[depth]) {
2611 (void) fprintf(
STDERR,
" instruction 'synchronize' is not allowed in a data cell file\n");
2616 (void) fprintf(
STDERR,
" bit width declaration <%ld> has no meaning here\n", width);
2623 if (0 == strcmp(tok1,
"no")) {
2625 }
else if ((0 != strcmp(tok1,
"yes") &&
ISNOTEMPTY(tok1)) || (0 != strcmp(brck,
"()"))) {
2627 (void) fprintf(
STDERR,
" syntax accepts only (yes) or (no)\n");
2645 (void) fprintf(
STDERR,
" C expression cannot be width limited\n");
2650 (void) fprintf(
STDERR,
" init expression is missing\n");
2653 (void) snprintf(buf, (
size_t) 31,
"$init$_%ld",
Num_Inits);
2690 char sgn[2] = {
'\0'};
2691 char brc[3] = {
'\0'};
2696 (void) fprintf(
STDERR,
" bit width declaration <%ld> has no meaning here\n", width);
2699 if (0 != strcmp(brc,
"()")) {
2701 (void) fprintf(
STDERR,
" declaration qualifier is missing\n");
2704 if (0 == strcmp(tok1,
"constant")) {
2706 }
else if (0 == strcmp(tok1,
"digital" )) {
2708 }
else if (0 == strcmp(tok1,
"analog" )) {
2710 }
else if (0 == strcmp(tok1,
"string" )) {
2712 }
else if (0 == strcmp(tok1,
"true" )) {
2718 (void) fprintf(
STDERR,
" (%s) is not a valid declaration qualifier\n", tok1);
2719 (void) fprintf(
STDERR,
" valid qualifiers are:\n");
2720 (void) fprintf(
STDERR,
" (digital)\n");
2721 (void) fprintf(
STDERR,
" (analog)\n");
2722 (void) fprintf(
STDERR,
" (string)\n");
2723 (void) fprintf(
STDERR,
" (constant)\n");
2724 (void) fprintf(
STDERR,
" (true)\n");
2729 (void) fprintf(
STDERR,
" node or variable identifier is missing\n");
2735 (void) fprintf(
STDERR,
" declare expression is missing\n");
2738 (void) snprintf(buf, (
size_t) 31,
"$declare$_%ld",
Num_Inits);
2780 (void) strcpy(tok2,
"");
2786 (void) strcat(tok2,
" ");
2787 (void) strcat(tok2, tok1);
2813 char brc[3] = {
'\0'};
2814 char *s = (
char*) NULL;
2818 (void) fprintf(
STDERR,
" bit width declaration <%ld> has no meaning here\n", width);
2822 (void) fprintf(
STDERR,
" assert message and conditional expression is missing\n");
2825 (void) snprintf(buf, (
size_t) 31,
"$assert$_%ld",
Num_Asserts);
2835 (void) fprintf(
STDERR,
" assert message is missing\n");
2838 if (0 != strcmp(brc,
"\"\"")) {
2840 (void) fprintf(
STDERR,
" double quotes are missing around assert message <%s>\n", s);
2868 char sgn[2] = {
'\0'};
2870 if (data_flag[depth]) {
2872 (void) fprintf(
STDERR,
" instruction 'gateway' is not allowed in a data cell file\n");
2877 (void) fprintf(
STDERR,
" bit width declaration <%ld> has no meaning here\n", width);
2881 (void) fprintf(
STDERR,
" only one gateway is allowed in a simulation\n");
2885 (void) snprintf(tok2, (
size_t) (
STRLENGTH-1L),
"%s%s", sgn, tok1);
2887 if (1 != sscanf(tok2,
"%li", &(
Gateway_List.counter))) {
2889 (void) fprintf(
STDERR,
" counter is not a well-formed positive C integer <%s>\n", tok2);
2894 (void) fprintf(
STDERR,
" counter must be a positive number\n");
2915 char *str2 = (
char*) NULL;
2918 char sgn[2] = {
'\0'};
2923 (void) fprintf(
STDERR,
" this special instruction is allowed only in the main netlist file\n");
2929 (void) fprintf(
STDERR,
" redeclaration of width limitation is not allowed\n");
2934 (void) fprintf(
STDERR,
" node name <%s> is not a NAPA identifier\n", tok1);
2939 (void) fprintf(
STDERR,
" node name is missing\n");
2944 (void) fprintf(
STDERR,
" no sign expected in front of the node identifier <%s>\n", tok1);
2949 (void) fprintf(
STDERR,
" stuck value is missing\n");
2958 if (0 == strcmp(tok2, tok1)) {
2960 (void) fprintf(
STDERR,
" node <%s> self-reference is not allowed in definition\n", tok1);
2987 char sgn[2] = {
'\0'};
2991 if (data_flag[depth]) {
2993 (void) fprintf(
STDERR,
" instruction 'inject' is not allowed in a data cell file\n");
2999 (void) fprintf(
STDERR,
" width limitation is not allowed\n");
3004 (void) fprintf(
STDERR,
" node name <%s> is not a NAPA identifier\n", tok1);
3009 (void) fprintf(
STDERR,
" node name is missing\n");
3014 (void) fprintf(
STDERR,
" no sign expected in front of the node identifier <%s>\n", tok1);
3019 (void) fprintf(
STDERR,
" inject value is missing\n");
3022 if ((1 == sscanf(str,
"%lf", &dtemp)) &&
ISSMALL(dtemp)) {
3051 if (data_flag[depth]) {
3053 (void) fprintf(
STDERR,
" instruction 'call' is not allowed in a data cell file\n");
3058 (void) fprintf(
STDERR,
" C expression cannot be width limited\n");
3063 (void) fprintf(
STDERR,
" call expression is missing\n");
3066 (void) snprintf(buf, (
size_t) 31,
"$call$_%ld",
Num_Calls);
3094 if (data_flag[depth]) {
3096 (void) fprintf(
STDERR,
" instruction 'restart' is not allowed in a data cell file\n");
3101 (void) fprintf(
STDERR,
" instruction 'restart' does not accept any parameter\n");
3105 (void) fprintf(
STDERR,
" bit width declaration <%ld> has no meaning here\n", width);
3107 (void) snprintf(buf, (
size_t) 31,
"$restart$_%ld",
Num_Restarts);
3132 char sgn[2] = {
'\0'};
3137 (void) fprintf(
STDERR,
" bit width declaration <%ld> has no meaning here\n", width);
3141 (void) fprintf(
STDERR,
" debug identifier is missing\n");
3148 (void) fprintf(
STDERR,
" no sign expected in front of a debug identifier <%s>\n", tok);
3158 (void) fprintf(
STDERR,
" <%s>, an instruction cannot be used as debug directive\n", tok);
3162 (void) fprintf(
STDERR,
" <%s>, a directive cannot be used as debug directive\n", tok);
3166 (void) fprintf(
STDERR,
" <%s>, a node cannot be used as debug directive\n", tok);
3169 (void) fprintf(
STDERR,
" <%s>, a variable cannot be used as debug directive\n", tok);
3172 (void) fprintf(
STDERR,
" <%s>, a record cannot be used as debug directive\n", tok);
3175 (void) fprintf(
STDERR,
" <%s>, an array cannot be used as debug directive\n", tok);
3176 }
else if ((
'"' == tok[0]) && (
'"' == tok[
LENGTH(tok)-1L])) {
3178 (void) fprintf(
STDERR,
" <%s>, a string cannot be used as debug directive\n", tok);
3182 (void) fprintf(
STDERR,
" <%s> is not a NAPA identifier\n", tok);
3208 (void) fprintf(
STDERR,
" there are multiple ping instructions in this netlist\n");
3214 (void) fprintf(
STDERR,
" this special instruction is allowed only in the main netlist file\n");
3219 (void) fprintf(
STDERR,
" bit width declaration <%ld> has no meaning here\n", width);
3223 (void) strcpy(tok1,
"stderr");
3229 (void) fprintf(
STDERR,
" ping file name is not a string\n");
3234 if (0 == strcmp(tok1,
"stdin")) {
3236 (void) fprintf(
STDERR,
" ping output stream cannot be \"stdin\"\n");
3239 if (0 == strcmp(tok1,
"stdout")) {
3241 (void) fprintf(
STDERR,
" to avoid collision, ping output stream cannot be \"stdout\"\n");
3265 if (
'"' != str[0]) {
3267 (void) fprintf(
STDERR,
" parameter is not a well-formed string\n");
3271 if (
'\0' == str[i]) {
3272 if (
'"' != str[i-1]) {
3274 (void) fprintf(
STDERR,
" parameter is not a well formed string\n");
3279 if (
'\\' == str[i]) {
3286 buffer[j-1L] =
'\0';
3300 char sgn[2] = {
'\0'};
3301 char tag[3] = {
'\0'};
3306 (void) fprintf(
STDERR,
" collision with a previous definition of the sampling frequency\n");
3312 (void) fprintf(
STDERR,
" collision with a previous definition of the sampling period\n");
3318 (void) fprintf(
STDERR,
" collision with a precious definition of a sampling formula\n");
3323 (void) strcpy(tag,
"ts");
3327 (void) strcpy(tag,
"fs");
3331 if (data_flag[depth]) {
3333 (void) fprintf(
STDERR,
" instructions '%s' is not allowed in a data cell file\n", tag);
3338 (void) fprintf(
STDERR,
" bit width declaration <%ld> has no meaning here\n", width);
3342 (void) strcpy(tok,
"1.0");
3346 (void) fprintf(
STDERR,
" sampling <%s> must be an analog type constant\n", tok);
3352 (void) fprintf(
STDERR,
" no sign expected in front of the sampling");
3354 (void) fprintf(
STDERR,
" period\n");
3356 (void) fprintf(
STDERR,
" frequency\n");
3363 (void) fprintf(
STDERR,
" spurious text <%s> appears at the end of sampling definition\n", str);
3368 (void) fprintf(
STDERR,
" sampling period '%s' is not a well-formed positive C number <%s>\n", tag, tok);
3374 (void) fprintf(
STDERR,
" sampling period must be strictly positive\n");
3382 (void) fprintf(
STDERR,
" sampling frequency '%s' is not a well-formed positive C number <%s>\n", tag, tok);
3388 (void) fprintf(
STDERR,
" sampling frequency must be strictly positive\n");
3414 if (data_flag[depth]) {
3416 (void) fprintf(
STDERR,
" instruction 'sampling' is not allowed in a data cell file\n");
3421 (void) fprintf(
STDERR,
" bit width declaration <%ld> has no meaning here\n", width);
3425 (void) fprintf(
STDERR,
" collision with a previous definition of the sampling frequency\n");
3431 (void) fprintf(
STDERR,
" only one sampling instruction is allowed in a simulation\n");
3436 (void) fprintf(
STDERR,
" sampling formula is missing\n");
3465 char sgn[2] = {
'\0'};
3467 if (data_flag[depth]) {
3469 (void) fprintf(
STDERR,
" instruction 'interlude' is not allowed in a data cell file\n");
3474 (void) fprintf(
STDERR,
" bit width declaration <%ld> has no meaning here\n", width);
3478 (void) fprintf(
STDERR,
" overwriting a previous definition of interlude\n");
3482 (void) fprintf(
STDERR,
" waiting for a value or for min and max values\n");
3486 (void) snprintf(tok2, (
size_t) (
STRLENGTH-1L),
"%s%s", sgn, tok1);
3491 (void) snprintf(tok4, (
size_t) (
STRLENGTH-1L),
"%s%s", sgn, tok3);
3498 (void) snprintf(tok6, (
size_t) (
STRLENGTH-1L),
"%s%s", sgn, tok5);
3504 (void) fprintf(
STDERR,
" spurious text <%s> appears at the end of the instruction\n", str);
3510 (void) fprintf(
STDERR,
" the range value is not a well-formed positive C integer <%s>\n", tok2);
3512 (void) fprintf(
STDERR,
" the min value is not a well-formed positive C integer <%s>\n", tok2);
3521 (void) fprintf(
STDERR,
" the range value is not a positive integer <%ld>\n",
Interlude_List.number1);
3523 (void) fprintf(
STDERR,
" the min value is not a positive integer <%ld>\n",
Interlude_List.number1);
3531 (void) fprintf(
STDERR,
" the max value is not a well-formed positive C integer <%s>\n", tok4);
3540 (void) fprintf(
STDERR,
" the max value is not a strictly positive integer <%ld>\n",
Interlude_List.number2);
3548 (void) fprintf(
STDERR,
" the max value <%ld> cannot be smaller than the min value <%ld> and will be ignored\n",
3559 (void) fprintf(
STDERR,
" the resolution value is not a well-formed positive C integer <%s>\n", tok6);
3570 (void) fprintf(
STDERR,
" the resolution <%ld>, being too small, will be reset to 0\n",
Interlude_List.number3);
3594 (void) fprintf(
STDERR,
" bit width declaration <%ld> has no meaning here\n", width);
3598 (void) fprintf(
STDERR,
" seed of the random number is missing\n");
3603 (void) fprintf(
STDERR,
" overwriting a previous definition of random_seed\n");
3606 if (1 != sscanf(str,
"%li", &
Seed_List.rndseed)) {
3608 (void) fprintf(
STDERR,
" random_seed is not a well-formed C long integer <%s>\n", str);
3630#if (IS_WIN64 == PLATFORM)
3632 for (n = 0L; n <
LENGTH(str); n++) {
3633 if (
'\\' == str[n]) {
3640 (void) fprintf(
STDERR,
" bit width declaration <%ld> has no meaning here\n", width);
3646 (void) fprintf(
STDERR,
" title will be truncated, use double quotes\n");
3652 (void) fprintf(
STDERR,
" title is too long and will be truncated\n");
3669 if (data_flag[depth]) {
3671 (void) fprintf(
STDERR,
" instruction 'export' is not allowed in a data cell file\n");
3676 (void) fprintf(
STDERR,
" export declaration does not support a width limit\n");
3681 (void) fprintf(
STDERR,
" export variable or node is missing\n");
3710 char brc[3] = {
'\0'};
3714 char *s = (
char*) NULL;
3715 if (0 == strcmp(variant,
"array")) {
3720 (void) strcpy(tok2,
"(");
3721 (void) strcpy(tok3,
"pointer");
3722 (void) strcpy(tok4,
")");
3724 (void) snprintf(tok1, (
size_t) (
STRLENGTH-1L),
"%s%s%s", tok2, tok3, tok4);
3728 (void) fprintf(
STDERR,
" %s name <%s> is not a NAPA identifier\n", variant, tok2);
3734 (void) fprintf(
STDERR,
" %s <%s> cannot be width limited\n", variant, tok2);
3739 (void) fprintf(
STDERR,
" %s name is missing\n", variant);
3746 (void) fprintf(
STDERR,
" duplicate record definition, <%s> is already defined\n", tok2);
3754 (void) fprintf(
STDERR,
" definition <%s> is colliding an array defined\n", tok2);
3762 (void) fprintf(
STDERR,
" definition <%s> is colliding an alias defined\n", tok2);
3769 (void) fprintf(
STDERR,
" definition <%s> is colliding a variable defined\n", tok2);
3777 (void) fprintf(
STDERR,
" definition <%s> is colliding a node defined\n", tok2);
3785 (void) fprintf(
STDERR,
" definition <%s> is colliding a directive defined\n", tok2);
3791 if (0 != strcmp(brc,
"[]")) {
3793 (void) fprintf(
STDERR,
" size is not properly declared\n");
3800 (void) strcpy(tok3,
"0");
3804 (void) fprintf(
STDERR,
" <%s> is not properly declared as an array\n", tok2);
3809 (void) strcpy(tok6, str);
3810 if (0 == strcmp(tok1,
"(analog)" )) {
3812 }
else if (0 == strcmp(tok1,
"(digital)")) {
3814 }
else if (0 == strcmp(tok1,
"(hex)" )) {
3816 }
else if (0 == strcmp(tok1,
"(pointer)")) {
3820 (void) fprintf(
STDERR,
" (%s) is not a correct type qualifier\n", tok1);
3821 (void) fprintf(
STDERR,
" valid qualifiers are:\n");
3822 (void) fprintf(
STDERR,
" (digital) (hex)\n");
3823 (void) fprintf(
STDERR,
" (analog)\n");
3824 (void) fprintf(
STDERR,
" (pointer)\n");
3833 if ((0 != strcmp(brc,
"\"\"")) &&
ISNOTEMPTY(str)) {
3838 (void) fprintf(
STDERR,
" <%s> is not a string variable\n", tok5);
3844 (void) snprintf(tok6, (
size_t) (
STRLENGTH-1L),
"\"%s\"", tok4);
3867 if (1 != sscanf(tok3,
"%li", &size)) {
3869 (void) fprintf(
STDERR,
" size is not a well-formed positive C integer <%s>\n", tok3);
3876 (void) fprintf(
STDERR,
" size is not positive <%ld>\n", size);
3881 if (((
char*) NULL != strstr(str,
" ::")) || ((
char*) NULL != strstr(str,
":: "))) {
3883 (void) fprintf(
STDERR,
" no space is allowed around the operator '::'\n" );
3915 char brc[3] = {
'\0'};
3917 if (data_flag[depth]) {
3919 (void) fprintf(
STDERR,
" instruction 'format' is not allowed in a data cell file\n");
3924 (void) fprintf(
STDERR,
" bit width declaration <%ld> has no meaning here\n", width );
3928 (void) fprintf(
STDERR,
" format parameters are missing\n");
3932 if ((0 != strcmp(brc,
"()")) || (
ISEMPTY(tok1))) {
3934 (void) fprintf(
STDERR,
" format type is missing. Expecting (analog), (digital) or (string)\n");
3937 if (0 == strncmp(tok1,
"analog", (
size_t) 6)) {
3941 if (0 == strcmp(tok1,
"digital")) {
3945 if (0 == strncmp(tok1,
"hex", (
size_t) 3)) {
3949 if (0 == strcmp(tok1,
"string")) {
3954 (void) fprintf(
STDERR,
" format type is not correct. Expecting (analog), (digital) or (string)\n");
3962 char brc[3] = {
'\0'};
3964 if (0 == strncmp(str,
"S", 1)) {
3967 if (0 == strncmp(str,
"M", 1)) {
3970 if (0 == strncmp(str,
"L", 1)) {
3974 if (0 != strcmp(brc,
"\"\"")) {
3976 (void) fprintf(
STDERR,
" double quotes are missing\n");
3981 (void) fprintf(
STDERR,
" analog number format specification is invalid\n");
3986 (void) fprintf(
STDERR,
" spurious text appears at the end of format definition: <%s>\n", str);
3990 (void) fprintf(
STDERR,
" redefining analog number output format\n");
4002 char brc[3] = {
'\0'};
4004 if (0 == strncmp(str,
"S", 1)) {
4007 if (0 == strncmp(str,
"M", 1)) {
4010 if (0 == strncmp(str,
"L", 1)) {
4014 if (0 != strcmp(brc,
"\"\"")) {
4016 (void) fprintf(
STDERR,
" double quotes are missing\n");
4021 (void) fprintf(
STDERR,
" digital number format specification is invalid\n");
4026 (void) fprintf(
STDERR,
" spurious text appears at the end of format definition: <%s>\n", str);
4030 (void) fprintf(
STDERR,
" redefining digital number output format\n");
4042 char brc[3] = {
'\0'};
4044 if (0 == strncmp(str,
"S", 1)) {
4047 if (0 == strncmp(str,
"M", 1)) {
4050 if (0 == strncmp(str,
"L", 1)) {
4054 if (0 != strcmp(brc,
"\"\"")) {
4056 (void) fprintf(
STDERR,
" double quotes are missing\n");
4061 (void) fprintf(
STDERR,
" digital hexadecimal number format specification is invalid\n");
4066 (void) fprintf(
STDERR,
" spurious text appears at the end of format definition: <%s>\n", str);
4070 (void) fprintf(
STDERR,
" redefining digital hexadecimal number output format\n");
4082 char brc[3] = {
'\0'};
4084 if (0 == strncmp(str,
"S", 1)) {
4087 if (0 == strncmp(str,
"M", 1)) {
4090 if (0 == strncmp(str,
"L", 1)) {
4094 if (0 != strcmp(brc,
"\"\"")) {
4096 (void) fprintf(
STDERR,
" double quotes are missing\n");
4101 (void) fprintf(
STDERR,
" string format specification is invalid\n");
4106 (void) fprintf(
STDERR,
" spurious text appears at the end of format definition: <%s>\n", str);
4110 (void) fprintf(
STDERR,
" redefining string output format\n");
4129 char sgn[2] = {
'\0'};
4135 (void) fprintf(
STDERR,
" opcode <%s> cannot be width limited\n", tok1);
4140 (void) fprintf(
STDERR,
" opcode name <%s> is not a NAPA identifier\n", tok1);
4145 (void) snprintf(tok2, (
size_t) (
STRLENGTH-1L),
"%s%s", sgn, tok3);
4146 if (1 != sscanf(tok2,
"%li", &i)) {
4148 (void) fprintf(
STDERR,
" opcode for <%s> is not a well-formed positive C integer <%s>\n", tok1, tok2);
4153 (void) fprintf(
STDERR,
" opcode for <%s> cannot be a negative number\n", tok1);
4179 char brc[3] = {
'\0'};
4180 char *str1 = (
char*) NULL;
4184 if (data_flag[depth]) {
4186 (void) fprintf(
STDERR,
" instruction 'dump' is not allowed in a data cell file\n" );
4191 (void) fprintf(
STDERR,
" bit width declaration <%ld> has no meaning here\n", width );
4195 (void) fprintf(
STDERR,
" dump already defined, previous definition is overwritten\n");
4198 if (
ISEMPTY(tok1) || (0 != strcmp(brc,
"\"\""))) {
4204 if (0 == strcmp(tok1,
"when")) {
4205 (void) fprintf(
STDERR,
" file name is missing\n");
4207 (void) fprintf(
STDERR,
" file name is missing or not correct: <%s>\n", tok1);
4216 for (i = 0; i <
Num_IOs; i++) {
4219 (void) fprintf(
STDERR,
" collision between I/O streams, <%s> is already defined", tok2);
4221 (void) fprintf(
STDERR,
" as input\n");
4224 (void) fprintf(
STDERR,
" as output\n");
4229 (void) strcpy(tok2, str);
4232 (void) fprintf(
STDERR,
" C conditional expression is missing\n");
4256 char brc[3] = {
'\0'};
4257 char *str1 = (
char*) NULL;
4259 (void) strcpy(buf, str);
4260 if (data_flag[depth]) {
4262 (void) fprintf(
STDERR,
" instruction 'load' is not allowed in a data cell file\n" );
4267 (void) fprintf(
STDERR,
" bit width declaration <%ld> has no meaning here\n", width );
4271 (void) fprintf(
STDERR,
" load already defined, previous definition is overwritten\n");
4275 if (0 == strcmp(tok1,
"when")) {
4277 (void) fprintf(
STDERR,
" keyword 'when' is not allowed in a load statement\n" );
4283 (void) strcpy(str, buf);
4285 if (
ISEMPTY(tok1) || (0 != strcmp(brc,
"\"\""))) {
4291 (void) fprintf(
STDERR,
" file name is missing or not correct: <%s>\n", tok1);
4309void get_data(
char *str,
const char *buffer,
char *cell) {
4317 char data_interface[
LINLENGTH] = {
'\0'};
4318 char inst_interface[
LINLENGTH] = {
'\0'};
4323 char sgn1[2] = {
'\0'};
4324 char sgn2[2] = {
'\0'};
4325 char brc[3] = {
'\0'};
4326 char *str1 = (
char*) NULL;
4327 char *str2 = (
char*) NULL;
4331 unsigned long nl = 0L;
4332 static long num_data = -1L;
4337 (void) fprintf(
STDOUT,
"\n#* ");
4338 (void) fprintf(
STDERR,
" ");
4339 for (j = 0L; j < depth; j++) {
4342 (void) fprintf(
STDOUT,
">> %s\n\n", buffer);
4343 (void) fprintf(
STDERR,
">> ");
4347 (void) fprintf(
STDERR,
" declaration of width is not allowed\n");
4359 (void) fprintf(
STDERR,
" cell hierarchy overflow, currently limited to a depth of %ld\n",
MAXDEPTH);
4363 (void) snprintf(cell, (
size_t) (
LINLENGTH-1L),
"dat_%ld", num_data);
4371 if ((0 == strcmp(tok1,
"data_interface")) && (0 == strcmp(brc,
""))) {
4374 (void) fprintf(
STDERR,
" data cell interface is only allowed as head line of a data cell\n");
4377 if (
ISEMPTY(tok1) || ((0 != strcmp(brc,
"\"\"")) && (0 != strcmp(brc,
"<>")))) {
4383 (void) fprintf(
STDERR,
" file name is missing or not correct: <%s>\n", tok1);
4391 (void) strcpy(inst_interface, str);
4396 if ((
char*) NULL == strstr(
Cur_Fil_Name[depth],
".")) {
4400 (void) time(&time_start);
4403 (void) time(&time_stop);
4404 }
while (((FILE*) NULL == fhandle[depth]) && (3L >= ((
long) (time_stop-time_start))));
4409 if ((FILE*) NULL == fhandle[depth]) {
4415 if ((
char*) NULL ==
get_a_line(buff, &nl, fhandle[depth], mline, mfile)) {
4425 (void) fprintf(
STDERR,
" first line of file <\"%s\"> cannot be blank\n", tok1);
4429 if (0 == strcmp(tok2,
"cell")) {
4431 (void) fprintf(
STDERR,
" cell file <\"%s\"> cannot be used as a data file\n", tok1);
4434 if (0 == strcmp(tok2,
"data")) {
4437 if (0 != strcmp(tok2,
"data_interface")) {
4439 (void) fprintf(
STDERR,
" file <\"%s\"> is not a data cell as proper interface is missing on first line\n", tok1);
4442 (void) strcpy(data_interface, str);
4446 str = inst_interface;
4450 if (0 == strcmp(
Inst_Plist[depth][i],
"void")) {
4454 if (0 == strcmp(
Inst_Plist[depth][i],
"+")) {
4456 }
else if (0 == strcmp(
Inst_Plist[depth][i],
"-")) {
4463 (void) fprintf(
STDERR,
" string overflow, parameter names are too long, use shorter identifiers\n");
4474 (void) fprintf(
STDERR,
" <%s> is not a correct data cell parameter\n",
Inst_Plist[depth][i]);
4487 (void) fprintf(
STDERR,
" overflow, too many parameters (max %ld) for data instantiation\n",
MAXPARMS);
4492 str = data_interface;
4498 (void) fprintf(
STDERR,
" formal parameter cannot be signed\n");
4507 (void) fprintf(
STDERR,
" formal parameter <%s> must begin with letter '$'\n",
Cell_Plist[depth][d]);
4512 (void) fprintf(
STDERR,
" overflow, too many formal parameters (max %ld) for data instantiation\n",
MAXPARMS);
4522 (void) fprintf(
STDERR,
" discrepancy between the number of formal and actual parameters\n");
4523 str1 = data_interface;
4524 str2 = inst_interface;
4526 (void) strcpy(sgn1,
" ");
4529 if ((((0 == strcmp(tok1,
"+")) || (0 == strcmp(tok1,
"-"))) &&
ISNOTEMPTY(str1))) {
4530 (void) strcpy(sgn1, tok1);
4534 (void) strcpy(tok1,
"?");
4536 (void) strcpy(sgn2,
" ");
4539 if ((((0 == strcmp(tok2,
"+")) || (0 == strcmp(tok2,
"-"))) &&
ISNOTEMPTY(str2))) {
4540 (void) strcpy(sgn2, tok2);
4544 (void) strcpy(tok2,
"?");
4546 if ( (0 == strcmp(tok1,
"?")) && (0 == strcmp(tok2,
"?")) ) {
4549 (void) fprintf(
STDERR,
" %s%-10s <-> %s%-10s\n", sgn1, tok1, sgn2, tok2);
4551 (void) fprintf(
STDERR,
"\n");
4555 data_flag[depth] =
true;
4575 char brc[3] = {
'\0'};
4576 char *s = (
char*) NULL;
4577 char *t = (
char*) NULL;
4579#if (IS_WIN64 == PLATFORM)
4584 FILE *fp = (FILE*) NULL;
4590 if (data_flag[depth]) {
4592 (void) fprintf(
STDERR,
" generator calls are not allowed in a data cell file\n");
4600 (void) snprintf(tok1, (
size_t) (
LINLENGTH-1L),
"%s%s", tok4, tok3);
4601 if ((
'/' == tok1[0]) || (
':' == tok1[1])) {
4602 (void) strcpy(tok3, tok1);
4607 (void) fprintf(
STDERR,
" string buffer overflow while tracking generator file pathname\n");
4615 (void) strcpy(tok3,
Var_List[v].value);
4617#if (IS_WIN64 == PLATFORM)
4619 while (
'\0' != tok3[i]) {
4620 if (
'/' == tok3[i]) {
4627 (void) snprintf(tok2, (
size_t) (
LINLENGTH-1L),
"%s \"%s.gen\" %s", cell, tok1, str);
4628 (void) snprintf(command0, (
size_t) (
LINLENGTH-1L),
"%s %s.gen", tok3, tok1);
4629 (void) snprintf(tok4, (
size_t) (
LINLENGTH-1L),
"%s.gen", tok1);
4630 (void) time(&time_start);
4633 fp = fopen(tok4,
"w");
4634 (void) time(&time_stop);
4635 }
while (((FILE*) NULL == fp) && (3L >= ((
long) (time_stop-time_start))));
4636 if ((FILE*) NULL == fp) {
4638 (void) fprintf(
STDERR,
" OUCH!- can't create cell file <%s>\n\n", tok4);
4641 (void) time(&time_start);
4644 (void) time(&time_stop);
4645 }
while ((EOF == o) && (3L >= ((
long) (time_stop-time_start))));
4648 (void) fprintf(
STDERR,
" OUCH!- cell file pathname <%s> is locked\n", tok4);
4654 (void) strcpy(tok5, str);
4656 if (0 == strcmp(brc,
"<>")) {
4658 (void) fprintf(
STDERR,
"<%s>: triangular brackets are not expected here\n", tok3);
4661 (void) strcpy(str, tok5);
4668 (void) strcpy(tok3,
Var_List[v].value);
4672 (void) strcat(command0,
" ");
4673 (void) strcat(command0, tok3);
4676 (void) fprintf(
STDERR,
" string overflow, parameter names are too long, use shorter identifiers\n");
4683 (void) strcpy(command2, command1);
4684 if (98L <
LENGTH(command2)) {
4685 s = &(command2[90L]);
4686 t = &(command2[
LENGTH(command2) - 8L]);
4687 while ((
' ' != *s) && (s != t)) {
4690 *(s++) =
' '; *(s++) =
' ';
4691 *(s++) =
'.'; *(s++) =
'.'; *(s++) =
'.'; *(s++) =
' ';
4692 *(s++) =
'e'; *(s++) =
't'; *(s++) =
'c'; *(s++) =
'.';
4693 *(s++) =
' '; *(s++) =
'\0';
4696 (void) fprintf(
STDERR,
"Generating and ");
4698 (void) fprintf(
STDERR,
"\nNAPA Compiler Information: (generator)\n");
4699 (void) fprintf(
STDERR,
" Generating cell file <./%s>,\n", tok4);
4700 (void) fprintf(
STDERR,
" through system call: '%s'\n", command2);
4705 status = system(command1);
4710 (void) fprintf(
STDERR,
"\n");
4712 (void) fprintf(
STDERR,
" generation of the cell file <%s> didn't succeed!\n\n", tok4);
4716 (void) fprintf(
STDERR,
"\n");
4724void process_cell(
char *str,
const char *nodnam,
long *pseudo,
char *cell) {
4729 char cell_interface[
LINLENGTH] = {
'\0'};
4730 char inst_interface[
LINLENGTH] = {
'\0'};
4735 char brc[3] = {
'\0'};
4736 char sgn1[2] = {
'\0'};
4737 char sgn2[2] = {
'\0'};
4738 char *str1 = (
char*) NULL;
4739 char *str2 = (
char*) NULL;
4743 unsigned long nl = 0UL;
4747 if (data_flag[depth]) {
4749 (void) fprintf(
STDERR,
" cell instantiations other than data cells are not allowed in a data cell file\n");
4754 (void) fprintf(
STDERR,
" declaration of width is not allowed\n");
4760 (void) fprintf(
STDERR,
" cell name is missing\n");
4765 (void) fprintf(
STDERR,
" cell name <%s> is not a correct identifier\n", cell);
4776 (void) fprintf(
STDERR,
" cell hierarchy overflow, currently limited to %ld\n",
MAXDEPTH);
4787 if (
ISEMPTY(tok1) || ((0 != strcmp(brc,
"\"\"")) && (0 != strcmp(brc,
"<>")))) {
4793 (void) fprintf(
STDERR,
" cell file name is missing or not correct: <%s>\n", tok1);
4801 (void) strcpy(inst_interface, nodnam);
4803 (void) strcat(inst_interface,
" ");
4804 (void) strcat(inst_interface, str);
4807 (void) fprintf(
STDERR,
" interface identifiers are too long, use shorter identifiers\n");
4810 if ((
char*) NULL != strstr(inst_interface,
"::")) {
4812 (void) fprintf(
STDERR,
" transfer by names is allowed for a data cell but not for a cell\n");
4819 if ((
char*) NULL == strstr(
Cur_Fil_Name[depth],
".")) {
4823 (void) time(&time_start);
4826 (void) time(&time_stop);
4827 }
while (((FILE*) NULL == fhandle[depth]) && (3L >= ((
long) (time_stop-time_start))));
4832 if ((FILE*) NULL == fhandle[depth]) {
4834 (void) fprintf(
STDERR,
"\n");
4836 (void) fprintf(
STDERR,
" OUCH!- can't read cell file <\"%s\">\n",
Cur_Fil_Name[depth]);
4839 if ((
char*) NULL ==
get_a_line(buff, &nl, fhandle[depth], mline, mfile)) {
4841 (void) fprintf(
STDERR,
"\n");
4850 (void) fprintf(
STDERR,
" first line of cell file <\"%s\"> cannot be blank\n", tok1);
4854 if (0 == strcmp(tok2,
"data_interface")) {
4856 (void) fprintf(
STDERR,
" data cell file <\"%s\"> cannot be used as a cell file\n", tok1);
4859 if (0 != strcmp(tok2,
"cell_interface")) {
4861 (void) fprintf(
STDERR,
"file <\"%s\"> is not a cell as proper interface is missing on first line\n", tok1);
4864 (void) strcpy(cell_interface, str);
4865 str = inst_interface;
4869 if ((0 == strcmp(
Inst_Plist[depth][i],
"&delayed" ))
4870 || (0 == strcmp(
Inst_Plist[depth][i],
"&constant"))
4871 || (0 == strcmp(
Inst_Plist[depth][i],
"&update" ))
4872 || (0 == strcmp(
Inst_Plist[depth][i],
"&export" ))) {
4874 (void) fprintf(
STDERR,
" <%s>, a short form cannot be used in a cell instantiation\n",
Inst_Plist[depth][i]);
4877 if (0 == strcmp(
Inst_Plist[depth][i],
"void")) {
4881 if (0 == strcmp(
Inst_Plist[depth][i],
"+")) {
4883 }
else if (0 == strcmp(
Inst_Plist[depth][i],
"-")) {
4890 (void) fprintf(
STDERR,
" string overflow, parameter names are too long, use shorter identifiers\n");
4898 if ((0 != strcmp(
Inst_Plist[depth][i],
"&delayed"))
4903 (void) fprintf(
STDERR,
" <%s> is not a correct cell parameter\n",
Inst_Plist[depth][i]);
4910 (void) fprintf(
STDERR,
" overflow, too many parameters (max %ld) for cell <%s>\n",
MAXPARMS, cell);
4915 str = cell_interface;
4921 (void) fprintf(
STDERR,
" formal parameter cannot be signed\n");
4930 (void) fprintf(
STDERR,
" formal parameter <%s> must begin with letter '$'\n",
Cell_Plist[depth][j]);
4935 (void) fprintf(
STDERR,
" overflow, too many formal parameters (max %ld) for cell <%s>\n",
MAXPARMS, cell);
4944 (void) fprintf(
STDERR,
" cell file pathname: \"%s\", instance identifier: '%s'\n",
Cur_Fil_Name[depth], cell);
4945 (void) fprintf(
STDERR,
" discrepancy between the number of formal and actual parameters\n");
4946 str1 = cell_interface;
4947 str2 = inst_interface;
4949 (void) strcpy(sgn1,
" ");
4952 if ((((0 == strcmp(tok1,
"+")) || (0 == strcmp(tok1,
"-"))) &&
ISNOTEMPTY(str1))) {
4953 (void) strcpy(sgn1, tok1);
4957 (void) strcpy(tok1,
"?");
4959 (void) strcpy(sgn2,
" ");
4962 if ((((0 == strcmp(tok2,
"+")) || (0 == strcmp(tok2,
"-"))) &&
ISNOTEMPTY(str2))) {
4963 (void) strcpy(sgn2, tok2);
4967 (void) strcpy(tok2,
"?");
4969 if ((0 == strcmp(tok1,
"?")) && (0 == strcmp(tok2,
"?"))) {
4972 (void) fprintf(
STDERR,
" %s%-10s <-> %s%-10s\n", sgn1, tok1, sgn2, tok2);
4974 (void) fprintf(
STDERR,
"\n");
4978 data_flag[depth] =
false;
4990 if ((0 != strcmp(brc,
"()")) && (0 != strcmp(brc,
"<>"))) {
4993 signed_number = ( 0 == strcmp(brc,
"()") ) ?
true :
false;
4994 if (1 != sscanf(tok,
"%li", &w)) {
4996 (void) fprintf(
STDERR,
" width casting %c%s%c must be a positive integer constant\n", brc[0], tok, brc[1]);
5001 if ((w == wmax) && (signed_number)) {
5004 if (((1L > w) || (w > wmax)) && (signed_number)) {
5006 (void) fprintf(
STDERR,
" width casting %c%ld%c is outside range [1..%ld] of signed digital signals\n", brc[0], w, brc[1], wmax);
5010 if (((1L > w) || (w >= wmax)) && (!signed_number)) {
5012 (void) fprintf(
STDERR,
" width casting %c%ld%c is outside range [1..%ld[ of unsigned digital signals\n", brc[0], w, brc[1], wmax);
5016 if (!signed_number) {
5026 char *strd = (
char*) NULL;
5027 char *stri = (
char*) NULL;
5028 char *t1 = (
char*) NULL;
5029 char *t2 = (
char*) NULL;
5039 long i, d, j, dd, ni, nd;
5042 if ((
char*) NULL == strstr(inst_if,
"::")) {
5046 if (((
char*) NULL != strstr(inst_if,
" ::")) || ((
char*) NULL != strstr(inst_if,
":: "))) {
5048 (void) fprintf(
STDERR,
" syntax error, no space is allowed before or after the operator '::'\n");
5058 (void) strcpy(tok1, toki);
5059 (void) strcpy(tok2, toki);
5060 t1 = strstr(tok1,
"::");
5061 t2 = strstr(tok2,
"::");
5062 if ((
char*) NULL != t1) {
5063 (void) strcpy(tok1, t1+2);
5066 (void) strcpy(ilist1[ni], tok1);
5067 (void) strcpy(ilist2[ni], tok2);
5070 (void) fprintf(
STDERR,
" inconsistent transfer of parameters, by name or by position?\n");
5084 (void) strcpy(dlist2[nd], t2);
5088 for (d = 0L; d < nd; d++) {
5091 for (d = 0L; d < nd; d++) {
5092 for (i = 0L; i < ni; i++) {
5093 if (0 == strcmp(ilist2[i], dlist2[d])) {
5099 for (d = 0L; d < nd; d++) {
5101 (void) strcpy(dlist3[dd], dlist2[d]);
5108 for (i = 0L; i < ni; i++) {
5109 for (d = 0L; d < nd; d++) {
5110 if (0 == strcmp(ilist2[i], dlist3[d])) {
5111 (void) strcpy(dlist4[dd], dlist3[d] );
5119 if ((ni - nd) == 1L) {
5120 (void) fprintf(stderr,
" 1 parameter of the instantiation cannot be matched with the data cell:\n");
5122 (void) fprintf(stderr,
"%ld parameters of the instantiation cannot be matched with the data cell:\n", ni-nd);
5124 fprintf(stderr,
"\n%20s %15s\n",
"instantiation",
"data cell");
5127 for (j = 0L; j <
MAX(ni, nd); j++) {
5128 if (0 == strcmp(ilist2[i], dlist4[d])) {
5129 fprintf(stderr,
"%20s %15s\n", ilist1[i], dlist4[d]);
5133 fprintf(stderr,
"%20s %15s %15s", ilist1[i],
"...",
"<<< ???\n");
5140 (void) strcpy(inst_if,
"");
5141 for (i = 0L; i < ni; i++) {
5142 (void) strcat(inst_if, ilist1[i]);
5143 (void) strcat(inst_if,
" ");
5145 (void) strcpy(data_if,
"");
5146 for (d = 0L; d < nd; d++) {
5147 (void) strcat(data_if,
"$");
5148 (void) strcat(data_if, dlist4[d]);
5149 (void) strcat(data_if,
" ");
5158void record_cell_nam(
const char *nam,
long cur_depth,
unsigned long *mlin,
const unsigned long *mfil) {
5159 char *s = (
char*) NULL;
5163 if (0 == strcmp(nam, s)) {
5164 mlin[cur_depth] = 0UL;
5166 (void) fprintf(
STDERR,
" cell name <%s> is not unique\n", s);
5182 for (j = 1L; j < d; j++) {
5185 (void) fprintf(
STDERR,
" it is forbidden to loop instantiations of cells!\n");
5190 mfile[d] = (
unsigned long) i;
5203 char *t = (
char*) NULL;
5205 if (0 == strcmp(instruction,
"node")) {
5206 t = strstr(
string,
"&update");
5207 if ((
char*) NULL != t) {
5209 (void) fprintf(
STDERR,
" a node accepts only the short form '&delayed'\n");
5212 t = strstr(
string,
"&constant");
5213 if ((
char*) NULL != t) {
5215 (void) fprintf(
STDERR,
" a node accepts only the short form '&delayed'\n");
5218 t = strstr(
string,
"&export");
5219 if ((
char*) NULL != t) {
5221 (void) fprintf(
STDERR,
" the short form '&export' cannot be used for a node, use the explicit instruction 'export'\n");
5227 if (0 == strcmp(tok,
"&delayed")) {
5228 t = strstr(
string,
"&delayed");
5229 if ((
char*) NULL != t) {
5231 (void) fprintf(
STDERR,
" this instruction does not accept the short form '&delayed'\n" );
5237 if (0 == strcmp(tok,
"&any")) {
5238 t = strstr(
string,
"&delayed");
5239 if ((
char*) NULL != t) {
5241 (void) fprintf(
STDERR,
" this instruction does not accept the short form '&delayed'\n" );
5244 t = strstr(
string,
"&update");
5245 if ((
char*) NULL != t) {
5247 (void) fprintf(
STDERR,
" this instruction does not accept the short form '&update'\n" );
5250 t = strstr(
string,
"&constant");
5251 if ((
char*) NULL != t) {
5253 (void) fprintf(
STDERR,
" this instruction does not accept the short form '&constant'\n");
5256 t = strstr(
string,
"&export");
5257 if ((
char*) NULL != t) {
5259 (void) fprintf(
STDERR,
" this instruction does not accept the short form '&export'\n" );
5272 (void) fprintf(
STDERR,
" user-defined sampling rate is not compatible with interpolation concept\n");
5276 (void) fprintf(
STDERR,
" user-defined sampling rate is not compatible with a sampling period or frequency definition\n");
5280 (void) fprintf(
STDERR,
" No explicit instruction is given to the simulator to terminate!\n" );
5281 (void) fprintf(
STDERR,
" One instruction <terminate> is required in a simulation netlist. \n" );
5285 (void) fprintf(
STDERR,
" Generic header file <napa.hdr> must be called in every simulation.\n" );
5286 (void) fprintf(
STDERR,
" This header contains essential informations for the compilation.\n" );
5287 (void) fprintf(
STDERR,
" If needed, this header can be replaced by a customized version.\n" );
5288 (void) fprintf(
STDERR,
" File name must begin by the prefix <napa>, the suffix must be <.hdr>\n");
5292 (void) fprintf(
STDERR,
"\n");
5294 (void) fprintf(
STDERR,
" Instruction 'ping' is ignored in a standalone simulator\n\n");
void print_location(const unsigned long *mlin, const unsigned long *mfil)
void print_warning_location(const char *type, const unsigned long *mlin, const unsigned long *mfil)
void print_error_location(const char *type, const unsigned long *mlin, const unsigned long *mfil)
long f2printf(FILE *fp1, FILE *fp2, char *fmt,...)
char * get_a_line(char *buf, unsigned long *nl, FILE *fp, unsigned long *mlin, const unsigned long *mfil)
void increment_debug_number(const char *kind)
long constant_type(char *identifier)
void increment_call_number(const char *kind)
long get_type(char *identifier)
void increment_post_number(const char *kind)
long alias_id(const char *identifier)
void increment_opcode_number(const char *kind)
void increment_array_number(const char *kind)
void increment_generator_number(const char *kind)
void increment_node_number(const char *kind)
void increment_alias_number(const char *kind)
void increment_declare_number(const char *kind)
void increment_assert_number(const char *kind)
void increment_record_number(const char *kind)
void increment_IO_number(const char *kind)
long cmdline_id(const char *identifier)
void increment_comment_number(const char *kind)
void increment_cmdline_number(const char *kind)
void increment_inject_number(const char *kind)
void strcpy_alloc(char **dest, const char *sour, const unsigned long *mlin, const unsigned long *mfil)
int is_an_instruction(const char *identifier)
void increment_init_number(const char *kind)
long array_id(const char *identifier)
long directive_id(const char *identifier)
long node_kind(const char *identifier)
void increment_export_number(const char *kind)
void increment_void_number(void)
int is_a_keyword(const char *identifier)
void increment_restart_number(const char *kind)
void increment_directive_number(const char *kind)
long node_id(const char *identifier)
long var_id(const char *identifier)
void increment_filecell_number(const char *kind)
long debug_id(const char *identifier)
void increment_common_number(const char *kind)
void increment_var_number(const char *kind)
void increment_segment_number(const char *kind)
void increment_update_number(const char *kind)
long record_id(const char *identifier)
void increment_instance_number(const char *kind)
void increment_group_number(const char *kind)
void increment_stuck_number(const char *kind)
void strcpy_realloc(char **dest, const char *sour, const unsigned long *mlin, const unsigned long *mfil)
void increment_header_number(const char *kind)
char * process_gen(char *str, long *pseudo, char *cell)
void get_opcode(char *str)
void get_output(char *str)
void read_int_format(char *str)
void get_input(char *str)
void get_title(char *str)
#define NOT_INSTRUCTION(x)
void get_update(char *str, const char *instruction)
void get_alias(char *str)
void get_random_seed(const char *str)
void get_restart(const char *str)
void get_array(const char *variant, char *str)
char * get_node(char *str, char *nodnam, long *pseudo)
void get_nominal(char *str)
void trap_unconsistencies(void)
void get_data(char *str, const char *buffer, char *cell)
void read_hex_format(char *str)
void process_cell(char *str, const char *nodnam, long *pseudo, char *cell)
void get_event(const char *str)
long process_width(const char *brc, const char *tok, const char *instr)
void get_interlude(char *str)
void get_stuck(char *str)
void get_sampling(char *str)
void get_gateway(char *str)
void get_inject(char *str)
void read_str_format(char *str)
void get_command_line(char *str)
void get_comment(const char *str)
void get_synchronize(char *str)
void check_version(const char *str)
void get_terminate(char *str)
void get_directive(char *str1)
void get_var(char *str, const char *instruction)
void record_file_nam(long d, const unsigned long *mlin, const unsigned long *mfil)
void get_fs_ts(char *str, long fs1ts0)
void get_export(const char *str)
void get_format(char *str)
void read_doub_format(char *str)
void rearrange_data_interfaces(char *data_if, char *inst_if, const unsigned long *mlin, const unsigned long *mfil)
void record_cell_nam(const char *nam, long cur_depth, unsigned long *mlin, const unsigned long *mfil)
void get_decimate(char *str)
void get_interpolate(char *str)
void get_assert(char *str)
void get_debug(char *str)
void get_declare(char *str)
void get_header(char *str)
void inspect_short_form(const char *instruction, char *string, const char *tok)
void process_node_kind_error(const char *kind)
void process_instruction_error(const char *instr)
void process_array_error(const char *tok1)
void process_node_error(const char *tok1)
void process_variable_error(const char *tok1)
EXTERN int Interpolate_Flag
#define DECIMATE_SEGMENT_TYPE
#define DROP_SEGMENT_TYPE
EXTERN char * Generator_Lib_Name
EXTERN char Inst_Plist[31L][127L][16383L]
EXTERN RANDOMSEED_TYPE Seed_List
EXTERN VAR_TYPE Var_List[2047L]
EXTERN char I_String_Format[2047L]
EXTERN int Interlude_Flag3
EXTERN RECORD_TYPE Record_List[127L]
EXTERN DECLARE_COMMON_TYPE Declare_Common_List[255L]
EXTERN ARRAY_TYPE Array_List[63L]
EXTERN char Cell_Name_Prefix[31L][2047L]
EXTERN DECLARE_TYPE Declare_List[1023L]
EXTERN char S_Format[2047L]
EXTERN char R_Format[2047L]
EXTERN char Last_Postprocess[2047L]
EXTERN POST_TYPE Post_List[63L]
EXTERN NODE_TYPE Node_List[4095L]
EXTERN int Hierarchy_Flag
EXTERN char S_String_Format[2047L]
EXTERN EXPORT_TYPE Export_List[31L]
EXTERN SAMPLING_TYPE Sampling_List
EXTERN char R_String_Format[2047L]
EXTERN char X_String_Format[2047L]
EXTERN char * Record_Cell_File_Table[511L]
EXTERN ALIAS_TYPE Alias_List[127L]
EXTERN DIRECTIVE_TYPE Directive_List[255L]
EXTERN DEBUG_TYPE Debug_List[63L]
EXTERN HEADER_TYPE Header_List[63L]
#define INTERPOLATE_SEGMENT_TYPE
EXTERN char X_Format[2047L]
EXTERN INJECT_TYPE Inject_List[63L]
#define NAPA_COMPILER_VERSION
EXTERN LOAD_TYPE Load_List
EXTERN PING_TYPE Ping_List
EXTERN INTERLUDE_TYPE Interlude_List
EXTERN long Num_Directives
EXTERN int Interlude_Flag1
EXTERN char Cur_Lib_Name[31L][2047L]
EXTERN char Comment_String[63L][16383L]
EXTERN char * Header_Lib_Name
EXTERN OPCODE_TYPE Opcode_List[127L]
EXTERN char Void_List_Name[2047L]
EXTERN long Num_FileCells
EXTERN long Cell_Num_Parms[31L]
#define NOMINAL_SEGMENT_TYPE
EXTERN char I_Format[2047L]
EXTERN GATEWAY_TYPE Gateway_List
EXTERN long Record_Cell_File_Usage[511L]
EXTERN char Cur_Fil_Name[31L][2047L]
EXTERN long Num_Instances
EXTERN CMDLINE_TYPE Cmdline_List[63L]
EXTERN char Title_String[2 *2047L]
EXTERN int Terminate_Flag
#define MAIN_SEGMENT_TYPE
EXTERN TERMINATE_TYPE Terminate_List
EXTERN SEGMENT_TYPE Segment_List[127L]
EXTERN char * Main_File_Name
EXTERN char * Record_Instantiation_Name[511L]
EXTERN GROUP_TYPE Group_List[31L]
#define NAPA_DIGITAL_TYPE
EXTERN int Antithetic_Flag
EXTERN char * Net_Lib_Name
EXTERN STUCK_TYPE Stuck_List[63L]
EXTERN long Num_Generators
EXTERN DUMP_TYPE Dump_List
#define BOOLEAN_DATA_TYPE
EXTERN char Cell_Plist[31L][127L][16383L]
EXTERN char Last_Instruction[2047L]
EXTERN IO_TYPE IO_List[63L]
EXTERN long Num_Declare_Commons
#define DIGITAL_DATA_TYPE
EXTERN int Interlude_Flag2
EXTERN UPDATE_TYPE Update_List[2047L]
void print_error_banner_and_exit(void)
char * expand_nodeset(char *str, long n, long w, const unsigned long *mlin, const unsigned long *mfil)
void extract_directory(char *pn, char *fn, long depth)
void build_pathname(const char *brc, char *tok, const char *path, const unsigned long *mlin, const unsigned long *mfil)
void replace_parentheses(char *str)
int is_an_extended_identifier(const char *tok)
void strip_extension(char *fnam)
char * get_token(char *str, char *tok, long keep_quotes)
void clean_line(char *str)
int fnstrcmp(char const *a, char const *b)
void process_cell_line(char *buf, long d, const unsigned long *mlin, const unsigned long *mfil)
void clean_parentheses(char *tok)
void restore_line(char *lin)
char * compact_line(char *str1, char *str2)
int is_an_identifier(const char *tok)
char * multiple(char c, long n)
char * get_function_identifier(char *str, char *fun_id, char *fun_parm)
void replace_dollar(char *tok)
void sanity_check(char *s, const unsigned long *mlin, const unsigned long *mfil)
char * get_token_between_braces(char *str, char *brc, char *tok)
void expand_indirections(char *str)
void simplify_pathname(char *pnam)
void drop_pathname(char *pnam)
long record_function_identifier(const char *tok, long m, const unsigned long *mlin, const unsigned long *mfil)
void resolve_pathnames(char *lin, long d)
char * get_sign_and_token(char *str, char *sgn, char *tok)
void C_syntax_checker(char *str, const unsigned long *mlin, const unsigned long *mfil)