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:13:58 2009
19 ****************************************************************************/
20 #include "tkgate.h"
21
22 #define BUFFER_IN 0
23 #define BUFFER_OUT 1
24
25 static void Buffer_WriteCellDef(FILE *f,GCellSpec *gcs);
26
27
28 iconDimensions buf_iconDims[] = {
29 {0, 0, 15, 15, 5, 7},
30 {16, 0, 15, 15, 7, 9},
31 {16, 16, 15, 15, 9, 7},
32 {0,16, 15, 15, 7, 5},
33 };
34 int buf_iconBoldOffset = 32;
35
36 GPadLoc buffer_in_loc[] = {
37 {-6,0,-6,0,D_LEFT},
38 {0,6,0,6,D_DOWN},
39 {6,0,6,0,D_RIGHT},
40 {0,-6,0,-6,D_UP}};
41
42 GPadLoc buffer_out_loc[] = {
43 {10,0,10,0,D_RIGHT},
44 {0,-10,0,-10,D_UP},
45 {-10,0,-10,0,D_LEFT},
46 {0,10,0,10,D_DOWN}};
47
48
49 char *psBuffer[] = {
50 "%",
51 "% A Buffer",
52 "/psbuf {",
53 " startgate",
54 " -5.5 -7.5 moveto",
55 " 9.5 0 lineto",
56 " -5.5 7.5 lineto",
57 " closepath",
58 " stroke",
59 " grestore",
60 "} bind def",
61 0
62 };
63
64 GGateInfo gate_buf_info = {
65 0,
66 "BUF",
67 "buf:not",0x2,
68 "psbuf",psBuffer,
69 -1,0,
70
71 {{"b", {"gm.gate",0}, {"gm.gate.buf",0,0,400}, "gat_make BUF"},
72 {"I", {"gm.gate",0}, {"gm.gate.inv",0,0,401}, "gat_make BUF -invert Z"},
73 {0}},
74
75 buf_iconDims,
76
77 2,{{"I",IN,1,1,buffer_in_loc},
78 {"Z",OUT,1,1,buffer_out_loc}},
79 {{0,-12,CT},{12,0,LJ},{0,-12,CT},{12,0,LJ}},
80 {1},
81
82 {"Diz",0},
83
84 Generic_Make,
85 Buffer_WriteCellDef,
86 Generic_Init,
87 Generic_Delete,
88 Generic_GetExtents,
89 Generic_HitDistance,
90 Generic_Draw,
91 Generic_Move,
92 Generic_Copy,
93 Err_AddInput,
94 Err_AddOutput,
95 Err_AddInOut,
96 Generic_Rotate,
97 Err_RemovePort,
98 Err_ChangePin,
99 Nop_SimInitFunc,
100 Nop_SimHitFunc,
101 Generic_PSWrite,
102 Generic_EditProps,
103 Generic_VerSave
104 };
105
106 /*****************************************************************************
107 *
108 * Generate primitive cell definition for buffer.
109 *
110 * Parameters:
111 * f File to write cell to.
112 * name Name of cell to write.
113 *
114 *****************************************************************************/
Buffer_WriteCellDef(FILE * f,GCellSpec * gcs)115 static void Buffer_WriteCellDef(FILE *f,GCellSpec *gcs)
116 {
117 int numBit = gcs->gc_numBits;
118 const char *invSpec = gcs->gc_invSpec;
119 PrimParm primParm;
120
121 PrimParm_init(&primParm);
122 PrimParm_rangeSet(&primParm,"IZ_RANGE",numBit);
123 PrimParm_invSet(&primParm,"invZ",(*invSpec == 'N'));
124 Primitive_write(f,"buf",gcs,&primParm);
125 }
126
init_buffer()127 void init_buffer()
128 {
129 Pixmap P;
130 P = Pixmap_registerFromFile("buf","buf.b");
131 gateinfo_iconInit(&gate_buf_info,P,buf_iconDims,buf_iconBoldOffset);
132 RegisterGate(&gate_buf_info);
133 }
134