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:01 2009
19 ****************************************************************************/
20
21 #include "tkgate.h"
22 #include "print.h"
23
24 #define LOGICIN_OUT 0
25
26 iconDimensions in_iconDims[] = {
27 {0, 0, 7, 7, 3, 3},
28 {8, 0, 7, 7, 3, 3},
29 {16, 0, 7, 7, 3, 3},
30 {14, 8, 7, 7, 3, 3},
31 };
32 int in_iconBoldOffset = 16;
33
34 GPadLoc in_out_loc[] = {
35 {2,0,2,0,D_RIGHT},
36 {0,-2,0,-2,D_UP},
37 {-2,0,-2,0,D_LEFT},
38 {0,2,0,2,D_DOWN}};
39
40 static char *psIn[] = {
41 "%",
42 "% An input pin",
43 "%",
44 "/psin {",
45 " startgate",
46 " -6 -3 moveto",
47 " 0 0 lineto",
48 " -6 3 lineto",
49 " stroke",
50 " grestore",
51 "} bind def",
52 0
53 };
54
55 GGateInfo gate_in_info = {
56 GC_LOGICIN,
57 "IN",
58 "input",0x0,
59 "psin", psIn,
60 -1,-1,
61
62 {{"}", {"gm.mod",2}, {"gm.mod.in",7,0,200}, "gat_make IN"},
63 {0}},
64
65 in_iconDims,
66
67 1,{{"Z",OUT,1,1,in_out_loc}},
68 {{-8,4,RJ},{0,16,CT},{8,4,LJ},{0,-7,CT}},
69 {1,1,1},
70
71 {0},
72
73 InOut_Make,
74 Nop_WriteCellDef,
75 Generic_Init,
76 Generic_Delete,
77 Generic_GetExtents,
78 Generic_HitDistance,
79 InOut_Draw,
80 Generic_Move,
81 Generic_Copy,
82 Err_AddInput,
83 Err_AddOutput,
84 Err_AddInOut,
85 Generic_Rotate,
86 Err_RemovePort,
87 Err_ChangePin,
88 Nop_SimInitFunc,
89 Nop_SimHitFunc,
90 InOut_PSWrite,
91 Generic_EditProps,
92 InOut_VerSave
93 };
94
InOut_Make(EditState ** es,GModuleDef * env,int GType,int x,int y,int r,const char * Name,int noWire,const char ** options,int nOptions)95 GCElement *InOut_Make(EditState **es,GModuleDef *env,int GType,
96 int x,int y,int r,const char *Name,int noWire,const char **options,int nOptions)
97 {
98 GCElement *g;
99 /** @TODO to remove */
100 /*
101 GGateInfo *gi;
102 */
103
104 if (!(g = Generic_Make(es,env,GType,x,y,r,Name,noWire,options,nOptions)))
105 return NULL;
106
107 /** @TODO to remove */
108 /* gi = g->typeinfo; */
109
110 if (es) {
111 Tcl_SetVar(TkGate.tcl,"edgat_newPort","1",TCL_GLOBAL_ONLY);
112 net_editProps(g->wires[0]->net,x,y);
113 Tcl_SetVar(TkGate.tcl,"edgat_newPort","0",TCL_GLOBAL_ONLY);
114 }
115 return g;
116 }
117
InOut_Draw(GCElement * g,int md)118 void InOut_Draw(GCElement *g,int md)
119 {
120 GWire *w;
121
122 mk_gate(g->xpos,g->ypos,g->typeinfo,g->orient,g->selected);
123
124 gate_drawWires(g,md);
125
126 if ((w = g->wires[0]))
127 gate_drawgatename(g,w->net->n_signame);
128 }
129
InOut_VerSave(FILE * f,GCElement * g)130 void InOut_VerSave(FILE *f,GCElement *g)
131 {
132 fprintf(f," //: %s %s (%s)"
133 ,g->typeinfo->name
134 ,g->ename
135 ,g->wires[0]->net->n_signame);
136 VerilogBasicGateComment(f,g,0);
137 fprintf(f,"\n");
138 }
139
InOut_PSWrite(GPrint * P,GModLayout * L,GCElement * g)140 void InOut_PSWrite(GPrint *P,GModLayout *L,GCElement *g)
141 {
142 Generic_DrawGateLabel(P,g,g->wires[0]->net->n_signame);
143
144 fprintf(P->p_f,"%d %d %d %s\n",
145 g->xpos,g->ypos,-g->orient*90,
146 g->typeinfo->psprint);
147 }
148
init_in()149 void init_in()
150 {
151 Pixmap P;
152
153 P = Pixmap_registerFromFile("inout","inout.b");
154 gateinfo_iconInit(&gate_in_info,P,in_iconDims,in_iconBoldOffset);
155
156 RegisterGate(&gate_in_info);
157 }
158