1 /****************************************************************************
2 Copyright (C) 1987-2015 by Jeffery P. Hansen
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License along
15 with this program; if not, write to the Free Software Foundation, Inc.,
16 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17
18 Last edit by hansen on Mon Jan 19 18:16:51 2009
19 ****************************************************************************/
20 #include "tkgate.h"
21
22 #define NMOS_IN 0
23 #define NMOS_OUT 1
24
25 void Mos_WriteCellDef(FILE *f,GCellSpec *gcs);
26
27 static iconDimensions nmos_iconDims[] = {
28 {0, 0, 14, 18, 7, 7},
29 {0, 19, 18, 14, 7, 7},
30 {19, 15, 14, 18, 7, 9},
31 {15, 0, 18, 14, 9, 7},
32 };
33 static int nmos_iconBoldOffset = 34;
34
35 GPadLoc nmos_out_loc[] ={ /* Tr. out */
36 {6,-8,6,-8,D_UP},
37 {-7,-8,-7,-8,D_LEFT},
38 {-8,8,-8,8,D_DOWN},
39 {8,7,8,7,D_RIGHT}};
40
41 GPadLoc nmos_data_loc[] = { /* Tr. data */
42 {6,9,6,9,D_DOWN},
43 {8,-8,8,-8,D_RIGHT},
44 {-8,-7,-8,-7,D_UP},
45 {-7,7,-7,7,D_LEFT}};
46
47 GPadLoc nmos_gate_loc[] = { /* Tr. gate */
48 {-8,0,-8,0,D_LEFT},
49 {0,7,0,7,D_DOWN},
50 {7,0,7,0,D_RIGHT},
51 {0,-8,0,-8,D_UP}};
52
53 static char *psNmos[] = {
54 "%",
55 "% An NMOS gate",
56 "%",
57 "/psnmos {",
58 " [[0 0][0 -1][-1 1][0 -1]] adjstartgate",
59 " -8 8 moveto",
60 " -8 -9 lineto stroke",
61 " 6.5 7.5 moveto",
62 " -4 7.5 lineto",
63 " -4 -8.5 lineto",
64 " 6.5 -8.5 lineto stroke",
65 " 6 -8.5 moveto",
66 " 2 -11 lineto",
67 " 2 -6 lineto",
68 " closepath fill",
69 " grestore",
70 "} bind def",
71 0
72 };
73
74 GGateInfo gate_nmos_info = {
75 0,
76 "NMOS",
77 "nmos",0x0,
78 "psnmos",psNmos,
79 -1,0,
80
81 {{"Ctl-t n", {"gm.gate",0}, {"gm.gate.nmos",0,"tr"}, "gat_make NMOS"},
82 {0}
83 },
84
85 nmos_iconDims,
86
87 3,{
88 {"Z",OUT,1,1,nmos_out_loc,0},
89 {"S",IN,1,1,nmos_data_loc,0},
90 {"G",IN,1,1,nmos_gate_loc,0}},
91 {{10,4,LJ},{0,-12,CT},{-10,4,RJ},{0,18,CT}},
92 {1},
93
94 {"Diz","Dgz",0},
95
96 Generic_Make,
97 Mos_WriteCellDef,
98 Generic_Init,
99 Generic_Delete,
100 Generic_GetExtents,
101 Generic_HitDistance,
102 Generic_Draw,
103 Generic_Move,
104 Generic_Copy,
105 Err_AddInput,
106 Err_AddOutput,
107 Err_AddInOut,
108 Generic_Rotate,
109 Err_RemovePort,
110 Err_ChangePin,
111 Nop_SimInitFunc,
112 Nop_SimHitFunc,
113 Generic_PSWrite,
114 Generic_EditProps,
115 Generic_VerSave,
116 };
117
118 /*****************************************************************************
119 *
120 * Generate primitive cell definition for Mos gates.
121 *
122 * Parameters:
123 * f File to write cell to.
124 * name Name of cell to write.
125 *
126 *****************************************************************************/
Mos_WriteCellDef(FILE * f,GCellSpec * gcs)127 void Mos_WriteCellDef(FILE *f,GCellSpec *gcs)
128 {
129 GGateInfo *gi = gcs->gc_info;
130 int numBit = gcs->gc_numBits;
131 const char *op =0;
132 int inv = (*gcs->gc_invSpec == 'N');
133 PrimParm primParm;
134
135 if (strcmp(gi->name,"PMOS") == 0)
136 op = "pmos_trans";
137 else
138 op = "nmos_trans";
139
140 PrimParm_init(&primParm);
141 PrimParm_rangeSet(&primParm,"SGZ_RANGE",numBit);
142 PrimParm_invSet(&primParm,"invZ",inv);
143 Primitive_write(f,op,gcs,&primParm);
144 }
145
init_nmos()146 void init_nmos()
147 {
148 Pixmap P;
149
150 P = Pixmap_registerFromFile("nmos","nmos.b");
151 gateinfo_iconInit(&gate_nmos_info,P,nmos_iconDims,nmos_iconBoldOffset);
152 RegisterGate(&gate_nmos_info);
153 }
154