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
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
|
%%
%% askmaps.sty
%%
%% American Style K-maps (2, 3, 4 and 5 variables)
%%
%% (c)2013 Jesse op den Brouw, <J.E.J.opdenBrouw@hhs.nl>
%%
%% LPPL LaTeX Public Project License
%%
\NeedsTeXFormat{LaTeX2e}[1994/06/01]
%% Version and date
\gdef\askmapsversion{0.1}
\gdef\askmapsdate{2013/12/04}
%
\ProvidesPackage{askmaps}[\askmapsdate\space Version \askmapsversion\space
LaTeX package for drawing American Style Karnaugh maps]
%% This package provides 2, 3, 4 and 5 variable Karnaugh maps that can
%% be found in numerous american text books on digital design. Note
%% that it is possible to draw many different K-maps that are all
%% legitimate as long as a square (minterm) differs only in one
%% literal with its adjacent squares.
%% This package draws K-maps where the most significant input variables
%% are placed on top of the columns and the least significant variables
%% are placed left of the rows. Such K-maps can be found in the text books:
%% Design of Logic Systems, 2nd, Lewin & Protheroe
%% Digital System Design with VHDL, 2nd, Zwolinski
%% Packages needed
\RequirePackage{pict2e}
%% The macros \askmapargumentstring, \askmapgetchar and \askmapgetonechar are
%% needed to process the variable-length parameters in \askmapxxx:
%% These routine politely reused from karnaugh package
\def\askmapargumentstring#1{\gdef\askmapdummystring{#1{}\noexpand\end}}
\def\askmapgetchar{\expandafter\askmapgetonechar\askmapdummystring}
\def\askmapgetonechar#1#2\end{{#1}\gdef\askmapdummystring{#2\noexpand\end}}%
%% Dimension for length of one square
\newdimen\askmapunitlength
\askmapunitlength=10mm
%% Some use options
\newif\ifaskmap@opti% want indexes
\newif\ifaskmap@optf% want output function printed
\newif\ifaskmap@optb% want input variable bit combinations at columns and rows
%% We want bit combinations along with the columns and rows
%\askmap@optbtrue
%% Process user options
\def\askmap@processoptions#1{%
\askmap@optifalse\askmap@optftrue\askmap@optbtrue%
\@tfor\askmap@opt:=#1\do{%
\if i\askmap@opt\askmap@optitrue\fi%
\if I\askmap@opt\askmap@optifalse\fi%
\if f\askmap@opt\askmap@optftrue\fi%
\if F\askmap@opt\askmap@optffalse\fi%
\if b\askmap@opt\askmap@optbtrue\fi%
\if B\askmap@opt\askmap@optbfalse\fi%
\if c\askmap@opt\askmap@optitrue\askmap@optftrue\askmap@optbtrue\fi%
\if C\askmap@opt\askmap@optifalse\askmap@optffalse\askmap@optbfalse\fi%
}%
}%
%% Replacement for macros from karnaugh package
%% #1 = number of input variables
%% #2 = function output variable
%% #3 = function input variables
%% #4 = list of function values
%% #5 = user picture commands
\newcommand{\askmap}[5]{%
\if 2#1\relax
\askmapii{#2}{#3}{f}{#4}{#5}%
\else
\if 3#1\relax
\askmapiii{#2}{#3}{f}{#4}{#5}%
\else
\if 4#1\relax
\askmapiv{#2}{#3}{f}{#4}{#5}%
\else
\if 5#1\relax
\askmapv{#2}{#3}{f}{#4}{#5}%
\else
\PackageWarning{askmaps}{Sorry, no K-maps with #1 variables supported by package askmaps!}
\fi%
\fi%
\fi%
\fi%
}%
%% #1= output function variable
%% #2= 2 input variables
%% #3= options list
%% #4= 4 function values
%% #5= user defined picture commands
\newcommand{\askmapii}[5]{%
{\unitlength\askmapunitlength%
\askmap@processoptions{#3}%
\begin{picture}(4.4,3)(-1.2,0)%
\linethickness{1pt}%
\put(0,0){\framebox(2,2)}%
\put(1,0){\line(0,1){2}}%
\put(0,1){\line(1,0){2}}%
\ifaskmap@optf%
\put(2.35,2.25){#1}%
\put(1.9,1.9){\line(1,1){0.4}}%
\fi%
\askmapargumentstring{#2}%
\put(-0.4,2.55){\askmapgetchar}%
\put(-0.9,2.1){\makebox(0.5,0){\askmapgetchar}}%
\ifaskmap@opti%
\put(0.01,1.05){\scriptsize{\textsl{0}}}% a little bit to the edge because
\put(0.01,0.03){\scriptsize{\textsl{1}}}% the edge line is thick
\put(1.03,1.05){\scriptsize{\textsl{2}}}%
\put(1.03,0.03){\scriptsize{\textsl{3}}}%
\fi%
\ifaskmap@optb%
\put(-0.6,1.5){\makebox(0.5,0)[r]{\footnotesize{0}}}%
\put(-0.6,0.5){\makebox(0.5,0)[r]{\footnotesize{1}}}%
\put(0.5,2.2){\makebox(0,0){\footnotesize{0}}}%
\put(1.5,2.2){\makebox(0,0){\footnotesize{1}}}%
\fi%
\askmapargumentstring{#4}%
\put(0.5,1.5){\makebox(0,0){\askmapgetchar}}%
\put(0.5,0.5){\makebox(0,0){\askmapgetchar}}%
\put(1.5,1.5){\makebox(0,0){\askmapgetchar}}%
\put(1.5,0.5){\makebox(0,0){\askmapgetchar}}%
\thicklines%
\put(0,2){\line(-1,1){0.70}}%
\thinlines%
#5%
\end{picture}%
}%
}% end \askmapii
%% #1= output function variable
%% #2= 3 input variables
%% #3= options list
%% #4= 8 function values
%% #5= user defined picture commands
\newcommand{\askmapiii}[5]{%
{\unitlength\askmapunitlength%
\askmap@processoptions{#3}%
\begin{picture}(6.4,3)(-1.2,0)%
\linethickness{1pt}%
\put(0,0){\framebox(4,2)}%
\multiput(1,0)(1,0){3}{\line(0,1){2}}%
\put(0,1){\line(1,0){4}}%
\ifaskmap@optf%
\put(4.35,2.25){#1}%
\put(3.9,1.9){\line(1,1){0.4}}%
\fi%
\askmapargumentstring{#2}%
\put(-0.4,2.55){\askmapgetchar\askmapgetchar}%
\put(-0.9,2.1){\makebox(0.5,0){\askmapgetchar}}%
\ifaskmap@opti%
\put(0.01,1.05){\scriptsize{\textsl{0}}}%
\put(0.01,0.03){\scriptsize{\textsl{1}}}%
\put(1.03,1.05){\scriptsize{\textsl{2}}}%
\put(1.03,0.03){\scriptsize{\textsl{3}}}%
\put(3.03,1.05){\scriptsize{\textsl{4}}}%
\put(3.03,0.03){\scriptsize{\textsl{5}}}%
\put(2.03,1.05){\scriptsize{\textsl{6}}}%
\put(2.03,0.03){\scriptsize{\textsl{7}}}%
\fi%
\askmapargumentstring{#4}%
\put(0.5,1.5){\makebox(0,0){\askmapgetchar}}%
\put(0.5,0.5){\makebox(0,0){\askmapgetchar}}%
\put(1.5,1.5){\makebox(0,0){\askmapgetchar}}%
\put(1.5,0.5){\makebox(0,0){\askmapgetchar}}%
\put(3.5,1.5){\makebox(0,0){\askmapgetchar}}%
\put(3.5,0.5){\makebox(0,0){\askmapgetchar}}%
\put(2.5,1.5){\makebox(0,0){\askmapgetchar}}%
\put(2.5,0.5){\makebox(0,0){\askmapgetchar}}%
\ifaskmap@optb%
\put(-0.6,1.5){\makebox(0.5,0)[r]{\footnotesize{0}}}%
\put(-0.6,0.5){\makebox(0.5,0)[r]{\footnotesize{1}}}%
\put(0.5,2.2){\makebox(0,0){\footnotesize{00}}}%
\put(1.5,2.2){\makebox(0,0){\footnotesize{01}}}%
\put(2.5,2.2){\makebox(0,0){\footnotesize{11}}}%
\put(3.5,2.2){\makebox(0,0){\footnotesize{10}}}%
\fi%
\thicklines%
\put(0,2){\line(-1,1){0.70}}%
\thinlines%
#5%
\end{picture}%
}%
}% end \askmapiii
%% #1= output function variable
%% #2= 4 input variables
%% #3= options list
%% #4= 16 function values
%% #5= user defined picture commands
\newcommand{\askmapiv}[5]{%
{\unitlength\askmapunitlength%
\askmap@processoptions{#3}%
\begin{picture}(6.4,5)(-1.2,0)%
\linethickness{1pt}%
\put(0,0){\framebox(4,4)}%
\multiput(1,0)(1,0){3}{\line(0,1){4}}%
\multiput(0,1)(0,1){3}{\line(1,0){4}}%
\ifaskmap@optf%
\put(4.35,4.25){#1}%
\put(3.9,3.9){\line(1,1){0.4}}%
\fi%
\askmapargumentstring{#2}%
\put(-0.4,4.55){\askmapgetchar\askmapgetchar}%
\put(-1.0,4.1){\makebox(0.5,0){\askmapgetchar\askmapgetchar}}%
\ifaskmap@opti%
\put(0.01,3.05){\scriptsize{\textsl{0}}}%
\put(0.01,2.05){\scriptsize{\textsl{1}}}%
\put(0.01,0.03){\scriptsize{\textsl{2}}}%
\put(0.01,1.05){\scriptsize{\textsl{3}}}%
\put(1.03,3.05){\scriptsize{\textsl{4}}}%
\put(1.03,2.05){\scriptsize{\textsl{5}}}%
\put(1.03,0.03){\scriptsize{\textsl{6}}}%
\put(1.03,1.05){\scriptsize{\textsl{7}}}%
\put(3.03,3.05){\scriptsize{\textsl{8}}}%
\put(3.03,2.05){\scriptsize{\textsl{9}}}%
\put(3.03,0.03){\scriptsize{\textsl{10}}}%
\put(3.03,1.05){\scriptsize{\textsl{11}}}%
\put(2.03,3.05){\scriptsize{\textsl{12}}}%
\put(2.03,2.05){\scriptsize{\textsl{13}}}%
\put(2.03,0.03){\scriptsize{\textsl{14}}}%
\put(2.03,1.05){\scriptsize{\textsl{15}}}%
\fi%
\askmapargumentstring{#4}%
\put(0.5,3.5){\makebox(0,0){\askmapgetchar}}%
\put(0.5,2.5){\makebox(0,0){\askmapgetchar}}%
\put(0.5,0.5){\makebox(0,0){\askmapgetchar}}%
\put(0.5,1.5){\makebox(0,0){\askmapgetchar}}%
\put(1.5,3.5){\makebox(0,0){\askmapgetchar}}%
\put(1.5,2.5){\makebox(0,0){\askmapgetchar}}%
\put(1.5,0.5){\makebox(0,0){\askmapgetchar}}%
\put(1.5,1.5){\makebox(0,0){\askmapgetchar}}%
\put(3.5,3.5){\makebox(0,0){\askmapgetchar}}%
\put(3.5,2.5){\makebox(0,0){\askmapgetchar}}%
\put(3.5,0.5){\makebox(0,0){\askmapgetchar}}%
\put(3.5,1.5){\makebox(0,0){\askmapgetchar}}%
\put(2.5,3.5){\makebox(0,0){\askmapgetchar}}%
\put(2.5,2.5){\makebox(0,0){\askmapgetchar}}%
\put(2.5,0.5){\makebox(0,0){\askmapgetchar}}%
\put(2.5,1.5){\makebox(0,0){\askmapgetchar}}%
\ifaskmap@optb%
\put(-0.6,3.5){\makebox(0.5,0)[r]{\footnotesize{00}}}%
\put(-0.6,2.5){\makebox(0.5,0)[r]{\footnotesize{01}}}%
\put(-0.6,1.5){\makebox(0.5,0)[r]{\footnotesize{11}}}%
\put(-0.6,0.5){\makebox(0.5,0)[r]{\footnotesize{10}}}%
\put(0.5,4.2){\makebox(0,0){\footnotesize{00}}}%
\put(1.5,4.2){\makebox(0,0){\footnotesize{01}}}%
\put(2.5,4.2){\makebox(0,0){\footnotesize{11}}}%
\put(3.5,4.2){\makebox(0,0){\footnotesize{10}}}%
\fi
\thicklines%
\put(0,4){\line(-1,1){0.70}}%
\thinlines%
#5%
\end{picture}%
}%
}% end \askmapiv
%% #1= output function variable
%% #2= 5 input variables
%% #3= options list
%% #4= 32 function values
%% #5= user defined picture commands
\newcommand{\askmapv}[5]{%
{\unitlength\askmapunitlength%
\askmap@processoptions{#3}%
\begin{picture}(10.4,5)(-1.2,0)%
\linethickness{1pt}%
\put(0,0){\framebox(8,4)}%
\multiput(1,0)(1,0){7}{\line(0,1){4}}%
\multiput(0,1)(0,1){3}{\line(1,0){8}}%
\ifaskmap@optf%
\put(8.35,4.25){#1}%
\put(7.9,3.9){\line(1,1){0.4}}%
\fi%
\askmapargumentstring{#2}%
\put(-0.4,4.55){\askmapgetchar\askmapgetchar\askmapgetchar}%
\put(-1.0,4.1){\makebox(0.5,0){\askmapgetchar\askmapgetchar}}%
\ifaskmap@opti%
\put(0.01,3.05){\scriptsize{\textsl{0}}}%
\put(0.01,2.05){\scriptsize{\textsl{1}}}%
\put(0.01,0.03){\scriptsize{\textsl{2}}}%
\put(0.01,1.05){\scriptsize{\textsl{3}}}%
\put(1.03,3.05){\scriptsize{\textsl{4}}}%
\put(1.03,2.05){\scriptsize{\textsl{5}}}%
\put(1.03,0.03){\scriptsize{\textsl{6}}}%
\put(1.03,1.05){\scriptsize{\textsl{7}}}%
\put(3.03,3.05){\scriptsize{\textsl{8}}}%
\put(3.03,2.05){\scriptsize{\textsl{9}}}%
\put(3.03,0.03){\scriptsize{\textsl{10}}}%
\put(3.03,1.05){\scriptsize{\textsl{11}}}%
\put(2.03,3.05){\scriptsize{\textsl{12}}}%
\put(2.03,2.05){\scriptsize{\textsl{13}}}%
\put(2.03,0.03){\scriptsize{\textsl{14}}}%
\put(2.03,1.05){\scriptsize{\textsl{15}}}%
\put(7.03,3.05){\scriptsize{\textsl{16}}}%
\put(7.03,2.05){\scriptsize{\textsl{17}}}%
\put(7.03,0.03){\scriptsize{\textsl{18}}}%
\put(7.03,1.05){\scriptsize{\textsl{19}}}%
\put(6.03,3.05){\scriptsize{\textsl{20}}}%
\put(6.03,2.05){\scriptsize{\textsl{21}}}%
\put(6.03,0.03){\scriptsize{\textsl{22}}}%
\put(6.03,1.05){\scriptsize{\textsl{23}}}%
\put(4.03,3.05){\scriptsize{\textsl{24}}}%
\put(4.03,2.05){\scriptsize{\textsl{25}}}%
\put(4.03,0.03){\scriptsize{\textsl{26}}}%
\put(4.03,1.05){\scriptsize{\textsl{27}}}%
\put(5.03,3.05){\scriptsize{\textsl{28}}}%
\put(5.03,2.05){\scriptsize{\textsl{29}}}%
\put(5.03,0.03){\scriptsize{\textsl{30}}}%
\put(5.03,1.05){\scriptsize{\textsl{31}}}%
\fi%
\askmapargumentstring{#4}%
\put(0.5,3.5){\makebox(0,0){\askmapgetchar}}%
\put(0.5,2.5){\makebox(0,0){\askmapgetchar}}%
\put(0.5,0.5){\makebox(0,0){\askmapgetchar}}%
\put(0.5,1.5){\makebox(0,0){\askmapgetchar}}%
\put(1.5,3.5){\makebox(0,0){\askmapgetchar}}%
\put(1.5,2.5){\makebox(0,0){\askmapgetchar}}%
\put(1.5,0.5){\makebox(0,0){\askmapgetchar}}%
\put(1.5,1.5){\makebox(0,0){\askmapgetchar}}%
\put(3.5,3.5){\makebox(0,0){\askmapgetchar}}%
\put(3.5,2.5){\makebox(0,0){\askmapgetchar}}%
\put(3.5,0.5){\makebox(0,0){\askmapgetchar}}%
\put(3.5,1.5){\makebox(0,0){\askmapgetchar}}%
\put(2.5,3.5){\makebox(0,0){\askmapgetchar}}%
\put(2.5,2.5){\makebox(0,0){\askmapgetchar}}%
\put(2.5,0.5){\makebox(0,0){\askmapgetchar}}%
\put(2.5,1.5){\makebox(0,0){\askmapgetchar}}%
\put(7.5,3.5){\makebox(0,0){\askmapgetchar}}%
\put(7.5,2.5){\makebox(0,0){\askmapgetchar}}%
\put(7.5,0.5){\makebox(0,0){\askmapgetchar}}%
\put(7.5,1.5){\makebox(0,0){\askmapgetchar}}%
\put(6.5,3.5){\makebox(0,0){\askmapgetchar}}%
\put(6.5,2.5){\makebox(0,0){\askmapgetchar}}%
\put(6.5,0.5){\makebox(0,0){\askmapgetchar}}%
\put(6.5,1.5){\makebox(0,0){\askmapgetchar}}%
\put(4.5,3.5){\makebox(0,0){\askmapgetchar}}%
\put(4.5,2.5){\makebox(0,0){\askmapgetchar}}%
\put(4.5,0.5){\makebox(0,0){\askmapgetchar}}%
\put(4.5,1.5){\makebox(0,0){\askmapgetchar}}%
\put(5.5,3.5){\makebox(0,0){\askmapgetchar}}%
\put(5.5,2.5){\makebox(0,0){\askmapgetchar}}%
\put(5.5,0.5){\makebox(0,0){\askmapgetchar}}%
\put(5.5,1.5){\makebox(0,0){\askmapgetchar}}%
\ifaskmap@optb%
\put(-0.6,3.5){\makebox(0.5,0)[r]{\footnotesize{00}}}%
\put(-0.6,2.5){\makebox(0.5,0)[r]{\footnotesize{01}}}%
\put(-0.6,1.5){\makebox(0.5,0)[r]{\footnotesize{11}}}%
\put(-0.6,0.5){\makebox(0.5,0)[r]{\footnotesize{10}}}%
\put(0.5,4.2){\makebox(0,0){\footnotesize{000}}}%
\put(1.5,4.2){\makebox(0,0){\footnotesize{001}}}%
\put(2.5,4.2){\makebox(0,0){\footnotesize{011}}}%
\put(3.5,4.2){\makebox(0,0){\footnotesize{010}}}%
\put(4.5,4.2){\makebox(0,0){\footnotesize{110}}}%
\put(5.5,4.2){\makebox(0,0){\footnotesize{111}}}%
\put(6.5,4.2){\makebox(0,0){\footnotesize{101}}}%
\put(7.5,4.2){\makebox(0,0){\footnotesize{100}}}%
\fi%
\thicklines%
\put(0,4){\line(-1,1){0.70}}%
\thinlines%
#5%
\end{picture}%
}%
}% end \askmapv
\endinput
%%
%% End of file 'askmaps.sty'.
|