7 %% http://www.michaelshell.org/
8 %% for current contact information.
10 %% This is a skeleton file demonstrating the use of IEEEtran.cls
11 %% (requires IEEEtran.cls version 1.7 or later) with an IEEE conference paper.
14 %% http://www.michaelshell.org/tex/ieeetran/
15 %% http://www.ctan.org/tex-archive/macros/latex/contrib/IEEEtran/
17 %% http://www.ieee.org/
19 %%*************************************************************************
21 %% This code is offered as-is without any warranty either expressed or
22 %% implied; without even the implied warranty of MERCHANTABILITY or
23 %% FITNESS FOR A PARTICULAR PURPOSE!
24 %% User assumes all risk.
25 %% In no event shall IEEE or any contributor to this code be liable for
26 %% any damages or losses, including, but not limited to, incidental,
27 %% consequential, or any other damages, resulting from the use or misuse
28 %% of any information contained here.
30 %% All comments are the opinions of their respective authors and are not
31 %% necessarily endorsed by the IEEE.
33 %% This work is distributed under the LaTeX Project Public License (LPPL)
34 %% ( http://www.latex-project.org/ ) version 1.3, and may be freely used,
35 %% distributed and modified. A copy of the LPPL, version 1.3, is included
36 %% in the base LaTeX documentation of all distributions of LaTeX released
37 %% 2003/12/01 or later.
38 %% Retain all contribution notices and credits.
39 %% ** Modified files should be clearly indicated as such, including **
40 %% ** renaming them and changing author support contact information. **
42 %% File list of work: IEEEtran.cls, IEEEtran_HOWTO.pdf, bare_adv.tex,
43 %% bare_conf.tex, bare_jrnl.tex, bare_jrnl_compsoc.tex
44 %%*************************************************************************
46 % *** Authors should verify (and, if needed, correct) their LaTeX system ***
47 % *** with the testflow diagnostic prior to trusting their LaTeX platform ***
48 % *** with production work. IEEE's font choices can trigger bugs that do ***
49 % *** not appear when using other class files. ***
50 % The testflow support page is at:
51 % http://www.michaelshell.org/tex/testflow/
55 % Note that the a4paper option is mainly intended so that authors in
56 % countries using A4 can easily print to A4 and see how their papers will
57 % look in print - the typesetting of the document will not typically be
58 % affected with changes in paper size (but the bottom and side margins will).
59 % Use the testflow package mentioned above to verify correct handling of
60 % both paper sizes by the user's LaTeX system.
62 % Also note that the "draftcls" or "draftclsnofoot", not "draft", option
63 % should be used if it is desired that the figures are to be displayed in
66 \documentclass[conference]{IEEEtran}
67 % Add the compsoc option for Computer Society conferences.
69 % If IEEEtran.cls has not been installed into the LaTeX system files,
70 % manually specify the path to it like:
71 % \documentclass[conference]{../sty/IEEEtran}
77 % Some very useful LaTeX packages include:
78 % (uncomment the ones you want to load)
81 % *** MISC UTILITY PACKAGES ***
84 % Heiko Oberdiek's ifpdf.sty is very useful if you need conditional
85 % compilation based on whether the output is pdf or dvi.
92 % The latest version of ifpdf.sty can be obtained from:
93 % http://www.ctan.org/tex-archive/macros/latex/contrib/oberdiek/
94 % Also, note that IEEEtran.cls V1.7 and later provides a builtin
95 % \ifCLASSINFOpdf conditional that works the same way.
96 % When switching from latex to pdflatex and vice-versa, the compiler may
97 % have to be run twice to clear warning/error messages.
104 % *** CITATION PACKAGES ***
107 % cite.sty was written by Donald Arseneau
108 % V1.6 and later of IEEEtran pre-defines the format of the cite.sty package
109 % \cite{} output to follow that of IEEE. Loading the cite package will
110 % result in citation numbers being automatically sorted and properly
111 % "compressed/ranged". e.g., [1], [9], [2], [7], [5], [6] without using
112 % cite.sty will become [1], [2], [5]--[7], [9] using cite.sty. cite.sty's
113 % \cite will automatically add leading space, if needed. Use cite.sty's
114 % noadjust option (cite.sty V3.8 and later) if you want to turn this off.
115 % cite.sty is already installed on most LaTeX systems. Be sure and use
116 % version 4.0 (2003-05-27) and later if using hyperref.sty. cite.sty does
117 % not currently provide for hyperlinked citations.
118 % The latest version can be obtained at:
119 % http://www.ctan.org/tex-archive/macros/latex/contrib/cite/
120 % The documentation is contained in the cite.sty file itself.
127 % *** GRAPHICS RELATED PACKAGES ***
130 % \usepackage[pdftex]{graphicx}
131 % declare the path(s) where your graphic files are
132 % \graphicspath{{../pdf/}{../jpeg/}}
133 % and their extensions so you won't have to specify these with
134 % every instance of \includegraphics
135 % \DeclareGraphicsExtensions{.pdf,.jpeg,.png}
137 % or other class option (dvipsone, dvipdf, if not using dvips). graphicx
138 % will default to the driver specified in the system graphics.cfg if no
139 % driver is specified.
140 % \usepackage[dvips]{graphicx}
141 % declare the path(s) where your graphic files are
142 % \graphicspath{{../eps/}}
143 % and their extensions so you won't have to specify these with
144 % every instance of \includegraphics
145 % \DeclareGraphicsExtensions{.eps}
147 % graphicx was written by David Carlisle and Sebastian Rahtz. It is
148 % required if you want graphics, photos, etc. graphicx.sty is already
149 % installed on most LaTeX systems. The latest version and documentation can
151 % http://www.ctan.org/tex-archive/macros/latex/required/graphics/
152 % Another good source of documentation is "Using Imported Graphics in
153 % LaTeX2e" by Keith Reckdahl which can be found as epslatex.ps or
154 % epslatex.pdf at: http://www.ctan.org/tex-archive/info/
156 % latex, and pdflatex in dvi mode, support graphics in encapsulated
157 % postscript (.eps) format. pdflatex in pdf mode supports graphics
158 % in .pdf, .jpeg, .png and .mps (metapost) formats. Users should ensure
159 % that all non-photo figures use a vector format (.eps, .pdf, .mps) and
160 % not a bitmapped formats (.jpeg, .png). IEEE frowns on bitmapped formats
161 % which can result in "jaggedy"/blurry rendering of lines and letters as
162 % well as large increases in file sizes.
164 % You can find documentation about the pdfTeX application at:
165 % http://www.tug.org/applications/pdftex
171 % *** MATH PACKAGES ***
173 %\usepackage[cmex10]{amsmath}
174 % A popular package from the American Mathematical Society that provides
175 % many useful and powerful commands for dealing with mathematics. If using
176 % it, be sure to load this package with the cmex10 option to ensure that
177 % only type 1 fonts will utilized at all point sizes. Without this option,
178 % it is possible that some math symbols, particularly those within
179 % footnotes, will be rendered in bitmap form which will result in a
180 % document that can not be IEEE Xplore compliant!
182 % Also, note that the amsmath package sets \interdisplaylinepenalty to 10000
183 % thus preventing page breaks from occurring within multiline equations. Use:
184 %\interdisplaylinepenalty=2500
185 % after loading amsmath to restore such page breaks as IEEEtran.cls normally
186 % does. amsmath.sty is already installed on most LaTeX systems. The latest
187 % version and documentation can be obtained at:
188 % http://www.ctan.org/tex-archive/macros/latex/required/amslatex/math/
194 % *** SPECIALIZED LIST PACKAGES ***
196 %\usepackage{algorithmic}
197 % algorithmic.sty was written by Peter Williams and Rogerio Brito.
198 % This package provides an algorithmic environment fo describing algorithms.
199 % You can use the algorithmic environment in-text or within a figure
200 % environment to provide for a floating algorithm. Do NOT use the algorithm
201 % floating environment provided by algorithm.sty (by the same authors) or
202 % algorithm2e.sty (by Christophe Fiorio) as IEEE does not use dedicated
203 % algorithm float types and packages that provide these will not provide
204 % correct IEEE style captions. The latest version and documentation of
205 % algorithmic.sty can be obtained at:
206 % http://www.ctan.org/tex-archive/macros/latex/contrib/algorithms/
207 % There is also a support site at:
208 % http://algorithms.berlios.de/index.html
209 % Also of interest may be the (relatively newer and more customizable)
210 % algorithmicx.sty package by Szasz Janos:
211 % http://www.ctan.org/tex-archive/macros/latex/contrib/algorithmicx/
216 % *** ALIGNMENT PACKAGES ***
219 % Frank Mittelbach's and David Carlisle's array.sty patches and improves
220 % the standard LaTeX2e array and tabular environments to provide better
221 % appearance and additional user controls. As the default LaTeX2e table
222 % generation code is lacking to the point of almost being broken with
223 % respect to the quality of the end results, all users are strongly
224 % advised to use an enhanced (at the very least that provided by array.sty)
225 % set of table tools. array.sty is already installed on most systems. The
226 % latest version and documentation can be obtained at:
227 % http://www.ctan.org/tex-archive/macros/latex/required/tools/
230 %\usepackage{mdwmath}
232 % Also highly recommended is Mark Wooding's extremely powerful MDW tools,
233 % especially mdwmath.sty and mdwtab.sty which are used to format equations
234 % and tables, respectively. The MDWtools set is already installed on most
235 % LaTeX systems. The lastest version and documentation is available at:
236 % http://www.ctan.org/tex-archive/macros/latex/contrib/mdwtools/
239 % IEEEtran contains the IEEEeqnarray family of commands that can be used to
240 % generate multiline equations as well as matrices, tables, etc., of high
244 %\usepackage{eqparbox}
245 % Also of notable interest is Scott Pakin's eqparbox package for creating
246 % (automatically sized) equal width boxes - aka "natural width parboxes".
248 % http://www.ctan.org/tex-archive/macros/latex/contrib/eqparbox/
254 % *** SUBFIGURE PACKAGES ***
255 %\usepackage[tight,footnotesize]{subfigure}
256 % subfigure.sty was written by Steven Douglas Cochran. This package makes it
257 % easy to put subfigures in your figures. e.g., "Figure 1a and 1b". For IEEE
258 % work, it is a good idea to load it with the tight package option to reduce
259 % the amount of white space around the subfigures. subfigure.sty is already
260 % installed on most LaTeX systems. The latest version and documentation can
262 % http://www.ctan.org/tex-archive/obsolete/macros/latex/contrib/subfigure/
263 % subfigure.sty has been superceeded by subfig.sty.
267 %\usepackage[caption=false]{caption}
268 %\usepackage[font=footnotesize]{subfig}
269 % subfig.sty, also written by Steven Douglas Cochran, is the modern
270 % replacement for subfigure.sty. However, subfig.sty requires and
271 % automatically loads Axel Sommerfeldt's caption.sty which will override
272 % IEEEtran.cls handling of captions and this will result in nonIEEE style
273 % figure/table captions. To prevent this problem, be sure and preload
274 % caption.sty with its "caption=false" package option. This is will preserve
275 % IEEEtran.cls handing of captions. Version 1.3 (2005/06/28) and later
276 % (recommended due to many improvements over 1.2) of subfig.sty supports
277 % the caption=false option directly:
278 %\usepackage[caption=false,font=footnotesize]{subfig}
280 % The latest version and documentation can be obtained at:
281 % http://www.ctan.org/tex-archive/macros/latex/contrib/subfig/
282 % The latest version and documentation of caption.sty can be obtained at:
283 % http://www.ctan.org/tex-archive/macros/latex/contrib/caption/
288 % *** FLOAT PACKAGES ***
290 %\usepackage{fixltx2e}
291 % fixltx2e, the successor to the earlier fix2col.sty, was written by
292 % Frank Mittelbach and David Carlisle. This package corrects a few problems
293 % in the LaTeX2e kernel, the most notable of which is that in current
294 % LaTeX2e releases, the ordering of single and double column floats is not
295 % guaranteed to be preserved. Thus, an unpatched LaTeX2e can allow a
296 % single column figure to be placed prior to an earlier double column
297 % figure. The latest version and documentation can be found at:
298 % http://www.ctan.org/tex-archive/macros/latex/base/
302 %\usepackage{stfloats}
303 % stfloats.sty was written by Sigitas Tolusis. This package gives LaTeX2e
304 % the ability to do double column floats at the bottom of the page as well
305 % as the top. (e.g., "\begin{figure*}[!b]" is not normally possible in
306 % LaTeX2e). It also provides a command:
308 % to enable the placement of footnotes below bottom floats (the standard
309 % LaTeX2e kernel puts them above bottom floats). This is an invasive package
310 % which rewrites many portions of the LaTeX2e float routines. It may not work
311 % with other packages that modify the LaTeX2e float routines. The latest
312 % version and documentation can be obtained at:
313 % http://www.ctan.org/tex-archive/macros/latex/contrib/sttools/
314 % Documentation is contained in the stfloats.sty comments as well as in the
315 % presfull.pdf file. Do not use the stfloats baselinefloat ability as IEEE
316 % does not allow \baselineskip to stretch. Authors submitting work to the
317 % IEEE should note that IEEE rarely uses double column equations and
318 % that authors should try to avoid such use. Do not be tempted to use the
319 % cuted.sty or midfloat.sty packages (also by Sigitas Tolusis) as IEEE does
320 % not format its papers in such ways.
326 % *** PDF, URL AND HYPERLINK PACKAGES ***
329 % url.sty was written by Donald Arseneau. It provides better support for
330 % handling and breaking URLs. url.sty is already installed on most LaTeX
331 % systems. The latest version can be obtained at:
332 % http://www.ctan.org/tex-archive/macros/latex/contrib/misc/
333 % Read the url.sty source comments for usage information. Basically,
340 % *** Do not adjust lengths that control margins, column widths, etc. ***
341 % *** Do not use packages that alter fonts (such as pslatex). ***
342 % There should be no need to do such things with IEEEtran.cls V1.6 and later.
343 % (Unless specifically asked to do so by the journal or conference you plan
344 % to submit to, of course. )
347 % correct bad hyphenation here
348 \hyphenation{op-tical net-works semi-conduc-tor}
350 % Macro for certain acronyms in small caps. Doesn't work with the
351 % default font, though (it contains no smallcaps it seems).
352 \def\VHDL{\textsc{VHDL}}
353 \def\GHC{\textsc{GHC}}
355 % Macro for pretty printing haskell snippets. Just monospaced for now, perhaps
356 % we'll get something more complex later on.
357 \def\hs#1{\texttt{#1}}
362 % can use linebreaks \\ within to get better formatting as desired
363 \title{Haskell as a Structural\\ Hardware Description Language}
366 % author names and affiliations
367 % use a multiple column layout for up to three different
369 \author{\IEEEauthorblockN{Christiaan P.R. Baaij, Matthijs Kooijman, Jan Kuper, Marco E.T. Gerards, Bert Molenkamp, Sabih H. Gerez}
370 \IEEEauthorblockA{University of Twente, Department of EEMCS\\
371 P.O. Box 217, 7500 AE, Enschede, The Netherlands\\
372 c.p.r.baaij@utwente.nl, matthijs@stdin.nl}}
374 % \IEEEauthorblockN{Homer Simpson}
375 % \IEEEauthorblockA{Twentieth Century Fox\\
377 % Email: homer@thesimpsons.com}
379 % \IEEEauthorblockN{James Kirk\\ and Montgomery Scott}
380 % \IEEEauthorblockA{Starfleet Academy\\
381 % San Francisco, California 96678-2391\\
382 % Telephone: (800) 555--1212\\
383 % Fax: (888) 555--1212}}
385 % conference papers do not typically use \thanks and this command
386 % is locked out in conference mode. If really needed, such as for
387 % the acknowledgment of grants, issue a \IEEEoverridecommandlockouts
388 % after \documentclass
390 % for over three affiliations, or if they all won't fit within the width
391 % of the page, use this alternative format:
393 %\author{\IEEEauthorblockN{Michael Shell\IEEEauthorrefmark{1},
394 %Homer Simpson\IEEEauthorrefmark{2},
395 %James Kirk\IEEEauthorrefmark{3},
396 %Montgomery Scott\IEEEauthorrefmark{3} and
397 %Eldon Tyrell\IEEEauthorrefmark{4}}
398 %\IEEEauthorblockA{\IEEEauthorrefmark{1}School of Electrical and Computer Engineering\\
399 %Georgia Institute of Technology,
400 %Atlanta, Georgia 30332--0250\\ Email: see http://www.michaelshell.org/contact.html}
401 %\IEEEauthorblockA{\IEEEauthorrefmark{2}Twentieth Century Fox, Springfield, USA\\
402 %Email: homer@thesimpsons.com}
403 %\IEEEauthorblockA{\IEEEauthorrefmark{3}Starfleet Academy, San Francisco, California 96678-2391\\
404 %Telephone: (800) 555--1212, Fax: (888) 555--1212}
405 %\IEEEauthorblockA{\IEEEauthorrefmark{4}Tyrell Inc., 123 Replicant Street, Los Angeles, California 90210--4321}}
410 % use for special paper notices
411 %\IEEEspecialpapernotice{(Invited Paper)}
416 % make the title area
422 The abstract goes here.
424 % IEEEtran.cls defaults to using nonbold math in the Abstract.
425 % This preserves the distinction between vectors and scalars. However,
426 % if the conference you are submitting to favors bold math in the abstract,
427 % then you can use LaTeX's standard command \boldmath at the very start
428 % of the abstract to achieve this. Many IEEE journals/conferences frown on
429 % math in the abstract anyway.
436 % For peer review papers, you can put extra information on the cover
438 % \ifCLASSOPTIONpeerreview
439 % \begin{center} \bfseries EDICS Category: 3-BBND \end{center}
442 % For peerreview papers, this IEEEtran command inserts a page break and
443 % creates the second title. It will be ignored for other modes.
444 \IEEEpeerreviewmaketitle
447 \section{Introduction}
448 Hardware description languages has allowed the productivity of hardware engineers to keep pace with the development of chip technology. Standard Hardware description languages, like VHDL and Verilog, allowed an engineer to describe circuits using a programming language. These standard languages are very good at describing detailed hardware properties such as timing behavior, but are generally cumbersome in expressing higher-level abstraction. These languages also tend to have a complex syntax and a lack of formal semantics. To overcome these complexities, and raise the abstraction level, a great number of approaches based on functional languages has been proposed \cite{T-Ruby,Hydra,HML2,Hawk1,Lava,ForSyDe1,Wired,reFLect}. The idea of using functional languages started in the early 1980s \cite{Cardelli1981,muFP,DAISY,FHDL}, a time which also saw the birth of the currently popular hardware description languages such as VHDL.
450 \section{Hardware description in Haskell}
452 To translate Haskell to hardware, every Haskell construct needs a
453 translation to \VHDL. There are often multiple valid translations
454 possible. When faced with choices, the most obvious choice has been
455 chosen wherever possible. In a lot of cases, when a programmer looks
456 at a functional hardware description it is completely clear what
457 hardware is described. We want our translator to generate exactly that
458 hardware whenever possible, to make working with Cλash as intuitive as
461 \subsection{Function application}
462 The basic syntactic elements of a functional program are functions
463 and function application. These have a single obvious \VHDL\
464 translation: each top level function becomes a hardware component,
465 where each argument is an input port and the result value is the
466 (single) output port. This output port can have a complex type (such
467 as a tuple), so having just a single output port does not pose a
470 Each function application in turn becomes component instantiation.
471 Here, the result of each argument expression is assigned to a
472 signal, which is mapped to the corresponding input port. The output
473 port of the function is also mapped to a signal, which is used as
474 the result of the application.
476 Since every top level function generates its own component, the
477 hierarchy of of function calls is reflected in the final \VHDL\
478 output as well, creating a hierarchical \VHDL\ description of the
479 hardware. This separation in different components makes the
480 resulting \VHDL\ output easier to read and debug.
483 Although describing components and connections allows us to describe
484 a lot of hardware designs already, there is an obvious thing
485 missing: choice. We need some way to be able to choose between
486 values based on another value. In Haskell, choice is achieved by
487 \hs{case} expressions, \hs{if} expressions, pattern matching and
490 However, to be able to describe our hardware in a more convenient
491 way, we also want to translate Haskell's choice mechanisms. The
492 easiest of these are of course case expressions (and \hs{if}
493 expressions, which can be very directly translated to \hs{case}
494 expressions). A \hs{case} expression can in turn simply be
495 translated to a conditional assignment, where the conditions use
496 equality comparisons against the constructors in the \hs{case}
499 A slightly more complex (but very powerful) form of choice is
500 pattern matching. A function can be defined in multiple clauses,
501 where each clause specifies a pattern. When the arguments match the
502 pattern, the corresponding clause will be used.
505 Translation of two most basic functional concepts has been
506 discussed: function application and choice. Before looking further
507 into less obvious concepts like higher-order expressions and
508 polymorphism, the possible types that can be used in hardware
509 descriptions will be discussed.
511 Some way is needed to translate every values used to its hardware
512 equivalents. In particular, this means a hardware equivalent for
513 every \emph{type} used in a hardware description is needed
515 Since most functional languages have a lot of standard types that
516 are hard to translate (integers without a fixed size, lists without
517 a static length, etc.), a number of \quote{built-in} types will be
518 defined first. These types are built-in in the sense that our
519 compiler will have a fixed VHDL type for these. User defined types,
520 on the other hand, will have their hardware type derived directly
521 from their Haskell declaration automatically, according to the rules
524 \subsection{Built-in types}
525 The language currently supports the following built-in types. Of these,
526 only the \hs{Bool} type is supported by Haskell out of the box (the
527 others are defined by the Cλash package, so they are user-defined types
528 from Haskell's point of view).
532 This is the most basic type available. It is mapped directly onto
533 the \texttt{std\_logic} \VHDL\ type. Mapping this to the
534 \texttt{bit} type might make more sense (since the Haskell version
535 only has two values), but using \texttt{std\_logic} is more standard
536 (and allowed for some experimentation with don't care values)
539 This is the only built-in Haskell type supported and is translated
540 exactly like the Bit type (where a value of \hs{True} corresponds to a
541 value of \hs{High}). Supporting the Bool type is particularly
542 useful to support \hs{if ... then ... else ...} expressions, which
543 always have a \hs{Bool} value for the condition.
545 A \hs{Bool} is translated to a \texttt{std\_logic}, just like \hs{Bit}.
546 \item[\hs{SizedWord}, \hs{SizedInt}]
547 These are types to represent integers. A \hs{SizedWord} is unsigned,
548 while a \hs{SizedInt} is signed. These types are parametrized by a
549 length type, so you can define an unsigned word of 32 bits wide as
553 type Word32 = SizedWord D32
556 Here, a type synonym \hs{Word32} is defined that is equal to the
557 \hs{SizedWord} type constructor applied to the type \hs{D32}. \hs{D32}
558 is the \emph{type level representation} of the decimal number 32,
559 making the \hs{Word32} type a 32-bit unsigned word.
561 These types are translated to the \small{VHDL} \texttt{unsigned} and
562 \texttt{signed} respectively.
564 This is a vector type, that can contain elements of any other type and
565 has a fixed length. It has two type parameters: its
566 length and the type of the elements contained in it. By putting the
567 length parameter in the type, the length of a vector can be determined
568 at compile time, instead of only at run-time for conventional lists.
570 The \hs{Vector} type constructor takes two type arguments: the length
571 of the vector and the type of the elements contained in it. The state
572 type of an 8 element register bank would then for example be:
575 type RegisterState = Vector D8 Word32
578 Here, a type synonym \hs{RegisterState} is defined that is equal to
579 the \hs{Vector} type constructor applied to the types \hs{D8} (The type
580 level representation of the decimal number 8) and \hs{Word32} (The 32
581 bit word type as defined above). In other words, the
582 \hs{RegisterState} type is a vector of 8 32-bit words.
584 A fixed size vector is translated to a \VHDL\ array type.
585 \item[\hs{RangedWord}]
586 This is another type to describe integers, but unlike the previous
587 two it has no specific bit-width, but an upper bound. This means that
588 its range is not limited to powers of two, but can be any number.
589 A \hs{RangedWord} only has an upper bound, its lower bound is
590 implicitly zero. There is a lot of added implementation complexity
591 when adding a lower bound and having just an upper bound was enough
592 for the primary purpose of this type: type-safely indexing vectors.
594 To define an index for the 8 element vector above, we would do:
597 type RegisterIndex = RangedWord D7
600 Here, a type synonym \hs{RegisterIndex} is defined that is equal to
601 the \hs{RangedWord} type constructor applied to the type \hs{D7}. In
602 other words, this defines an unsigned word with values from
603 0 to 7 (inclusive). This word can be be used to index the
604 8 element vector \hs{RegisterState} above.
606 This type is translated to the \texttt{unsigned} \VHDL type.
608 \subsection{User-defined types}
609 There are three ways to define new types in Haskell: algebraic
610 data-types with the \hs{data} keyword, type synonyms with the \hs{type}
611 keyword and type renamings with the \hs{newtype} keyword. \GHC\
612 offers a few more advanced ways to introduce types (type families,
613 existential typing, \small{GADT}s, etc.) which are not standard
614 Haskell. These will be left outside the scope of this research.
616 Only an algebraic datatype declaration actually introduces a
617 completely new type, for which we provide the \VHDL\ translation
618 below. Type synonyms and renamings only define new names for
619 existing types (where synonyms are completely interchangeable and
620 renamings need explicit conversion). Therefore, these do not need
621 any particular \VHDL\ translation, a synonym or renamed type will
622 just use the same representation as the original type. The
623 distinction between a renaming and a synonym does no longer matter
624 in hardware and can be disregarded in the generated \VHDL.
626 For algebraic types, we can make the following distinction:
631 A product type is an algebraic datatype with a single constructor with
632 two or more fields, denoted in practice like (a,b), (a,b,c), etc. This
633 is essentially a way to pack a few values together in a record-like
634 structure. In fact, the built-in tuple types are just algebraic product
635 types (and are thus supported in exactly the same way).
637 The ``product'' in its name refers to the collection of values belonging
638 to this type. The collection for a product type is the Cartesian
639 product of the collections for the types of its fields.
641 These types are translated to \VHDL\ record types, with one field for
642 every field in the constructor. This translation applies to all single
643 constructor algebraic data-types, including those with just one
644 field (which are technically not a product, but generate a VHDL
645 record for implementation simplicity).
646 \item[Enumerated types]
647 An enumerated type is an algebraic datatype with multiple constructors, but
648 none of them have fields. This is essentially a way to get an
649 enumeration-like type containing alternatives.
651 Note that Haskell's \hs{Bool} type is also defined as an
652 enumeration type, but we have a fixed translation for that.
654 These types are translated to \VHDL\ enumerations, with one value for
655 each constructor. This allows references to these constructors to be
656 translated to the corresponding enumeration value.
658 A sum type is an algebraic datatype with multiple constructors, where
659 the constructors have one or more fields. Technically, a type with
660 more than one field per constructor is a sum of products type, but
661 for our purposes this distinction does not really make a
662 difference, so this distinction is note made.
664 The ``sum'' in its name refers again to the collection of values
665 belonging to this type. The collection for a sum type is the
666 union of the the collections for each of the constructors.
668 Sum types are currently not supported by the prototype, since there is
669 no obvious \VHDL\ alternative. They can easily be emulated, however, as
670 we will see from an example:
673 data Sum = A Bit Word | B Word
676 An obvious way to translate this would be to create an enumeration to
677 distinguish the constructors and then create a big record that
678 contains all the fields of all the constructors. This is the same
679 translation that would result from the following enumeration and
680 product type (using a tuple for clarity):
684 type Sum = (SumC, Bit, Word, Word)
687 Here, the \hs{SumC} type effectively signals which of the latter three
688 fields of the \hs{Sum} type are valid (the first two if \hs{A}, the
689 last one if \hs{B}), all the other ones have no useful value.
691 An obvious problem with this naive approach is the space usage: the
692 example above generates a fairly big \VHDL\ type. Since we can be
693 sure that the two \hs{Word}s in the \hs{Sum} type will never be valid
694 at the same time, this is a waste of space.
696 Obviously, duplication detection could be used to reuse a
697 particular field for another constructor, but this would only
698 partially solve the problem. If two fields would be, for
699 example, an array of 8 bits and an 8 bit unsigned word, these are
700 different types and could not be shared. However, in the final
701 hardware, both of these types would simply be 8 bit connections,
702 so we have a 100\% size increase by not sharing these.
706 \section{C$\lambda$ash prototype}
710 \section{Related work}
711 Many functional hardware description languages have been developed over the years. Early work includes such languages as $\mu$FP~\cite{muFP}, an extension of Backus' FP language to synchronous streams, designed particularly for describing and reasoning about regular circuits. The Ruby~\cite{Ruby} language uses relations, instead of functions, to describe circuits, and has a particular focus on layout. HML~\cite{HML2} is a hardware modeling language based on the strict functional language ML, and has support for polymorphic types and higher-order functions. Published work suggests that there is no direct simulation support for HML, and that the translation to VHDL is only partial.
713 Like this work, many functional hardware description languages have some sort of foundation in the functional programming language Haskell. Hawk~\cite{Hawk1} uses Haskell to describe system-level executable specifications used to model the behavior of superscalar microprocessors. Hawk specifications can be simulated, but there seems to be no support for automated circuit synthesis. The ForSyDe~\cite{ForSyDe2} system uses Haskell to specify abstract system models, which can (manually) be transformed into an implementation model using semantic preserving transformations. ForSyDe has several simulation and synthesis backends, though synthesis is restricted to the synchronous subset of the ForSyDe language.
715 Lava~\cite{Lava} is a hardware description language that focuses on the structural representation of hardware. Besides support for simulation and circuit synthesis, Lava descriptions can be interfaced with formal method tools for formal verification. Lava descriptions are actually circuit generators when viewed from a synthesis viewpoint, in that the language elements of Haskell, such as choice, can be used to guide the circuit generation. If a developer wants to insert a choice element inside an actual circuit he will have to specify this explicitly as a component. In this respect C$\lambda$aSH differs from Lava, in that all the choice elements, such as case-statements and patter matching, are synthesized to choice elements in the eventual circuit. As such, richer control structures can both be specified and synthesized in C$\lambda$aSH compared to any of the languages mentioned in this section.
717 The merits of polymorphic typing, combined with higher-order functions, are now also recognized in the `main-stream' hardware description languages, exemplified by the new VHDL 2008 standard~\cite{VHDL2008}. VHDL-2008 has support to specify types as generics, thus allowing a developer to describe polymorphic components. Note that those types still require an explicit generic map, whereas type-inference and type-specialization are implicit in C$\lambda$aSH.
719 Wired~\cite{Wired},, T-Ruby~\cite{T-Ruby}, Hydra~\cite{Hydra}.
721 A functional language designed specifically for hardware design is $re{\mathit{FL}}^{ect}$~\cite{reFLect}, which draws experience from earlier language called FL~\cite{FL} to la
723 % An example of a floating figure using the graphicx package.
724 % Note that \label must occur AFTER (or within) \caption.
725 % For figures, \caption should occur after the \includegraphics.
726 % Note that IEEEtran v1.7 and later has special internal code that
727 % is designed to preserve the operation of \label within \caption
728 % even when the captionsoff option is in effect. However, because
729 % of issues like this, it may be the safest practice to put all your
730 % \label just after \caption rather than within \caption{}.
732 % Reminder: the "draftcls" or "draftclsnofoot", not "draft", class
733 % option should be used if it is desired that the figures are to be
734 % displayed while in draft mode.
738 %\includegraphics[width=2.5in]{myfigure}
739 % where an .eps filename suffix will be assumed under latex,
740 % and a .pdf suffix will be assumed for pdflatex; or what has been declared
741 % via \DeclareGraphicsExtensions.
742 %\caption{Simulation Results}
746 % Note that IEEE typically puts floats only at the top, even when this
747 % results in a large percentage of a column being occupied by floats.
750 % An example of a double column floating figure using two subfigures.
751 % (The subfig.sty package must be loaded for this to work.)
752 % The subfigure \label commands are set within each subfloat command, the
753 % \label for the overall figure must come after \caption.
754 % \hfil must be used as a separator to get equal spacing.
755 % The subfigure.sty package works much the same way, except \subfigure is
756 % used instead of \subfloat.
759 %\centerline{\subfloat[Case I]\includegraphics[width=2.5in]{subfigcase1}%
760 %\label{fig_first_case}}
762 %\subfloat[Case II]{\includegraphics[width=2.5in]{subfigcase2}%
763 %\label{fig_second_case}}}
764 %\caption{Simulation results}
768 % Note that often IEEE papers with subfigures do not employ subfigure
769 % captions (using the optional argument to \subfloat), but instead will
770 % reference/describe all of them (a), (b), etc., within the main caption.
773 % An example of a floating table. Note that, for IEEE style tables, the
774 % \caption command should come BEFORE the table. Table text will default to
775 % \footnotesize as IEEE normally uses this smaller font for tables.
776 % The \label must come after \caption as always.
779 %% increase table row spacing, adjust to taste
780 %\renewcommand{\arraystretch}{1.3}
781 % if using array.sty, it might be a good idea to tweak the value of
782 % \extrarowheight as needed to properly center the text within the cells
783 %\caption{An Example of a Table}
784 %\label{table_example}
786 %% Some packages, such as MDW tools, offer better commands for making tables
787 %% than the plain LaTeX2e tabular which is used here.
788 %\begin{tabular}{|c||c|}
798 % Note that IEEE does not put floats in the very first column - or typically
799 % anywhere on the first page for that matter. Also, in-text middle ("here")
800 % positioning is not used. Most IEEE journals/conferences use top floats
801 % exclusively. Note that, LaTeX2e, unlike IEEE journals/conferences, places
802 % footnotes above bottom floats. This can be corrected via the \fnbelowfloat
803 % command of the stfloats package.
808 The conclusion goes here.
813 % conference papers do not normally have an appendix
816 % use section* for acknowledgement
817 \section*{Acknowledgment}
820 The authors would like to thank...
826 % trigger a \newpage just before the given reference
827 % number - used to balance the columns on the last page
828 % adjust value as needed - may need to be readjusted if
829 % the document is modified later
830 %\IEEEtriggeratref{8}
831 % The "triggered" command can be changed if desired:
832 %\IEEEtriggercmd{\enlargethispage{-5in}}
836 % can use a bibliography generated by BibTeX as a .bbl file
837 % BibTeX documentation can be easily obtained at:
838 % http://www.ctan.org/tex-archive/biblio/bibtex/contrib/doc/
839 % The IEEEtran BibTeX style support page is at:
840 % http://www.michaelshell.org/tex/ieeetran/bibtex/
841 \bibliographystyle{IEEEtran}
842 % argument is your BibTeX string definitions and bibliography database(s)
843 \bibliography{IEEEabrv,cλash.bib}
845 % <OR> manually copy in the resultant .bbl file
846 % set second argument of \begin to the number of references
847 % (used to reserve space for the reference number labels box)
848 % \begin{thebibliography}{1}
850 % \bibitem{IEEEhowto:kopka}
851 % H.~Kopka and P.~W. Daly, \emph{A Guide to \LaTeX}, 3rd~ed.\hskip 1em plus
852 % 0.5em minus 0.4em\relax Harlow, England: Addison-Wesley, 1999.
854 % \end{thebibliography}
862 % vim: set ai sw=2 sts=2 expandtab: