Skip to content

Commit

Permalink
Merge branch 'master' of github.com:ucb-bar/chisel into dse
Browse files Browse the repository at this point in the history
  • Loading branch information
Adam Izraelevitz authored and Adam Izraelevitz committed Feb 19, 2014
2 parents fcb94b3 + cbce259 commit c5794df
Show file tree
Hide file tree
Showing 22 changed files with 301 additions and 109 deletions.
2 changes: 1 addition & 1 deletion doc/bootcamp/bootcamp-20130930.tex
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
\input{../style/scala.tex}
\input{../style/talk.tex}

\title{Chisel Bootcamp}
\title{Chisel Bootcamp 3}
\author{Jonathan Bachrach}
\date{\today}
\institute[UC Berkeley]{EECS UC Berkeley}
Expand Down
78 changes: 60 additions & 18 deletions doc/bootcamp/bootcamp-20140206.tex
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
\input{../style/scala.tex}
\input{../style/talk.tex}

\title{Chisel Bootcamp}
\title{Chisel Bootcamp 4}
\author{Jonathan Bachrach}
\date{\today}
\institute[UC Berkeley]{EECS UC Berkeley}
Expand Down Expand Up @@ -45,14 +45,31 @@
\begin{frame}[fragile]{Goals for Bootcamp}

\begin{itemize}
\item get yout started with Chisel
\item get you started with Chisel
\item get a basic working knowledge of Chisel
\item learn how to think in Chisel
\item know where to get more information
\end{itemize}

\end{frame}

\begin{frame}[fragile]{CS291C Specific Notes for Bootcamp}

\begin{itemize}
\item teaching digital circuit design in chisel
\item will later teach
\begin{itemize}
\item floating point
\item fixed point
\item complex numbers
\item integration with matlab
\end{itemize}
\item new chisel release with DSP support coming soon
\end{itemize}

\end{frame}


\setbeamercolor{frametitle}{bg=\frametitleproblemcolor}
\begin{frame}[fragile]{Logging into EC2}

Expand Down Expand Up @@ -86,7 +103,7 @@

if you don't have chisel-tutorial already
\begin{scala}
git clone git@github.com:ucb-bar/chisel-tutorial.git
git clone https://github.com/ucb-bar/chisel-tutorial.git
cd chisel-tutorial
\end{scala}

Expand Down Expand Up @@ -123,7 +140,7 @@

\begin{center}
\fbox{
\url{chisel.eecs.berkeley.edu/bootcamp-20140206.pdf}
\url{chisel.eecs.berkeley.edu/2.0.6/chisel-bootcamp-20140206.pdf}
}
\end{center}

Expand Down Expand Up @@ -783,7 +800,7 @@
} .elsewhen (io.opcode === UInt(2)) {
io.output := io.a + UInt(1) // inc A by 1
} .elsewhen (io.opcode === UInt(3)) {
io.output := io.a - UInt(1) // inc B by 1
io.output := io.a - UInt(1) // dec B by 1
} .elsewhen (io.opcode === UInt(4)) {
io.output := io.a + UInt(4) // inc A by 4
} .elsewhen (io.opcode === UInt(5)) {
Expand Down Expand Up @@ -826,7 +843,7 @@
\verb+^+ & Bitwise XOR & UInt\\ \hline
\verb+&+ & Bitwise AND & UInt \\ \hline
\verb+|+ & Bitwise OR & Bool \\ \hline
\verb+===+ & Equal & Bool \\ \hline
{\color{red}\verb+===+} & Equal & Bool \\ \hline
\verb+!=+ & Not Equal & Bool \\ \hline
\verb+>+ & Greater & Bool \\ \hline
\verb+<+ & Less & Bool \\ \hline
Expand Down Expand Up @@ -978,10 +995,10 @@
wire[15:0] T1;

assign io_Lo = T0;
assign T0 = mult[4'hf/*15*/:1'h0/*0*/];
assign T0 = mult[4'hf:1'h0];
assign mult = io_A * io_B;
assign io_Hi = T1;
assign T1 = mult[5'h1f/*31*/:5'h10/*16*/];
assign T1 = mult[5'h1f:5'h10];
endmodule
\end{scala}
}
Expand Down Expand Up @@ -1215,7 +1232,7 @@
val out = UInt(OUTPUT, 1)
}
val delays = Vec.fill(4){ Reg(UInt()) }
when ( ...) {
when ( ... ) {
// fill in here ...
} .elsewhen (io.shift) {
...
Expand Down Expand Up @@ -1362,7 +1379,7 @@
\setbeamercolor{frametitle}{bg=\frametitleproblemcolor}
\begin{frame}[fragile]{Testbench for MaxN -- \tt MaxN.scala}
\begin{columns}
\column{0.48\textwidth}
\column{0.49\textwidth}

\begin{itemize}
\item write a testbench for MaxN
Expand All @@ -1389,7 +1406,7 @@
val x = rnd.nextInt(lim)
\end{scala}

\column{0.43\textwidth}
\column{0.42\textwidth}

{\lstset{basicstyle={\scriptsize\ttfamily}}
\begin{scala}
Expand Down Expand Up @@ -1433,7 +1450,7 @@
val list = Vec(UInt(0), UInt(4), UInt(15), UInt(14),
UInt(2), UInt(5), UInt(13)){ UInt(width = 4) }
val memVal = list(index)
val done = !io.en && ((memVal === io.target) || (index === UInt(7)))
val done = !io.en && ((memVal === io.target) || (index === UInt(7)))
when (io.en) {
index := UInt(0)
} .elsewhen (done === Bool(false)) {
Expand Down Expand Up @@ -1514,8 +1531,7 @@
\end{itemize}

\begin{scala}
al ram1r1w =
Mem(UInt(width = 32), 1024, seqRead = true)
val ram1r1w = Mem(UInt(width = 32), 1024, seqRead = true)
val reg_raddr = Reg(UInt())
when (wen) { ram1r1w(waddr) := wdata }
when (ren) { reg_raddr := raddr }
Expand Down Expand Up @@ -1880,7 +1896,34 @@
for example, you can create a parallel set of blocks using map and reduce to creation reduction trees and chain to create a pipeline.}
\end{frame}

\begin{frame}[fragile]{Map / Reduce Generator}
\begin{frame}[fragile]{Flo Map / Reduce Generator}

{\lstset{basicstyle={\scriptsize\ttfamily}}
\begin{scala}
object FloDelays {
def apply(x: Flo, n: Int): List[Flo] =
if (n <= 1) List(x) else x :: FloDelays(RegNext(x), n-1)
}
object FloFIR {
def apply(ws: Seq[Flo], x: T): T =
(ws, FloDelays(x, ws.length)).zipped.map( _ * _ ).reduce( _ + _ )
}
class FIR extends Module {
val io = new Bundle { val x = Flo(INPUT); val z = Flo(OUTPUT) }
val ws = Array(Flo(0.25), Flo(0.75))
io.z := FloFIR(ws, io.x)
}
\end{scala}
}
\begin{center}
\includegraphics[height=0.35\textheight]{../cs294-88/lectures/advanced-chisel/figs/inner-product-fir.png}
\end{center}
\note{as an advanced example, consider writing an FIR filter which is defined by the equation below. \\[1cm]
essentially it's a sum of products of coefficients and delayed versions of input.\\[1cm]
we can write this quite simply using map and reduce as above.}
\end{frame}

\begin{frame}[fragile]{Generic Map / Reduce Generator}

{\lstset{basicstyle={\scriptsize\ttfamily}}
\begin{scala}
Expand Down Expand Up @@ -2223,7 +2266,6 @@
\begin{tabular}{rl}
\textbf{manual} & \code{manual.pdf} \\
\textbf{bootcamp2014} & \code{bootcamp-20140206.pdf} \\
\textbf{bootcamp2013} & \code{bootcamp-20130930.pdf} \\
\textbf{bootcamp2012} & \code{bootcamp-20121026.pdf} \\
\textbf{tutorial} & \code{tutorial.pdf} \\
\textbf{getting started} & \code{getting-started.pdf} \\
Expand Down Expand Up @@ -2287,8 +2329,8 @@

\begin{frame}{Thanks}
\begin{itemize}
\item \textbf{Arrangements} -- Roxana and Kostas
\item \textbf{EC2 configuration} -- Sebastien Mirolo
\item \textbf{Arrangements} -- Borivoje Nikolic
\item \textbf{Educational Machines} -- Michael Zimmer
\item \textbf{Bootcamp Materials} -- Vincent Lee, Stephen Twigg, Huy Vo
\item \textbf{Funding} -- Department of Energy, Department of Defense
\end{itemize}
Expand Down
2 changes: 1 addition & 1 deletion doc/bootcamp/bootcamp.tex
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
\input{../style/scala.tex}
\input{../style/talk.tex}

\title{Chisel Bootcamp}
\title{Chisel Bootcamp 2}
\author{Jonathan Bachrach}
\date{\today}
\institute[UC Berkeley]{EECS UC Berkeley}
Expand Down
33 changes: 31 additions & 2 deletions doc/bootcamp/scala-intro.tex
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,36 @@
val a :: b :: c :: Nil = els
val m = els.length

// Tuple's
val (x, y, z) = (1, 2, 3)
\end{scala}
\end{frame}

\begin{frame}[fragile]{Scala Maps and Sets}
\begin{scala}
import scala.collection.mutable.HashMap

val vars = new HashMap[String, Int]()
vars("a") = 1
vars("b") = 2
vars.size
vars.contains("c")
vars.getOrElse("c", -1)
vars.keys
vars.values
\end{scala}

\begin{scala}
import scala.collection.mutable.HashSet

val keys = new HashSet[Int]()
keys += 1
keys += 5
keys.size -> 2
keys.contains(2) -> false
\end{scala}
\end{frame}

% // Tuple's
% val (x, y, z) = (1, 2, 3)


\begin{frame}[fragile]{Scala Iteration}
Expand All @@ -50,6 +75,10 @@
val tbl2 = new ArrayBuffer[Int]
for (e <- tbl)
tbl2 += 2*e

// loop over hashmap key / values
for ((x, y) <- vars)
println("K " + x + " V " + y)
\end{scala}

% // create second table with doubled elements
Expand Down
25 changes: 15 additions & 10 deletions doc/getting-started/modules-guts.tex
Original file line number Diff line number Diff line change
Expand Up @@ -178,18 +178,23 @@ \subsection{The Mux Class}
val out = Mux(select, A, B)
\end{scala}

Thus if \verb+A=10+, \verb+B=14+, and \verb+select+ was \verb+true+, the value of \verb+out+ would be assigned 10. Notice how using the \verb+Mux+ primitive type abstracts away the logic structures required if we had wanted to implement the multiplexor explicitly. The instantiation would look something like this:
Thus if \verb+A=10+, \verb+B=14+, and \verb+select+ was \verb+true+, the value of \verb+out+ would be assigned 10. Notice how using the \verb+Mux+ primitive type abstracts away the logic structures required if we had wanted to implement the multiplexor explicitly.

\begin{scala}
// where n is the width of A and m is the width of B
val mux = Module(new Mux(n, m))
mux.io.select := select
mux.io.A := A
mux.io.B := B
val out = mux.io.out
\end{scala}
% Martin: I would drop the following as it is just confusing in a tutorial
% state simple that there is a Mux primitive and that is fine.

We see that clearly it is much cleaner to use the primitive \verb+Mux+ type instead of trying to write and implement our own general multiplexor since the \verb+Mux+ type does all the wiring for you.
%The instantiation would look something like this:
%
%\begin{scala}
%// where n is the width of A and m is the width of B
%val mux = Module(new Mux(n, m))
%mux.io.select := select
%mux.io.A := A
%mux.io.B := B
%val out = mux.io.out
%\end{scala}
%
%We see that clearly it is much cleaner to use the primitive \verb+Mux+ type instead of trying to write and implement our own general multiplexor since the \verb+Mux+ type does all the wiring for you.


%\section{Exercises}
Expand Down
10 changes: 9 additions & 1 deletion doc/getting-started/state-guts.tex
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ \subsection{The .otherwise Clause}

\subsection{The unless Clause}

% Martin: this feels a little bit strange as it is not a usual construct in a programming language.
% It is simple !condition, right? So I would drop it.

To complement the \verb+when+ statement, Chisel also supports an \verb+unless+ statement. The \verb+unless+ statement is a conditional assignment that triggers only if the condition is false. The general structure for the \verb+unless+ statement is:

\begin{scala}
Expand Down Expand Up @@ -193,6 +196,8 @@ \subsection{Synchronous vs. Combinational Read}
val syncMem = Mem(UInt(width = 32), 128, seqRead = true)
\end{scala}

% this needs more elaboration. Memories in hardware are tough...

By default, Chisel will assume that the read behavior is combinational.

\subsection{Adding Write Ports}
Expand Down Expand Up @@ -269,7 +274,10 @@ \subsubsection{Synchronous Read Ports}

\subsection{Example of Mem in Action}

We introduced a basic stack pointer bookkeeping example earlier in the tutorial. In this section we show how the complete stack implementation would look like.
% Martin: no, it was not yet shown
%We introduced a basic stack pointer bookkeeping example earlier in the tutorial. In this section we show how the complete stack implementation would look like.

Here we provide a small example of using a memory by implementing a stack.

Suppose we would like to implement a stack that takes two signals \verb+push+ and \verb+pop+ where \verb+push+ tells the stack to push an input \verb+dataIn+ to the top of the stack, and \verb+pop+ tells the stack to pop off the top value from the stack. Furthermore, an enable signal \verb+en+ disables pushing or popping if not asserted. Finally, the stack should always output the top value of the stack.

Expand Down
Loading

0 comments on commit c5794df

Please sign in to comment.