From: Christiaan Baaij Date: Mon, 22 Feb 2010 08:30:46 +0000 (+0100) Subject: Add pictures for choice section. Update section on function application X-Git-Url: https://git.stderr.nl/gitweb?a=commitdiff_plain;h=432416d4f3cb67cdb0ae332d01a78dae6328d0f5;p=matthijs%2Fmaster-project%2Fdsd-paper.git Add pictures for choice section. Update section on function application --- diff --git a/choice-case.svg b/choice-case.svg new file mode 100644 index 0000000..7d6c9d6 --- /dev/null +++ b/choice-case.svg @@ -0,0 +1,588 @@ + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/choice-ifthenelse.svg b/choice-ifthenelse.svg new file mode 100644 index 0000000..c08068c --- /dev/null +++ b/choice-ifthenelse.svg @@ -0,0 +1,670 @@ + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git "a/c\316\273ash.lhs" "b/c\316\273ash.lhs" index 6dd6520..a0ccb8e 100644 --- "a/c\316\273ash.lhs" +++ "b/c\316\273ash.lhs" @@ -63,6 +63,7 @@ % should be used if it is desired that the figures are to be displayed in % draft mode. % + \documentclass[conference,pdf,a4paper,10pt,final,twoside,twocolumn]{IEEEtran} % Add the compsoc option for Computer Society conferences. % @@ -93,9 +94,6 @@ - - - % *** CITATION PACKAGES *** % \usepackage{cite} @@ -371,6 +369,12 @@ \usepackage{xcolor} \def\comment#1{{\color[rgb]{1.0,0.0,0.0}{#1}}} +\usepackage{cleveref} +\crefname{figure}{figure}{figures} +\newcommand{\fref}[1]{\cref{#1}} +\newcommand{\Fref}[1]{\Cref{#1}} + + %include polycode.fmt %include clash.fmt @@ -526,43 +530,44 @@ by an optimizing \VHDL\ synthesis tools. \subsection{Function application} The basic syntactic elements of a functional program are functions - and function application. These have a single obvious \VHDL\ - translation: each top level function becomes a hardware component, - where each argument is an input port and the result value is the - (single) output port. This output port can have a complex type (such - as a tuple), so having just a single output port does not create a - limitation. - - Each function application in turn becomes a component instantiation. - Here, the result of each argument expression is assigned to a - signal, which is mapped to the corresponding input port. The output - port of the function is also mapped to a signal, which is used as - the result of the application itself. + and function application. These have a single obvious translation to a + netlist: every function becomes a component, every function argument is an + input port and the result value is of a function is an output port. This + output port can have a complex type (such as a tuple), so having just a + single output port does not create a limitation. Each function application + in turn becomes a component instantiation. Here, the result of each + argument expression is assigned to a signal, which is mapped to the + corresponding input port. The output port of the function is also mapped + to a signal, which is used as the result of the application itself. Since every top level function generates its own component, the - hierarchy of function calls is reflected in the final \VHDL\ - output as well, creating a hierarchical \VHDL\ description of the - hardware. This separation in different components makes the - resulting \VHDL\ output easier to read and debug. - - Example that defines the \texttt{mac} function by applying the - \texttt{add} and \texttt{mul} functions to calculate $a * b + c$: - -\begin{code} -mac a b c = add (mul a b) c -\end{code} - -\begin{figure} -\centerline{\includegraphics{mac}} -\caption{Combinatorial Multiply-Accumulate (curried)} -\label{img:mac-comb} -\end{figure} - -\begin{figure} -\centerline{\includegraphics{mac-nocurry}} -\caption{Combinatorial Multiply-Accumulate (uncurried)} -\label{img:mac-comb-nocurry} -\end{figure} + hierarchy of function calls is reflected in the final netlist aswell, + creating a hierarchical description of the hardware. This separation in + different components makes the resulting \VHDL\ output easier to read and + debug. + + As an example we can see the netlist of the |mac| function in + \Cref{img:mac-comb}; the |mac| function applies both the |mul| and |add| + function to calculate $a * b + c$: + \begin{code} + mac a b c = add (mul a b) c + \end{code} + \begin{figure} + \centerline{\includegraphics{mac}} + \caption{Combinatorial Multiply-Accumulate} + \label{img:mac-comb} + \end{figure} + The result of using a complex input type can be seen in + \cref{img:mac-comb-nocurry} where the |mac| function now uses a single + input tuple for the |a|, |b|, and |c| arguments: + \begin{code} + mac (a, b, c) = add (mul a b) c + \end{code} + \begin{figure} + \centerline{\includegraphics{mac-nocurry}} + \caption{Combinatorial Multiply-Accumulate (complex input)} + \label{img:mac-comb-nocurry} + \end{figure} \subsection{Choices} Although describing components and connections allows describing a @@ -613,7 +618,17 @@ mac a b c = add (mul a b) c sumif _ _ _ = 0 \end{code} - \comment{TODO: Pretty picture} + \begin{figure} + \centerline{\includegraphics{choice-ifthenelse}} + \caption{Choice - \emph{if-then-else}} + \label{img:choice} + \end{figure} + + \begin{figure} + \centerline{\includegraphics{choice-case}} + \caption{Choice - \emph{case-statement / pattern matching}} + \label{img:choice} + \end{figure} \subsection{Types} Translation of two most basic functional concepts has been diff --git a/mac-nocurry.svg b/mac-nocurry.svg index 9da1b98..bc3450d 100644 --- a/mac-nocurry.svg +++ b/mac-nocurry.svg @@ -23,61 +23,61 @@ borderopacity="1.0" inkscape:pageopacity="0.0" inkscape:pageshadow="2" - inkscape:zoom="2.8284271" - inkscape:cx="74.06218" - inkscape:cy="49.956073" + inkscape:zoom="4.3338301" + inkscape:cx="83.875" + inkscape:cy="31.024985" inkscape:document-units="px" inkscape:current-layer="layer1" - showgrid="true" + showgrid="false" inkscape:snap-grids="true" inkscape:window-width="1091" inkscape:window-height="838" - inkscape:window-x="903" - inkscape:window-y="224" + inkscape:window-x="575" + inkscape:window-y="194" inkscape:window-maximized="0"> + empspacing="5" + visible="true" + enabled="true" + snapvisiblegridlinesonly="true" /> + refY="0" + refX="0" + id="Arrow1Mend" + style="overflow:visible"> + style="fill-rule:evenodd;stroke:#000000;stroke-width:1pt;marker-start:none" + transform="matrix(-0.4,0,0,-0.4,-4,0)" /> + refY="0" + refX="0" + id="Arrow1Send" + style="overflow:visible"> + style="fill-rule:evenodd;stroke:#000000;stroke-width:1pt;marker-start:none" + transform="matrix(-0.2,0,0,-0.2,-1.2,0)" /> + inkscape:vp_y="0 : 1000 : 0" + inkscape:vp_z="744.09448 : 526.18109 : 1" + inkscape:persp3d-origin="372.04724 : 350.78739 : 1" + id="perspective10" /> @@ -92,121 +92,177 @@ + id="layer1" + transform="translate(-342.5,-556.3198)"> + width="115" + height="55.315327" + x="378.5" + y="562.75385" /> - + + width="29.5" + height="29.999987" + x="404.5" + y="567.75385" /> + id="path2946" + sodipodi:nodetypes="cc" /> + id="path4172" + sodipodi:nodetypes="cccc" /> + id="tspan5184" + style="font-size:10px;font-style:italic;-inkscape-font-specification:Bitstream Vera Sans Oblique" /> - + sodipodi:nodetypes="cccc" /> - - - - - - - - - - - + d="m 10,33.200127 0,5 14.5,0.0203" + id="path2876" + transform="translate(378.5,555.14935)" /> + sodipodi:nodetypes="ccc" + style="fill:none;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;marker-end:url(#Arrow1Mend)" + d="m 10,38.200127 0,15 63.5,0.0203" + id="path2878" + transform="translate(378.5,555.14935)" /> + + + + + + + + + + + + + + + id="path3417" /> + id="path3419" /> + id="path3421" /> + transform="matrix(1,0,0,-1,202.405,1218.0698)" + id="g3705"> diff --git a/mac.svg b/mac.svg index 749b4d3..8adad81 100644 --- a/mac.svg +++ b/mac.svg @@ -2,6 +2,7 @@ - - - - - - - - - - - - - - - - - - - - - - + id="defs4"> + + + + + + + + + + @@ -117,7 +106,7 @@ @@ -167,65 +156,143 @@ id="path4172" d="m 434.5,583.34948 9,0 0,5 9,0" style="fill:none;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;marker-end:url(#Arrow1Mend)" /> - - - - - - - - - - - - - - - - - - + style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;letter-spacing:normal;word-spacing:normal;text-anchor:start;fill:none;stroke:#000000;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:10.43299961;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + id="content" + transform="matrix(1,0,0,-1,159.63335,1229.1404)" + xml:space="preserve" + stroke-miterlimit="10.433" + font-style="normal" + font-variant="normal" + font-weight="normal" + font-stretch="normal" + font-size-adjust="none" + letter-spacing="normal" + word-spacing="normal" + ns0:text="$\\mathit{a}$\n" + ns0:preamble=""> + + + + + + + + + + + + + + + + + +