FreeCalypso > hg > ueda-linux
comparison ueda/sverp/main.c @ 0:cd92449fdb51
initial import of ueda and ifctf-part-lib from ifctfvax CVS
author | Space Falcon <falcon@ivan.Harhan.ORG> |
---|---|
date | Mon, 20 Jul 2015 00:24:37 +0000 |
parents | |
children | 7b4f78fcca08 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:cd92449fdb51 |
---|---|
1 /* | |
2 * main() function for ueda-sverp | |
3 */ | |
4 | |
5 #include <stdio.h> | |
6 #include "struct.h" | |
7 | |
8 struct module_def *glob_module_list, *top_module_def; | |
9 char *primitives_filename = "primitives", *top_module_expl; | |
10 int verbose, top_module_candidates; | |
11 char *output_filename = "sverp.out"; | |
12 | |
13 static void | |
14 usage() | |
15 { | |
16 fprintf(stderr, | |
17 "usage: ueda-sverp [-p primfile] [-t top-module] [-v] verilog-sources\n"); | |
18 exit(1); | |
19 } | |
20 | |
21 static void | |
22 process_options(argc, argv) | |
23 char **argv; | |
24 { | |
25 register int c; | |
26 extern char *optarg; | |
27 | |
28 while ((c = getopt(argc, argv, "I:o:p:t:v")) != EOF) { | |
29 switch (c) { | |
30 case 'I': | |
31 add_symfile_dir(optarg); | |
32 continue; | |
33 case 'o': | |
34 output_filename = optarg; | |
35 continue; | |
36 case 'p': | |
37 primitives_filename = optarg; | |
38 continue; | |
39 case 't': | |
40 top_module_expl = optarg; | |
41 continue; | |
42 case 'v': | |
43 verbose++; | |
44 continue; | |
45 default: | |
46 usage(); | |
47 } | |
48 } | |
49 } | |
50 | |
51 main(argc, argv) | |
52 char **argv; | |
53 { | |
54 extern int optind; | |
55 | |
56 process_options(argc, argv); | |
57 if (optind >= argc) | |
58 usage(); | |
59 for (; optind < argc; optind++) { | |
60 if (verbose) | |
61 printf("Reading Verilog source %s\n", argv[optind]); | |
62 read_verilog_file(argv[optind]); | |
63 } | |
64 if (top_module_expl) | |
65 process_explicit_topmod(); | |
66 if (verbose) | |
67 printf("Reading primitive definitions from %s\n", | |
68 primitives_filename); | |
69 set_default_sympath(); /* for xGA definition files */ | |
70 read_primitives_file(primitives_filename); | |
71 if (verbose) | |
72 printf("Linking instantiations to lower modules\n"); | |
73 link_pass(); | |
74 if (!top_module_def) { | |
75 fprintf(stderr, "error: no top module found\n"); | |
76 exit(1); | |
77 } | |
78 if (!top_module_expl && top_module_candidates > 1) { | |
79 fprintf(stderr, | |
80 "error: more than one top module candidate, use -t option\n"); | |
81 exit(1); | |
82 } | |
83 if (verbose) | |
84 printf("Elaborating hierarchy from top module %s\n", | |
85 top_module_def->name); | |
86 elaborate_module(top_module_def, top_module_def->name, "", 0); | |
87 tally_output_nets(); | |
88 generate_output(); | |
89 exit(0); | |
90 } |