-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.c
77 lines (58 loc) · 1.37 KB
/
main.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#include <stdio.h>
#include "options.h"
#include "components.h"
#include "hash_table.h"
#include "mna.h"
#include "dc_instruction.h"
#include "transient.h"
extern FILE* yyin;
int yyparse();
int yylex_destroy();
enum IterativeMethods method_iter = BiCG;
enum SolutionMethods method_choice = NonIterative;
enum NonIterativeMethods method_noniter = LUDecomp;
enum TransientMethods method_tran = Tr;
int sparse_use = 0;
double itol = 1e-6;
extern int mna_size;
int main(int argc, char* argv[])
{
int debug;
yyin = fopen(argv[1], "r");
if ( argc !=4 ) {
printf("usage:\n%s <file.spice> <output_file> DEBUG\n", argv[0]);
return 0;
}
f = fopen(argv[2],"w");
name_of_file = argv[2];
debug = atoi(argv[3]);
if ( yyin == NULL ) {
printf("[-] Could not open %s\n", argv[1]);
return 0;
}
hash_initialize();
if ( yyparse() == 0 ) {
printf("[+] Parsed %s succesfully.\n", argv[1]);
if (debug){
method_choice = NonIterative;
method_noniter = LUDecomp;
sparse_use=0;
}
mna_analysis();
solve_dc();
if ( do_transient ) {
printf("[+] Performing Transient analysis\n");
transient_analysis();
}
if ( do_dc_instruction) {
printf("[+] Performing DC instruction\n");
dc_instruction();
}
mna_free();
}
components_cleanup();
fclose(yyin);
yylex_destroy();
hash_cleanup();
return mna_size;
}