\documentclass{article}
\usepackage[affil-it]{authblk}
\usepackage{graphicx}
\usepackage[space]{grffile}
\usepackage{latexsym}
\usepackage{textcomp}
\usepackage{longtable}
\usepackage{tabulary}
\usepackage{booktabs,array,multirow}
\usepackage{amsfonts,amsmath,amssymb}
\providecommand\citet{\cite}
\providecommand\citep{\cite}
\providecommand\citealt{\cite}
\usepackage{url}
\usepackage{hyperref}
\hypersetup{colorlinks=false,pdfborder={0 0 0}}
\usepackage{etoolbox}
\makeatletter
\patchcmd\@combinedblfloats{\box\@outputbox}{\unvbox\@outputbox}{}{%
  \errmessage{\noexpand\@combinedblfloats could not be patched}%
}%
\makeatother
% You can conditionalize code for latexml or normal latex using this.
\newif\iflatexml\latexmlfalse
\AtBeginDocument{\DeclareGraphicsExtensions{.pdf,.PDF,.eps,.EPS,.png,.PNG,.tif,.TIF,.jpg,.JPG,.jpeg,.JPEG}}

\usepackage[utf8]{inputenc}
\usepackage[english]{babel}




\begin{document}

\title{FPGA Lab 5}


\author{Alec Aivazis}
\affil{Affiliation not available}



\date{\today}

\maketitle

\selectlanguage{english}
\begin{abstract}
Lab 5 instructed us to design a stopwatch using the supplied FPGAs. The circuit needed to be able to increment every tenth of a second and track the number of minutes and hours that had passed. While I was instructed to make a three-state machine that is driven by one button that causes the timer to stop/stop/reset in that order. However, I implemented a two-state system and attached the reset functionality to a second button in order to reflect the design of stopwatches that I had encountered. This lab was very useful in demonstrating the steps that are involved when creating a complete circuit. This included designing state machines as well as importing modules previously defined as external libraries which are extremely common when designing circuits. %
\end{abstract}%



\section{Introduction}

There were two main parts to the stopwatch: the controller which handled the state of the counters, and the counter itself. The main obstacle that I encountered while designing this circuit was to find a way to have the same button perform two different tasks. By implementing the controller using a finite state machine, I could easily trigger the transition between the various states off of the same input. Another difficulty I encountered was that the inputs were staying high longer than the transition time, causing two transitions to happen back to back. In order to prevent this, I attached the button to a positive edge trigger which only sent a short burst.

The counter was implemented using a series of decimal coded binary counters with appropriate modulus's in order to cause the next counter to increment at 59 minutes rather than 99. 


\section{Circuits / Figures}

The circuit built in this lab can be broken into two separate parts: the controller and the display. The controller is discussed in figure \ref{fig:control} and the display in figure \ref{fig:display}.\selectlanguage{english}
\begin{figure}[h!]
\begin{center}
\includegraphics[width=0.70\columnwidth]{figures/lab-5-1/lab-5-1}
\caption{{\label{fig:control}
This diagram shows the part of the circuit that is responsible for the logic driving the counter. The core of the controller is the finite state machine labeled \textit{stop} in the diagram. The state machine is responsible for causing the counter to begin counting from its current value as well as stopping the count. As shown in figure \ref{fig:fsm}, when the button goes high, the state machine switches between \textit{start} and \textit{stop}. In order to trigger the transition, the built in keys on the FPGA were hooked up a positive edge trigger which sent a short pulse to the state machine causing only a single transition \footnote{If the pulse is too long then it will still be high when the transition occurs causing another one.}. Since the keys on the FPGA are attached to built in debouncers, I did not have to bring one in from previous projects. The second button is attached to the clear of each counter and acts as a reset.%
}}
\end{center}
\end{figure}\selectlanguage{english}
\begin{figure}[h!]
\begin{center}
\includegraphics[width=0.70\columnwidth]{figures/lab5-3/lab5-3}
\caption{{\label{fig:fsm}
This figure shows the logic for the finit state machine discussed in figure \ref{fig:control}. There are two inputs defined: \textit{button} and \textit{clock}; and one output: \textit{count}. When count is high, this corresponds to causing the counter to increment. When count is low, the counter stops counting. As previously discussed, the state machine transitions between the two behaviors when the button input goes high, triggered by the positive edge trigger.%
}}
\end{center}
\end{figure}\selectlanguage{english}
\begin{figure}[h!]
\begin{center}
\includegraphics[width=0.70\columnwidth]{figures/lab-5-2/lab-5-2}
\caption{{\label{fig:display}
This figure shows the display circuitry for the stopwatch. As shown, the first counter has a modulus of 500000 causing the \textit{cout} pin to go high every tenth of a second when driven by the 50 MHz clock on the FPGA. This is then connected to a counter with a modulus of 10. The output of which tracks the counter and the \textit{cout} pin triggers the next counter. The only tricky part is to make the tens counter for minutes and hours have a modulus of 6 which causes the counter to count 1 minute as 60 seconds.%
}}
\end{center}
\end{figure}

\selectlanguage{english}
\FloatBarrier
\end{CJK}\end{document}

