Initial version of donated sources by Avertec, 3.4p5.
[tas-yagle.git] / distrib / sources / tas / trc / trc_spice.c
1 #include "trc.h"
2
3 int rcx_spidrivenet( rcxfile *file, lofig_list *lofig, losig_list *losig )
4 {
5 rcx_list *rcx;
6 num_list *node;
7 int idx;
8 lowire_list *wire;
9 loctc_list *ctc;
10 chain_list *scan;
11 chain_list *internal;
12 float c;
13 int n;
14
15 rcx = getrcx( losig );
16 if( !rcx )
17 return 0;
18
19 rcn_lock_signal( lofig, losig );
20
21 rcx_file_print( file, "* Connecteur order on subckt\n" );
22
23 for( internal = rcx->RCXEXTERNAL ; internal ; internal = internal->NEXT )
24 for( node=((locon_list*)internal->DATA)->PNODE ; node ; node=node->NEXT )
25 rcx_file_print( file, "* %s\n", getloconrcxname((locon_list*)internal->DATA));
26
27 for( internal = rcx->RCXINTERNAL ; internal ; internal = internal->NEXT ) {
28 for( node=((locon_list*)internal->DATA)->PNODE ; node ; node=node->NEXT )
29 rcx_file_print( file, "* %s\n", getloconrcxname((locon_list*)internal->DATA) );
30 }
31
32 rcx_file_print( file, ".subckt %s ", rcx_getsigname( losig ) );
33
34 for( internal = rcx->RCXEXTERNAL ; internal ; internal = internal->NEXT )
35 for( node=((locon_list*)internal->DATA)->PNODE ; node ; node=node->NEXT )
36 rcx_file_print( file, "%ld ", node->DATA );
37
38 for( internal = rcx->RCXINTERNAL ; internal ; internal = internal->NEXT ) {
39 for( node=((locon_list*)internal->DATA)->PNODE ; node ; node=node->NEXT )
40 rcx_file_print( file, "%ld ", node->DATA );
41 }
42
43 rcx_file_print( file, "\n" );
44
45 idx=0;
46 for( wire = losig->PRCN->PWIRE ; wire ; wire = wire->NEXT ) {
47 idx++;
48 rcx_file_print( file, "R%d %ld %ld %g\n", idx,
49 wire->NODE1,
50 wire->NODE2,
51 wire->RESI
52 );
53 if( wire->CAPA > 0.0 ) {
54 rcx_file_print( file, "Ca%d %ld 0 %gpF\n", idx,
55 wire->NODE1,
56 wire->CAPA/2.0
57 );
58 rcx_file_print( file, "Cb%d %ld 0 %gpF\n", idx,
59 wire->NODE2,
60 wire->CAPA/2.0
61 );
62 }
63 }
64
65 idx=0;
66 for( scan = losig->PRCN->PCTC ; scan ; scan = scan->NEXT ) {
67 ctc = (loctc_list*)scan->DATA;
68 if( rcn_ctcnode( ctc, losig ) ) {
69 idx++;
70 rcx_file_print( file, "C%d %ld 0 %gpF\n", idx,
71 rcn_ctcnode( ctc, losig ),
72 ctc->CAPA
73 );
74 }
75 }
76
77 idx=0;
78 for( internal = rcx->RCXEXTERNAL ; internal ; internal = internal->NEXT ) {
79 c = rcx_getloconcapa( ((locon_list*)internal->DATA), TRC_SLOPE_UNK, TRC_CAPA_NOM, TRC_HALF, NULL );
80 if( c > 0.0 ) {
81 for( node=((locon_list*)internal->DATA)->PNODE, n=0 ; node ; node=node->NEXT, n++ );
82 for( node =((locon_list*)internal->DATA)->PNODE ; node ; node = node->NEXT ) {
83 idx++;
84 rcx_file_print( file, "Cx%d %ld 0 %gpF\n", idx,
85 node->DATA,
86 c/n
87 );
88 }
89 }
90 }
91
92 for( internal = rcx->RCXINTERNAL ; internal ; internal = internal->NEXT ) {
93 c = rcx_getloconcapa( ((locon_list*)internal->DATA), TRC_SLOPE_UNK, TRC_CAPA_NOM, TRC_HALF, NULL );
94 if( c>0.0 ) {
95 for( node = ((locon_list*)internal->DATA)->PNODE, n=0 ;
96 node ;
97 node = node->NEXT, n++ );
98 for( node = ((locon_list*)internal->DATA)->PNODE ;
99 node ;
100 node = node->NEXT ) {
101 idx++;
102 rcx_file_print( file, "Cx%d %ld 0 %gpF\n", idx,
103 node->DATA,
104 c/n
105 );
106 }
107 }
108 }
109
110 rcx_file_print( file, ".ends\n\n" );
111
112 rcn_unlock_signal( lofig, losig );
113 return 1;
114 }