\documentclass[noanswers,addpoints,10pt]{exam}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage[most]{tcolorbox}
\usepackage{datetime}
\usepackage{enumerate}
\usepackage{enumitem}
\usepackage{xltxtra}
\usepackage{listings}
\usepackage{listings-mips}

\usepackage{graphicx}
\usepackage{hyperref}
\usepackage{makecell}
\usepackage{multicol}
\usepackage{multirow}

\usepackage{tabularx}
\usepackage{textcomp}
\usepackage{tikz}
\usetikzlibrary{arrows,automata,decorations.pathmorphing,backgrounds,positioning,fit}
\usepackage{pgf-umlcd}

% compact itemized and then enumerated
\setlist{leftmargin=*,
  noitemsep,
  topsep=5pt,
  parsep=0pt,
  partopsep=0pt,
}

\setlist[enumerate]{leftmargin=*,
  itemsep=2pt,
  topsep=0pt,
  parsep=0pt,
  partopsep=0pt,
}


\usepackage{fontspec}
\setmainfont{Gentium Basic}
\setmonofont{Comic Code}[
  Scale          = 0.80,
  UprightFont    = *-Regular,
  ItalicFont     = *-Italic,
  BoldFont       = *-Bold,
  BoldItalicFont = *-Bold Italic
]

\lstset{
  language=[mips]assembler,
  basicstyle=\ttfamily,
}

\DeclareMathOperator{\limplies}{\Rightarrow}
\DeclareMathOperator{\liff}{\iff}
\DeclareMathOperator{\lxor}{\oplus}
\DeclareMathOperator{\qeq}{\overset{?}{=}}
\DeclareMathOperator{\modulus}{\mathbf{mod}}
\DeclareMathOperator{\even}{even}
\DeclareMathOperator{\odd}{odd}
\DeclareMathOperator{\ddiv}{|}
\DeclareMathOperator{\ndiv}{\not|}
\DeclareMathOperator{\contra}{\Rightarrow\mskip-\thinmuskip\Leftarrow}
\newcommand{\Q}{\mathbb{Q}}
\newcommand{\R}{\mathbb{R}}
\newcommand{\Z}{\mathbb{Z}}
\renewcommand{\P}[1]{\mathbb{P}(#1)}

\DeclareMathOperator{\vowel}{vowel}
\DeclareMathOperator{\consonant}{consonant}
\DeclareMathOperator{\isprime}{prime}
\DeclareMathOperator{\equals}{equals}
\DeclareMathOperator{\divides}{divides}

% classname
\newcommand\examNumber{gProgramCounter -- With Load/Enable/Reset}
\newcommand\semester{Spring 2024}
\newcommand\className{Computer Organization}
\newcommand\classNumber{CIS~356}
\newcommand\classFullName{\classNumber~\className}
\renewcommand{\dateseparator}{-}
\yyyymmdddate

% /classname

\pagestyle{headandfoot}
\firstpageheader{\classFullName\\\semester}{\examNumber\\~}{\today\\~}
\runningheader{\examNumber}{}{\today}


\title{\examNumber}


\newenvironment{showExample}[1]{
  \begingroup
  \renewcommand{\solutiontitle}{\noindent\textbf{Example:}\enspace}
  \printanswers
  \begin{solution}[#1]
  }{
  \end{solution}
  \endgroup
}

\newcommand{\NOR}{\texttt{Nor}}
\newcommand{\NAND}{\texttt{Nand}}
\newcommand{\AND}{\texttt{And}}
\newcommand{\OR}{\texttt{Or}}
\newcommand{\NOT}{\texttt{Not}}
\newcommand{\BIT}{\texttt{Bit}}
\newcommand{\BYTE}{\texttt{Byte}}
\newcommand{\REGISTER}{\texttt{Register}}

\begin{document}

\subsection*{Introduction}
This assignment is a \emph{group} assignment. If I, in the room, do
not \textbf{hear} you interacting with the other students, you are
doing it \emph{wrong}!

\section*{Assignment Goals}
\paragraph{Learning Outcomes} After completing this group assignment,
each student is expected to be able to
  \begin{itemize}
  \item \emph{Implement} a \texttt{PC} with a
    \texttt{Register} and combinatorial logic.
  \item \emph{Discuss} simpler \texttt{PC} variants (and see their
    implementation).
\end{itemize}

\section*{Procedure}

Get out paper for a \emph{single} turn-in at the end of class. Copy
enough of each question so that the paper could stand alone as a study
guide.

\noindent
\textbf{Assign Roles.} \textbf{Manager}, \textbf{Recorder}, \textbf{Reflector}, \textbf{Speaker}.

\noindent
\textbf{Answer these questions.}

\begin{questions}
\question{} What is the difference between \emph{combinatorial}
  circuits and \emph{synchronous} circuits? Answer in terms of when
  \textbf{outputs} change relative to when \textbf{inputs} change.

\question{} Given an unlimited number of sequential circuits
  (including plexers and adders) and one (1) 32-bit \REGISTER{},
  construct a \texttt{SimpleProgramCounter} that has a 32-bit
  output (its current value) and increments by 4 on every clock tick.

\question{} What makes the \texttt{SimpleProgramCounter} less
  useful than a proper \texttt{ProgramCounter}? What \emph{can't}
  it do?

\question{} Modify the \texttt{SimpleProgramCounter} to a
  \texttt{PausableSimpleProgramCounter}: it has an input,
  \texttt{run}, and it increments only on clock ticks while
  \texttt{run} is high.

\question{} Extend the \textbf{\texttt{SimpleProgramCounter}} to a
  \texttt{LoadableSimpleProgramCounter}: it has inputs: \texttt{D}
  with a new value to load; \texttt{en} to \emph{enable} loading the
  new value. On a clock tick, if \texttt{en}, latch \texttt{D},
  otherwise latch \texttt{Q} plus 4.

\question{} Extend the \texttt{LoadableSimpleProgramCounter} to a
  \texttt{ProgramCounter}. Inputs are extended with a
  \texttt{reset} flag: if \texttt{reset}, latch 0.

  \begin{tabular}{|l|l|l|}
    \hline
    \texttt{reset}&\texttt{en}&Latch\\\hline
    \texttt{0}&\texttt{0}&\texttt{Q}+4\\\hline
    \texttt{0}&\texttt{1}&\texttt{D}\\\hline
    \texttt{1}&\texttt{0}&\texttt{0}\\\hline
    \texttt{1}&\texttt{1}&\texttt{0}\\\hline
  \end{tabular}

\question{} Which flag, \lstinline{en} or \lstinline{reset}, has
  \emph{priority} in the \texttt{ProgramCounter} circuit?

  (No need to write the whole circuit.) \emph{How} would you reverse
  the priority between them?
\end{questions}
\end{document}

%%% Local Variables:
%%% mode: latex
%%% TeX-master: t
%%% End:
