NAPA Compiler V4.50
Author: Yves Leduc, yves.leduc.be@gmail.com
Loading...
Searching...
No Matches
C:/Simulate/Napados/Source/rd.c File Reference
#include "./napa.h"
#include "./proto.h"

Go to the source code of this file.

Macros

#define EXTERN   extern

Functions

void redefine_node_segments (void)
void separe_qualifiers (void)
void redefine_nodes (void)
void create_nodes (void)
char * create_constant_var (char *str, int type, const unsigned long *mlin, const unsigned long *mfil)
void create_automatic_node (const char *identifier, const unsigned long *mlin, const unsigned long *mfil)
void inject_nodes (void)
void redefine_random_seed (void)
void name_mangling (void)
void collect_functions (void)
void purge_constants_in_ganging (void)
void purge_constants_in_options (void)
void mark_directives (void)
long record_function_identifier (const char *tok, long m, const unsigned long *mlin, const unsigned long *mfil)
void stuck_nodes (void)
void process_init (void)

Macro Definition Documentation

◆ EXTERN

#define EXTERN   extern

Definition at line 4 of file rd.c.

Function Documentation

◆ collect_functions()

void collect_functions ( void )

Definition at line 1148 of file rd.c.

1148 {
1149 long i;
1150 long kd;
1151 long tp;
1152 char *str = (char*) NULL;
1153 char tok1[STRLENGTH] = {'\0'};
1154 char tok2[STRLENGTH] = {'\0'};
1155 for (i = 0L; i < Num_Posts; i++) { /* inspect postprocesses */
1156 (void) record_function_identifier(Post_List[i].function, 1, Post_List[i].mline, Post_List[i].mfile);
1157 }
1158 str = Terminate_List.condition; /* inspect terminate */
1159 for (;;) {
1160 str = get_function_identifier(str, tok1, tok2);
1161 if (ISNOTEMPTY(tok1)) {
1162 (void) record_function_identifier(tok1, 0, Terminate_List.mline, Terminate_List.mfile);
1163 }
1164 if (ISEMPTY(str)) {
1165 break;
1166 }
1167 }
1168 for (i = 0L; i < Num_Nodes; i++) { /* inspect nodes */
1169 kd = Node_List[i].kind;
1170 if ((DALGEBRA_KIND == kd) || (IALGEBRA_KIND == kd) || (ALGEBRA_KIND == kd)
1171 || (DC_KIND == kd) || (CONST_KIND == kd) || (TEST_KIND == kd)) {
1172 str = Node_List[i].value;
1173 for (;;) {
1174 str = get_function_identifier(str, tok1, tok2);
1175 if (ISNOTEMPTY(tok1)) {
1176 (void) record_function_identifier(tok1, 0, Node_List[i].mline, Node_List[i].mfile);
1177 }
1178 if (ISEMPTY(str)) {
1179 break;
1180 }
1181 }
1182 }
1183 }
1184 for (i = 0L; i < Num_Vars; i++) { /* inspect vars */
1185 tp = Var_List[i].type;
1186 if (STRING_DATA_TYPE != tp) {
1187 str = Var_List[i].value;
1188 for (;;) {
1189 str = get_function_identifier(str, tok1, tok2);
1190 if (ISNOTEMPTY(tok1)) {
1191 (void) record_function_identifier(tok1, 0, Var_List[i].mline, Var_List[i].mfile);
1192 }
1193 if (ISEMPTY(str)) {
1194 break;
1195 }
1196 }
1197 }
1198 }
1199 for (i = 0L; i < Num_Directives; i++) { /* inspect directives */
1200 str = Directive_List[i].value;
1201 for (;;) {
1202 str = get_function_identifier(str, tok1, tok2);
1203 if (ISNOTEMPTY(tok1)) {
1204 (void) record_function_identifier(tok1, 0, Directive_List[i].mline, Directive_List[i].mfile);
1205 }
1206 if (ISEMPTY(str)) {
1207 break;
1208 }
1209 }
1210 }
1211 for (i = 0L; i < Num_Updates; i++) { /* inspect updates */
1212 tp = Var_List[var_id(Update_List[i].name)].type;
1213 if (STRING_DATA_TYPE != tp) {
1214 str = Update_List[i].value;
1215 for (;;) {
1216 str = get_function_identifier(str, tok1, tok2);
1217 if (ISNOTEMPTY(tok1)) {
1218 (void) record_function_identifier(tok1, 0, Update_List[i].mline, Update_List[i].mfile);
1219 }
1220 if (ISEMPTY(str)) {
1221 break;
1222 }
1223 }
1224 }
1225 str = Update_List[i].condition;
1226 for (;;) {
1227 str = get_function_identifier(str, tok1, tok2);
1228 if (ISNOTEMPTY(tok1)) {
1229 (void) record_function_identifier(tok1, 0, Update_List[i].mline, Update_List[i].mfile);
1230 }
1231 if (ISEMPTY(str)) {
1232 break;
1233 }
1234 }
1235 }
1236 for (i = 0L; i < Num_IOs; i++) { /* inspect IO's */
1237 if (OUTPUT_TYPE != IO_List[i].type) {
1238 continue;
1239 }
1240 str = IO_List[i].condition;
1241 for (;;) {
1242 str = get_function_identifier(str, tok1, tok2);
1243 if (ISNOTEMPTY(tok1)) {
1244 (void) record_function_identifier(tok1, 0, IO_List[i].mline, IO_List[i].mfile);
1245 }
1246 if (ISEMPTY(str)) {
1247 break;
1248 }
1249 }
1250 }
1251 for (i = 0L; i < Num_Injects; i++) { /* inspect injects */
1252 str = Inject_List[i].value;
1253 for (;;) {
1254 str = get_function_identifier(str, tok1, tok2);
1255 if (ISNOTEMPTY(tok1)) {
1256 (void) record_function_identifier(tok1, 0, Inject_List[i].mline, Inject_List[i].mfile);
1257 }
1258 if (ISEMPTY(str)) {
1259 break;
1260 }
1261 }
1262 }
1263 for (i = 0L; i < Num_Segments; i++) { /* inspect segments */
1264 tp = Segment_List[i].type;
1265 if (DROP_SEGMENT_TYPE == tp) {
1266 str = Segment_List[i].value;
1267 for (;;) {
1268 str = get_function_identifier(str, tok1, tok2);
1269 if (ISNOTEMPTY(tok1)) {
1270 (void) record_function_identifier(tok1, 0, Segment_List[i].mline, Segment_List[i].mfile);
1271 }
1272 if (ISEMPTY(str)) {
1273 break;
1274 }
1275 }
1276 }
1277 }
1278 for (i = 0L; i < Num_Opcodes; i++) { /* inspect opcodes */
1279 str = Opcode_List[i].function;
1280 for (;;) {
1281 str = get_function_identifier(str, tok1, tok2);
1282 if (ISNOTEMPTY(tok1)) {
1283 (void) record_function_identifier(tok1, 0, Opcode_List[i].mline, Opcode_List[i].mfile);
1284 }
1285 if (ISEMPTY(str)) {
1286 break;
1287 }
1288 }
1289 }
1290 if (Dump_Flag) { /* inspect dump condition */
1291 str = Dump_List.condition;
1292 for (;;) {
1293 str = get_function_identifier(str, tok1, tok2);
1294 if (ISNOTEMPTY(tok1)) {
1295 (void) record_function_identifier(tok1, 0, Dump_List.mline, Dump_List.mfile);
1296 }
1297 if (ISEMPTY(str)) {
1298 break;
1299 }
1300 }
1301 }
1302 if (!Periodic_Flag) { /* inspect sampling formula */
1303 str = Sampling_List.formula;
1304 for (;;) {
1305 str = get_function_identifier(str, tok1, tok2);
1306 if (ISNOTEMPTY(tok1)) {
1307 (void) record_function_identifier(tok1, 0, Sampling_List.mline, Sampling_List.mfile);
1308 }
1309 if (ISEMPTY(str)) {
1310 break;
1311 }
1312 }
1313 }
1314 return;
1315}
long var_id(const char *identifier)
Definition id.c:855
EXTERN long Num_Injects
Definition napa.h:820
#define DROP_SEGMENT_TYPE
Definition napa.h:353
EXTERN VAR_TYPE Var_List[2047L]
Definition napa.h:970
EXTERN long Num_Vars
Definition napa.h:836
EXTERN long Num_Updates
Definition napa.h:834
EXTERN POST_TYPE Post_List[63L]
Definition napa.h:964
EXTERN NODE_TYPE Node_List[4095L]
Definition napa.h:962
EXTERN int Dump_Flag
Definition napa.h:852
#define CONST_KIND
Definition napa.h:246
EXTERN SAMPLING_TYPE Sampling_List
Definition napa.h:978
EXTERN DIRECTIVE_TYPE Directive_List[255L]
Definition napa.h:955
#define TEST_KIND
Definition napa.h:316
EXTERN long Num_Nodes
Definition napa.h:824
EXTERN INJECT_TYPE Inject_List[63L]
Definition napa.h:960
EXTERN long Num_Directives
Definition napa.h:812
EXTERN long Num_Posts
Definition napa.h:827
#define DALGEBRA_KIND
Definition napa.h:251
EXTERN OPCODE_TYPE Opcode_List[127L]
Definition napa.h:963
#define DC_KIND
Definition napa.h:252
#define IALGEBRA_KIND
Definition napa.h:274
EXTERN long Num_IOs
Definition napa.h:822
EXTERN long Num_Segments
Definition napa.h:831
#define ISNOTEMPTY(s)
Definition napa.h:395
EXTERN TERMINATE_TYPE Terminate_List
Definition napa.h:980
EXTERN SEGMENT_TYPE Segment_List[127L]
Definition napa.h:966
#define STRLENGTH
Definition napa.h:217
EXTERN long Num_Opcodes
Definition napa.h:826
#define ISEMPTY(s)
Definition napa.h:394
#define STRING_DATA_TYPE
Definition napa.h:339
#define ALGEBRA_KIND
Definition napa.h:227
EXTERN DUMP_TYPE Dump_List
Definition napa.h:972
#define OUTPUT_TYPE
Definition napa.h:359
EXTERN IO_TYPE IO_List[63L]
Definition napa.h:961
EXTERN UPDATE_TYPE Update_List[2047L]
Definition napa.h:968
EXTERN int Periodic_Flag
Definition napa.h:873
char * get_function_identifier(char *str, char *fun_id, char *fun_parm)
Definition tk.c:1036
long record_function_identifier(const char *tok, long m, const unsigned long *mlin, const unsigned long *mfil)
Definition rd.c:1656

References ALGEBRA_KIND, CONST_KIND, DALGEBRA_KIND, DC_KIND, Directive_List, DROP_SEGMENT_TYPE, Dump_Flag, Dump_List, get_function_identifier(), IALGEBRA_KIND, Inject_List, IO_List, ISEMPTY, ISNOTEMPTY, Node_List, Num_Directives, Num_Injects, Num_IOs, Num_Nodes, Num_Opcodes, Num_Posts, Num_Segments, Num_Updates, Num_Vars, Opcode_List, OUTPUT_TYPE, Periodic_Flag, Post_List, record_function_identifier(), Sampling_List, Segment_List, STRING_DATA_TYPE, STRLENGTH, Terminate_List, TEST_KIND, Update_List, var_id(), and Var_List.

Referenced by main().

◆ create_automatic_node()

void create_automatic_node ( const char * identifier,
const unsigned long * mlin,
const unsigned long * mfil )

Definition at line 897 of file rd.c.

897 {
898 long i, j;
899 char tok1[STRLENGTH] = {'\0'};
900 char tok2[STRLENGTH] = {'\0'};
901 char *s = (char*) NULL;
902 if (UNDEFINED != node_id(identifier)) {
903 return; /* node was already defined */
904 }
905 if (0 == strcmp(identifier, "One")) {
906 strcpy_alloc(&(Node_List[Num_Nodes].name1), "One", mlin, mfil);
907 strcpy_alloc(&(Node_List[Num_Nodes].name2), "One", mlin, mfil);
908 Node_List[Num_Nodes].aliased = false; /* not aliased */
909 strcpy_alloc(&(Node_List[Num_Nodes].tag), "One", mlin, mfil);
910 strcpy_alloc(&(Node_List[Num_Nodes].value), "(digital) 1LL", mlin, mfil);
911 strcpy_alloc(&(Node_List[Num_Nodes].option), "", mlin, mfil);
914 Node_List[Num_Nodes].declare = DIGITAL_DATA_TYPE; /* considered as declared */
915 Node_List[Num_Nodes].inject = false;
916 Node_List[Num_Nodes].segment = 0L;
917 } else if (0 == strcmp(identifier, "Zero")) {
918 strcpy_alloc(&(Node_List[Num_Nodes].name1), "Zero", mlin, mfil);
919 strcpy_alloc(&(Node_List[Num_Nodes].name2), "Zero", mlin, mfil);
920 Node_List[Num_Nodes].aliased = false; /* not aliased */
921 strcpy_alloc(&(Node_List[Num_Nodes].tag), "Zero", mlin, mfil);
922 strcpy_alloc(&(Node_List[Num_Nodes].value), "(digital) 0LL", mlin, mfil);
923 strcpy_alloc(&(Node_List[Num_Nodes].option), "", mlin, mfil);
926 Node_List[Num_Nodes].declare = DIGITAL_DATA_TYPE; /* considered as declared */
927 Node_List[Num_Nodes].inject = false;
928 Node_List[Num_Nodes].segment = 0L;
929 } else if (0 == strcmp(identifier, "Ground")) {
930 strcpy_alloc(&(Node_List[Num_Nodes].name1), "Ground", mlin, mfil);
931 strcpy_alloc(&(Node_List[Num_Nodes].name2), "Ground", mlin, mfil);
932 Node_List[Num_Nodes].aliased = false; /* not aliased */
933 strcpy_alloc(&(Node_List[Num_Nodes].tag), "Ground", mlin, mfil);
934 strcpy_alloc(&(Node_List[Num_Nodes].value), "(analog) 0.0", mlin, mfil);
935 strcpy_alloc(&(Node_List[Num_Nodes].option), "", mlin, mfil);
938 Node_List[Num_Nodes].declare = ANALOG_DATA_TYPE; /* considered as declared */
939 Node_List[Num_Nodes].inject = false;
940 Node_List[Num_Nodes].segment = 0L;
941 } else if ((char*) NULL != strchr(identifier, ':')) { /* bit-field extraction */
942 if ((':' == identifier[0]) || (':' == identifier[LENGTH(identifier)-1L])) {
943 return;
944 }
945 s = strchr(identifier, ':');
946 if ((isspace((int) *(s-1))) || (!isdigit((int) *(s+1)))) {
947 return;
948 }
949 (void) strcpy(tok1, identifier);
950 strcpy_alloc(&(Node_List[Num_Nodes].name1), tok1, mlin, mfil);
951 strcpy_alloc(&(Node_List[Num_Nodes].name2), tok1, mlin, mfil);
952 Node_List[Num_Nodes].aliased = false; /* not aliased */
953 *s = '\0'; /* remove bit field suffix from identifier */
954 j = var_id(identifier);
955 if (UNDEFINED != j) {
956 print_error_location("bit field", mlin, mfil);
957 (void) fprintf(STDERR, " <%s> must be a node, not a variable\n", identifier);
958 return;
959 }
960 j = node_id(identifier);
961 if (UNDEFINED == j) {
962 print_error_location("bit field extraction", mlin, mfil);
963 (void) fprintf(STDERR, " root node <%s> does not exist\n", identifier);
964 process_node_error(identifier);
965 return;
966 }
967 (void) snprintf(tok2, (size_t) (STRLENGTH-1L), "%s %s", s+1, identifier);
968 strcpy_alloc(&(Node_List[Num_Nodes].tag), "bit field", mlin, mfil);
969 strcpy_alloc(&(Node_List[Num_Nodes].value), tok2, mlin, mfil);
970 strcpy_alloc(&(Node_List[Num_Nodes].option), "", mlin, mfil);
973 Node_List[Num_Nodes].declare = DIGITAL_DATA_TYPE; /* considered as declared */
974 Node_List[Num_Nodes].segment = Node_List[j].segment; /* same segment as root!! */
975 Node_List[Num_Nodes].inject = false;
976 Segment_List[Node_List[Num_Nodes].segment].used2 = true;
977 } else {
978 return;
979 }
980 Num_Creates++;
982 Node_List[Num_Nodes].width = 0L;
983 Node_List[Num_Nodes].determined = false;
984 Node_List[Num_Nodes].used = true;
985 Node_List[Num_Nodes].init = false;
986 Node_List[Num_Nodes].flag = NO;
987 Node_List[Num_Nodes].errflag = 0L;
988 Node_List[Num_Nodes].ID2 = 0L;
989 for (i = 0L; i < MAXDEPTH; i++) {
990 Node_List[Num_Nodes].mline[i] = mlin[i];
991 Node_List[Num_Nodes].mfile[i] = mfil[i];
992 }
993 increment_node_number("automatic definition");
994 return;
995}
void print_error_location(const char *type, const unsigned long *mlin, const unsigned long *mfil)
Definition fc.c:1476
void increment_node_number(const char *kind)
Definition id.c:413
void strcpy_alloc(char **dest, const char *sour, const unsigned long *mlin, const unsigned long *mfil)
Definition id.c:114
long node_id(const char *identifier)
Definition id.c:718
void process_node_error(const char *tok1)
Definition mp.c:259
#define MAXDEPTH
Definition napa.h:212
#define LENGTH(s)
Definition napa.h:397
#define UNDEFINED
Definition napa.h:331
#define STDERR
Definition napa.h:105
#define ANALOG_DATA_TYPE
Definition napa.h:338
#define ITOB_KIND
Definition napa.h:277
#define NO
Definition napa.h:406
EXTERN long Num_Creates
Definition napa.h:808
#define DIGITAL_DATA_TYPE
Definition napa.h:337

References ANALOG_DATA_TYPE, DC_KIND, DIGITAL_DATA_TYPE, increment_node_number(), ITOB_KIND, LENGTH, MAXDEPTH, NO, node_id(), Node_List, Num_Creates, Num_Nodes, print_error_location(), process_node_error(), Segment_List, STDERR, strcpy_alloc(), STRLENGTH, UNDEFINED, and var_id().

Referenced by create_nodes().

◆ create_constant_var()

char * create_constant_var ( char * str,
int type,
const unsigned long * mlin,
const unsigned long * mfil )

Definition at line 848 of file rd.c.

848 {
849 static char tok1[STRLENGTH] = {'\0'};
850 char tok2[STRLENGTH] = {'\0'};
851 long d, i, j;
852 (void) strcpy(tok2, str); /* value of the constant */
853 j = Num_Vars;
854 for (i = (Num_Vars-Num_Consts); i < Num_Vars; i++) { /* check only in the created constants ! */
855 if (0 == strcmp(tok2, Var_List[i].value)) {
856 j = i; /* this value is already stored in such a constant */
857 break;
858 }
859 }
860 if (j == Num_Vars) { /* not already stored, create a new constant */
861 (void) snprintf(tok1, (size_t) (STRLENGTH-1L), "const__%ld", Num_Consts); /* create a new variable name for this constant */
862 Var_List[j].type = type; /* analog or digital */
863 strcpy_alloc(&(Var_List[j].value), tok2, mlin, mfil); /* store the value of the variable */
864 strcpy_alloc(&(Var_List[j].comment), " ", mlin, mfil); /* no comment necesssary */
865 Var_List[j].width = 0L; /* no width limitation */
866 strcpy_alloc(&(Var_List[j].name1), tok1, mlin, mfil); /* variable name */
867 strcpy_alloc(&(Var_List[j].name2), tok1, mlin, mfil); /* copy of var name */
868 Var_List[j].aliased = false; /* no aliasing */
869 Var_List[j].declare = type; /* analog or digital */
870 Var_List[j].used = true; /* variable usage */
871 Var_List[j].external = false; /* never a command line parm */
872 Var_List[j].ID = j; /* unique variable ID */
873 Var_List[j].segment = 0L; /* record segment level */
874 Var_List[j].event = 0; /* not an event */
875 Var_List[j].determined = true; /* no need to be sorted */
876 Var_List[j].constant = true; /* it is a constant number ! */
877 for (d = 0L; d < MAXDEPTH; d++) {
878 Var_List[j].mline[d] = mlin[d]; /* record line for identification */
879 Var_List[j].mfile[d] = mfil[d]; /* record file for identification */
880 }
882 increment_var_number("constant");
883 }
884 (void) strcpy(tok1, Var_List[j].name1);
885 str = tok1;
886 return str;
887}
void increment_const_number(void)
Definition id.c:558
void increment_var_number(const char *kind)
Definition id.c:545
EXTERN long Num_Consts
Definition napa.h:807

References increment_const_number(), increment_var_number(), MAXDEPTH, Num_Consts, Num_Vars, strcpy_alloc(), STRLENGTH, and Var_List.

Referenced by purge_constants_in_ganging(), and purge_constants_in_options().

◆ create_nodes()

void create_nodes ( void )

Definition at line 715 of file rd.c.

715 {
716 long out;
717 char *s = (char*) NULL;
718 char tok[STRLENGTH] = {'\0'};
719 char sgn[2] = {'\0'};
720
721 for (out = 0L; out < Num_Nodes; out++) {
722 s = Node_List[out].value;
723 for (;;) {
724 s = get_sign_and_token(s, sgn, tok);
725 if (ISEMPTY(tok)) {
726 break;
727 }
728 if ((0 == strcmp(tok, "One" )) || (0 == strcmp(tok, "Zero")) ||
729 (0 == strcmp(tok, "Ground")) || ((char*) NULL != strchr(tok, ':'))) {
730 create_automatic_node(tok, Node_List[out].mline, Node_List[out].mfile);
731 }
732 }
733 }
734 for (out = 0L; out < Num_Vars; out++) {
735 s = Var_List[out].value;
736 for (;;) {
737 s = get_sign_and_token(s, sgn, tok);
738 if (ISEMPTY(tok)) {
739 break;
740 }
741 if ((0 == strcmp(tok, "One" )) || (0 == strcmp(tok, "Zero")) ||
742 (0 == strcmp(tok, "Ground")) || ((char*) NULL != strchr(tok, ':'))) {
743 create_automatic_node(tok, Var_List[out].mline, Var_List[out].mfile);
744 }
745 }
746 }
747 for (out = 0L; out < Num_Records; out++) {
748 s = Record_List[out].list1;
749 for (;;) {
750 s = get_sign_and_token(s, sgn, tok);
751 if (ISEMPTY(tok)) {
752 break;
753 }
754 if ((0 == strcmp(tok, "One" )) || (0 == strcmp(tok, "Zero")) ||
755 (0 == strcmp(tok, "Ground")) || ((char*) NULL != strchr(tok, ':'))) {
756 create_automatic_node(tok, Record_List[out].mline, Record_List[out].mfile);
757 }
758 }
759 }
760 for (out = 0L; out < Num_Updates; out++) {
761 s = Update_List[out].value;
762 for (;;) {
763 s = get_sign_and_token(s, sgn, tok);
764 if (ISEMPTY(tok)) {
765 break;
766 }
767 if ((0 == strcmp(tok, "One" )) || (0 == strcmp(tok, "Zero")) ||
768 (0 == strcmp(tok, "Ground")) || ((char*) NULL != strchr(tok, ':'))) {
769 create_automatic_node(tok, Update_List[out].mline, Update_List[out].mfile);
770 }
771 }
772 }
773 for (out = 0L; out < Num_IOs; out++) {
774 s = IO_List[out].element;
775 for (;;) {
776 s = get_sign_and_token(s, sgn, tok);
777 if (ISEMPTY(tok)) {
778 break;
779 }
780 if ((0 == strcmp(tok, "One" )) || (0 == strcmp(tok, "Zero")) ||
781 (0 == strcmp(tok, "Ground")) || ((char*) NULL != strchr(tok, ':'))) {
782 if (OUTPUT_TYPE == IO_List[out].type) {
783 create_automatic_node(tok, IO_List[out].mline, IO_List[out].mfile);
784 } else {
785 print_error_location("automatic node", IO_List[out].mline, IO_List[out].mfile);
786 (void) fprintf(STDERR, " <%s> cannot be defined from input instruction\n", tok);
787 }
788 }
789 }
790 }
791 for (out = 0L; out < Num_Segments; out++) {
792 if (DROP_SEGMENT_TYPE != Segment_List[out].type) {
793 continue;
794 }
795 s = Segment_List[out].value;
796 for (;;) {
797 s = get_sign_and_token(s, sgn, tok);
798 if (ISEMPTY(tok)) {
799 break;
800 }
801 if ((0 == strcmp(tok, "One" )) || (0 == strcmp(tok, "Zero")) ||
802 (0 == strcmp(tok, "Ground")) || ((char*) NULL != strchr(tok, ':'))) {
803 create_automatic_node(tok, Segment_List[out].mline, Segment_List[out].mfile);
804 }
805 }
806 }
807 s = Terminate_List.condition;
808 for (;;) {
809 s = get_sign_and_token(s, sgn, tok);
810 if (ISEMPTY(tok)) {
811 break;
812 }
813 if ((0 == strcmp(tok, "One" )) || (0 == strcmp(tok, "Zero")) ||
814 (0 == strcmp(tok, "Ground")) || ((char*) NULL != strchr(tok, ':'))) {
816 }
817 }
818 if (Dump_Flag) {
819 s = Dump_List.condition;
820 for (;;) {
821 s = get_sign_and_token(s, sgn, tok);
822 if (ISEMPTY(tok)) {
823 break;
824 }
825 if ((0 == strcmp(tok, "One" )) || (0 == strcmp(tok, "Zero")) ||
826 (0 == strcmp(tok, "Ground")) || ((char*) NULL != strchr(tok, ':'))) {
827 create_automatic_node(tok, Dump_List.mline, Dump_List.mfile);
828 }
829 }
830 }
831 if (!Periodic_Flag) {
832 s = Sampling_List.formula;
833 for (;;) {
834 s = get_sign_and_token(s, sgn, tok);
835 if (ISEMPTY(tok)) {
836 break;
837 }
838 if ((0 == strcmp(tok, "One" )) || (0 == strcmp(tok, "Zero")) ||
839 (0 == strcmp(tok, "Ground")) || ((char*) NULL != strchr(tok, ':'))) {
841 }
842 }
843 }
844 return;
845}
EXTERN RECORD_TYPE Record_List[127L]
Definition napa.h:965
EXTERN long Num_Records
Definition napa.h:828
char * get_sign_and_token(char *str, char *sgn, char *tok)
Definition tk.c:1188
void create_automatic_node(const char *identifier, const unsigned long *mlin, const unsigned long *mfil)
Definition rd.c:897

References create_automatic_node(), DROP_SEGMENT_TYPE, Dump_Flag, Dump_List, get_sign_and_token(), IO_List, ISEMPTY, Node_List, Num_IOs, Num_Nodes, Num_Records, Num_Segments, Num_Updates, Num_Vars, OUTPUT_TYPE, Periodic_Flag, print_error_location(), Record_List, Sampling_List, Segment_List, STDERR, STRLENGTH, Terminate_List, Update_List, and Var_List.

Referenced by main().

◆ inject_nodes()

void inject_nodes ( void )

Definition at line 1002 of file rd.c.

1002 {
1003 long i, n;
1004 if (!Inject_Flag) {
1005 return;
1006 }
1007 for (i = 0L; i < Num_Injects; i++) {
1008 n = node_id(Inject_List[i].name);
1009 if (UNDEFINED == n) {
1010 if (UNDEFINED == var_id(Inject_List[i].name)) {
1011 print_error_location("inject", Inject_List[i].mline, Inject_List[i].mfile);
1012 (void) fprintf(STDERR, " There is no node named <%s> in the netlist\n", Inject_List[i].name);
1014 } else {
1015 print_error_location("inject", Inject_List[i].mline, Inject_List[i].mfile);
1016 (void) fprintf(STDERR, " <%s> is a variable. No injection is allowed\n", Inject_List[i].name);
1017 }
1018 continue;
1019 } else {
1020 if (0 == strcmp(Node_List[n].name1, "Ground")) {
1021 print_error_location("inject", Inject_List[i].mline, Inject_List[i].mfile);
1022 (void) fprintf(STDERR, " Not allowed on node <Ground>\n");
1023 }
1024 if (Node_List[n].inject) {
1025 print_error_location("inject", Inject_List[i].mline, Inject_List[i].mfile);
1026 (void) fprintf(STDERR, " Inject to node <%s> only once\n", Inject_List[i].name);
1027 continue;
1028 }
1029 Node_List[n].inject = true;
1030 }
1031 }
1032 return;
1033}
EXTERN int Inject_Flag
Definition napa.h:861

References Inject_Flag, Inject_List, node_id(), Node_List, Num_Injects, print_error_location(), process_node_error(), STDERR, UNDEFINED, and var_id().

Referenced by main().

◆ mark_directives()

void mark_directives ( void )

Definition at line 1478 of file rd.c.

1478 {
1479 long d, i;
1480 long kd;
1481 long tp;
1482 char *str = (char*) NULL;
1483 char sgn[2] = {'\0'};
1484 char tok[STRLENGTH] = {'\0'};
1485 str = Terminate_List.condition; /* inspect terminate */
1486 for (;;) {
1487 str = get_sign_and_token(str, sgn, tok);
1488 d = directive_id(tok);
1489 if (UNDEFINED != d) {
1490 Directive_List[d].used = true;
1491 }
1492 if (ISEMPTY(str)) {
1493 break;
1494 }
1495 }
1496 for (i = 0L; i < Num_Nodes; i++) { /* inspect nodes */
1497 kd = Node_List[i].kind;
1498 if ((DALGEBRA_KIND == kd) || (IALGEBRA_KIND == kd) || (ALGEBRA_KIND == kd) || (DC_KIND == kd) || (TEST_KIND == kd)) {
1499 str = Node_List[i].value;
1500 for (;;) {
1501 str = get_sign_and_token(str, sgn, tok);
1502 d = directive_id(tok);
1503 if (UNDEFINED != d) {
1504 Directive_List[d].used = true;
1505 }
1506 if (ISEMPTY(str)) {
1507 break;
1508 }
1509 }
1510 }
1511 }
1512 for (i = 0L; i < Num_Vars; i++) { /* inspect vars */
1513 tp = Var_List[i].type;
1514 if (STRING_DATA_TYPE != tp) {
1515 str = Var_List[i].value;
1516 for (;;) {
1517 str = get_sign_and_token(str, sgn, tok);
1518 d = directive_id(tok);
1519 if (UNDEFINED != d) {
1520 Directive_List[d].used = true;
1521 }
1522 if (ISEMPTY(str)) {
1523 break;
1524 }
1525 }
1526 }
1527 }
1528 for (i = 0L; i < Num_Directives; i++) { /* inspect directives */
1529 str = Directive_List[i].value;
1530 for (;;) {
1531 str = get_sign_and_token(str, sgn, tok);
1532 d = directive_id(tok);
1533 if (UNDEFINED != d) {
1534 Directive_List[d].used = true;
1535 }
1536 if (ISEMPTY(str)) {
1537 break;
1538 }
1539 }
1540 }
1541 for (i = 0L; i < Num_Updates; i++) { /* inspect updates */
1542 tp = Var_List[var_id(Update_List[i].name)].type;
1543 if (STRING_DATA_TYPE != tp) {
1544 str = Update_List[i].value;
1545 for (;;) {
1546 str = get_sign_and_token(str, sgn, tok);
1547 d = directive_id(tok);
1548 if (UNDEFINED != d) {
1549 Directive_List[d].used = true;
1550 }
1551 if (ISEMPTY(str)) {
1552 break;
1553 }
1554 }
1555 }
1556 str = Update_List[i].condition;
1557 for (;;) {
1558 str = get_sign_and_token(str, sgn, tok);
1559 d = directive_id(tok);
1560 if (UNDEFINED != d) {
1561 Directive_List[d].used = true;
1562 }
1563 if (ISEMPTY(str)) {
1564 break;
1565 }
1566 }
1567 }
1568 for (i = 0L; i < Num_IOs; i++) { /* inspect IO's */
1569 if (OUTPUT_TYPE != IO_List[i].type) {
1570 continue;
1571 }
1572 str = IO_List[i].condition;
1573 for (;;) {
1574 str = get_sign_and_token(str, sgn, tok);
1575 d = directive_id(tok);
1576 if (UNDEFINED != d) {
1577 Directive_List[d].used = true;
1578 }
1579 if (ISEMPTY(str)) {
1580 break;
1581 }
1582 }
1583 }
1584 for (i = 0L; i < Num_Injects; i++) { /* inspect injects */
1585 str = Inject_List[i].value;
1586 for (;;) {
1587 str = get_sign_and_token(str, sgn, tok);
1588 d = directive_id(tok);
1589 if (UNDEFINED != d) {
1590 Directive_List[d].used = true;
1591 }
1592 if (ISEMPTY(str)) {
1593 break;
1594 }
1595 }
1596 }
1597 for (i = 0L; i < Num_Segments; i++) { /* inspect segments */
1598 tp = Segment_List[i].type;
1599 if (DROP_SEGMENT_TYPE == tp) {
1600 str = Segment_List[i].value;
1601 for (;;) {
1602 str = get_sign_and_token(str, sgn, tok);
1603 d = directive_id(tok);
1604 if (UNDEFINED != d) {
1605 Directive_List[d].used = true;
1606 }
1607 if (ISEMPTY(str)) {
1608 break;
1609 }
1610 }
1611 }
1612 }
1613 for (i = 0L; i < Num_Opcodes; i++) { /* inspect opcodes */
1614 str = Opcode_List[i].function;
1615 for (;;) {
1616 str = get_sign_and_token(str, sgn, tok);
1617 d = directive_id(tok);
1618 if (UNDEFINED != d) {
1619 Directive_List[d].used = true;
1620 }
1621 if (ISEMPTY(str)) {
1622 break;
1623 }
1624 }
1625 }
1626 if (Dump_Flag) { /* inspect dump condition */
1627 str = Dump_List.condition;
1628 for (;;) {
1629 str = get_sign_and_token(str, sgn, tok);
1630 d = directive_id(tok);
1631 if (UNDEFINED != d) {
1632 Directive_List[d].used = true;
1633 }
1634 if (ISEMPTY(str)) {
1635 break;
1636 }
1637 }
1638 }
1639 if (!Periodic_Flag) { /* inspect sampling formula */
1640 str = Sampling_List.formula;
1641 for (;;) {
1642 str = get_sign_and_token(str, sgn, tok);
1643 d = directive_id(tok);
1644 if (UNDEFINED != d) {
1645 Directive_List[d].used = true;
1646 }
1647 if (ISEMPTY(str)) {
1648 break;
1649 }
1650 }
1651 }
1652 return;
1653}
long directive_id(const char *identifier)
Definition id.c:707

References ALGEBRA_KIND, DALGEBRA_KIND, DC_KIND, directive_id(), Directive_List, DROP_SEGMENT_TYPE, Dump_Flag, Dump_List, get_sign_and_token(), IALGEBRA_KIND, Inject_List, IO_List, ISEMPTY, Node_List, Num_Directives, Num_Injects, Num_IOs, Num_Nodes, Num_Opcodes, Num_Segments, Num_Updates, Num_Vars, Opcode_List, OUTPUT_TYPE, Periodic_Flag, Sampling_List, Segment_List, STRING_DATA_TYPE, STRLENGTH, Terminate_List, TEST_KIND, UNDEFINED, Update_List, var_id(), and Var_List.

Referenced by check_directive_usage().

◆ name_mangling()

void name_mangling ( void )

Definition at line 1050 of file rd.c.

1050 {
1051 long out;
1052 long kd;
1053 long num;
1054 long d;
1055 char *s = (char*) NULL;
1056 char tok1[STRLENGTH] = {'\0'};
1057 char tok2[STRLENGTH] = {'\0'};
1058 char tok3[STRLENGTH] = {'\0'};
1059 char tok4[STRLENGTH] = {'\0'};
1060 char tok5[STRLENGTH] = {'\0'};
1061 char sgn[2] = {'\0'};
1062 unsigned long *ml = (unsigned long*) NULL;
1063 unsigned long *mf = (unsigned long*) NULL;
1064
1065 for (out = 0L; out < Num_Nodes; out++) {
1066 kd = Node_List[out].kind;
1067
1068 switch (kd) {
1069
1070 case DUSER_KIND :
1071 case DTOOL_KIND :
1072 case IUSER_KIND :
1073 case ITOOL_KIND :
1074 s = Node_List[out].value;
1075 s = get_sign_and_token(s, sgn, tok1); /* get user function name */
1076 (void) strcpy(tok3, s); /* get function parms */
1077 num = 0L;
1078 s = get_sign_and_token(s, sgn, tok4);
1079 for (;;) {
1080 if (ISEMPTY(tok4)) {
1081 break;
1082 }
1083 if (0 == strcmp(tok4, "after") || 0 == strcmp(tok4, "with")) {
1084 num--;
1085 s = get_sign_and_token(s, sgn, tok4); /* skip token following 'after' or 'with' */
1086 continue;
1087 }
1088 s = get_sign_and_token(s, sgn, tok4);
1089 num++;
1090 }
1091 if (ITOOL_KIND == kd) {
1092 (void) strcpy(tok2, "itool_");
1093 Tool_Flag = true;
1094 UserTool_List[Num_UserTools].mailbox = Num_Tools; /* tool mailbox number */
1095 increment_tool_number("tool registering");
1096 }
1097 if (DTOOL_KIND == kd) {
1098 Tool_Flag = true;
1099 (void) strcpy(tok2, "dtool_");
1100 UserTool_List[Num_UserTools].mailbox = Num_Tools; /* tool mailbox number */
1101 increment_tool_number("tool registering");
1102 }
1103 if (IUSER_KIND == kd) {
1104 User_Flag = true;
1106 (void) strcpy(tok2, "iuser_");
1107 }
1108 if (DUSER_KIND == kd) {
1109 User_Flag = true;
1111 (void) strcpy(tok2, "duser_");
1112 }
1113 if (Node_List[out].delayed) { /* at least one user node is '&delayed' */
1114 Delayed_Flag = true;
1115 }
1116 (void) strcat(tok2, tok1);
1117 ml = Node_List[out].mline;
1118 mf = Node_List[out].mfile;
1119 strcpy_alloc(&(UserTool_List[Num_UserTools].name), Node_List[out].name1, ml, mf);
1120 strcpy_alloc(&(UserTool_List[Num_UserTools].function), tok2, ml, mf);
1121 (void) snprintf(tok5, (size_t) (STRLENGTH-1L), "%s %s", UserTool_List[Num_UserTools].function, tok3);
1122 strcpy_alloc(&(UserTool_List[Num_UserTools].parms), tok5, ml, mf);
1123 strcpy_alloc(&(UserTool_List[Num_UserTools].option), Node_List[out].option, ml, mf);
1124 Node_List[out].ID2 = usertool_num(tok2); /* ID of function call:0,1,.. */
1125 UserTool_List[Num_UserTools].ID = usertool_num(tok2); /* ID of function call:0,1,.. */
1126 UserTool_List[Num_UserTools].number = num; /* number of parms */
1127 UserTool_List[Num_UserTools].kind = kd; /* kind of tool */
1128 UserTool_List[Num_UserTools].node = out; /* node corresponding to this user/tool function */
1129 for (d = 0L; d < MAXDEPTH; d++) {
1130 UserTool_List[Num_UserTools].mline[d] = Node_List[out].mline[d];
1131 UserTool_List[Num_UserTools].mfile[d] = Node_List[out].mfile[d];
1132 }
1133 UserTool_List[Num_UserTools].segment= Node_List[out].segment;
1134 (void) record_function_identifier(tok2, 1, ml, mf);
1135 increment_usertool_number("name mangling");
1136 break;
1137 default:
1138 break;
1139 }
1140 }
1141 return;
1142}
void increment_tool_number(const char *kind)
Definition id.c:505
long usertool_num(const char *nam)
Definition id.c:1224
void increment_usertool_number(const char *kind)
Definition id.c:531
EXTERN long Num_UserTools
Definition napa.h:835
EXTERN USERTOOL_TYPE UserTool_List[511L]
Definition napa.h:969
EXTERN int Delayed_Flag
Definition napa.h:849
EXTERN int Tool_Flag
Definition napa.h:883
#define IUSER_KIND
Definition napa.h:280
#define DUSER_KIND
Definition napa.h:261
EXTERN long Num_Tools
Definition napa.h:833
#define ITOOL_KIND
Definition napa.h:279
#define DTOOL_KIND
Definition napa.h:260
EXTERN int User_Flag
Definition napa.h:887

References Delayed_Flag, DTOOL_KIND, DUSER_KIND, get_sign_and_token(), increment_tool_number(), increment_usertool_number(), ISEMPTY, ITOOL_KIND, IUSER_KIND, MAXDEPTH, Node_List, Num_Nodes, Num_Tools, Num_UserTools, record_function_identifier(), strcpy_alloc(), STRLENGTH, Tool_Flag, UNDEFINED, User_Flag, UserTool_List, and usertool_num().

Referenced by main().

◆ process_init()

void process_init ( void )

Definition at line 1735 of file rd.c.

1735 { /* value of the initialization of a delay is transferred to the input of the delay */
1736 long i, k, n;
1737 char *str = (char*) NULL;
1738 char sgn[2] = {'\0'};
1739 char tok1[STRLENGTH] = {'\0'};
1740 char tok2[STRLENGTH] = {'\0'};
1741 char tok3[STRLENGTH] = {'\0'};
1742 char tok4[STRLENGTH] = {'\0'};
1743 for (i = 0L; i < Num_Vars; i++) {
1744 if ((char*) NULL != strstr(Var_List[i].name1, "$init$")) {
1745 str = Var_List[i].value;
1746 str = get_sign_and_token(str, sgn, tok1);
1747 (void) strcpy(tok2, str);
1748 n = node_id(tok1);
1749 if (UNDEFINED != n) {
1750 k = Node_List[n].kind;
1751 if ((DELAY_KIND == k) || (DELAY1_KIND == k) || (DELAY2_KIND == k) || (DELAY3_KIND == k)) {
1752 str = Node_List[n].value;
1753 str = get_sign_and_token(str, sgn, tok3);
1754 str = get_sign_and_token(str, sgn, tok3); /* a node, input of the delay */
1755 (void) snprintf(tok4, (size_t) (STRLENGTH-1L), "%s %s", tok3, tok2);
1756 strcpy_realloc(&(Var_List[i].value), tok4, Var_List[i].mline, Var_List[i].mfile);
1757 }
1758 }
1759 }
1760 }
1761 return;
1762}
void strcpy_realloc(char **dest, const char *sour, const unsigned long *mlin, const unsigned long *mfil)
Definition id.c:129
#define DELAY2_KIND
Definition napa.h:255
#define DELAY3_KIND
Definition napa.h:256
#define DELAY1_KIND
Definition napa.h:254
#define DELAY_KIND
Definition napa.h:253

References DELAY1_KIND, DELAY2_KIND, DELAY3_KIND, DELAY_KIND, get_sign_and_token(), node_id(), Node_List, Num_Vars, strcpy_realloc(), STRLENGTH, UNDEFINED, and Var_List.

Referenced by main().

◆ purge_constants_in_ganging()

void purge_constants_in_ganging ( void )

Definition at line 1320 of file rd.c.

1320 {
1321 long i, type;
1322 int first;
1323 char *s1 = (char*) NULL;
1324 char *t2 = (char*) NULL;
1325 char *t3 = (char*) NULL;
1326 char *t4 = (char*) NULL;
1327 char *t5 = (char*) NULL;
1328 char str1[LINLENGTH] = {'\0'};
1329 char tok2[STRLENGTH] = {'\0'};
1330 char tok3[STRLENGTH] = {'\0'};
1331 char tok4[STRLENGTH] = {'\0'};
1332 char tok5[STRLENGTH] = {'\0'};
1333 char sgn2[2] = {'\0'};
1334 char buf1[LINLENGTH] = {'\0'};
1335 for (i = 0L; i < Num_Records; i++) { /* scan the record list (ganging) */
1336 (void) strcpy(str1, Record_List[i].list1);
1337 s1 = str1; /* list source */
1338 (void) strcpy(tok2, "");
1339 t2 = tok2; /* token source */
1340 (void) strcpy(tok3, "");
1341 t3 = tok3; /* token destination */
1342 (void) strcpy(tok4, "");
1343 t4 = tok4; /* token destination with sign */
1344 (void) strcpy(tok5, "");
1345 t5 = tok5; /* token */
1346 (void) strcpy(buf1, "");
1347 first = true;
1348 for (;;) {
1349 s1 = get_sign_and_token(s1, sgn2, tok2);
1350 if (ISEMPTY(tok2)) {
1351 break;
1352 }
1353 type = constant_type(tok2); /* if not a constant, type is 0 */
1354 if (ANALOG_DATA_TYPE == type) {
1355 (void) snprintf(t5, (size_t) (STRLENGTH-1L), "%s%s", sgn2, tok2);
1356 t3 = create_constant_var(t5, ANALOG_DATA_TYPE, Record_List[i].mline, Record_List[i].mfile);
1357 (void) strcpy(t4, t3);
1358 } else if ((DIGITAL_DATA_TYPE == type) || (HEX_DATA_TYPE == type)) {
1359 (void) snprintf(t5, (size_t) (STRLENGTH-1L), "%s%s", sgn2, tok2);
1360 t3 = create_constant_var(t5, DIGITAL_DATA_TYPE, Record_List[i].mline, Record_List[i].mfile);
1361 (void) strcpy(t4, t3);
1362 } else if (STRING_DATA_TYPE == type) {
1363 t3 = create_constant_var(tok2, STRING_DATA_TYPE, Record_List[i].mline, Record_List[i].mfile);
1364 (void) strcpy(t4, t3);
1365 } else {
1366 (void) strcpy(t4, t2);
1367 }
1368 if ((0 == strcmp(tok2, "stdin" )) || (0 == strcmp(tok2, "stderr")) || (0 == strcmp(tok2, "stdout"))) {
1369 (void) snprintf(t5, (size_t) (STRLENGTH-1L), "\"%s\"", tok2);
1370 t3 = create_constant_var(t5, STRING_DATA_TYPE, Record_List[i].mline, Record_List[i].mfile);
1371 (void) strcpy(t4, t3);
1372 }
1373 if (!first) {
1374 (void) strcat(buf1, " ");
1375 } else {
1376 (void) strcpy(buf1, "");
1377 }
1378 first = false;
1379 (void) strcat(buf1, t4); /* build the new list of parameters */
1380 }
1381 strcpy_realloc(&(Record_List[i].list1), buf1, Record_List[i].mline, Record_List[i].mfile); /* reload updated parms */
1382 }
1383 return;
1384}
long constant_type(char *identifier)
Definition id.c:1130
#define LINLENGTH
Definition napa.h:216
#define HEX_DATA_TYPE
Definition napa.h:340
char * create_constant_var(char *str, int type, const unsigned long *mlin, const unsigned long *mfil)
Definition rd.c:848

References ANALOG_DATA_TYPE, constant_type(), create_constant_var(), DIGITAL_DATA_TYPE, get_sign_and_token(), HEX_DATA_TYPE, ISEMPTY, LINLENGTH, Num_Records, Record_List, strcpy_realloc(), STRING_DATA_TYPE, and STRLENGTH.

Referenced by main().

◆ purge_constants_in_options()

void purge_constants_in_options ( void )

Definition at line 1389 of file rd.c.

1389 {
1390 long u, p, type;
1391 char *t1 = (char*) NULL;
1392 char *t2 = (char*) NULL;
1393 char *t3 = (char*) NULL;
1394 char sgn[2] = {'\0'};
1395 char tok1[STRLENGTH] = {'\0'};
1396 char tok2[STRLENGTH] = {'\0'};
1397 char tok3[STRLENGTH] = {'\0'};
1398 for (u = 0L; u < Num_UserTools; u++) {
1399 (void) strcpy(tok3, "");
1400 t1 = UserTool_List[u].option;
1401 while (0L <= LENGTH(t1)) { /* analysis, option after option xxx::yyy */
1402 t1 = get_sign_and_token(t1, sgn, tok1);
1403 if ((char*) NULL == strstr(tok1, "::")) {
1404 (void) strcat(tok3, tok1); /* option without value */
1405 (void) strcat(tok3, " ");
1406 if (0 == LENGTH(t1)) {
1407 break;
1408 }
1409 } else {
1410 t2 = strstr(tok1, "::");
1411 *t2 = '\0'; /* introduce a separation between option and value */
1412 (void) strcat(tok3, tok1); /* the option */
1413 (void) strcpy(tok2,t2 + 2); /* the value */
1414 type = constant_type(tok2); /* if not a constant, type is 0 */
1415 if ((0 != type) && (ANALOG_DATA_TYPE != type) && (DIGITAL_DATA_TYPE != type) && (HEX_DATA_TYPE != type)) {
1416 print_error_location("option", UserTool_List[u].mline, UserTool_List[u].mfile);
1417 (void) fprintf(STDERR, " <%s> value of an option must be a number, analog or digital\n", tok2);
1418 }
1419 (void) strcat(tok3, "::");
1420 if (0 == type) {
1421 (void) strcat(tok3, tok2); /* unprocessed value */
1422 (void) strcat(tok3, " ");
1423 } else { /* analog or digital created as analog constants ! */
1424 t3 = create_constant_var(tok2, ANALOG_DATA_TYPE, UserTool_List[u].mline, UserTool_List[u].mfile); /* value is analog */
1425 (void) strcat(tok3, t3); /* processed value */
1426 (void) strcat(tok3, " ");
1427 }
1428 if (0 == LENGTH(t1)) {
1429 break;
1430 }
1431 }
1432 }
1433 strcpy_realloc(&(UserTool_List[u].option), tok3, UserTool_List[u].mline, UserTool_List[u].mfile); /* load modified option */
1434 }
1435 (void) strcpy(tok1, "");
1436 (void) strcpy(tok2, "");
1437 for (p = 0L; p < Num_Posts; p++) {
1438 (void) strcpy(tok3, "");
1439 t1 = Post_List[p].option;
1440 while (0L <= LENGTH(t1)) { /* analysis, option after option xxx::yyy */
1441 t1 = get_sign_and_token(t1, sgn, tok1);
1442 if ((char*) NULL == strstr(tok1, "::")) {
1443 (void) strcat(tok3, tok1); /* option without value */
1444 (void) strcat(tok3, " ");
1445 if (0 == LENGTH(t1)) {
1446 break;
1447 }
1448 } else {
1449 t2 = strstr(tok1, "::");
1450 *t2 = '\0'; /* introduce a separation between option and value */
1451 (void) strcat(tok3, tok1); /* the option */
1452 (void) strcpy(tok2,t2 + 2); /* the value */
1453 type = constant_type(tok2); /* if not a constant, type is 0 */
1454 if ((0 != type) && (ANALOG_DATA_TYPE != type) && (DIGITAL_DATA_TYPE != type) && (HEX_DATA_TYPE != type)) {
1455 print_error_location("option", Post_List[p].mline, Post_List[p].mfile);
1456 (void) fprintf(STDERR, " value <%s> of an option must be a number, analog or digital\n", tok2);
1457 }
1458 (void) strcat(tok3, "::");
1459 if (0 == type) {
1460 (void) strcat(tok3, tok2); /* unprocessed value */
1461 (void) strcat(tok3, " ");
1462 } else { /* analog or digital created as analog constants ! */
1463 t3 = create_constant_var(tok2, ANALOG_DATA_TYPE, Post_List[p].mline, Post_List[p].mfile); /* value is analog */
1464 (void) strcat(tok3, t3); /* processed value */
1465 (void) strcat(tok3, " ");
1466 }
1467 if (0 == LENGTH(t1)) {
1468 break;
1469 }
1470 }
1471 }
1472 strcpy_realloc(&(Post_List[p].option), tok3, Post_List[p].mline, Post_List[p].mfile); /* load modified option */
1473 }
1474 return;
1475}

References ANALOG_DATA_TYPE, constant_type(), create_constant_var(), DIGITAL_DATA_TYPE, get_sign_and_token(), HEX_DATA_TYPE, LENGTH, Num_Posts, Num_UserTools, Post_List, print_error_location(), STDERR, strcpy_realloc(), STRLENGTH, and UserTool_List.

Referenced by main().

◆ record_function_identifier()

long record_function_identifier ( const char * tok,
long m,
const unsigned long * mlin,
const unsigned long * mfil )

Definition at line 1656 of file rd.c.

1656 {
1657 long i;
1658 for (i = 0L; i < Num_Functions; i++) {
1659 if (0 == strcmp(tok, Function_List[i].table)) { /* function already recorded */
1660 Function_List[i].number += m;
1661 return Function_List[i].number;
1662 }
1663 }
1664 if (is_a_known_function(tok)) {
1665 return 0; /* function already available */
1666 }
1667 if (UNDEFINED != var_id(tok)) {
1668 print_error_location("function", mlin, mfil);
1669 (void) fprintf(STDERR, " collision between a variable and the function <%s()>\n", tok);
1670 return 0;
1671 }
1672 if (UNDEFINED != node_id(tok)) {
1673 print_error_location("function", mlin, mfil);
1674 (void) fprintf(STDERR, " collision between a node and the function <%s()>\n", tok);
1675 return 0;
1676 }
1677 if (UNDEFINED != array_id(tok)) {
1678 print_error_location("function", mlin, mfil);
1679 (void) fprintf(STDERR, " collision between an array and the function <%s()>\n", tok);
1680 return 0;
1681 }
1682 strcpy_alloc(&(Function_List[Num_Functions].table), tok, mlin, mfil);
1683 Function_List[Num_Functions].number = m;
1684 increment_function_number("function");
1685 return m;
1686}
void increment_function_number(const char *kind)
Definition id.c:306
int is_a_known_function(const char *identifier)
Definition id.c:1346
long array_id(const char *identifier)
Definition id.c:635
EXTERN long Num_Functions
Definition napa.h:815
EXTERN FUNCTION_TYPE Function_List[255L]
Definition napa.h:957

References array_id(), Function_List, increment_function_number(), is_a_known_function(), node_id(), Num_Functions, print_error_location(), STDERR, strcpy_alloc(), UNDEFINED, and var_id().

Referenced by collect_functions(), get_node(), and name_mangling().

◆ redefine_node_segments()

void redefine_node_segments ( void )

Definition at line 58 of file rd.c.

58 {
59 long out;
60 long kd, kd2, id2;
61 char *s = (char*) NULL;
62 char *t = (char*) NULL;
63 char *u = (char*) NULL;
64 char tok1[STRLENGTH] = {'\0'};
65 char tok2[STRLENGTH] = {'\0'};
66 char tok3[STRLENGTH] = {'\0'};
67 char *tg = (char*) NULL;
68 unsigned long *ml = (unsigned long*) NULL;
69 unsigned long *mf = (unsigned long*) NULL;
70
71 for (out = 0L; out < Num_Nodes; out++) {
72 kd = Node_List[out].kind;
73 tg = Node_List[out].tag;
74 ml = Node_List[out].mline;
75 mf = Node_List[out].mfile;
76
77 /* redefine and/or syntax nodes with qualifier 'when', 'with', 'after' or 'before' */
78 s = Node_List[out].value;
79
80 do {
81 t = s; /* point to first letter of the token */
82 s = get_token(s, tok1, true);
83 if (0 == strcmp(tok1, "when")) {
84 print_error_location("node", Node_List[out].mline, Node_List[out].mfile);
85 (void) fprintf(STDERR, " a node cannot be controlled by a 'when' condition\n");
86 break;
87 }
88 if (0 == strcmp(tok1, "after")) {
89 if ((DUSER_KIND != kd) && (IUSER_KIND != kd) && (DTOOL_KIND != kd) && (ITOOL_KIND!= kd)
90 && (DALGEBRA_KIND!= kd) && (IALGEBRA_KIND!= kd) && (ALGEBRA_KIND!= kd) && (TEST_KIND != kd)) {
91 print_error_location(tg, Node_List[out].mline, Node_List[out].mfile);
92 (void) fprintf(STDERR, " the keyword <%s> cannot be used with this kind of node\n", tok1);
93 break;
94 }
95 s = get_token(s, tok2, true); /* get token after keyword 'after' */
96 id2 = node_id(tok2);
97 if (UNDEFINED == id2) {
98 print_error_location(tg, Node_List[out].mline, Node_List[out].mfile);
99 (void) fprintf(STDERR, " the keyword <%s> should be followed by a node,\n", tok1);
100 (void) fprintf(STDERR, " <%s> must be a node defined in this netlist\n", tok2);
101 process_node_error(tok2);
102 break;
103 }
104 }
105 if (0 == strcmp(tok1, "before")) {
106 if ((DUSER_KIND != kd) && (IUSER_KIND != kd) && (DTOOL_KIND != kd) && (ITOOL_KIND!= kd)
107 && (DALGEBRA_KIND!= kd) && (IALGEBRA_KIND!= kd) && (ALGEBRA_KIND!= kd) && (TEST_KIND != kd)) {
108 print_error_location(tg, Node_List[out].mline, Node_List[out].mfile);
109 (void) fprintf(STDERR, " the keyword <%s> cannot be used with this kind of node\n", tok1);
110 break;
111 }
112 s = get_token(s, tok2, true); /* get token after keyword 'before' */
113 id2 = node_id(tok2);
114 if (UNDEFINED == id2) {
115 print_error_location(tg, Node_List[out].mline, Node_List[out].mfile);
116 (void) fprintf(STDERR, " the keyword <%s> should be followed by a node,\n", tok1);
117 (void) fprintf(STDERR, " <%s> must be a node defined in this netlist\n", tok2);
118 process_node_error(tok2);
119 break;
120 }
121 kd2 = Node_List[id2].kind;
122 if ((DUSER_KIND != kd2) && (IUSER_KIND != kd2) && (DTOOL_KIND != kd2) && (ITOOL_KIND!= kd2)
123 && (DALGEBRA_KIND != kd2) && (IALGEBRA_KIND != kd2) && (ALGEBRA_KIND != kd2) && (TEST_KIND != kd2)) {
124 print_error_location(tg, Node_List[out].mline, Node_List[out].mfile);
125 (void) fprintf(STDERR, " the keyword <%s> cannot reference this kind of node\n", tok1);
126 break;
127 }
128 (void) strcpy(tok3, Node_List[id2].value); /* ADD <after> <node_name> to node value */
129 (void) strcat(tok3, " after ");
130 (void) strcat(tok3, Node_List[out].name1);
131 strcpy_realloc(&(Node_List[id2].value), tok3, ml, mf);
132 }
133 if (0 == strcmp(tok1, "with")) {
134 s = get_token(s, tok2, true); /* get token after keyword 'with' */
135 id2 = node_id(tok2);
136 if (UNDEFINED == id2) {
137 print_error_location(tg, Node_List[out].mline, Node_List[out].mfile);
138 (void) fprintf(STDERR, " the keyword <%s> should be followed by a node,\n", tok1);
139 (void) fprintf(STDERR, " <%s> must be a node defined in this netlist\n", tok2);
140 process_node_error(tok2);
141 break;
142 }
143 Node_List[out].segment = Node_List[id2].segment; /* redefine segment belonging */
144 }
145 if ((0 == strcmp("before", tok1)) || (0 == strcmp("with", tok1))) {
146 u = t; /* u, s point to begin and end of area to erase */
147 while (u < s) { /* erase <with> or <before> and the node after */
148 *u = ' ';
149 u++;
150 }
151 }
152 } while (ISNOTEMPTY(tok1));
153 }
154 return;
155}
char * get_token(char *str, char *tok, long keep_quotes)
Definition tk.c:1210

References ALGEBRA_KIND, DALGEBRA_KIND, DTOOL_KIND, DUSER_KIND, get_token(), IALGEBRA_KIND, ISNOTEMPTY, ITOOL_KIND, IUSER_KIND, node_id(), Node_List, Num_Nodes, print_error_location(), process_node_error(), STDERR, strcpy_realloc(), STRLENGTH, TEST_KIND, and UNDEFINED.

Referenced by main().

◆ redefine_nodes()

void redefine_nodes ( void )

Definition at line 350 of file rd.c.

350 {
351 long out;
352 long kd;
353 long i;
354 long v;
355 double dtemp;
356 char *s = (char*) NULL;
357 char *t = (char*) NULL;
358 char tok1[STRLENGTH] = {'\0'};
359 char tok2[STRLENGTH] = {'\0'};
360 char tok3[STRLENGTH] = {'\0'};
361 char tok4[STRLENGTH] = {'\0'};
362 char sgn[2] = {'\0'};
363 char brck[3] = {'\0'};
364 char *tg = (char*) NULL;
365 unsigned long *ml = (unsigned long*) NULL;
366 unsigned long *mf = (unsigned long*) NULL;
367 int flag;
368
369 for (out = 0L; out < Num_Nodes; out++) {
370 kd = Node_List[out].kind;
371 tg = Node_List[out].tag;
372 ml = Node_List[out].mline;
373 mf = Node_List[out].mfile;
374
375 /* process short form of nodes identifier using symbol ', replace this symbol by $ */
376 do {
377 s = strchr(Node_List[out].name1, '\'');
378 if ((char*) NULL != s) {
379 *s = '$';
380 }
381 } while ((char*) NULL != s);
382
383 /* node redefinition if any */
384 s = Node_List[out].value;
385
386 switch (kd) {
387
388 /* DELAY : chameleonic type depending on single input */
389 /* This node is degenerated in single, double or triple delay if number of delays <= 3 */
390
391 case DELAY_KIND :
392 s = get_sign_and_token(s, sgn, tok1);
393 s = get_sign_and_token(s, sgn, tok2);
394 if (ISEMPTY(tok2)) {
395 s = Node_List[out].value; /* single delay recoded using a multiple delay of 1 */
396 (void) snprintf(tok3, (size_t) (STRLENGTH-1L), "1 %s", s); /* trick to handle all delays */
397 Node_List[out].kind = DELAY1_KIND;
398 strcpy_realloc(&(Node_List[out].value), tok3, ml, mf);
399 s = tok3;
400 Num_Redefs--; /* to blank the redefinition below */
401 break;
402 }
403 if (0 == strcmp(tok1, "0")) { /* NOT a delay but a simple copy */
404 Node_List[out].kind = COPY_KIND;
405 s = Node_List[out].value; /* single delay recoded using a multiple delay of 1 */
406 strcpy_realloc(&(Node_List[out].value), tok2, ml, mf);
407 Num_Redefs++;
408 } else if (0 == strcmp(tok1, "1")) { /* more efficient translation is chosen */
409 Node_List[out].kind = DELAY1_KIND;
410 Num_Redefs++;
411 } else if (0 == strcmp(tok1, "2")) { /* more efficient translation is chosen */
412 Node_List[out].kind = DELAY2_KIND;
413 Num_Redefs++;
414 } else if (0 == strcmp(tok1, "3")) { /* more efficient translation is chosen */
415 Node_List[out].kind = DELAY3_KIND;
416 Num_Redefs++;
417 } else { /* true multiple delays (larger than 3) */
418 Node_List[out].kind = DELAY_KIND;
419 Multdelay_Flag = true;
420 }
421 break;
422
423 /* To ease the writing of generators, these nodes are degenerated in a copy if it has only one input */
424
425 case SUM_KIND :
426 case PROD_KIND :
427 case MIN_KIND :
428 case MAX_KIND :
429 i = 0L;
430 for (;;) {
431 s = get_sign_and_token(s, sgn, tok1);
432 if (ISEMPTY(tok1)) {
433 break;
434 }
435 i++;
436 }
437 if (1L == i) { /* replaced by standard copy */
438 Node_List[out].kind = COPY_KIND;
439 Num_Redefs++;
440 }
441 break;
442
443 /* AVERAGE:analog type depending on N inputs */
444 /* To ease the writing of generators, these nodes are degenerated in a copy if it has only one input */
445
446 case AVERAGE_KIND :
447 i = 0L;
448 for (;;) {
449 s = get_sign_and_token(s, sgn, tok1);
450 if (ISEMPTY(tok1)) {
451 break;
452 }
453 i++;
454 }
455 if (1L == i) {
456 if (((char*) NULL != strstr(Node_List[out].option, "arithmetic"))
457 || ((char*) NULL != strstr(Node_List[out].option, "rms"))) {
458 Node_List[out].kind = COPY_KIND;
459 } else {
460 s = Node_List[out].value;
461 s = get_sign_and_token(s, sgn, tok1);
462 Node_List[out].kind = DALGEBRA_KIND;
463 if ((char*) NULL != strstr(Node_List[out].option, "geometric")) {
464 (void) snprintf(tok2, (size_t) (STRLENGTH-1L), "MAX(0.0, %s)", tok1);
465 } else {
466 (void) snprintf(tok2, (size_t) (STRLENGTH-1L), "MAX(EPSILON, %s)", tok1); /* for multiple in */
467 }
468 strcpy_realloc(&(Node_List[out].value), tok2, ml, mf);
469 }
470 strcpy_realloc(&(Node_List[out].option), "", ml, mf);
471 Num_Redefs++;
472 }
473 break;
474
475 /* WSUM: chameleonic type depending on N pairs of inputs */
476 /* To ease the writing of generators, these nodes are degenerated in a gain if it has only one pair of inputs */
477
478 case WSUM_KIND :
479 i = 0L;
480 for (;;) {
481 s = get_sign_and_token(s, sgn, tok1);
482 if (ISEMPTY(tok1)) {
483 break;
484 }
485 s = get_sign_and_token(s, sgn, tok1);
486 if (ISEMPTY(tok1)) {
487 break;
488 }
489 i++;
490 }
491 if (1L == i) { /* replaced by standard gain */
492 Node_List[out].kind = GAIN_KIND;
493 Num_Redefs++;
494 }
495 break;
496
497 /* AND, OR, XOR, BWAND, BWOR, BWXOR: digital type */
498
499 case AND_KIND :
500 case OR_KIND :
501 case XOR_KIND :
502 case BWAND_KIND :
503 case BWOR_KIND :
504 case BWXOR_KIND :
505 i = 0L;
506 for (;;) {
507 s = get_sign_and_token(s, sgn, tok1);
508 if (ISEMPTY(tok1)) {
509 break;
510 }
511 i++;
512 }
513 if (1L == i) { /* replaced by non inverting buffer */
514 if ((AND_KIND == kd) || (OR_KIND == kd) || (XOR_KIND == kd)) {
515 Node_List[out].width = 0L; /* bit width is irrelevant */
516 Node_List[out].kind = BUF_KIND;
517 } else {
518 Node_List[out].kind = COPY_KIND;
519 }
520 Num_Redefs++;
521 }
522 break;
523
524 /* NAND, NOR, XNOR, BWNAND, BWNOR, BWXNOR: digital type */
525
526 case NAND_KIND :
527 case NOR_KIND :
528 case XNOR_KIND :
529 case BWNAND_KIND :
530 case BWNOR_KIND :
531 case BWXNOR_KIND :
532 i = 0L;
533 for (;;) {
534 s = get_sign_and_token(s, sgn, tok1);
535 if (ISEMPTY(tok1)) {
536 break;
537 }
538 i++;
539 }
540 if (1L == i) { /* replaced by inverter */
541 if ((NAND_KIND == kd) || (NOR_KIND == kd) || (XNOR_KIND == kd)) {
542 Node_List[out].width = 0L; /* bit width is irrelevant */
543 Node_List[out].kind = INV_KIND;
544 } else {
545 Node_List[out].kind = BWINV_KIND;
546 }
547 Num_Redefs++;
548 }
549 break;
550
551 /* CLOCK: digital type */
552 /* compact definition by removing blanks */
553
554 case CLOCK_KIND :
555 t = s;
556 t = get_token(t, tok1, true);
557 t = get_token(t, tok2, false);
558 v = var_id(tok1);
559 if (UNDEFINED != v) { /* expand string variable */
560 (void) strcpy(tok3, Var_List[v].value);
561 (void) strcat(tok3, " ");
562 if(ISNOTEMPTY(tok2)) {
563 (void) strcat(tok3, tok2);
564 }
565 strcpy_realloc(&(Node_List[out].value), tok3, ml, mf);
566 }
567 Node_List[out].width = 0L; /* bit width is irrelevant */
568 s = Node_List[out].value;
569 s = get_token_between_braces(s, brck, tok1);
570 if ((0 != strcmp(brck, "\"\"")) || ISEMPTY(tok1)) {
571 print_error_location(tg, ml, mf);
572 (void) fprintf(STDERR, " pattern descriptor <%s> must be a string of 0's and 1's\n", s);
573 flag_node(out);
574 }
575 (void) strcpy(tok3, s);
576 if (ISEMPTY(tok3)) { /* widening default is 1 */
577 (void) strcpy(tok3, "1");
578 }
579 s = tok1;
580 t = tok2;
581 while ('\0' != *s) { /* remove spaces */
582 if (!isspace((int) *s)) {
583 *t = *s;
584 t++;
585 }
586 if (('0' != *s) && ('1' != *s) && ('.' != *s) && (!isspace((int) *s))) {
587 print_error_location(tg, ml, mf);
588 (void) fprintf(STDERR, " the pattern descriptor <%s> must contain only 0's, 1's, period or spaces\n", tok1);
589 flag_node(out);
590 break;
591 }
592 s++;
593 }
594 *t = '\0';
595 (void) strcat(tok2, " ");
596 (void) strcat(tok2, tok3);
597 strcpy_realloc(&(Node_List[out].value), tok2, ml, mf); /* store back clean pattern */
598 break;
599
600 /* ITOB, BUF, INV, TOGGLE, COMP, EQUAL, LATCH, TRIG, CHG, MULLER: digital type */
601
602 case ITOB_KIND :
603 case BUF_KIND :
604 case INV_KIND :
605 case TOGGLE_KIND :
606 case COMP_KIND :
607 case EQUAL_KIND :
608 case LATCH_KIND :
609 case TRIG_KIND :
610 case CHG_KIND :
611 case SIGN_KIND :
612 case MULLER_KIND :
613 Node_List[out].width = 0L; /* bit width is irrelevant */
614 break;
615
616 /* FZAND, FZOR, FZXOR : analog type */
617
618 case FZAND_KIND :
619 case FZOR_KIND :
620 case FZXOR_KIND :
621 i = 0L;
622 for (;;) {
623 s = get_sign_and_token(s, sgn, tok1);
624 if (ISEMPTY(tok1)) {
625 break;
626 }
627 i++;
628 }
629 if (1L == i) { /* replaced by non inverting buffer */
630 Node_List[out].kind = FZBUF_KIND;
631 Num_Redefs++;
632 }
633 break;
634
635 /* FZNAND, FZNOR, FZXNOR: analog type */
636
637 case FZNAND_KIND :
638 case FZNOR_KIND :
639 case FZXNOR_KIND :
640 i = 0L;
641 for (;;) {
642 s = get_sign_and_token(s, sgn, tok1);
643 if (ISEMPTY(tok1)) {
644 break;
645 }
646 i++;
647 }
648 if (1L == i) { /* replaced by inverter */
649 Node_List[out].kind = FZINV_KIND;
650 Num_Redefs++;
651 }
652 break;
653
654 /* OSC: analog type */
655
656 case OSC_KIND :
657 if (!Segment_List[Node_List[out].segment].periodic) {
658 print_warning_location(Node_List[out].name1, Node_List[out].mline, Node_List[out].mfile);
659 (void) fprintf(STDERR, " 'osc' node replaced by 'sine' node as periodic sampling is not guaranteed\n");
660 Node_List[out].kind = SIN_KIND;
661 Num_Redefs++;
662 }
663 break;
664
665 /* NOISE: analog type */
666
667 /* This noise is degenerated in a DALGEBRA if the rms value is zero. */
668 /* DALGEBRA and not DC as specific initial value not compatible wih the NOISE behavior. */
669
670 case NOISE_KIND :
671 s = get_sign_and_token(s, sgn, tok1); /* DC offset */
672 (void) snprintf(tok2, (size_t) (STRLENGTH-1L), "%s%s", sgn, tok1);
673 s = get_sign_and_token(s, sgn, tok3); /* RMS value */
674 (void) snprintf(tok4, (size_t) (STRLENGTH-1L), "%s%s", sgn, tok3);
675 flag = sscanf(tok4, "%lf", &dtemp);
676 if ((1 == flag) && ISSMALL(dtemp)) { /* second value [sigma] is zero */
677 Node_List[out].kind = DALGEBRA_KIND;
678 strcpy_realloc(&(Node_List[out].value), tok2, ml, mf);
679 strcpy_realloc(&(Node_List[out].option), "", ml, mf);
680 Num_Redefs++;
681 }
682 break;
683
684 /* DALGEBRA, IALGEBRA, ALGEBRA, TEST: analog type, digital type or type to be determined later */
685
686 case DALGEBRA_KIND :
687 case IALGEBRA_KIND :
688 case ALGEBRA_KIND :
689 case TEST_KIND :
690 clean_parentheses(Node_List[out].value); /* no realloc as result is shorter */
691 break;
692
693 /* DC with noise injection: analog type */
694 /* it is not possible here to redefine a DC node as type is not yet determined */
695 /* it is redefined if necessary during node determination as 'dalgebra' */
696
697 /* CONST : */
698 /* it is not possible here to redefine a CONST node as type is not yet determined */
699 /* it is redefined if necessary during node determination as 'dc' */
700
701 /* GAIN: chameleonic type */
702 /* it is not possible here to zero a null gain as the node type is not yet determined */
703
704 /* OFFSET: chameleonic type */
705 /* it is not possible here to degenerate in a COPY a null offset as the node type is not yet determined */
706
707 default:
708 break;
709 }
710 }
711 return;
712}
void print_warning_location(const char *type, const unsigned long *mlin, const unsigned long *mfil)
Definition fc.c:1484
void flag_node(long num)
Definition id.c:99
#define ISSMALL(x)
Definition napa.h:386
#define EQUAL_KIND
Definition napa.h:262
#define MULLER_KIND
Definition napa.h:287
#define WSUM_KIND
Definition napa.h:323
#define AND_KIND
Definition napa.h:229
#define LATCH_KIND
Definition napa.h:281
#define INV_KIND
Definition napa.h:276
#define BWNAND_KIND
Definition napa.h:236
#define FZNOR_KIND
Definition napa.h:267
#define OSC_KIND
Definition napa.h:294
#define CLOCK_KIND
Definition napa.h:244
#define NOR_KIND
Definition napa.h:291
#define COPY_KIND
Definition napa.h:247
#define OR_KIND
Definition napa.h:293
EXTERN long Num_Redefs
Definition napa.h:829
#define MIN_KIND
Definition napa.h:285
#define NAND_KIND
Definition napa.h:289
#define AVERAGE_KIND
Definition napa.h:230
#define PROD_KIND
Definition napa.h:296
#define GAIN_KIND
Definition napa.h:271
#define BUF_KIND
Definition napa.h:233
#define XOR_KIND
Definition napa.h:325
#define SIN_KIND
Definition napa.h:310
#define TOGGLE_KIND
Definition napa.h:317
#define XNOR_KIND
Definition napa.h:324
#define BWXNOR_KIND
Definition napa.h:239
#define FZBUF_KIND
Definition napa.h:264
#define SIGN_KIND
Definition napa.h:309
#define FZXNOR_KIND
Definition napa.h:269
#define SUM_KIND
Definition napa.h:315
#define BWXOR_KIND
Definition napa.h:240
#define FZNAND_KIND
Definition napa.h:266
#define FZOR_KIND
Definition napa.h:268
#define BWOR_KIND
Definition napa.h:238
#define FZXOR_KIND
Definition napa.h:270
#define MAX_KIND
Definition napa.h:283
#define BWNOR_KIND
Definition napa.h:237
#define COMP_KIND
Definition napa.h:245
EXTERN int Multdelay_Flag
Definition napa.h:867
#define FZINV_KIND
Definition napa.h:265
#define BWINV_KIND
Definition napa.h:235
#define FZAND_KIND
Definition napa.h:263
#define CHG_KIND
Definition napa.h:242
#define BWAND_KIND
Definition napa.h:234
#define TRIG_KIND
Definition napa.h:320
#define NOISE_KIND
Definition napa.h:290
void clean_parentheses(char *tok)
Definition tk.c:403
char * get_token_between_braces(char *str, char *brc, char *tok)
Definition tk.c:1110

References ALGEBRA_KIND, AND_KIND, AVERAGE_KIND, BUF_KIND, BWAND_KIND, BWINV_KIND, BWNAND_KIND, BWNOR_KIND, BWOR_KIND, BWXNOR_KIND, BWXOR_KIND, CHG_KIND, clean_parentheses(), CLOCK_KIND, COMP_KIND, COPY_KIND, DALGEBRA_KIND, DELAY1_KIND, DELAY2_KIND, DELAY3_KIND, DELAY_KIND, EQUAL_KIND, flag_node(), FZAND_KIND, FZBUF_KIND, FZINV_KIND, FZNAND_KIND, FZNOR_KIND, FZOR_KIND, FZXNOR_KIND, FZXOR_KIND, GAIN_KIND, get_sign_and_token(), get_token(), get_token_between_braces(), IALGEBRA_KIND, INV_KIND, ISEMPTY, ISNOTEMPTY, ISSMALL, ITOB_KIND, LATCH_KIND, MAX_KIND, MIN_KIND, MULLER_KIND, Multdelay_Flag, NAND_KIND, Node_List, NOISE_KIND, NOR_KIND, Num_Nodes, Num_Redefs, OR_KIND, OSC_KIND, print_error_location(), print_warning_location(), PROD_KIND, Segment_List, SIGN_KIND, SIN_KIND, STDERR, strcpy_realloc(), STRLENGTH, SUM_KIND, TEST_KIND, TOGGLE_KIND, TRIG_KIND, UNDEFINED, var_id(), Var_List, WSUM_KIND, XNOR_KIND, and XOR_KIND.

Referenced by main().

◆ redefine_random_seed()

void redefine_random_seed ( void )

Definition at line 1038 of file rd.c.

1038 {
1039 if ((!Seed_Flag) && (Cmdline_Flag)) {
1040 Seed_List.rndseed = 0L;
1041 Seed_Flag = true;
1042 }
1043 return;
1044}
EXTERN RANDOMSEED_TYPE Seed_List
Definition napa.h:979
EXTERN int Cmdline_Flag
Definition napa.h:846
EXTERN int Seed_Flag
Definition napa.h:877

References Cmdline_Flag, Seed_Flag, and Seed_List.

Referenced by main().

◆ separe_qualifiers()

void separe_qualifiers ( void )

Definition at line 158 of file rd.c.

158 {
159 long out;
160 long kd;
161 long len;
162 char *s = (char*) NULL;
163 char tok1[STRLENGTH] = {'\0'};
164 char tok2[STRLENGTH] = {'\0'};
165 char tok3[STRLENGTH] = {'\0'};
166 unsigned long *ml = (unsigned long*) NULL;
167 unsigned long *mf = (unsigned long*) NULL;
168 int flag;
169
170 for (out = 0L; out < Num_Nodes; out++) {
171 kd = Node_List[out].kind;
172 ml = Node_List[out].mline;
173 mf = Node_List[out].mfile;
174
175 /* option detection and processing, note that the options are already transformed in a '...$' format */
176 s = Node_List[out].value;
177
178 switch (kd) {
179
180 /* TRIG: move option from '.value' to 'option' now */
181 case TRIG_KIND :
182 flag = false;
183 (void) strcpy(tok2, "");
184 (void) strcpy(tok3, "");
185 for (;;) {
186 s = get_token(s, tok1, true);
187 if (ISEMPTY(tok1)) {
188 break;
189 }
190 if ('$' == tok1[(LENGTH(tok1)) - 1L]) { /* this is an option */
191 tok1[(LENGTH(tok1)) - 1L] = '\0'; /* remove the '$' */
192 (void) strcat(tok2, tok1);
193 (void) strcat(tok2, " ");
194 flag = true;
195 } else {
196 (void) strcat(tok3, tok1); /* this is not an option */
197 (void) strcat(tok3, " "); /* copy as it is */
198 }
199 }
200 if (!flag) { /* default: (dual) */
201 (void) strcat(tok2, "dual ");
202 }
203 strcpy_realloc(&(Node_List[out].option), tok2, ml, mf); /* store in '.option' */
204 strcpy_realloc(&(Node_List[out].value), tok3, ml, mf); /* store in '.value' */
205 break;
206
207 /* DIV, MOD: move option from '.value' to 'option' now */
208 case DIV_KIND :
209 case MOD_KIND :
210 flag = false;
211 (void) strcpy(tok2, "");
212 (void) strcpy(tok3, "");
213 for (;;) {
214 s = get_token(s, tok1, true);
215 if (ISEMPTY(tok1)) {
216 break;
217 }
218 if ('$' == tok1[(LENGTH(tok1)) - 1L]) { /* this is an option */
219 tok1[(LENGTH(tok1)) - 1L] = '\0'; /* remove the '$' */
220 (void) strcat(tok2, tok1);
221 (void) strcat(tok2, " ");
222 flag = true;
223 } else {
224 (void) strcat(tok3, tok1); /* this is not an option */
225 (void) strcat(tok3, " "); /* copy as it is */
226 }
227 }
228 if (!flag) { /* default: (none) */
229 (void) strcat(tok2, "none");
230 }
231 strcpy_realloc(&(Node_List[out].option), tok2, ml, mf); /* store in '.option' */
232 strcpy_realloc(&(Node_List[out].value), tok3, ml, mf); /* store in '.value' */
233 break;
234
235 /* AVERAGE: move option from '.value' to 'option' now */
236 case AVERAGE_KIND :
237 flag = false;
238 (void) strcpy(tok2, "");
239 (void) strcpy(tok3, "");
240 for (;;) {
241 s = get_token(s, tok1, true);
242 if (ISEMPTY(tok1)) {
243 break;
244 }
245 if ('$' == tok1[(LENGTH(tok1)) - 1L]) { /* this is an option */
246 tok1[(LENGTH(tok1)) - 1L] = '\0'; /* remove the '$' */
247 (void) strcat(tok2, tok1);
248 (void) strcat(tok2, " ");
249 flag = true;
250 } else {
251 (void) strcat(tok3, tok1); /* this is not an option */
252 (void) strcat(tok3, " "); /* copy as it is */
253 }
254 }
255 if (!flag) { /* default: (arithmetic) */
256 (void) strcat(tok2, "arithmetic ");
257 }
258 strcpy_realloc(&(Node_List[out].option), tok2, ml, mf); /* store in '.option' */
259 strcpy_realloc(&(Node_List[out].value), tok3, ml, mf); /* store in '.value' */
260 break;
261
262 /* CHANGE: move option from '.value' to 'option' now */
263 case CHG_KIND :
264 flag = false;
265 (void) strcpy(tok2, "");
266 (void) strcpy(tok3, "");
267 for (;;) {
268 s = get_token(s, tok1, true);
269 if (ISEMPTY(tok1)) {
270 break;
271 }
272 if ('$' == tok1[(LENGTH(tok1)) - 1L]) { /* this is an option */
273 tok1[(LENGTH(tok1)) - 1L] = '\0'; /* remove the '$' */
274 (void) strcat(tok2, tok1);
275 (void) strcat(tok2, " ");
276 flag = true;
277 } else {
278 (void) strcat(tok3, tok1); /* this is not an option */
279 (void) strcat(tok3, " "); /* copy as it is */
280 }
281 }
282 if (!flag) { /* default: (dual) */
283 (void) strcat(tok2, "dual ");
284 }
285 strcpy_realloc(&(Node_List[out].option), tok2, ml, mf); /* store in '.option' */
286 strcpy_realloc(&(Node_List[out].value), tok3, ml, mf); /* store in '.value' */
287 break;
288
289 /* DC, CONST: do not process the qualifiers nor the C equations! */
290 /* ALGEBRA, DALGEBRA, IALGEBRA: do not process the C equations! */
291 /* TEST: do not process the C equations! */
292 case DC_KIND :
293 case CONST_KIND :
294 case ALGEBRA_KIND :
295 case DALGEBRA_KIND :
296 case IALGEBRA_KIND :
297 case TEST_KIND :
298 break;
299
300 /* RAM_KIND, ROM_KIND, RAM2_KIND, ROM2_KIND: respect brackets */
301 case RAM_KIND :
302 case ROM_KIND :
303 case RAM2_KIND :
304 case ROM2_KIND :
305 break;
306
307 /* DTOOL, DUSER, IUSER, ITOOL: move option from '.value' to 'option' now */
308 /* and all other nodes */
309 case DUSER_KIND :
310 case DTOOL_KIND :
311 case ITOOL_KIND :
312 case IUSER_KIND :
313 default:
314 (void) strcpy(tok2, "");
315 (void) strcpy(tok3, "");
316 for (;;) {
317 s = get_token(s, tok1, true);
318 if (ISEMPTY(tok1)) {
319 break;
320 }
321 if ('$' == tok1[(LENGTH(tok1)) - 1L]) { /* this is an option */
322 tok1[(LENGTH(tok1)) - 1L] = '\0'; /* remove the '$' */
323 (void) strcat(tok2, tok1);
324 (void) strcat(tok2, " ");
325 flag = true;
326 } else {
327 (void) strcat(tok3, tok1); /* this is not an option */
328 (void) strcat(tok3, " "); /* copy as it is */
329 }
330 }
331 strcpy_realloc(&(Node_List[out].option), tok2, ml, mf); /* store in '.option' */
332 strcpy_realloc(&(Node_List[out].value), tok3, ml, mf); /* store in '.value' */
333 break;
334 }
335 }
336 for (out = 0L; out < Num_Nodes; out++) { /* clean line of options */
337 s = Node_List[out].option;
338 len = LENGTH(s);
339 if (1L > len) {
340 continue;
341 }
342 if (' ' == s[len - 1L]) {
343 s[len - 1L] = '\0';
344 }
345 }
346 return;
347}
#define MOD_KIND
Definition napa.h:286
#define ROM2_KIND
Definition napa.h:304
#define RAM_KIND
Definition napa.h:298
#define ROM_KIND
Definition napa.h:303
#define RAM2_KIND
Definition napa.h:299
#define DIV_KIND
Definition napa.h:258

References ALGEBRA_KIND, AVERAGE_KIND, CHG_KIND, CONST_KIND, DALGEBRA_KIND, DC_KIND, DIV_KIND, DTOOL_KIND, DUSER_KIND, get_token(), IALGEBRA_KIND, ISEMPTY, ITOOL_KIND, IUSER_KIND, LENGTH, MOD_KIND, Node_List, Num_Nodes, RAM2_KIND, RAM_KIND, ROM2_KIND, ROM_KIND, strcpy_realloc(), STRLENGTH, TEST_KIND, and TRIG_KIND.

Referenced by main().

◆ stuck_nodes()

void stuck_nodes ( void )

Definition at line 1689 of file rd.c.

1689 {
1690 long i, n;
1691 if (!Stuck_Flag) {
1692 return;
1693 }
1694 (void) fprintf(STDERR, "\nNAPA Compiler Warning: (stuck instruction usage)\n");
1695 for (i = 0L; i < Num_Stucks; i++) {
1696 n = node_id(Stuck_List[i].name);
1697 if (UNDEFINED == n) {
1698 if (UNDEFINED == var_id(Stuck_List[i].name)) {
1699 print_error_location("stuck", Stuck_List[i].mline, Stuck_List[i].mfile);
1700 (void) fprintf(STDERR, " There is no node named <%s> in the netlist\n", Stuck_List[i].name);
1702 continue;
1703 } else {
1704 print_error_location("stuck", Stuck_List[i].mline, Stuck_List[i].mfile);
1705 (void) fprintf(STDERR, " A variable cannot be stuck <%s>\n", Stuck_List[i].name);
1706 continue;
1707 }
1708 }
1709 if (0 == strcmp(Node_List[n].tag, "stuck")) {
1710 print_error_location("stuck", Stuck_List[i].mline, Stuck_List[i].mfile);
1711 (void) fprintf(STDERR, " Node <%s> can be stuck to a value only once\n", Stuck_List[i].name);
1712 continue;
1713 }
1714 clean_parentheses(Stuck_List[i].value); /* node redefinition */
1715 strcpy_realloc(&(Node_List[n].value), Stuck_List[i].value, Stuck_List[i].mline, Stuck_List[i].mfile);
1716 strcpy_realloc(&(Node_List[n].tag), "stuck", Stuck_List[i].mline, Stuck_List[i].mfile);
1717 strcpy_realloc(&(Node_List[n].option), "", Stuck_List[i].mline, Stuck_List[i].mfile);
1719 }
1720 if (0 != Error_Flag) {
1721 return;
1722 }
1723 for (i = 0L; i < Num_Stucks; i++) {
1724 (void) fprintf(STDERR, " -> at line %3lu of main netlist,", (Stuck_List[i].mline)[0]);
1725 n = node_id(Stuck_List[i].name);
1726 (void) fprintf(STDERR, " node <%s> is stuck by user to value <%s>\n", Node_List[n].name1, Stuck_List[i].value);
1727 }
1728 if (Stuck_Flag) {
1729 (void) fprintf(STDERR, "\n");
1730 }
1731 return;
1732}
EXTERN int Error_Flag
Definition napa.h:853
EXTERN int Stuck_Flag
Definition napa.h:878
EXTERN long Num_Stucks
Definition napa.h:832
EXTERN STUCK_TYPE Stuck_List[63L]
Definition napa.h:967

References clean_parentheses(), DALGEBRA_KIND, DIGITAL_DATA_TYPE, Error_Flag, IALGEBRA_KIND, node_id(), Node_List, Num_Stucks, print_error_location(), process_node_error(), STDERR, strcpy_realloc(), Stuck_Flag, Stuck_List, UNDEFINED, and var_id().

Referenced by main().