diff options
Diffstat (limited to 'Master/texmf-dist')
-rw-r--r-- | Master/texmf-dist/doc/latex/askmaps/README | 21 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/askmaps/askmaps.pdf | bin | 0 -> 308877 bytes | |||
-rw-r--r-- | Master/texmf-dist/doc/latex/askmaps/askmaps.tex | 590 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/askmaps/askmaps.sty | 376 |
4 files changed, 987 insertions, 0 deletions
diff --git a/Master/texmf-dist/doc/latex/askmaps/README b/Master/texmf-dist/doc/latex/askmaps/README new file mode 100644 index 00000000000..24ec1773123 --- /dev/null +++ b/Master/texmf-dist/doc/latex/askmaps/README @@ -0,0 +1,21 @@ +This small LaTex package provides the rendering of American style Karnaugh maps +as found in many American text books on Digital Design. There are four files: + +README - this file +askmaps.sty - the package file +askmaps.tex - the documention with examples +askmaps.pdf - PDF version of the documentation + +The Karnaugh maps are rendered with picture commands; only the pict2e package +is loaded. + +Current version is 0.1. At this point, only 2-5 variable Karnaugh maps +are supported. People familiar with the Karnaugh package should have +no problem in using the macros in this package. + +Suggestions and bug reports are welcome at J.E.J.opdenBrouw@hhs.nl + +Happy TeX-ing! + + Jesse op den Brouw + 2013/12/04 diff --git a/Master/texmf-dist/doc/latex/askmaps/askmaps.pdf b/Master/texmf-dist/doc/latex/askmaps/askmaps.pdf Binary files differnew file mode 100644 index 00000000000..b6803c74723 --- /dev/null +++ b/Master/texmf-dist/doc/latex/askmaps/askmaps.pdf diff --git a/Master/texmf-dist/doc/latex/askmaps/askmaps.tex b/Master/texmf-dist/doc/latex/askmaps/askmaps.tex new file mode 100644 index 00000000000..43dac8925d1 --- /dev/null +++ b/Master/texmf-dist/doc/latex/askmaps/askmaps.tex @@ -0,0 +1,590 @@ +%% +%% +%% askmaps.tex +%% +%% (c)2013, J.E.J. op den Brouw <J.E.J.opdenBrouw@hhs.nl> +%% +%% document v0.1 - 2013/12/04 +%% + +\documentclass[a4paper,10pt]{ltxdoc} +\usepackage[a4paper]{geometry} + +%% PDF Version and compression... +\pdfminorversion=5 +\pdfobjcompresslevel=2 + +%% English spelling of chapter, section, etc. +\usepackage[english]{babel} + +%% Use some packages +\usepackage[scaled=0.92]{helvet} +\usepackage{sansmath} +\usepackage{color} +\usepackage{float} +\usepackage{listings} +\usepackage{array} +%% The next lines are commented out by default. If you want these to appear +%% in the resulting PDF, you have to copy the kvmacros.tex file in the +%% current directory, uncomment the next lines and LaTex this file. +%% +%%\input kvmacros + +%% Use askmaps +\usepackage{askmaps} + +%% Use hyperrefs in PDFs +\usepackage{hyperref} +\hypersetup{ + colorlinks=true, + linkcolor=blue, + pdftitle={American Style Karnaugh Maps}, + pdfauthor={J.E.J op den Brouw}, + pdfsubject={Drawing 2, 3, 4 and 5 variables K-maps}, + pdfkeywords={K-maps, Karnaugh maps, Digital Design} +} +\definecolor{red}{rgb}{1,0,0} +\definecolor{blue}{rgb}{0,0,1} +\definecolor{darkgreen}{rgb}{0,0.4,0} +\definecolor{orange}{rgb}{1,0.5,0} +\definecolor{gray}{rgb}{0.5,0.5,0.5} +\definecolor{lightgray}{rgb}{0.95,0.95,0.95} + +%% Making captions nicer... +\usepackage[font=footnotesize,format=plain,labelfont=bf,up,textfont=it,up] + {caption} + +%% Set up the LaTex language layout +\lstset{ % + language=[LaTeX]tex, + basicstyle=\footnotesize\fontfamily{pcr}\selectfont, + commentstyle=\itshape, + numbers=left, + numberstyle=\tiny\color{gray}, + stepnumber=1, + numbersep=5pt, + backgroundcolor=\color{lightgray}, + showspaces=false, + showstringspaces=false, + showtabs=false, + frame=lines, + rulecolor=\color{black}, + tabsize=4, + captionpos=b, + breaklines=true, + breakatwhitespace=false, + title=\lstname, + morekeywords={RequirePackage,ProvidesPackage}, + aboveskip=\bigskipamount +} + +%% Need one more footnote... +%% Display package name boldface +\renewcommand*{\thefootnote}{\fnsymbol{footnote}} +\newcommand\Package[1]{\texttt{#1}} + +%% \cmdinvoke et al politely reused from the miscdoc.sty file +\makeatletter +\DeclareRobustCommand\cmdinvoke{\@ifstar + {\let\@tempa\emph\@scmdinvoke}% + {\let\@tempa\relax\@scmdinvoke}% +} +\def\@scmdinvoke#1{\texttt{\symbol{92}#1}% + \futurelet\@let@token\@cmdinvoke +} +\def\@cmdinvoke{\ifx\@let@token\bgroup + \let\@tempb\@cmdinvoke@lbrace + \else + \ifx\@let@token[% ] + \let\@tempb\@cmdinvoke@lbrack + \else + \ifx\@let@token(% ) + \let\@tempb\@cmdinvoke@lparen + \else + \let\@tempb\@empty + \fi + \fi + \fi + \@tempb +} +\def\@cmdinvoke@lbrace#1{\penalty0\hskip0pt\relax + \texttt{\symbol{123}\@tempa{#1}\symbol{125}}% + \futurelet\@let@token\@cmdinvoke +} +\def\@cmdinvoke@lbrack[#1]{\penalty-150\hskip0pt\relax + \texttt{[\@tempa{#1}]}% + \futurelet\@let@token\@cmdinvoke +} +\def\@cmdinvoke@lparen(#1){\penalty-150\hskip0pt\relax + \texttt{(\@tempa{#1})}% + \futurelet\@let@token\@cmdinvoke +} +\makeatother + +%% No indent +\setlength{\parindent}{0pt} + +%% At last, the document... +\begin{document} +\title{The \Package{askmaps} package} +\author{Jesse op den Brouw\thanks{The Hague University of Applied Sciences, + \url{J.E.J.opdenBrouw@hhs.nl}}} +\date{\askmapsdate, version \askmapsversion} +\maketitle +\setcounter{footnote}{1} + +\section{Abstract} +\label{sec:abstract} +This package generates configurable American style Karnaugh maps for +2, 3, 4 and 5 variables as can be found in numerous books on digital design. +Note that there are many ways to draw correct Karnaugh +maps\footnote{E.g., a four-variable Karnaugh map can be drawn in 384 different +and correct ways} and this packages creates only one version. + +There are more packages and examples that produce Karnaugh maps. A highly +recommendable package is written by Andreas W. Wieland\footnote{See +\url{http://www.ctan.org/tex-archive/macros/latex/contrib/karnaugh}}. +However, this package creates maps that are frequently found in dutch +textbooks\footnote{E.g. Digitale Techniek, A.P. Thijssen} +but not in American textbooks. + +\section{Overview} +\label{sec:overview} +After \cmdinvoke{usepackage}{askmaps}, four new commands are loaded +to draw Karnaugh maps using the picture environment: +\begin{table}[H] +\begin{tabular}{p{2cm}p{10cm}} +\cs{askmapii} & draws a two-variable Karnaugh map \\ +\cs{askmapiii} & draws a three-variable Karnaugh map \\ +\cs{askmapiv} & draws a four-variable Karnaugh map \\ +\cs{askmapv} & draws a five-variable Karnaugh map \\ +\end{tabular} +\end{table} + +These commands have five parameters which have the same meaning for each +commands. This will be explained in section \ref{sec:outline}. As can be seen +later on, much of the parameters can include typesetting commands such as +coloring and math notation. + +The new dimension \cs{askmapunitlength} is available and specifies +the length of the squares. It defaults to 1 cm (about 0.4 in) which is a good +value for 12 pt font size. + +The global definitions \cs{askmapsversion} and \cs{askmapsdate} will render +to the current version and date respectively. + +The command \cs{askmap} provides drop-in replacement for the \cs{karnaughmap} +command available in the \Package{kvdocs} package (although it is not really a +package) and internally calls one of the four +commands, but there are some drawbacks on using this command. + +\newpage +\section{Outline} +\label{sec:outline} +All four functions take the form +\cs{askmap<romannumber>\{\#1\}\{\#2\}\{\#3\}\{\#4\}\{\#5\}} +where \texttt{<romannumber>} is one of \texttt{ii}, \texttt{iii}, \texttt{iv} +or \texttt{v} and the parameters \texttt{\#1} to \texttt{\#5} have the +following meaning: + +\begin{itemize} + \itemsep0pt + %\labelsep0pt + \item[\texttt{\#1}] is the function output variable. + \item[\texttt{\#2}] is a list of function input variables. + \item[\texttt{\#3}] contains a list op options, see table below. + \item[\texttt{\#4}] is a list of function values. + \item[\texttt{\#5}] can be used to display user defined picture commands. +\end{itemize} + +If a parameter contains fewer elements than needed, you will get empty spaces +in the Karnaugh map. If a parameter contains more elements than needed, all +elements in excess are not printed. In both situations, you will not be +notified.\newline + +The third parameter contains a list of options as explained below. +\begin{itemize} + \itemsep0pt + \item[\texttt{i}] index numbers are printed in the lower left corner of + each square. + \item[\texttt{I}] no index numbers are printed (default). + \item[\texttt{f}] function output variable is printed at the upper right + corner of the Karnaugh map together with a small line + extending from the square to the function name (default). + \item[\texttt{F}] no function output variable is printed. + \item[\texttt{b}] bit combinations of the function input variables are + printed on top of the columns and at the right of the the + rows (default). + \item[\texttt{B}] bit combinations are not printed. + \item[\texttt{c}] shortcut for \texttt{ifb}. + \item[\texttt{C}] shortcut for \texttt{IFB}. +\end{itemize} + +Options are evaluated from left to right, so a combination of \texttt{iI} will +yield in no index numbers being printed. Please note that macros are not +expanded to a list of tokens but to one token.\newline + +If you look at American style Karnaugh maps, you will see that the function +output variable usually isn't printed with the map, but is printed below the +map (if it is printed at all). This behavior can be simulated by using the +\texttt{F} option, in which case the first parameter (the function output +variable) may be left unused. + + +\section{Use} +\label{sec:use} +Let's say we have the following truth table for a function S with two variables +a and b and the function values 1, 0, 1 and 1 respectively. + +\begin{table}[H] +\centering +\caption{Truth table} +\begin{tabular}{cc|c} +\hline +a & b & S \\ \hline +0 & 0 & 1 \\ +0 & 1 & 0 \\ +1 & 0 & 1 \\ +1 & 1 & 1 \\ +\hline +\end{tabular} +\end{table} + +Using the command +\begin{verbatim} + \askmapii{S}{ab}{i}{1011}{} +\end{verbatim} +will produce the two-variable Karnaugh map as presented in +figure~\ref{fig:askmapii}. +\begin{figure}[h] +\centering +\askmapunitlength=0.88cm +\askmapii{S}{ab}{i}{1011}{}% +\caption{Karnaughmap for two variables} +\label{fig:askmapii} +\end{figure} + +As you can see, the function output variable is printed top right of the +Karnaugh map, with a small line from the variable to the top right square. +The most significant function input variable is printed on the top left just +above the small line extending from the top left square. The least significant +function input variable is printed just below that line. The bit combinations +for the most significant function input variable is printed on top of the +columns, the bit combinations of the least significant function input variable +is printed on the left of the rows. You can see how the function values are +placed in the squares by observing the small index numbers in the lower left +corners of the squares. +\medskip + +The command +\begin{verbatim} + \askmapiii{S}{abc}{}{10110110}{} +\end{verbatim} +will produce a three-variable Karnaugh map as presented in +figure~\ref{fig:askmapiii}. In this case, the index numbers are not printed. + +\begin{figure}[H] +\centering +\askmapunitlength=0.88cm +\askmapiii{S}{abc}{}{10110110}{}% +\caption{Karnaugh map for three variables} +\label{fig:askmapiii} +\end{figure} + +Let's draw a Karnaugh map for a logic function with four inputs and one output. +The output will become logic 1 if three or four inputs are logic 1, otherwise +the output is logic 0. (Of course you can set up a truth table first; this is +left as an exercise to the reader). +The command +\begin{verbatim} + \askmapiv{S}{abcd}{}{0000000100010111}{} +\end{verbatim} +will produce a four-variable Karnaugh map for the given logic function and is +presented in figure~\ref{fig:askmapiv}. + +\begin{figure}[H] +\centering +\askmapunitlength=0.88cm + \askmapiv{S}{abdc}{}{0000000100010111}{} +\caption{Karnaugh map for four variables} +\label{fig:askmapiv} +\end{figure} + +Using the command +\begin{verbatim} + \askmapv{S}{abcde}{}{00101101010010111011110011101011}{} +\end{verbatim} +will produce a five-variable Karnaugh map as shown in figure \ref{fig:askmapv}. + +\begin{figure}[H] +\centering +\askmapunitlength=0.88cm + \askmapv{S}{abcde}{}{00101101010010111011110011101011}{} +\caption{Karnaugh map for five variables} +\label{fig:askmapv} +\end{figure} + +Of course you can do a lot more with the parameters of the commands. You +can use inline math to produce sophisticated variable names, you can +use coloring for the function values. However, please note that the second +and fourth parameter act as a list of tokens, so you have to use braces to +separate the tokens in the lists if they consists of multiple characters. +A list of tokens such as +\begin{verbatim} + {abcd} +\end{verbatim} +will yield a, b, c and d as separate tokens, but +\begin{verbatim} + {$m_{0}$$m_{1}$$m_{0}$$m_{1}$} +\end{verbatim} +will not work. You have to write +\begin{verbatim} + {{$m_{0}$}{$m_{1}$}{$m_{0}$}{$m_{1}$}} +\end{verbatim} + +The fifth parameter can be used to supply user created picture commands +such as dashed rectangles of ovals to emphasize the simplifications +in the function. Note that the origin +of the picture (0,0) is at the lower left corner of the lower left square. +Section \ref{sec:examples} shows some examples. +\bigskip + +The size of the indexes is scriptsize, the size of the bit combinations +on the edges of the Karnaugh maps is footnotesize. All other text is +in normalsize. Note that there are no commands to change the font sizes +in the Karnaugh diagrams. + + +The command \cs{askmap} provides a drop-in replacement for the command +\cs{karnaughmap} from the Karnaugh package. The command +\begin{verbatim} + \askmap{4}{F}{abcd}{0100101010100011}{} +\end{verbatim} +produces the Karnaugh map in figure \ref{fig:askmap}. +\begin{figure}[H] +\centering +\askmapunitlength=0.88cm + \askmap{4}{F}{abcd}{0100101010100011}{} +\caption{Karnaugh map using drop-in replacement} +\label{fig:askmap} +\end{figure} + +Only Karnaugh maps of two to five variables are supported, any other number +will trigger a warning. Please note that the \cs{kvindex}, \cs{kvindexsize} +and \cs{kvcontentsize} commands are not supported. +\medskip + +%% The next lines are commented out by default. If you want these to appear +%% in the resulting PDF, you have to copy the kvmacros.tex file in the +%% current directory, uncomment the next lines and LaTex this file. +%% +%%The packages \Package{kvmacros} and \Package{askmaps} can be used in the same +%%document. +%%\begin{figure}[H] +%%\centering +%% \karnaughmap{4}{f(a,b,c,d):}{abcd}{1110011001100110}{} +%%\caption{Karnaugh map using the \Package{kvmacros} package} +%%\label{fig:karnaughmap} +%%\end{figure} + +\newpage +\section{Examples} +\label{sec:examples} +\askmapunitlength=0.88cm +The Karnaugh maps for two variables: plain, with indexes, without function +output variable. +\begin{verbatim} + \askmapii{S}{ab}{}{1010}{} + \askmapii{S}{ab}{i}{1110}{} + \askmapii{S}{ab}{F}{1110}{} +\end{verbatim} +\askmapii{S}{ab}{}{1010}{} +\askmapii{S}{ab}{i}{1110}{} +\askmapii{S}{ab}{F}{1110}{} +\bigskip\bigskip + +The Karnaugh maps for three variables: plain, with indexes but without function +output variable. +\begin{verbatim} + \askmapiii{S}{abc}{}{00111010}{} + \askmapiii{F}{xyz}{iF}{11111010}{} +\end{verbatim} +\askmapiii{S}{abc}{}{00111010}{} +\askmapiii{F}{xyz}{iF}{11111010}{} +\bigskip\bigskip + +The Karnaugh maps for four variables: without function output variable, with +indexes. +\begin{verbatim} + \askmapiv{f}{wxyz}{F}{1110001101000101}{} + \askmapiv{S}{abcd}{i}{1100100100011101}{} +\end{verbatim} +\askmapiv{f}{wxyz}{F}{1110001101000101}{} +\askmapiv{S}{abcd}{i}{1100100100011101}{} +\bigskip\bigskip + +You can also do math things by using the known \$ signs... and you can make an +empty map for your exams... +\newpage +\begin{verbatim} + \askmapii{$S_{0}$}{{$a_{1}$}{$a_{0}$}}{}{1010}{} + \askmapii{}{}{}{}{} +\end{verbatim} +\askmapii{$S_{0}$}{{$a_{1}$}{$a_{0}$}}{}{1010}{} +\askmapii{}{}{}{}{} +\bigskip\bigskip + +You can do the math thing in roman font... and of course you can make a +\textsl{really} empty map for your exams... +\begin{verbatim} + \begin{verbatim} + \askmapiii{$\mathrm{M^{n+1}_{0}}$}{{$\mathrm{M^{n}_{2}}$}{$\mathrm{M^{n}_{1}}$} + {$\mathrm{M^{n}_{0}}$}}{}{11100111}{} + \askmapiii{}{}{BF}{}{} +\end{verbatim} +\askmapiii{$\mathrm{M^{n+1}_{0}}$}{{$\mathrm{M^{n}_{2}}$}{$\mathrm{M^{n}_{1}}$} + {$\mathrm{M^{n}_{0}}$}}{}{11100111}{} +\askmapiii{}{}{BF}{}{} +\bigskip\bigskip + +You can do things with don't cares... +\begin{verbatim} + \askmapii{S}{ab}{}{011-}{} + \askmapiii{S}{abc}{F}{001--10-}{} +\end{verbatim} +\askmapii{S}{ab}{}{011-}{} +\askmapiii{S}{abc}{F}{001--10-}{} +\bigskip\bigskip + +You can use colors and empty function values and variables as values too... +\begin{verbatim} + \askmapiii{S}{abc}{}{{\color{blue}{0}}{\color{blue}{0}}{\color{red}{1}}{ }{ } + {\color{red}{1}}{\color{blue}{0}}{ }}{} + \askmapii{S}{ab}{}{{$i_{0}$}{$i_{1}$}{$i_{2}$}{$i_{3}$}}{} +\end{verbatim} +\askmapiii{S}{abc}{}{{\color{blue}{0}}{\color{blue}{0}}{\color{red}{1}}{ }{ } + {\color{red}{1}}{\color{blue}{0}}{ }}{} +\askmapii{S}{ab}{}{{$i_{0}$}{$i_{1}$}{$i_{2}$}{$i_{3}$}}{} +\bigskip + +\newpage +You can set the font to something else ... and use sans math font ... +\begin{verbatim} + {\fontfamily{phv}\selectfont% + \askmapiv{S}{abcd}{}{0110111011110011}{}% + } + {\fontfamily{phv}\selectfont\sansmath + \askmapiv{$Q^{n+1}_{0}$}{{$p^{n}_{1}$}{$p^{n}_{0}$}{$q^{n}_{1}$}{$q^{n}_{0}$}} + {}{0110111011110011}{}% + } +\end{verbatim} +{\fontfamily{phv}\selectfont% +\askmapiv{S}{abcd}{}{0110111011110011}{}% +} +{\fontfamily{phv}\selectfont\sansmath +\askmapiv{$Q^{n+1}_{0}$}{{$p^{n}_{1}$}{$p^{n}_{0}$}{$q^{n}_{1}$}{$q^{n}_{0}$}} + {}{0110111011110011}{}% +} +\bigskip\bigskip + +You can use the last parameter to create to your own picture commands. Note +that the origin of the picture (0,0) is at the lower left corner of the lower +left square. It is also possible to use \cs{raisebox} in conjuction with +horizontal spacing to adjust the placing of the left (least significant) +variable(s). +\begin{verbatim} + {\fontfamily{phv}\selectfont\sansmath + \askmapiii{F}{xy{\raisebox{2ex}{\ \ z}}}{}{11100111}{% raise Z input + \color{red}\put(0.1,0.1){\dashbox{0.1}(0.8,1.8){}}% + \color{blue}\put(1.1,1.1){\dashbox{0.1}(1.8,0.8){}}% + \color{darkgreen}\put(2.1,0.1){\dashbox{0.1}(1.8,0.8){}}% + \color{orange}\put(0.15,1.15){\dashbox{0.1}(1.7,0.7){}}% + }}% + {\fontfamily{phv}\selectfont\sansmath + \askmapiii{F}{xyz}{}{11100111}{% + \put(0.5,1.0){\oval(0.8,1.8)}% + \put(2.0,1.5){\oval(1.8,0.8)}% + \put(2.5,0.5){\oval(0.8,0.8)}% circle + \put(3.5,0.5){\oval(0.8,0.8)[l]}% these three create + \put(3.5,0.9){\line(1,0){0.6}}% a oval open to the left + \put(3.5,0.1){\line(1,0){0.6}}% + }}% +\end{verbatim} +{\fontfamily{phv}\selectfont\sansmath +\askmapiii{F}{xy{\raisebox{1.5ex}{\ \ z}}}{}{11100111}{% raise Z input +\color{red}\put(0.1,0.1){\dashbox{0.1}(0.8,1.8){}}% +\color{blue}\put(1.1,1.1){\dashbox{0.1}(1.8,0.8){}}% +\color{darkgreen}\put(2.1,0.1){\dashbox{0.1}(1.8,0.8){}}% +\color{orange}\put(0.15,1.15){\dashbox{0.1}(1.7,0.7){}}% +}}% +{\fontfamily{phv}\selectfont\sansmath +\askmapiii{F}{xyz}{}{11100111}{% +\put(0.5,1.0){\oval(0.8,1.8)}% +\put(2.0,1.5){\oval(1.8,0.8)}% +\put(2.5,0.5){\oval(0.8,0.8)}% circle +\put(3.5,0.5){\oval(0.8,0.8)[l]}% these three create +\put(3.5,0.9){\line(1,0){0.7}}% an oval open to the left +\put(3.5,0.1){\line(1,0){0.7}}% +}}% +\bigskip\bigskip + +You can set the length of the squares, but please note that this will also +affect the rendering of the text... +\begin{verbatim} + \askmapunitlength=1cm + \askmapii{S}{ab}{}{1011}{} + \askmapunitlength=0.88cm + \askmapii{S}{ab}{}{1011}{} + \askmapunitlength=0.8cm + \askmapii{S}{ab}{}{1011}{} + \askmapunitlength=0.5cm + \askmapii{S}{ab}{}{1011}{} +\end{verbatim} + +{\askmapunitlength=1cm +\askmapii{S}{ab}{}{1011}{} +\askmapunitlength=0.88cm +\askmapii{S}{ab}{}{1011}{} +\askmapunitlength=0.8cm +\askmapii{S}{ab}{}{1011}{} +\askmapunitlength=0.5cm +\askmapii{S}{ab}{}{1011}{}} +\bigskip\bigskip + +An example directly from the Karnaugh package: + +\begin{verbatim} + \askmap{4}{$f(a,b,c,d):$}{{$a$}{$b$}{$c$}{$d$}}% + {0110011001100110}% + {% + \put(0,2){\oval(1.9,1.9)[r]} + \put(4,2){\oval(1.9,1.9)[l]} + \put(2,0){\oval(1.9,1.9)[t]} + \put(2,4){\oval(1.9,1.9)[b]} + } +\end{verbatim} +{\askmapunitlength=0.88cm +\askmap{4}{$f(a,b,c,d):$}{{$a$}{$b$}{$c$}{$d$}}% +{0110011001100110}% +{% +\put(0,2){\oval(1.9,1.9)[r]} +\put(4,2){\oval(1.9,1.9)[l]} +\put(2,0){\oval(1.9,1.9)[t]} +\put(2,4){\oval(1.9,1.9)[b]} +}} + +\bigskip +but please note that the ovals do not cover the logic 1's in the Karnaughmap +because the function values are placed differently. + +\newpage +\section{The source code} +\label{sec:sourcecode} +The source code is pretty straight forward. It uses a lot of picture primitives +for drawing the maps. The package uses three macros for processing +variable-length parameters, which were completely reused from the karnaugh +package. + +\lstinputlisting{askmaps.sty} + +\end{document} diff --git a/Master/texmf-dist/tex/latex/askmaps/askmaps.sty b/Master/texmf-dist/tex/latex/askmaps/askmaps.sty new file mode 100644 index 00000000000..9ff0122fbb0 --- /dev/null +++ b/Master/texmf-dist/tex/latex/askmaps/askmaps.sty @@ -0,0 +1,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'. |