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 #include "tkgate.h"
19 
20 #define TRIBUFFER_IN 0
21 #define TRIBUFFER_OUT 1
22 #define TRIBUFFER_ENABLE 2
23 
24 static void BufIf_WriteCellDef(FILE *f,GCellSpec *gcs);
25 
26 extern iconDimensions buf_iconDims[];
27 extern int buf_iconBoldOffset;
28 
29 GPadLoc bufif_in_loc[] = {
30 	{-6,0,-6,0,D_LEFT},
31 	{0,6,0,6,D_DOWN},
32 	{6,0,6,0,D_RIGHT},
33 	{0,-6,0,-6,D_UP}};
34 
35 GPadLoc bufif_out_loc[] = {
36 	{10,0,10,0,D_RIGHT},
37 	{0,-10,0,-10,D_UP},
38 	{-10,0,-10,0,D_LEFT},
39 	{0,10,0,10,D_DOWN}};
40 
41 GPadLoc bufif_enable_loc[] = {
42 	{2,-5,2,-5,D_UP},
43 	{-5,-2,-5,-2,D_LEFT},
44 	{-2,5,-2,5,D_DOWN},
45 	{5,2,5,2,D_RIGHT}};
46 
47 
48 GGateInfo gate_bufif_info = {
49   0,
50   "BUFIF",
51   "bufif1:notif1:bufif0:notif0",0x5 ,
52   "psbuf",0,
53   -1,0,
54 
55   {{"t",	{"gm.gate",0},		{"gm.gate.tribuf",0,0,500},	"gat_make BUFIF"},
56    {0}
57   },
58 
59   buf_iconDims,
60 
61   3,{{"Z",TRI,1,1,bufif_out_loc},
62      {"I",IN,1,1,bufif_in_loc},
63      {"E",IN,1,1,bufif_enable_loc}},
64   {{0,18,CT},{10,0,LJ},{0,-12,CT},{-8,8,RJ}},
65   {1},
66 
67   {"Dez","Diz",0},
68 
69   Generic_Make,
70   BufIf_WriteCellDef,
71   Generic_Init,
72   Generic_Delete,
73   Generic_GetExtents,
74   Generic_HitDistance,
75   Generic_Draw,
76   Generic_Move,
77   Generic_Copy,
78   Err_AddInput,
79   Err_AddOutput,
80   Err_AddInOut,
81   Generic_Rotate,
82   Err_RemovePort,
83   Err_ChangePin,
84   Nop_SimInitFunc,
85   Nop_SimHitFunc,
86   Generic_PSWrite,
87   Generic_EditProps,
88   Generic_VerSave
89 };
90 
91 /*****************************************************************************
92  *
93  * Generate primitive cell definition for bufifs.
94  *
95  * Parameters:
96  *    f			File to write cell to.
97  *    name		Name of cell to write.
98  *
99  *****************************************************************************/
BufIf_WriteCellDef(FILE * f,GCellSpec * gcs)100 static void BufIf_WriteCellDef(FILE *f,GCellSpec *gcs)
101 {
102   int numBit = gcs->gc_numBits;
103   const char *invSpec = gcs->gc_invSpec;
104   PrimParm primParm;
105 
106   PrimParm_init(&primParm);
107   PrimParm_rangeSet(&primParm,"IZ_RANGE",numBit);
108   PrimParm_intSet(&primParm,"IZ_BITS",numBit);
109   PrimParm_invSet(&primParm,"invZ",(*invSpec == 'N'));
110   Primitive_write(f,"tribuf",gcs,&primParm);
111 }
112 
init_bufif()113 void init_bufif()
114 {
115   Pixmap P;
116 
117   P = Pixmap_find("buf");
118   gateinfo_iconInit(&gate_bufif_info,P,buf_iconDims,buf_iconBoldOffset);
119 
120   RegisterGate(&gate_bufif_info);
121 }
122