+
+ For an \small{EDSL}, the definitions of compiletime and runtime
+ are typically fuzzy (and thus hard to define here), since the
+ \small{EDSL} \quote{compiler} is usually compiled by the same
+ Haskell compiler as the \small{EDSL} program itself.
+ \stopframedtext
+ }
+
+ An obvious question that arises when starting any research is \quote{Has
+ this not been done before?}. Using a functional language for describing hardware
+ is not a new idea at all. In fact, there has been research into functional
+ hardware description even before the conventional hardware description
+ languages were created. Examples of these are µFP \cite[sheeran83] and
+ Ruby \cite[jones90]. Functional languages were not nearly as advanced
+ as they are now, and functional hardware description never really got
+ off.
+
+ Recently, there have been some renewed efforts, especially using the
+ Haskell functional language. Examples are Lava \cite[claessen00] (an
+ \small{EDSL}) and ForSyde \cite[sander04] (an \small{EDSL} using
+ Template Haskell). \cite[baaij09] has a more complete overview of the
+ current field.
+
+ We will now have a look at the existing hardware description languages,
+ both conventional and functional to see the fields in which Cλash is
+ operating.
+
+ \section{Conventional hardware description languages}
+ Considering that we already have some hardware description languages like
+ \small{VHDL} and Verilog, why would we need anything else? By introducing
+ the functional style to hardware description, we hope to obtain a hardware
+ description language that is:
+ \startitemize
+ \item More concise. Functional programs are known for their conciseness
+ and ability to provide reusable functions that are abstractions of
+ common patterns. This is largely enabled by features like an
+ advanced type system with polymorphism and higher-order functions.
+ \item Type-safer. Functional programs typically have a highly
+ expressive type system, which allows a programmer to more strictly
+ define limitations on values, making it easier to find violations
+ and thus bugs.
+ \item Easy to process. Functional languages have nice properties like
+ purity \refdef{purity} and single binding behaviour, which make it easy
+ to apply program transformations and optimizations and could potentially
+ simplify program verification.
+ \stopitemize
+
+ \placeintermezzo{}{
+ \defref{Template Haskell}
+ \startframedtext[width=8.5cm,background=box,frame=no]
+ \startalignment[center]
+ {\tfa Template Haskell}
+ \stopalignment
+ \blank[medium]
+
+ Template Haskell is an extension to the \GHC compiler that allows
+ a program to mark some parts to be evaluated \emph{at compile
+ time}. These \emph{templates} can then access the abstract syntax
+ tree (\small{AST}) of the program that is being compiled and
+ generate parts of this \small{AST}.
+
+ Template Haskell is a very powerful, but also complex mechanism.
+ It was inteded to simplify the generation of some repetive pieces
+ of code, but its introspection features have inspired all sorts of
+ applications, such as hardware description compilers.