File: ResJunct.c

package info (click to toggle)
magic 7.5.220-1
  • links: PTS
  • area: main
  • in suites: wheezy
  • size: 17,860 kB
file content (162 lines) | stat: -rw-r--r-- 4,248 bytes parent folder | download | duplicates (2)
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

#ifndef lint
static char rcsid[] __attribute__ ((unused)) = "$Header: /usr/cvsroot/magic-7.5/resis/ResJunct.c,v 1.1.1.1 2006/04/10 22:03:14 tim Exp $";
#endif  /* not lint */

#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <math.h>

#include "utils/magic.h"
#include "utils/geometry.h"
#include "utils/geofast.h"
#include "tiles/tile.h"
#include "utils/hash.h"
#include "database/database.h"
#include "database/databaseInt.h"
#include "utils/malloc.h"
#include "textio/textio.h"
#include "extract/extract.h"
#include "extract/extractInt.h"
#include "windows/windows.h"
#include "dbwind/dbwind.h"
#include "utils/stack.h"
#include "utils/tech.h"
#include "textio/txcommands.h"
#include "resis/resis.h"



/*
 *-------------------------------------------------------------------------
 *
 * ResNewSDTransistor-- called when a transistor is reached via a piece of
 *			 diffusion. (Transistors  reached via poly, i.e.
 *			 gates, are handled by ResEachTile.)
 *
 * Results:none
 *
 * Side Effects: determines to which terminal (source or drain) node 
 * is connected. Makes new node if node hasn't already been created .
 * Allocates breakpoint in current tile for transistor.
 *
 *-------------------------------------------------------------------------
 */

void
ResNewSDTransistor(tile,tp,xj,yj,direction,PendingList)
	Tile 		*tile,*tp;
	int 		xj,yj,direction;
	resNode		**PendingList;
{
	resNode		*resptr;
	resTransistor	*resFet;
	tElement	*tcell;
	int		newnode;
	tileJunk	*j;
	
	newnode = FALSE;
	j = (tileJunk *) tp->ti_client;
	resFet = j->transistorList;
	if ((j->sourceEdge & direction) != 0)
	{
	     if (resFet->rt_source == (resNode *) NULL)
		 {
		     resptr = (resNode *) mallocMagic((unsigned)(sizeof(resNode)));
		     newnode = TRUE;
		     resFet->rt_source = resptr;
		 }
		 else
		 {
		      resptr = resFet->rt_source;
		 }
	}
	else
	{
	     if (resFet->rt_drain == (resNode *) NULL)
		 {
		     resptr = (resNode *) mallocMagic((unsigned)(sizeof(resNode)));
		     newnode = TRUE;
		     resFet->rt_drain = resptr;
		 }
		 else
		 {
		      resptr = resFet->rt_drain;
		 }
	}
	if (newnode)
	{
	     tcell = (tElement *) mallocMagic((unsigned)(sizeof(tElement)));
	     tcell->te_nextt = NULL;
	     tcell->te_thist = j->transistorList;
	     InitializeNode(resptr,xj,yj,RES_NODE_TRANSISTOR);
	     resptr->rn_te = tcell;
	     ResAddToQueue(resptr,PendingList);
	}
	NEWBREAK(resptr,tile,xj,yj,NULL);
}

/*
 *-------------------------------------------------------------------------
 *
 * ResProcessJunction-- Called whenever a tile  connecting to the tile being
 *	worked on is found. If a junction is already present, its address is
 *      returned. Otherwise, a new junction is made. 
 *
 * Results: None.
 *
 * Side Effects: Junctions may be created.
 *
 *-------------------------------------------------------------------------
 */

void
ResProcessJunction(tile, tp, xj, yj, NodeList)
	Tile 	*tile, *tp;
	int	xj,yj;
	resNode		**NodeList;
{
	ResJunction  	*junction;
	resNode	     	*resptr;
	jElement     	*jcell;
	tileJunk	*j0 = (tileJunk *)tile->ti_client;
	tileJunk	*j2 = (tileJunk *)tp->ti_client;

#ifdef PARANOID
	if (tile == tp)
	{
	     TxError("Junction being made between tile and itself \n");
	     return;
	}
#endif

	if (j2->tj_status & RES_TILE_DONE) return;
	resptr = (resNode *) mallocMagic((unsigned)(sizeof(resNode)));
	resptr->rn_te = (tElement *) NULL;
	junction = (ResJunction *) mallocMagic((unsigned)(sizeof(ResJunction)));
	jcell = (jElement *) mallocMagic((unsigned)(sizeof(jElement)));
	InitializeNode(resptr,xj,yj,RES_NODE_JUNCTION);
	resptr->rn_je = jcell;
	ResAddToQueue(resptr,NodeList);

	jcell->je_thisj = junction;
	jcell->je_nextj = NULL;
	junction->rj_status = FALSE;
	junction->rj_jnode = resptr;
	junction->rj_Tile[0] = tile;
	junction->rj_Tile[1] = tp;
	junction->rj_loc.p_x =xj;
	junction->rj_loc.p_y =yj;
	junction->rj_nextjunction[0] = j0->junctionList;
	j0->junctionList = junction;
	junction->rj_nextjunction[1] = j2->junctionList;
	j2->junctionList = junction;
	     
	NEWBREAK(junction->rj_jnode,tile,
     			junction->rj_loc.p_x,junction->rj_loc.p_y,NULL);

	NEWBREAK(junction->rj_jnode,tp,
     			junction->rj_loc.p_x,junction->rj_loc.p_y,NULL);

}