ecs2vl.c
3.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
#include "spikproc.h"
int Process_File();
extern char BaseFileName[], SymFileName[], SchmFileName[];
extern char ProgramName[];
int symbol_only;
unsigned long permission_mask = ALL_OK;
FILE *f;
char cname[64];
int n0;
int main( ac, av )
int ac;
char *av[];
{
char str[256],str1[256],str2[256];
int i,si;
if(ac!=3)
exit(1);
if(!Initialize())
exit(1);
sprintf( ProgramName, "ecs2vl ( %s )", av[1] );
sprintf(str,"%s",av[2]);
f = fopen(str,"w");
strcpy(str1,av[1]);
for(si=-1,i=0;av[1][i];i++)
if(str1[i]=='/')
si = i;
if(si>=0)
{
str1[si]=0;
chdir(str1);
strcpy(str2,&str1[si+1]);
}
else
strcpy(str2,str1);
if(f)
{
fprintf(f,"DW %s\n",str2);
Process_File(str2);
fclose(f);
}
}
Do_Pin( sp, pn, pin )
SP_PTR sp;
PN_PTR pn;
struct _pin *pin;
{
char name[256],netname[256];
char *pinname;
NT_PTR nt;
nt = NetContainingPin( sp );
if(nt)
{
strcpy(netname,Get_NA(nt,NAME));
if(netname[0]=='_')
netname[0]='~';
fprintf(f," %s",netname);
}
else
fprintf(f," ?");
return(FALSE );
}
static int Do_Port( pn, pin )
WORD pn;
struct _pin *pin;
{
char name[256];
hstrcpy( name, Get_PNA( pn, NAME ) );
if(name[0]=='_')
name[0]='~';
if ( *Get_PNA( pn, PINUSE ) == 'O' )
fprintf(f,"AP %s %d PINTYPE=OUT\n",cname,n0++,name);
if ( *Get_PNA( pn, PINUSE ) == 'I' )
fprintf(f,"AP %s %d PINTYPE=IN\n",cname,n0++,name);
if ( *Get_PNA( pn, PINUSE ) == 'B' )
fprintf(f,"AP %s %d PINTYPE=INOUT\n",cname,n0++,name);
return(FALSE);
}
static int Do_Port1( pn, pin )
WORD pn;
struct _pin *pin;
{
char name[256];
hstrcpy( name, Get_PNA( pn, NAME ) );
if(name[0]=='_')
name[0]='~';
fprintf(f," %s",name);
return(FALSE);
}
int Do_Component( st )
ST_PTR st;
{
Activate_Symbol_Type( st );
hstrcpy(cname,Get_DA(st,NAME));
strlwr(cname);
fprintf(f,"AS %s pinorder =",cname);
ForEachSymbolPin(Do_Port1);
fprintf(f,"\n");
n0 = 1;
ForEachSymbolPin(Do_Port);
return( FALSE );
}
int Do_Instance( si, inst )
SI_PTR si;
struct _inst *inst;
{
ST_PTR st;
char instance_name[80];
char module_name[256];
int type;
st = TypeOfInstance( si );
hstrcpy( (char _huge *)module_name, Get_DA( st, NAME ) );
strlwr( module_name );
hstrcpy( (char _huge *)instance_name, Get_IA( si, NAME ) );
fprintf(f,"I %s %s",instance_name,module_name);
ForEachInstancePin(si,Do_Pin);
fprintf(f," LABEL=%s`\n",instance_name);
return(FALSE);
}
int Process_File( name )
char *name;
{
int ok;
char buff[256];
int retn = FALSE;
AddExt( name, "" );
strcpy(SchmFileName,name );
strcpy(SymFileName,name );
strcpy(BaseFileName,FileInPath( SymFileName ) );
Free_Memory();
CTL_LeftParen = '[';
CTL_RightParen = ']';
ok = LoadSymbol(SymFileName);
if (ok)
{
if ( LoadSchematic( SchmFileName ) )
{
symbol_only = FALSE;
if ( ok = LoadSymbolsUsed() );
else fprintf(stderr,"Unable to Load Symbols for %s.sch\n", name );
}
else symbol_only = TRUE;
}
else
fprintf(stderr,"Can Not Read Symbol File %s.sym\n", name );
if(ok)
{
ForEachSymbolType(Do_Component);
fprintf(f,"G GND\n");
fprintf(f,"G VCC\n");
ForEachSymbolInstance(0,0x00,Do_Instance);
}
return( retn );
}
int ErrorMsg( string )
char *string;
{
MajorError( string );
return( 1 );
}