From: Matthijs Kooijman Date: Thu, 10 Dec 2009 11:28:25 +0000 (+0100) Subject: Add presentation so far. X-Git-Url: https://git.stderr.nl/gitweb?p=matthijs%2Fmaster-project%2Ffinal-presentation.git;a=commitdiff_plain;h=d0420235340ee715db69a023bf0f6ad75d573735 Add presentation so far. --- diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..79b8aac --- /dev/null +++ b/Makefile @@ -0,0 +1,49 @@ +FILE = clash-haskell09 +LHS2TEX = lhs2TeX -v --poly --haskell +LATEXMK = latexmk -pdf +RM = rm -f +RSVG = rsvg-convert --format=pdf + +LHSRCS = \ + introduction.lhs \ + matthijs/introduction.lhs \ + christiaan/introduction.lhs + +LHFORMATS = \ + talk.fmt + +TEXSRCS = \ + preamble.tex + +SVGFIGURES = \ + mealymachine2.svg \ + mealymachine2-func-red.svg \ + mealymachine2-state-red.svg \ + reducer.svg \ + figures/schakelingen/CMOS_NAND_Layout.svg + +default: clash-haskell09 + +clash-haskell09: texs figs $(TEXSRCS) $(LHFORMATS) + $(LHS2TEX) $(FILE).lhs > $(FILE).tex; \ + $(LATEXMK) $(FILE); \ + open $(FILE).pdf; \ + $(RM) $(LHSRCS:.lhs=.tex) + +texs : $(LHSRCS:.lhs=.tex) +%.tex : %.lhs + $(LHS2TEX) $< > $@ + +figs : $(SVGFIGURES:.svg=.pdf) +%.pdf : %.svg + $(RSVG) $< > $@ + +clean: + latexmk -CA clash-haskell09 + $(RM) $(SVGFIGURES:.svg=.pdf) + $(RM) $(FILE).tex + $(RM) $(FILE).ptb + $(RM) $(FILE).synctex.gz + $(RM) $(FILE).nav + $(RM) $(FILE).snm + $(RM) *.hi *.o *.aux diff --git a/PolyAlu b/PolyAlu new file mode 100755 index 0000000..f75d928 Binary files /dev/null and b/PolyAlu differ diff --git a/PolyAlu.hs b/PolyAlu.hs new file mode 100644 index 0000000..1cb8579 --- /dev/null +++ b/PolyAlu.hs @@ -0,0 +1,70 @@ +{-# LINE 4 "PolyAlu.lhs" #-} +{-# LANGUAGE TypeOperators, TypeFamilies, FlexibleContexts #-} +module Main where + +import CLasH.HardwareTypes +import CLasH.Translator.Annotations +import qualified Prelude as P +{-# LINE 52 "PolyAlu.lhs" #-} +type Op a = a -> a -> a +type Opcode = Bit +{-# LINE 60 "PolyAlu.lhs" #-} +type RegBank s a = + Vector s a +type RegState s a = + State (RegBank s a) +{-# LINE 68 "PolyAlu.lhs" #-} +type Word = SizedInt D12 +{-# LINE 88 "PolyAlu.lhs" #-} +alu :: + Op a -> Op a -> + Opcode -> a -> a -> a +alu op1 op2 Low x y = op1 x y +alu op1 op2 High x y = op2 x y +{-# LINE 110 "PolyAlu.lhs" #-} +registers :: + ((PositiveT s ,NaturalT (s :-: D1), (s :>: (s :-: D1)) ~ True )) => a -> RangedWord (s :-: D1) -> + RangedWord (s :-: D1) -> (RegState s a) -> (RegState s a, a ) +{-# LINE 118 "PolyAlu.lhs" #-} +registers data_in rdaddr wraddr (State mem) = + (State mem', data_out) + where + data_out = mem!rdaddr + mem' = replace mem wraddr data_in +{-# LINE 138 "PolyAlu.lhs" #-} +type Instruction = (Opcode, Word, RangedWord D8, RangedWord D8) +{-# LINE 142 "PolyAlu.lhs" #-} +{-# ANN cpu TopEntity#-} +cpu :: + Instruction -> RegState D9 Word -> (RegState D9 Word, Word) + +cpu (opc, d, rdaddr, wraddr) ram = (ram', alu_out) + where + alu_out = alu (+) (-) opc d ram_out + (ram',ram_out) = registers alu_out rdaddr wraddr ram +{-# LINE 165 "PolyAlu.lhs" #-} +{-# ANN initstate InitState#-} +initstate :: RegState D9 Word +initstate = State (copy (0 :: Word)) + +{-# ANN program TestInput#-} +program :: [Instruction] +program = + [ (Low, 4, 0, 0) -- Write 4 to Reg0 + , (Low, 3, 0, 1) -- Write 3+4 to Reg1 + , (High,8, 1, 2) -- Write 8-7 to Reg2 + ] + +run func state [] = [] +run func state (i:input) = o:out + where + (state', o) = func i state + out = run func state' input + +main :: IO () +main = do + let input = program + let istate = initstate + let output = run cpu istate input + mapM_ (\x -> putStr $ ("(" P.++ (show x) P.++ ")\n")) output + return () diff --git a/PolyAlu.lhs b/PolyAlu.lhs new file mode 100644 index 0000000..1379407 --- /dev/null +++ b/PolyAlu.lhs @@ -0,0 +1,192 @@ +%include talk.fmt +%if style == newcode +\begin{code} +{-# LANGUAGE TypeOperators, TypeFamilies, FlexibleContexts #-} +module Main where + +import CLasH.HardwareTypes +import CLasH.Translator.Annotations +import qualified Prelude as P +\end{code} +%endif + +\section{Polymorphic, Higher-Order CPU} +\subsection{Introduction} +\frame +{ +\frametitle{Small Use Case} +\begin{columns}[l] +\column{0.5\textwidth} +\begin{figure} +\includegraphics[width=4.75cm]{simpleCPU} +\end{figure} +\column{0.5\textwidth} +\vspace{5em} +\begin{itemize} + \item Polymorphic, Higher-Order CPU + \item Use of state will be simple +\end{itemize} +\end{columns} +}\note[itemize]{ +\item Small "toy"-example of what can be done in \clash{} +\item Show what can be translated to Hardware +\item Put your hardware glasses on: each function will be a component +\item Use of state will be kept simple +} + +\subsection{Type Definitions} +\frame +{ +\frametitle{Type definitions}\pause +\begin{columns}[l] +\column{0.5\textwidth} +\begin{figure} +\includegraphics[width=4.75cm]{simpleCPU} +\end{figure} +\column{0.5\textwidth} +\vspace{2em} + +First we define some ALU types: +\begin{beamercolorbox}[sep=-2.5ex,rounded=true,shadow=true,vmode]{codebox} +\begin{code} +type Op a = a -> a -> a +type Opcode = Bit +\end{code} +\end{beamercolorbox}\pause +\vspace{1em} +And some Register types: +\begin{beamercolorbox}[sep=-2.5ex,rounded=true,shadow=true,vmode]{codebox} +\begin{code} +type RegBank s a = + Vector s a +type RegState s a = + State (RegBank s a) +\end{code} +\end{beamercolorbox} +%if style == newcode +\begin{code} +type Word = SizedInt D12 +\end{code} +%endif +\end{columns} +}\note[itemize]{ +\item The ALU operation is already polymorphic in input / output type +\item We use a fixed size vector as the placeholder for the registers +\item State has to be of the State type to be recognized as such +} + +\subsection{Polymorphic, Higher-Order ALU} +\frame +{ +\frametitle{Simple ALU} +\begin{figure} +\includegraphics[width=5.25cm,trim=0mm 5.5cm 0mm 1cm, clip=true]{simpleCPU} +\end{figure} +Abstract ALU definition: +\begin{beamercolorbox}[sep=-2.5ex,rounded=true,shadow=true,vmode]{codebox} +\begin{code} +alu :: + Op a -> Op a -> + Opcode -> a -> a -> a +alu op1 op2 {-"{\color<2>[rgb]{1,0,0}"-}Low{-"}"-} x y = op1 x y +alu op1 op2 {-"{\color<2>[rgb]{1,0,0}"-}High{-"}"-} x y = op2 x y +\end{code} +\end{beamercolorbox} +}\note[itemize]{ +\item Alu is both higher-order, and polymorphic +\item First two parameters are "compile time", other three are "runtime" +\item We support pattern matching +} + +\subsection{Register bank} +\frame +{ +\frametitle{Register Bank} +\begin{figure} +\includegraphics[width=5.25cm,trim=0mm 0.4cm 0mm 6.2cm, clip=true]{simpleCPU} +\end{figure} +%if style == newcode +\begin{code} +registers :: + CXT((PositiveT s ,NaturalT (s :-: D1), (s :>: (s :-: D1)) ~ True )) => a -> RangedWord (s :-: D1) -> + RangedWord (s :-: D1) -> (RegState s a) -> (RegState s a, a ) +\end{code} +%endif +A simple register bank: +\begin{beamercolorbox}[sep=-2.5ex,rounded=true,shadow=true,vmode]{codebox} +\begin{code} +registers data_in rdaddr wraddr (State mem) = + (State mem', data_out) + where + data_out = mem!rdaddr + mem' = replace mem wraddr data_in +\end{code} +\end{beamercolorbox} +}\note[itemize]{ +\item mem is statefull, indicated by the 'State' type +\item replace and (!) are a builtin functions, (!) is vector equiv of (!!) for lists +} + +\subsection{Simple CPU: ALU \& Register Bank} +\frame +{ +\frametitle{Simple CPU} +Combining ALU and register bank: +\begin{beamercolorbox}[sep=-2.5ex,rounded=true,shadow=true,vmode]{codebox} +%if style == newcode +\begin{code} +type Instruction = (Opcode, Word, RangedWord D9, RangedWord D9) +\end{code} +%endif +\begin{code} +{-"{\color<2>[rgb]{1,0,0}"-}ANN(cpu TopEntity){-"}"-} +cpu :: + Instruction -> RegState D10 Word -> + (RegState D10 Word, Word) +cpu (opc, d, rdaddr, wraddr) ram = (ram', alu_out) + where + alu_out = alu {-"{\color<3>[rgb]{1,0,0}"-}(+){-"}"-} {-"{\color<3>[rgb]{1,0,0}"-}(-){-"}"-} opc d ram_out + (ram',ram_out) = registers alu_out rdaddr wraddr ram +\end{code} +\end{beamercolorbox} +\begin{itemize} +\uncover<2->{\item Annotation is used to indicate top-level component} +\uncover<3->{\item Instantiate actual operations} +\end{itemize} +}\note[itemize]{ +\item We use the new Annotion functionality to indicate this is the top level. TopEntity is defined by us. +\item At this stage, both operations for the ALU are defined +\item No polymorphism or higher-order stuff is allowed at this level. +\item Functions must be specialized, and have primitives for input and output +\item D10 is a type-level number, beyond the scope of this presentation +} + +%if style == newcode +\begin{code} +ANN(initstate InitState) +initstate :: RegState D10 Word +initstate = State (copy (0 :: Word)) + +ANN(program TestInput) +program :: [Instruction] +program = + [ (Low, 4, 0, 0) -- Write 4 to Reg0 + , (Low, 3, 0, 1) -- Write 3+4 to Reg1 + , (High,8, 1, 2) -- Write 8-7 to Reg2 + ] + +run func state [] = [] +run func state (i:input) = o:out + where + (state', o) = func i state + out = run func state' input + +main :: IO () +main = do + let input = program + let istate = initstate + let output = run cpu istate input + mapM_ (\x -> putStr $ ("(" P.++ (show x) P.++ ")\n")) output + return () +\end{code} +%endif diff --git a/beamercolorthemecaes.sty b/beamercolorthemecaes.sty new file mode 100644 index 0000000..48617c5 --- /dev/null +++ b/beamercolorthemecaes.sty @@ -0,0 +1,42 @@ +%% +%% beamercolorthemecaes.sty +%% +%% Copyright (C) 2008 CAES (http://caes.ewi.utwente.nl) +%% +%% Authors : Pascal Wolkotte +%% Created On : March 13 2008 +%% +%% $Author: wolkottept $ +%% $Date: 2008-03-19 09:39:34 +0100 (Wed, 19 Mar 2008) $ +%% $Revision: 40 $ +%% $HeadURL: https://ewi630/svn/general/templates/caes/trunk/beamercolorthemecaes.sty $ +%% + +\mode + +\definecolor{ut_orange}{rgb}{1,.4,.2} +\definecolor{ut_blue}{rgb}{0,0,.4} +\definecolor{ut_lightblue}{rgb}{0.5,0.5,.7} +\definecolor{ut_green}{rgb}{0,.8,0} + +\setbeamercolor{normal text}{fg=ut_blue,bg=white} +\setbeamercolor{alerted text}{fg=ut_orange} +\setbeamercolor{example text}{fg=ut_green} + +\setbeamercolor{structure}{fg=ut_blue} +\setbeamercolor{institute}{fg=ut_lightblue} + +\setbeamercolor{titlelike}{parent=structure} + +\setbeamercolor{frametitle}{parent=titlelike} +\setbeamercolor{framesubtitle}{parent=frametitle} + +\setbeamercolor{itemize item}{fg=ut_orange} +\setbeamercolor{itemize subitem}{fg=ut_green} +\setbeamercolor{itemize subsubitem}{fg=ut_blue} + +\colorlet{ut_light}{ut_blue!10!white} +\setbeamercolor{codebox}{bg=ut_light,fg=ut_blue} + +\mode + diff --git a/beamerfontthemecaes.sty b/beamerfontthemecaes.sty new file mode 100644 index 0000000..c39300d --- /dev/null +++ b/beamerfontthemecaes.sty @@ -0,0 +1,30 @@ +%% +%% beamerfontthemecaes.sty +%% +%% Copyright (C) 2008 CAES (http://caes.ewi.utwente.nl) +%% +%% Authors : Pascal Wolkotte +%% Created On : March 13 2008 +%% +%% $Author: wolkottept $ +%% $Date: 2008-03-13 09:41:28 +0100 (Thu, 13 Mar 2008) $ +%% $Revision: 36 $ +%% $HeadURL: https://svncaes/svn/general/templates/caes/trunk/beamerfontthemecaes.sty $ +%% + +\mode + +\setbeamerfont{item}{size=\large,parent=structure} +\setbeamerfont{subitem}{size=\small,parent=item} +\setbeamerfont{subsubitem}{size=\scriptsize,parent=subitem} + +\setbeamerfont{itemize item}{parent=item} +\setbeamerfont{itemize subitem}{parent=subitem} +\setbeamerfont{itemize subsubitem}{parent=subsubitem} + +\setbeamerfont{itemize/enumerate body}{size=\large} +\setbeamerfont{itemize/enumerate subbody}{size=\small} +\setbeamerfont{itemize/enumerate subsubbody}{size=\scriptsize} + +\mode + diff --git a/beamerinnerthemecaes.sty b/beamerinnerthemecaes.sty new file mode 100644 index 0000000..a9d495b --- /dev/null +++ b/beamerinnerthemecaes.sty @@ -0,0 +1,92 @@ +%% +%% beamerinnerthemecaes.sty +%% +%% Copyright (C) 2008 CAES (http://caes.ewi.utwente.nl) +%% +%% Authors : Pascal Wolkotte +%% Created On : March 13 2008 +%% +%% $Author: wolkottept $ +%% $Date: 2008-03-19 10:33:08 +0100 (Wed, 19 Mar 2008) $ +%% $Revision: 41 $ +%% $HeadURL: https://ewi630/svn/general/templates/caes/trunk/beamerinnerthemecaes.sty $ +%% + +\mode + +\setbeamertemplate{sections/subsections in toc}[square] + +\setbeamertemplate{items}[square] +\setbeamertemplate{itemize item}{\hbox{\vrule width 1.2ex height 1.2ex}} +\setbeamertemplate{itemize subitem}{\hbox{\vrule width 1ex height 1ex}} +\setbeamertemplate{itemize subsubitem}{\hbox{\vrule width .8ex height .8ex}} + +\addtolength{\leftmargini}{-.4\labelwidth} +\addtolength{\leftmarginii}{-.5\labelwidth} +\addtolength{\leftmarginiii}{-.6\labelwidth} + +%\pgfdeclareimage[interpolate=true, height=.1\paperheight]{ctit_logo}{ctit_logo} + +\makeatletter + +% +% +% The \committee command +% +% +\def\committee{\@dblarg\beamer@committee} +\long\def\beamer@committee[#1]#2{% + \def\beamer@temp{#2}% + \ifx\beamer@temp\@empty + \def\insertcommittee{} + \else + \def\insertcommittee{\def\inst{\beamer@committee}\def\and{\beamer@andcommittee}#2}% + \fi + \def\beamer@shortcommittee{#1}} +\committee{} + +\def\beamer@instcommittee#1{{\donotcoloroutermaths$^{#1}$}\ignorespaces} +\def\beamer@andcommittee{\\[1em]} + +\newcommand\insertshortcommittee[1][]{% + {% + \let\thanks=\@gobble% + \def\inst{\beamer@committeeother}\def\and{\beamer@andcommittee}% + \beamer@setupshort{#1}% + \beamer@insertshort{\beamer@shortcommittee}% + }} + + +\setbeamertemplate{title page} +{ + \begin{centering} + \vskip4em% + \begin{beamercolorbox}[sep=8pt,center]{title} + \usebeamerfont{title}\inserttitle\par% + \ifx\insertsubtitle\@empty% + \else% + \vskip0.25em% + {\usebeamerfont{subtitle}\usebeamercolor[fg]{subtitle}\insertsubtitle\par}% + \fi% + \end{beamercolorbox}% + \vskip.5em + \begin{beamercolorbox}[sep=8pt,center]{author} + \usebeamerfont{author}\insertauthor + \end{beamercolorbox}\vskip1em + % \begin{beamercolorbox}[sep=4pt,center]{date} + % \usebeamerfont{date}\insertcommittee + % \end{beamercolorbox} +% {\usebeamercolor[fg]{titlegraphic}\inserttitlegraphic\par} + \vfill% + \begin{tikzpicture} + \path[use as bounding box] (0,0) rectangle (\textwidth,1pt); +% \node[above left, inner sep=0pt] at (\textwidth,0) {\pgfuseimage{ctit_logo}}; + \end{tikzpicture} + \begin{beamercolorbox}[sep=8pt,center]{institute} + \usebeamerfont{institute}\insertinstitute + \end{beamercolorbox} + \end{centering} +} +\makeatother + +\mode diff --git a/beamerouterthemecaes.sty b/beamerouterthemecaes.sty new file mode 100644 index 0000000..f579437 --- /dev/null +++ b/beamerouterthemecaes.sty @@ -0,0 +1,241 @@ +%% +%% beamercolorthemecaes.sty +%% +%% Copyright (C) 2008 CAES (http://caes.ewi.utwente.nl) +%% +%% Authors : Pascal Wolkotte +%% Created On : March 13 2008 +%% +%% $Author: bakkerv $ +%% $Date: 2008-03-25 10:31:52 +0100 (Tue, 25 Mar 2008) $ +%% $Revision: 45 $ +%% $HeadURL: https://ewi630/svn/general/templates/caes/trunk/beamerouterthemecaes.sty $ +%% +\makeatletter + +\def\footlinetitle{title} +\def\beamer@theme@footline{title} +\DeclareOptionBeamer{footline}{\def\beamer@theme@footline{#1}} + +\newif\ifbeamer@theme@logoUT +\def\hidelogoUT{ \beamer@theme@logoUTfalse } +\def\showlogoUT{ \beamer@theme@logoUTtrue } +\showlogoUT + +\ProcessOptionsBeamer + +\usetikzlibrary{positioning} +\usetikzlibrary{fadings} + +\def\getcoordinates{ + \node[coordinate] (titlepos) at (.95\paperwidth,-.217\paperheight) {}; + \node[coordinate] (topleft) at (.05\paperwidth,-.225\paperheight) {}; + \node[coordinate] (TL) at (0,0) {}; + \node[coordinate] (BR) at (\paperwidth,-\textheight) {}; + \node[coordinate] (F1) at (.65\paperwidth,-.25\textheight) {}; + \node[coordinate] (F2) at (.95\paperwidth,-.5\textheight) {}; + \node[coordinate] (F1m) at (.35\paperwidth,-.25\textheight) {}; + \node[coordinate] (F2m) at (.05\paperwidth,-.5\textheight) {}; +} + +% -- Shading function. From 0 - 50 no transparency and from 50 - 100 transparency +\pgfdeclarehorizontalshading{shading}{100bp}{ color(0bp)=(transparent!0); color(25bp)=(transparent!0); color(60bp)=(transparent!0); color(75bp)=(transparent!100); color(100bp)=(transparent!100)} +\pgfdeclarefading{fading}{\pgfuseshading{shading}} +\def\placehorzfading#1{ + \pgfpathrectangle{\pgfpointorigin}{\pgfpoint{#1}{-\paperheight}} + \pgfsetfadingforcurrentpath{fading}{} + \pgfusepath{discard} +} +\pgfdeclarefading{LRfading}{ +\begin{tikzpicture}[line width=0pt] + \getcoordinates + \fill[pgftransparent!0] (TL -| F1m) rectangle (BR -| F1); + \shade[left color=pgftransparent!0, right color=pgftransparent!100] (TL -| F1) rectangle (BR -| F2); + \shade[right color=pgftransparent!0, left color=pgftransparent!100] (TL -| F2m) rectangle (BR -| F1m); +\end{tikzpicture} +} +\pgfdeclarefading{BRfading}{ +\begin{tikzpicture}[line width=0pt] + \getcoordinates + \fill[pgftransparent!0] (TL) rectangle (F1); + \begin{scope} + \path[clip] (F1) -- (F2) -- (BR) |- (TL) -- cycle; + \shade[left color=pgftransparent!0, right color=pgftransparent!100] (TL -| F1) rectangle (BR -| F2); + \end{scope} + \begin{scope} + \path[clip] (F1) -- (F2) -- (BR) -| (TL) -- cycle; + \shade[top color=pgftransparent!0, bottom color=pgftransparent!100] (TL |- F1) rectangle (BR |- F2); + \end{scope} +\end{tikzpicture} +} + +\mode + +% -- Headline and footline -- +\pgfdeclareimage[interpolate=true, height=.1\paperheight]{ut_logo}{ut_logo_blue} + +% -- HEADER -- + +%Select the correct logo + +\defbeamertemplate{headline}{empty}{% + \begin{tikzpicture} + \path[use as bounding box] (0,0) rectangle (\paperwidth,-.11\paperheight); + \end{tikzpicture} +} +\def\UTheadline{ + \begin{scope} + \placehorzfading{.95\paperwidth} + \node[fill=ut_blue, line width=0pt, minimum height=.033\paperheight, minimum width=.95\paperwidth, anchor=north west] (bart) at (0,0) {}; + \placehorzfading{.8\paperwidth} + \node[fill=ut_orange,line width=0pt, minimum height=.043\paperheight, minimum width=.8\paperwidth, below=0pt of bart.south west, anchor=north west] (barm) {}; + \placehorzfading{.675\paperwidth} + \node[fill=ut_lightblue, line width=0pt, minimum height=.032\paperheight, minimum width=.675\paperwidth, below=0pt of barm.south west, anchor=north west] (barb) {}; + \end{scope} + \ifbeamer@theme@logoUT + \path (\paperwidth,-.11\paperheight) node[above left=0pt and 3pt, line width=0pt,inner sep=0pt] {\pgfuseimage{ut_logo}}; + \fi +} +\pgfdeclareimage[interpolate=true, height=.1\paperheight]{logoNWchameleonA}{chameleonA} +\pgfdeclareimage[interpolate=true, height=.14\paperheight]{logoNWchameleonB}{chameleonB} +\pgfdeclareimage[interpolate=true, height=0.55\paperheight]{logoPoles}{poles_shaded} +\pgfdeclareimage[interpolate=true, height=0.14\paperheight]{logoSloth}{sloth} + +\defbeamertemplate*{headline}{chameleonA theme}{% + \begin{tikzpicture} + \getcoordinates + \path[use as bounding box] (0,0) rectangle (\paperwidth,-.11\paperheight); + \UTheadline + \path (0,-.12\paperheight) node[above right=0pt, line width=0pt,inner sep=0pt] {\pgfuseimage{logoNWchameleonA}}; + \end{tikzpicture} +} +\defbeamertemplate{headline}{chameleonB theme}{% + \begin{tikzpicture} + \getcoordinates + \path[use as bounding box] (0,0) rectangle (\paperwidth,-.11\paperheight); + \UTheadline + \path (-10pt,-.16\paperheight) node[above right=0pt, line width=0pt,inner sep=0pt] {\pgfuseimage{logoNWchameleonB}}; + \end{tikzpicture} +} +\defbeamertemplate{headline}{energy theme}{% + \begin{tikzpicture} + \getcoordinates + \path[use as bounding box] (0,0) rectangle (\paperwidth,-.11\paperheight); + \UTheadline + \path (-3.2pt,-.16\paperheight) node[above right=0pt, line width=0pt,inner sep=0pt] {\pgfuseimage{logoSloth}}; + \end{tikzpicture} +} + +\defbeamertemplate{headline}{caes theme}{% + \begin{tikzpicture} + \getcoordinates + \path[use as bounding box] (0,0) rectangle (\paperwidth,-.11\paperheight); + \UTheadline + \end{tikzpicture} +} + +% -- FOOTER -- +\defbeamertemplate{footline}{empty}{% + \leavevmode% + \begin{tikzpicture}[remember picture] + \path[clip,use as bounding box] (0,0) rectangle (\paperwidth,-.08\paperheight); + \end{tikzpicture} +} +\defbeamertemplate*{footline}{caes theme}{% + \leavevmode% + \begin{tikzpicture}[remember picture] + \path[clip,use as bounding box] (0,0) rectangle (\paperwidth,-.08\paperheight); + \draw[ut_orange,semithick] (.05\paperwidth,0) node[coordinate] (footerleft) {} -- node[coordinate] (footercenter) {} ++(.9\paperwidth,0pt) node [coordinate] (footerright) {}; + \path (footerleft) node[below right=1ex and 0ex] {\inserttitle\ \insertsubtitle}; + % \path (footercenter) node[below=1ex] {\insertshortdate}; + \path (footerright) node[below left=1ex and 0ex] {\insertframenumber}; + \end{tikzpicture} +} + +% -- BACKGROUND -- +\defbeamertemplate{background}{empty}{}% + +%\ifbeamer@theme@background@soc + \pgfdeclareimage[interpolate=true, width=.65\paperwidth]{soc_bg}{soc_bg} +%\fi +\defbeamertemplate*{background}{soc theme}{ + \begin{tikzpicture}[remember picture, overlay] + \getcoordinates + % Custom background + \makeatletter + \ifbeamer@plainframe\else + \path (\paperwidth,-\paperheight) node[above left, inner sep=0pt, line width=0pt,rotate=-15,yshift=-20mm,xshift=5mm] {\pgfuseimage{soc_bg}}; + \fi + \makeatother + \end{tikzpicture} +} +\defbeamertemplate{background}{electricity poles}{ + \begin{tikzpicture}[remember picture, overlay] + \getcoordinates + % Custom background + \makeatletter + \ifbeamer@plainframe\else + \path (\paperwidth,-\paperheight) node[anchor=south east,inner sep=0pt, line width=0pt] {\pgfuseimage{logoPoles}}; + \fi + \makeatother + \end{tikzpicture} +} + + +% -- Navigation symbols -- +\setbeamertemplate{navigation symbols}[vertical] +\defbeamertemplate{navigation symbols}{none}{} + +% -- Frame title: default -- +\defbeamertemplate{frametitle}{noleft}{ + \nointerlineskip + \begin{beamercolorbox}[wd=\paperwidth,ht=.115\paperheight,dp=0pt]{} + \begin{tikzpicture} + \node[anchor=base east, inner xsep=0pt] (frametitle) at (.93\paperwidth,.02\paperwidth) {\usebeamerfont{frametitle}\insertframetitle}; + \path[use as bounding box] (0,0) rectangle (\paperwidth,.115\paperheight); + \node[coordinate] (grayline) at (.05\paperwidth,0) {}; + \ifx\insertframesubtitle\@empty\else% + \node[inner xsep=1ex, anchor=north east] (subtitle) at (frametitle.base east) {\usebeamerfont{framesubtitle}\usebeamercolor[fg]{framesubtitle}\insertframesubtitle}; + \node[coordinate] (grayline) at (grayline |- subtitle.south) {}; + \fi% + \begin{scope} % Lines + \pgfsetfading{LRfading}{\pgftransformshift{\pgfpoint{.5\paperwidth}{-.5\textheight}}} + \draw[gray!50,ultra thin] (grayline) -- +(.9\paperwidth,0); + \end{scope} + \end{tikzpicture} + \end{beamercolorbox} + \vskip-.25em %Line 110 beamerbaseframe.sty + \vskip-.2cm %Line 248 beamerbaseframe.sty + \vskip.02\paperwidth +} +\defbeamertemplate*{frametitle}{caes theme}{ + \nointerlineskip + \begin{beamercolorbox}[wd=\paperwidth]{} + + \begin{tikzpicture} + \node[anchor=base east, inner xsep=0pt] (frametitle) at (.93\paperwidth,.02\paperwidth) {\usebeamerfont{frametitle}\insertframetitle}; + \node[coordinate] (grayline) at (.05\paperwidth,0) {}; + \ifx\insertframesubtitle\@empty\else% + \node[inner xsep=1ex, inner ysep=0pt, anchor=base east] (subtitle) at ([yshift=-.04\paperwidth] frametitle.base east) {\usebeamerfont{framesubtitle}\usebeamercolor[fg]{framesubtitle}\insertframesubtitle}; + \node[coordinate] (grayline) at ([yshift=-0.02\paperwidth] grayline |- subtitle.base) {}; + \fi% + + \path[use as bounding box] (TL |- grayline.south) rectangle (\paperwidth,.115\paperheight); + + \begin{scope} % Lines + \pgfsetfading{BRfading}{\pgftransformshift{\pgfpoint{.5\paperwidth}{-.5\textheight}}} + \draw[gray!50,ultra thin] (grayline) +(.9\paperwidth,0) -| +(0,-.5\textheight); + \end{scope} + \end{tikzpicture} + \end{beamercolorbox} + \vskip-.25em %Line 110 beamerbaseframe.sty + \vskip-.2cm %Line 248 beamerbaseframe.sty + \vskip.01\paperwidth +} + +\setbeamersize{text margin left=0.07\paperwidth, text margin right=0.07\paperwidth} + +\makeatother + +\mode + diff --git a/beamerthemecaes.sty b/beamerthemecaes.sty new file mode 100644 index 0000000..bb71e86 --- /dev/null +++ b/beamerthemecaes.sty @@ -0,0 +1,40 @@ +%% +%% beamerthemecaes.sty +%% +%% Copyright (C) 2008 CAES (http://caes.ewi.utwente.nl) +%% +%% Authors : Pascal Wolkotte +%% Created On : March 15 2008 +%% +%% $Author: wolkottept $ +%% $Date: 2008-03-14 10:07:37 +0100 (Fri, 14 Mar 2008) $ +%% $Revision: 40 $ +%% $HeadURL: https://svncaes/svn/general/templates/caes/trunk/caes_presentation.cls $ +%% + +\mode + +\useoutertheme{caes} +\useinnertheme{default} +\useinnertheme{caes} +\usecolortheme{caes} +\usefonttheme{caes} + +%\setbeamertemplate{headline}[caes theme] + +\setbeamertemplate{headline}[chameleonB theme] +\setbeamertemplate{footline}[caes theme] +\setbeamertemplate{background}[soc theme] +\setbeamertemplate{navigation symbols}[vertical] +\setbeamercovered{transparent} + +\DeclareOptionBeamer{empty}{ + \setbeamertemplate{background}[empty] + \setbeamertemplate{navigation symbols}[none] + \PassOptionsToPackage{navigation=false}{beamerouterthemecaes} +} + +\ProcessOptionsBeamer + +\mode + diff --git a/caes_presentation.cls b/caes_presentation.cls new file mode 100644 index 0000000..61ff482 --- /dev/null +++ b/caes_presentation.cls @@ -0,0 +1,51 @@ +%% +%% caes_presentation.cls +%% +%% Copyright (C) 2008 CAES (http://caes.ewi.utwente.nl) +%% +%% Authors : Pascal Wolkotte +%% Created On : March 13 2008 +%% +%% $Author: bakkerv $ +%% $Date: 2008-03-25 10:31:52 +0100 (Tue, 25 Mar 2008) $ +%% $Revision: 45 $ +%% $HeadURL: https://ewi630/svn/general/templates/caes/trunk/caes_presentation.cls $ +%% + +% -- BASIC SETTINGS -- +\NeedsTeXFormat{LaTeX2e} +\ProvidesClass{caes_presentation}[2008/03/13 Standard document class for presentations of the CAES group] % Name of this class-file + +\DeclareOption{empty}{\PassOptionsToPackage{\CurrentOption}{beamerthemecaes}} +\DeclareOption{powerpoint}{\PassOptionsToPackage{\CurrentOption}{beamerthemecaes}} +\DeclareOption{chameleonA}{\PassOptionsToPackage{\CurrentOption}{beamerthemecaes}} +\DeclareOption{chameleonB}{\PassOptionsToPackage{\CurrentOption}{beamerthemecaes}} +\DeclareOption{energy}{\PassOptionsToPackage{\CurrentOption}{beamerthemecaes}} + + +\DeclareOption*{\PassOptionsToClass{\CurrentOption}{beamer}} +%\DeclareOption*{\PassOptionsToClass{\CurrentOption}{beamer}} +\ProcessOptions\relax +\LoadClass[t,11pt,hyperref={unicode},notes=show]{beamer} + +\pdfpageattr {/Group << /S /Transparency /I true /CS /DeviceRGB>>} %Solves colorshift due to transparency in figures +\RequirePackage{tikz} +\RequirePackage{url} + +\usetheme{caes} +\date{\today} +\institute[University of Twente]{\raggedleft +Computer Architecture for Embedded Systems (CAES) group\\ +Faculty of Electrical Engineering, Mathematics and Computer Science\\ +University of Twente\\ +\url{http://caes.ewi.utwente.nl} \hfill Enschede, The Netherlands} + +\makeatletter +\def\caestitle{\maketitle} +\def\maketitle{ {\setbeamertemplate{navigation symbols}[none]\ifbeamer@inframe\titlepage\else\frame[b]{\titlepage}\fi} } +\makeatother + +%\RequirePackage{caes} + + +% -- END OF CLASS -- diff --git a/christiaan/introduction.lhs b/christiaan/introduction.lhs new file mode 100644 index 0000000..bfa3494 --- /dev/null +++ b/christiaan/introduction.lhs @@ -0,0 +1,7 @@ +%include talk.fmt +\title{\clash :} +\subtitle{From Haskell To Hardware} +\author{Christiaan Baaij} +\date{December 14, 2009} + +\frame{\titlepage \setcounter{framenumber}{1}} \ No newline at end of file diff --git a/christiaan/introduction.tex b/christiaan/introduction.tex new file mode 100644 index 0000000..e69de29 diff --git a/clash-haskell09.lhs b/clash-haskell09.lhs new file mode 100644 index 0000000..efcd034 --- /dev/null +++ b/clash-haskell09.lhs @@ -0,0 +1,25 @@ +\RequirePackage{atbegshi} +\documentclass[empty]{caes_presentation} +%include talk.fmt +\include{preamble} + +\title{Hardware and Functional Languages} +\author{Matthijs Kooijman, Christiaan Baaij \\ \& Jan Kuper} +\date{December 14, 2009} + +\begin{document} + +\frame{\titlepage} +\note[itemize]{ +\item Gezamenlijke introductie (verteld door Matthijs) +\item Presentatie Matthijs +\item Presentatie Christiaan +} + +\include{introduction} +\include{matthijs/introduction} +\include{christiaan/introduction} +% \include{fir} +% \include{reducer} + +\end{document} diff --git a/cpualu.png b/cpualu.png new file mode 100644 index 0000000..ed1baee Binary files /dev/null and b/cpualu.png differ diff --git a/cpucomplete.png b/cpucomplete.png new file mode 100644 index 0000000..dd138b2 Binary files /dev/null and b/cpucomplete.png differ diff --git a/cpuregisters.png b/cpuregisters.png new file mode 100644 index 0000000..977afb6 Binary files /dev/null and b/cpuregisters.png differ diff --git a/demo.lhs b/demo.lhs new file mode 100644 index 0000000..740a38e --- /dev/null +++ b/demo.lhs @@ -0,0 +1,39 @@ +\section{Demonstration} + +\frame{ +\frametitle{Demo} +Pre-Recorded Video: VHDL Synthesis takes too long\pause +\vspace{3em} +\begin{itemize} + \item Simulate the Haskell CPU description + \item Translate the Haskell description to VHDL + \item Simulate the generated VHDL +\end{itemize} +}\note[itemize]{ +\item Will show video +} + +\frame{ +\frametitle{Generated Schematic} +\begin{figure} +\centerline{\includegraphics<1>[width=10.3cm]{cpucomplete} +\includegraphics<2>[width=11.3cm]{cpualu} +%\includegraphics<3>[height=6.3cm]{cpuregisters} +} +\end{figure} +} + +% +% \frame{ +% \frametitle{How do we use \clash{}?} +% As a library: +% \begin{itemize} +% \item Import the module: CLasH.Translator +% \item And call \emph{makeVHDLAnnotations ghc\_lib\_dir [files\_to\_translate]} +% \end{itemize} +% Customized GHC: +% \begin{itemize} +% \item Call GHC with the --vhdl flag +% \item Use the :vhdl command in GHCi +% \end{itemize} +% } diff --git a/figures/chameleonB.png b/figures/chameleonB.png new file mode 100644 index 0000000..ad6cf8a Binary files /dev/null and b/figures/chameleonB.png differ diff --git a/figures/cpus/6600GT_GPU.jpg b/figures/cpus/6600GT_GPU.jpg new file mode 100644 index 0000000..b0ef25e Binary files /dev/null and b/figures/cpus/6600GT_GPU.jpg differ diff --git a/figures/cpus/Altera_StratixIV.jpg b/figures/cpus/Altera_StratixIV.jpg new file mode 100644 index 0000000..e002dd2 Binary files /dev/null and b/figures/cpus/Altera_StratixIV.jpg differ diff --git a/figures/cpus/Intel_core_i7.jpg b/figures/cpus/Intel_core_i7.jpg new file mode 100644 index 0000000..8ce1179 Binary files /dev/null and b/figures/cpus/Intel_core_i7.jpg differ diff --git a/figures/cpus/pmiphone_boardtopbig.jpg b/figures/cpus/pmiphone_boardtopbig.jpg new file mode 100644 index 0000000..b19d4df Binary files /dev/null and b/figures/cpus/pmiphone_boardtopbig.jpg differ diff --git a/figures/schakelingen/CMOS_NAND_Layout.svg b/figures/schakelingen/CMOS_NAND_Layout.svg new file mode 100644 index 0000000..0c9d79e --- /dev/null +++ b/figures/schakelingen/CMOS_NAND_Layout.svg @@ -0,0 +1,220 @@ + + + + + + + + + + Page-1 + + + Sheet.1 + + + + Sheet.2 + + + + Sheet.3 + + + + Sheet.4 + B + + + + + B + + Sheet.5 + A + + + + + A + + Sheet.6 + + Sheet.7 + + + + Sheet.8 + METAL1 + + + + + METAL1 + + + Sheet.9 + + Sheet.10 + + + + Sheet.11 + POLY + + + + + POLY + + + Sheet.12 + + Sheet.13 + + + + Sheet.14 + CONTACT + + + + + CONTACT + + + Sheet.15 + + Sheet.16 + + + + Sheet.17 + N DIFFUSION + + + + + N DIFFUSION + + + Sheet.18 + + Sheet.19 + + + + Sheet.20 + N-WELL + + + + + N-WELL + + + Sheet.21 + + Sheet.22 + + + + Sheet.23 + P DIFFUSION + + + + + P DIFFUSION + + + Sheet.24 + + + + Sheet.25 + + + + Sheet.26 + + + + Sheet.27 + + + + Sheet.28 + + + + Sheet.29 + + + + Sheet.30 + + + + Sheet.31 + + + + Sheet.32 + + + + Sheet.33 + VDD + + + + + VDD + + Sheet.34 + OUT + + + + + OUT + + Sheet.35 + VSS + + + + + VSS + + Sheet.36 + + + + Sheet.37 + + + + Sheet.38 + + + + diff --git a/figures/schakelingen/NAND.PNG b/figures/schakelingen/NAND.PNG new file mode 100644 index 0000000..04aeb19 Binary files /dev/null and b/figures/schakelingen/NAND.PNG differ diff --git a/figures/schakelingen/ttl.gif b/figures/schakelingen/ttl.gif new file mode 100644 index 0000000..b730845 Binary files /dev/null and b/figures/schakelingen/ttl.gif differ diff --git a/figures/transistor/Replica-of-first-transistor.jpg b/figures/transistor/Replica-of-first-transistor.jpg new file mode 100644 index 0000000..14482f6 Binary files /dev/null and b/figures/transistor/Replica-of-first-transistor.jpg differ diff --git a/figures/transistor/Transistorer_(croped).jpg b/figures/transistor/Transistorer_(croped).jpg new file mode 100644 index 0000000..f6db50c Binary files /dev/null and b/figures/transistor/Transistorer_(croped).jpg differ diff --git a/figures/transistor/firsttransistor.gif b/figures/transistor/firsttransistor.gif new file mode 100644 index 0000000..0808116 Binary files /dev/null and b/figures/transistor/firsttransistor.gif differ diff --git a/figures/transistor/hr-1sttransistor.jpg b/figures/transistor/hr-1sttransistor.jpg new file mode 100644 index 0000000..9832fe6 Binary files /dev/null and b/figures/transistor/hr-1sttransistor.jpg differ diff --git a/figures/transistor/nehalem-core.jpg b/figures/transistor/nehalem-core.jpg new file mode 100644 index 0000000..8925f6c Binary files /dev/null and b/figures/transistor/nehalem-core.jpg differ diff --git a/figures/transistor/nehalem_432x315.jpg b/figures/transistor/nehalem_432x315.jpg new file mode 100644 index 0000000..7e12b6e Binary files /dev/null and b/figures/transistor/nehalem_432x315.jpg differ diff --git a/figures/transistor/transistor_nano.jpg b/figures/transistor/transistor_nano.jpg new file mode 100644 index 0000000..372466c Binary files /dev/null and b/figures/transistor/transistor_nano.jpg differ diff --git a/figures/transistor/worldsfastes.jpg b/figures/transistor/worldsfastes.jpg new file mode 100644 index 0000000..8611d37 Binary files /dev/null and b/figures/transistor/worldsfastes.jpg differ diff --git a/fir.lhs b/fir.lhs new file mode 100644 index 0000000..f8d6959 --- /dev/null +++ b/fir.lhs @@ -0,0 +1,22 @@ +\section{4-taps FIR Filter} + +\begin{frame}[plain] + \vspace{-0.8em} + \begin{figure} + \centerline{\includegraphics[width=\paperwidth,trim=9mm 4cm 14mm 4cm, clip=true]{fir0.png}} + \end{figure} +\end{frame} + +\begin{frame}[plain] + \vspace{-0.8em} + \begin{figure} + \centerline{\includegraphics[width=\paperwidth,trim=9mm 4cm 14mm 4cm, clip=true]{fir1.png}} + \end{figure} +\end{frame} + +\begin{frame}[plain] + \vspace{-0.8em} + \begin{figure} + \centerline{\includegraphics[width=\paperwidth,trim=9mm 4cm 14mm 4cm, clip=true]{fir2.png}} + \end{figure} +\end{frame} \ No newline at end of file diff --git a/fir0.png b/fir0.png new file mode 100644 index 0000000..71782b8 Binary files /dev/null and b/fir0.png differ diff --git a/fir1.png b/fir1.png new file mode 100644 index 0000000..7fdb772 Binary files /dev/null and b/fir1.png differ diff --git a/fir2.png b/fir2.png new file mode 100644 index 0000000..8541aba Binary files /dev/null and b/fir2.png differ diff --git a/foldr.svg b/foldr.svg new file mode 100644 index 0000000..fd9235e --- /dev/null +++ b/foldr.svg @@ -0,0 +1,528 @@ + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + : + + + : + + + : + + + : + + + : + + + 1 + 2 + 3 + 4 + 5 + [] + f + + + f + + + f + + + f + + + f + + + 1 + 2 + 3 + 4 + 5 + z + + foldr f z + diff --git a/howdoesitwork.lhs b/howdoesitwork.lhs new file mode 100644 index 0000000..4c26ca5 --- /dev/null +++ b/howdoesitwork.lhs @@ -0,0 +1,21 @@ +%include talk.fmt +\section{How do you make Hardware from Haskell?} +\frame +{ + \frametitle{So how do you make Hardware from Haskell?}\pause + \large{In three simple steps really:} \pause + \begin{itemize} + \item No Effort:\\ + GHC API Parses, Typechecks and Desugars the Haskell code \pause + \item Hard: \\ + Transform resulting Core, GHC's Intermediate Language,\linebreak to a normal form. Uses reduction rules. \pause + \item Easy: \\ + Translate Normalized Core to synthesizable VHDL + \end{itemize} +}\note[itemize]{ +\item Here is a quick insight as to how WE translate Haskell to Hardware +\item Reduction rules are used to get a required normal form. +\item Normal form already looks like hardware (components and lines) +\item You can also use TH, like ForSyDe. Or traverse datastructures, like Lava? +\item We're in luck with the GHC API update of 6.10 and onwards +} diff --git a/introduction.lhs b/introduction.lhs new file mode 100644 index 0000000..1c9eef8 --- /dev/null +++ b/introduction.lhs @@ -0,0 +1,229 @@ +%include talk.fmt +\section{Introduction} +\subsection{Hardware as we know it} +\frame +{ +\frametitle{Hardware} +\begin{figure} +\centerline{ +\includegraphics<1>[height=6cm]{figures/cpus/pmiphone_boardtopbig} +\includegraphics<2>[height=6cm]{figures/cpus/Intel_core_i7} +\includegraphics<3>[height=6cm]{figures/cpus/6600GT_GPU} +\includegraphics<4>[height=6cm]{figures/cpus/Altera_StratixIV} +} +\label{img:chips} +\end{figure} +} +\note[itemize] +{ +\item Iedereen weet wel wat hardware is. Hier een paar voorbeelden. +\item Binnenkant iPhone met veelvoud aan chips, Laatste Intel CPU, Nvidia Videochip, Altere FPGA +} + +\frame +{ +\frametitle{Transistor} +\begin{figure} +\centerline{ +\includegraphics<1>[height=6cm]{figures/transistor/hr-1sttransistor} +\includegraphics<2>[height=6cm]{figures/transistor/worldsfastes} +\includegraphics<3>[height=6cm]{figures/transistor/nehalem_432x315} +} +\label{img:chips} +\end{figure} +} +\note[itemize] +{ +\item Hardware is opgebouwd uit transistoren, simpele schakelaar +\item Eerste transistor 60 jaar geleden, ter grootte van je hand +\item Het word allemaal steeds kleiner +\item Nu: Chip net iets groter dan je duim: 731 miljoen transistoren +} + +\frame +{ +\frametitle{Transistor Counts} +\begin{itemize} +\item Cell (Playstation 3): 241 Million +\item Intel Core i7: 731 Million +\item ATI HD5800: 2150 Million +\item Nvidia GF100 (Expected Summer 2010): 2900 Million +\end{itemize} +} +\note[itemize] +{ +\item Aantal gebruikte transistoren wordt steeds groter +} + +\frame +{ +\frametitle{Designing Hardware} +\centerline{Design with 4 transistors} +\begin{columns}[c] +\column{0.5\textwidth} +\vspace{-0.5cm} +\begin{figure} +\centerline{\includegraphics[height=5cm, trim = 0 0 0 2.5cm, clip]{figures/schakelingen/NAND}} +\end{figure} +\column{0.5\textwidth} +\begin{figure} +\centerline{\includegraphics[height=5cm, trim = 0 4.5cm 0 0, clip]{figures/schakelingen/CMOS_NAND_Layout}} +\end{figure} +\end{columns} +} +\note[itemize] +{ +\item NAND: Gaat na dat beide ingangen niet 1 zijn +\item Een simpel hardware ontwerp met 4 transistoren +\item Links een schematisch ontwerp, Rechts de layout van de metaal lagen +} + +\frame +{ +\frametitle{Designing Hardware} +\vspace{0.5cm} +\centerline{\Large This won't work for 730 million transistors!} +\begin{figure} +\centerline{\includegraphics[height=4cm]{figures/transistor/nehalem-core}} +\end{figure} +} + +\frame +{ +\frametitle{Designing Hardware} +\begin{itemize} +\item We design hardware in the same format as software +\item We make designs in plain text! +\item Software: Programming Languages +\item Hardware: Hardware Description Languages +\end{itemize} +} +\note[itemize] +{ +\item Harware designs worden gewoon in tekst opgeschreven. +\item Maar wel in een special taal voor hardware +\item Waar je voor software programmeer talen hebt, +\item Heb je voor hardware zogeheette hardwarebeschrijvingstalen +} + +\frame +{ +\frametitle{Designing Hardware} +\begin{itemize} +\item Algorithmic / Behavioral Descriptions: +\begin{itemize} +\item Describe \emph{what} the Hardware does +\item Relation between input and output +\end{itemize} +\item Structural Descriptions: +\begin{itemize} +\item Describe \emph{how} the Hardware does it +\item Hierarchal composition +\end{itemize} +\end{itemize} +} +\note[itemize] +{ +\item Algoritmische beschrijvingen beschrijven wat de Hardware moet doen, niet hoe die dat doet +\item Structurele beschrijvingen beschrijven hoe de Hardware dingen doet +\item In Structurele beschrijvingen worden componenten opgebouwd uit simpele schakelingen en/of andere componenten +\item Graag willen wij algorithmische beschrijvingen maken, en de structurele beschrijving hier automatisch van afleiden +} + +\frame +{ +\frametitle{Why do we make Hardware?} +\begin{itemize} +\item We make hardware to solve problems +\item The solutionss are often described as a set of mathematical equations\footnote{But what is the equation for a CPU?} +\item `Holy Grail' Hardware Descriptions: +\begin{itemize} +\item Input: Set of Mathematical Equations +\item Output: Hardware that is Provably correct, Fast , Small, Cheap to manufacture, and has a low Energy Usage +\end{itemize} +\end{itemize} +} +\note[itemize] +{ +\item We maken hardware omdat we, soms vaag gedefineerde, problemen willen oplossen. +\item Oplossingen, vooral in de signaalverwerking (video, muziek, TV, etc.), zijn beschreven als een verzameling van wiskundige formules +\item Wat we dus graag zouden hebben, een zogenaamde heilige graal, is een programma aan welke we deze formules geven, en dat er dan automatisch super efficiente hardware uit komt. +\item Maar... wat is de formule van een CPU/Processor? Misschien moet is een oplossingen in `normaal nederlands' soms een betere input voor zo'n programma? +} + +\frame +{ +\frametitle{Functional Languages} +\begin{itemize} +\item Functional programming languages allow us to specify programs that are close to a set of mathematical equations. +\end{itemize} +} +\note[itemize] +{ +\item Functionele talen liggen dicht bij de wiskunde +} + +\frame +{ +\frametitle{Functional Languages \& Hardware} +\begin{itemize} +\item When we want to calculate, 1 + 2 + 3, there is nothing that dictates that we should first calculate 1 + 2 +\item Like mathematical equations, Functional languages do not dictate an order when there is none. So everything can be calculated in parallel. +\item In hardware, everything also happens in parallel: electrons flow through all the transistors every moment in time. +\item IDEA: Use functional languages to describe hardware! +\end{itemize} +} +\note[itemize] +{ +\item In wiskundige formules is er vaak geen volgorde gedefineerd +\item Dit is dus hetzelfde in functionele talen, wat betekent dat alles tegelijk/parallel kan worden uitgerekent. +\item Bij `normale' programmeertalen is er vaak wel een volgorde +\item In hardware gebeurt ook alles tegelijkertijd +\item Het idee is dus om hardware te beschrijven in een functionele taal +} + +% \frame +% { +% \frametitle{Mealy Machine} +% \begin{figure} +% \centerline{\includegraphics<1>[width=6.25cm]{mealymachine2} +% \includegraphics<2>[width=6.25cm]{mealymachine2-func-red} +% \includegraphics<3>[width=6.25cm]{mealymachine2-state-red}} +% \label{img:mealymachine} +% \end{figure} +% \begin{beamercolorbox}[sep=-2.5ex,rounded=true,shadow=true,vmode]{codebox} +% \begin{code} +% run {-"{\color<2>[rgb]{1,0,0}"-}func{-"}"-} {-"{\color<3>[rgb]{1,0,0}"-}state{-"}"-} [] = [] +% run {-"{\color<2>[rgb]{1,0,0}"-}func{-"}"-} {-"{\color<3>[rgb]{1,0,0}"-}state{-"}"-} (i:inputs) = o:outputs +% where +% ({-"{\color<3>[rgb]{1,0,0}"-}state'{-"}"-}, o) = {-"{\color<2>[rgb]{1,0,0}"-}func{-"}"-} i {-"{\color<3>[rgb]{1,0,0}"-}state{-"}"-} +% outputs = run {-"{\color<2>[rgb]{1,0,0}"-}func{-"}"-} {-"{\color<3>[rgb]{1,0,0}"-}state'{-"}"-} inputs +% \end{code} +% \end{beamercolorbox} +% } +% \note[itemize]{ +% \item A Mealy machine bases its output on the current state and the input +% \item State is part of the function signature +% \item Both the current state, and the updated State +% \item The run function simulates a mealy machine for the provided number of inputs +% } +% +% \frame +% { +% \frametitle{Haskell Description} +% \begin{figure} +% \centerline{\includegraphics[width=6.25cm]{mealymachine2-func-red}} +% \end{figure} +% \begin{beamercolorbox}[sep=-2.5ex,rounded=true,shadow=true,vmode]{codebox} +% \begin{code} +% func :: +% InputSignal -> +% State -> +% (State, OutputSignal) +% \end{code} +% \end{beamercolorbox} +% } +% \note[itemize]{ +% \item In \clash{} you describe the logic part of the mealy machine +% \item The state in the signature is turned into memory elements when translating to VHDL +% } diff --git a/introduction.tex b/introduction.tex new file mode 100644 index 0000000..e69de29 diff --git a/macc.hs b/macc.hs new file mode 100644 index 0000000..f1f6d50 --- /dev/null +++ b/macc.hs @@ -0,0 +1,30 @@ +{-# LANGUAGE TemplateHaskell, TypeOperators, RecordWildCards, ScopedTypeVariables, TypeFamilies #-} +module MultiplyAccumulate where + +import CLasH.HardwareTypes +import CLasH.Translator.Annotations +type Word = SizedInt D8 + +initacc :: Word +initacc = 0 + +{-# ANN macc (InitState 'initacc) #-} +{-# ANN macc TopEntity #-} +macc :: (Word,Word) -> State Word -> (State Word, Word) +macc (x, y) (State acc) = (State u, u) + where + u = acc + x * y + +{-# ANN program TestInput #-} +program :: [(Word,Word)] +program = + [ (4, 2) -- 4 * 2 + 0 = 8 + , (1, 3) -- 1 * 3 + 8 = 11 + , (2, 2) -- 2 * 2 + 11 = 15 + ] + +run _ _ [] = [] +run func state (i:input) = o:out + where + (state', o) = func i state + out = run func state' input diff --git a/macc.lhs b/macc.lhs new file mode 100644 index 0000000..7bf988e --- /dev/null +++ b/macc.lhs @@ -0,0 +1,114 @@ +%include talk.fmt +%if style == newcode +\begin{code} +{-# LANGUAGE TemplateHaskell #-} +module Main where + +import qualified Prelude as P +\end{code} +%endif + +\section{Multiply-Accumulate} +\subsection{Pure description} +\frame +{ +\frametitle{Multiply-Accumulate} +Purely Functional Description: +\begin{beamercolorbox}[sep=-2.5ex,rounded=true,shadow=true,vmode]{codebox} +%if style == newcode + +%else +\begin{code} +macc (x,y) acc = (u, u) + where + u = acc + x * y +\end{code} +\end{beamercolorbox} +}\note[itemize]{ +\item Purely functional design (that Jan showed you earlier). +\item \emph{acc} is the current state. \emph{u} is the updated state and output. +} +%endif + +\subsection{Extra's to make it compile} +\frame +{ +\frametitle{Extra's to make it compile} +{\clash} Description: +\begin{beamercolorbox}[sep=-2.5ex,rounded=true,shadow=true,vmode]{codebox} +\begin{code} +{-"{\color<3>[rgb]{1,0,0}"-}import CLasH.HardwareTypes{-"}"-} +{-"{\color<4>[rgb]{1,0,0}"-}import CLasH.Translator.Annotations{-"}"-} +{-"{\color<3>[rgb]{1,0,0}"-}type Word = SizedInt D8{-"}"-} + +initacc :: {-"{\color<3>[rgb]{1,0,0}"-}Word{-"}"-} +{-"{\color<5>[rgb]{1,0,0}"-}initacc = 0{-"}"-} + +ANN(macc (InitState {-"\ "-} `initacc)) +ANN(macc TopEntity) +macc :: ({-"{\color<3>[rgb]{1,0,0}"-}Word{-"}"-},{-"{\color<3>[rgb]{1,0,0}"-}Word{-"}"-}) -> {-"{\color<2>[rgb]{1,0,0}"-}State{-"}"-} {-"{\color<3>[rgb]{1,0,0}"-}Word{-"}"-} -> ({-"{\color<2>[rgb]{1,0,0}"-}State{-"}"-} {-"{\color<3>[rgb]{1,0,0}"-}Word{-"}"-}, {-"{\color<3>[rgb]{1,0,0}"-}Word{-"}"-}) +macc (x, y) ({-"{\color<2>[rgb]{1,0,0}"-}State{-"}"-} acc) = ({-"{\color<2>[rgb]{1,0,0}"-}State{-"}"-} u, u) + where + u = acc + x * y +\end{code} +\end{beamercolorbox} +}\note[itemize]{ +\item Stuff you need to add to make it compile in \clash{}. +\item State wrapper, tells the compiler which argument is the state +\item Type declarations. Top-level entity needs to be mono-morphic (and first-order). +\item Annotation pragma's. The TopEntity pragma tells the compiler which entity is the top entity. +\item The InitState pragma points to the initial state. +} + +\begin{frame}[plain] + \vspace{-0.8em} + \begin{figure} + \centerline{\includegraphics[width=\paperwidth,trim=9mm 4cm 14mm 4cm, clip=true]{macc.png}} + \end{figure} +\end{frame} +\note[itemize]{ +\item We see the register and multiplier on the left +\item The adder on the right +} + +\subsection{Test input} +\frame +{ +\frametitle{Test input} +Test program for the Multiply-Accumulate circuit: +\begin{beamercolorbox}[sep=-2.5ex,rounded=true,shadow=true,vmode]{codebox} +\begin{code} +ANN(program TestInput) +program :: [(Word,Word)] +program = + [ (4, 2) -- 4 * 2 + 0 = 8 + , (1, 3) -- 1 * 3 + 8 = 11 + , (2, 2) -- 2 * 2 + 11 = 15 + ] +\end{code} +\end{beamercolorbox} +\begin{itemize} + \item VHDL Testbench is automatically generated due to the \emph{TestInput} annotation pragma. +\end{itemize} + +}\note[itemize]{ +\item We can also generate VHDL Testbench +} + +%if style == newcode +\begin{code} +run _ _ [] = [] +run func state (i:input) = o:out + where + (state', o) = func i state + out = run func state' input + +main :: IO () +main = do + let input = program + let istate = (State initacc) + let output = run macc istate input + mapM_ (\x -> putStr $ ((show x) P.++ "\n")) output + return () +\end{code} +%endif diff --git a/macc.png b/macc.png new file mode 100644 index 0000000..0535e4b Binary files /dev/null and b/macc.png differ diff --git a/matthijs/introduction.lhs b/matthijs/introduction.lhs new file mode 100644 index 0000000..b8f01b9 --- /dev/null +++ b/matthijs/introduction.lhs @@ -0,0 +1,6 @@ +%include talk.fmt +\title{Haskell as a higher order structural hardware description language} +\author{Matthijs Kooijman} +\date{December 14, 2009} + +\frame{\titlepage \setcounter{framenumber}{1}} \ No newline at end of file diff --git a/matthijs/introduction.tex b/matthijs/introduction.tex new file mode 100644 index 0000000..e69de29 diff --git a/mealymachine.pdf b/mealymachine.pdf new file mode 100644 index 0000000..d293e47 Binary files /dev/null and b/mealymachine.pdf differ diff --git a/mealymachine.svg b/mealymachine.svg new file mode 100644 index 0000000..0606504 --- /dev/null +++ b/mealymachine.svg @@ -0,0 +1,270 @@ + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Inputs + Outputs + + + + + + Present + State + + + CombinatorialLogic + + + + MemoryElements + + + diff --git a/mealymachine2-func-red.svg b/mealymachine2-func-red.svg new file mode 100644 index 0000000..21a7d1b --- /dev/null +++ b/mealymachine2-func-red.svg @@ -0,0 +1,229 @@ + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + func + + + state + + (i : inputs) + (o : outputs) + diff --git a/mealymachine2-state-red.svg b/mealymachine2-state-red.svg new file mode 100644 index 0000000..0754f35 --- /dev/null +++ b/mealymachine2-state-red.svg @@ -0,0 +1,225 @@ + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + func + + state + (i : inputs) + (o : outputs) + diff --git a/mealymachine2.svg b/mealymachine2.svg new file mode 100644 index 0000000..251780c --- /dev/null +++ b/mealymachine2.svg @@ -0,0 +1,229 @@ + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + func + + + state + + (i : inputs) + (o : outputs) + diff --git a/preamble.tex b/preamble.tex new file mode 100644 index 0000000..20c6a89 --- /dev/null +++ b/preamble.tex @@ -0,0 +1,4 @@ +\usepackage[english]{babel} +\usepackage{xcolor} + +\newcommand{\clash}[0]{C$\lambda$asH} \ No newline at end of file diff --git a/presentatie.tar.bz2 b/presentatie.tar.bz2 new file mode 100644 index 0000000..2276a1e Binary files /dev/null and b/presentatie.tar.bz2 differ diff --git a/reducer.lhs b/reducer.lhs new file mode 100644 index 0000000..09e2ad8 --- /dev/null +++ b/reducer.lhs @@ -0,0 +1,38 @@ +\section{Real Hardware Designs} +\frame{ +\frametitle{Beyond trivial designs} +\pause +\begin{columns}[l] +\column{0.5\textwidth} +\vspace{-2.4em} +\begin{figure} +\includegraphics<2->[height=6.5cm]{reducer} +\end{figure} +\column{0.5\textwidth} +\begin{itemize} + \item We implemented a reduction circuit in \clash{}\pause + \item Haskell and VHDL simulation match\pause + \item Synthesis completes without errors or warnings\pause + \item Around half the speed of handcoded and optimized VHDL +\end{itemize} +\end{columns} +}\note[itemize]{ +\item Toys like the poly cpu one are good to give a quick demo +\item But we used \clash{} to design 'real' hardware +\item Reduction circuit sums the numbers in a row, of different length +\item It uses a pipelined adder: multiple rows in pipeline, rows longer than pipeline +\item We hope you see this is not a trivial problem +\item Nice speed considering we don't optimize for it (only single example!) +} + +\begin{frame}[plain] + \vspace{-0.8em} + \begin{figure} + \includegraphics[height=\paperheight]{reducerschematic} + \end{figure} +\end{frame} +\note[itemize]{ +\item Big part on the left is the input buffer +\item Big part on the right is the buffer for partially reduced results +\item In the middle is the control logic and the adder pipeline +} diff --git a/reducer.svg b/reducer.svg new file mode 100644 index 0000000..eeb39b3 --- /dev/null +++ b/reducer.svg @@ -0,0 +1,553 @@ + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Input + AdderPipeline + diff --git a/reducerschematic.png b/reducerschematic.png new file mode 100644 index 0000000..637a546 Binary files /dev/null and b/reducerschematic.png differ diff --git a/simpleCPU.pdf b/simpleCPU.pdf new file mode 100644 index 0000000..b2ff166 Binary files /dev/null and b/simpleCPU.pdf differ diff --git a/simpleCPU.svg b/simpleCPU.svg new file mode 100644 index 0000000..d5baee3 --- /dev/null +++ b/simpleCPU.svg @@ -0,0 +1,411 @@ + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ALU + Registers + + + + CPU + + + opcode + x + y + data_in + rdaddr + + wraddr + data_out + alu_out + diff --git a/summary.lhs b/summary.lhs new file mode 100644 index 0000000..1ad3cca --- /dev/null +++ b/summary.lhs @@ -0,0 +1,68 @@ +%include talk.fmt +\section{Conclusion} + +\frame{ +\frametitle{Some final words} +\begin{itemize} + \item Still a lot to do: translate larger subset of Haskell + \item Real world prototype designs can already be made in \clash{} +% \item \clash{} is another great example of how to bring functional expressivity to hardware designs +\end{itemize} +} + +\frame{ +\vspace{6em} +\begin{figure} +\Huge{Thank you for listening} +\end{figure} +\vspace{5em} +\centerline{\clash{} Clone URL:} +\centerline{\url{git://github.com/christiaanb/clash.git}} +} + +\frame +{ +\frametitle{Complete signatures and Types} +\begin{code} +type Word = SizedInt D12 +type Instruction = ( Opcode, Word, RangedWord D9 + , RangedWord D9 ) + +registers :: + ( PositiveT s + , NaturalT (s :-: D1) + , (s :>: (s :-: D1)) ~ True )) => + a -> RangedWord (s :-: D1) -> RangedWord (s :-: D1) -> + (RegState s a) -> + (RegState s a, a ) +\end{code} +} + +\frame +{ +\frametitle{Supported Functionality} +\begin{itemize} +\item Polymorphism +\item Higher Order Functions +\item Fixed-Size Vectors (Simulation) +\item Ranged and Sized Integers (Simulation) +\item Custom Datatypes +\item Booleans +\item Tuples +\item Pattern Matching +\item Guards +\end{itemize} +} + +\frame +{ +\frametitle{Unsupported Functionality} +\begin{itemize} +\item Recursion +\item Lists (Dynamic Length) +\item Standard Haskell Types: Integer, Char, etc. +\item Type Classes +\item Monads +\item And much much more... +\end{itemize} +} diff --git a/talk.fmt b/talk.fmt new file mode 100644 index 0000000..0cf1757 --- /dev/null +++ b/talk.fmt @@ -0,0 +1,26 @@ +%include polycode.fmt + +%if style == newcode +%format ANN(x) = "{-# ANN " x " #-}" +%format CXT(x) = "(" x ")" +%format ` = "''" +%format ^^ = " " +%else +%format ANN(x) = "\{-\#\ \mathit{ANN}\ " x "\ \#-\}" +%format CXT(x) = "(Some\ context...)" +%format ` = "''" +%format ^^ = "\; " +%format :>: = "\ensuremath{>}" +%format :<: = "\ensuremath{<}" +%format :==: = "\ensuremath{\equiv}" +%format :-: = "\ensuremath{-}" +%format :+: = "\ensuremath{+}" +%format :*: = "\ensuremath{*}" +%format :<=: = "\ensuremath{\leq}" +%format SPL(x) = "\$" ( x ) +%format QU(x) = "\llbracket " x "\rrbracket " +%format QUd(x) = "[d|" x "\rrbracket " +%format QUt(x) = "[t|" x "\rrbracket " +%format ^^ = "\; " +%format ** = "\ \mathit{**}\ " +%endif \ No newline at end of file diff --git a/upload.sh b/upload.sh new file mode 100755 index 0000000..d9c8a57 --- /dev/null +++ b/upload.sh @@ -0,0 +1 @@ +rsync -avz --delete --stats --progress ~/Documents/msc_thesis/git/haskell09/vhdl baaijcpr@ewi630.ewi.utwente.nl:/home/studaid/baaijcpr/haskell09 diff --git a/ut_logos/ut_logo_blue.pdf b/ut_logos/ut_logo_blue.pdf new file mode 100644 index 0000000..b8088fd Binary files /dev/null and b/ut_logos/ut_logo_blue.pdf differ