\documentstyle[fancyheadings]{article}
\newcommand{\path}{/mann/a/a/bigu/}
\newcommand{\hu}[1]{\noindent {\Huge #1}}
\newcommand{\hunew}[1]{\newpage \noindent {\Huge #1}}
\newcommand{\hru}{\vspace{.1in}\hrule \vspace{.1in}}

%\usepackage{fancyheadings}
\pagestyle{fancy}
\setlength{\headrulewidth}{0.0 pt}
%\setlength{\footrulewidth}{0.4 pt}
\setlength{\footrulewidth}{0.0 pt}
%\lhead{\textbf Mann}
%\chead{}
%\rhead{\thepage}
\lfoot{ECE385F Final Exam}
\cfoot{\thepage}
\rfoot{/16}

\input{/mann/a/a/bigu/extracommands.tex}
\input{/mann/a/a/bigu/figs/psfig.sty}
\input{/mann/a/a/bigu/figs/figcommands.tex}
\begin{document}
Q1$\_\_\_\_\_\_\_\_$/10  Q2$\_\_\_\_\_\_\_\_$/10  Q3$\_\_\_\_\_\_\_\_$/10  Q4$\_\_\_\_\_\_\_\_$/10  Q5$\_\_\_\_\_\_\_\_$/10\\
(All five questions weighted equally.)
\begin{center}
University of Toronto\\
Faculty of Applied Science and Engineering\\
Department of Electrical and Computer Engineering\\
Faculty of Arts and Science\\
{\bf ECE385F} - Microprocessor Systems\\
Final Exam\\
December 10, 2002\\
{\bf OPEN BOOK EXAM}\\
{\bf TYPE X (SELF-CONTAINTED COMPUTATIOAN AIDS PERMITTED)}
\end{center}
Family Name: $\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_$\\
First Name: $\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_$\\
Student Number: $\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_$\\
Signature: $\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_$\\
Duration: 2 Hours\\
Answer all questions on this test paper.

\hu{Q1:}
A shaft rotational encoding wheel comprises an outer portion, labelled
``Re'', and an inner portion, labelled ``Im'', as shown below:\\
\figc{ece385final2002/shaft_encoder_description.idraw}\\
As the shaft is turned through one revolution, the waveforms, shown,
are produced.  (This is what one might observe on a dual trace oscilloscope.)

Q1a: Can the output from this shaft encoder be used to distinguish the
difference between clockwise rotation and counterclockwise rotation?
If so, explain how.

\hru
\hru
\hru
\hru
\hru
\hru
\hru
\hru
\hru

Q1b: A shaft encoder, like the one shown above, is connected to
a first gerbil wheel, at a remote
site where you cannot see the gerbil or the wheel.
A second identical shaft encoder, is connected to a second gerbil wheel,
at a remote
site where you cannot see the gerbil or the wheel.
From the remote site,
the output of the two shaft encoders is transmitted to you, and you can observe
the following waveforms, on a four-trace oscilloscope:\\
\figc{ece385final2002/shaft_encoder_what_happened.idraw}\\
The pair of waveforms, labelled Gerbil 1, denote the output from the first
gerbil wheel.  The second pair of waveforms, labelled Gerbil 2,
denote the output from the second gerbil wheel.
Write down everything you know about the manner in which each of the two
gerbils are turning their respective wheels.\\
{\bf Gerbil 1:}
\hru
\hru
\hru
\hru
\noindent {\bf Gerbil 2:}
\hru
\hru
\hru
\hru

Q1c: The professionally manufactured shaft encoders in Q1a and Q1b are
too expensive, and we need them by the dozen, so suppose we come across a
dumpster full of hundreds of small fragments of magnetic material that can each
be used as a magnet, as well as hundreds of magnetic sensors (surplus
magnetic recording and playback
tape heads like the ones you used in the card readers), as well as hundreds
of logic circuits, that can each convert the output of one of the
magnetic sensors into a short
pulse, i.e. a ``blip'' as shown in the diagram below (or next page):\\
\figc{ece385final2002/inventing_3phase.idraw}\\
Here we have stuck two magnets to a gerbil wheel as shown in the diagram,
and then used two of the magnetic sensors, as shown, each connected to
a logic circuit (denoted SIG. PROC.).  Can this configuration reliably
be used to determine the direction of rotation of the gerbil wheel?
If so, write a device driver to tell speed and direction using IRQ 9 and
IRQ 10 of the ISA bus.
If not, suggest an alternative arrangement that can, and write
a device driver for this alternative arrangement.
State any assumptions you might make.
\hru
\hru
\hru
\hru
\hru
\hru
\hru
\vspace{2in}
\hru
\hru
\hru
\hru
\hru
\hru
\hru
\vspace{2in}
\hru
\hru
\hru
\hru
\hru
\hru
\vspace{1in}

Q1d: Assume you come across another dumpster that has a wide assortment of
7400 series logic gates, i.e. anything with part number 74*.
Design a circuit that enables the system of Q1c to plug into the parallel
port of a personal computer.  Hint: note that the parallel port only has
one interrupt available.
%\vspace{1in}
\hru
.
\hru
.
\hru
.
\hru
.
\hru
.
\hru
.
\hru
.
\hru
.
\hru
.
\hru
%\vspace{2in}

\hunew{Q2:}
An industrial accident has caused 1000 workers to be exposed to a hazardous
substance.  To minimize exposure, they must all have the substance washed off
quickly.
They form four lines, in front of four shower nozzles,
as shown below:\\
\figc{ece385final2002/showerpipelines.idraw,height=4in}\\
with 250 workers in each of LINE 1, LINE 2, LINE 3, and LINE 4.
Each worker requires a 30 second soaking, a 30 second soaping, and then
a 60 second rinse.
There are four shower nozzles, and each can be programmed
by way of the parallel port.  Water input is denoted ``W''.
Soap input is denoted ``S''.
Initially all eight inputs (four ``W'' and four ``S'') are zero.
Four workers move forward, for a 30 second soaking, while the number
0x55 is written out to the parallel port.
Then the number 0xAA is sent out the parallel port to change the
controllers to ``Soap''.  It takes 15 seconds to change from Water to Soap.
The four workers are then soaped for 30 seconds.  Then the number
0x55 is written out to the parallel port, whereupon it takes 30 seconds for
the system to change from Soap to Water.  After the changeover,
a one minute rinse is performed.  After this, the next four
workers move forward, and the process repeats.  (Assume that the
next four workers can move forward without any delay.)
It takes therefore 165 seconds total for each four workers, and thus,
41250 seconds total, i.e. 687.5 minutes (more than 11 hours).
For those at the back of the line, that's a long time to wait.

Can the system be improved without adding any new equipment?
\hru
If so, how?  Explain in detail, using
diagrams, equations, text, or whatever other means you can devise.
(Ignore gender separation issues, i.e. for simplicity, you may assume
that the threat of the exposure outweighs any privacy concerns that
might otherwise arise.)
\hru
\hru
\hru
\hru
\hru
\hru
\hru
\hru
\hru
\hru
\hru
\vspace{4in}
.
\hru
\hru
\hru
\hru
\hru
\hru
\hru
\hru
\hru
\hru
\hru
\hru
\hru

\hunew{Q3:}
Q3a:
On average, will RISC machine language code be shorter (take up less memory)
or longer (take up more memory) than CISC machine language code?
Which is easier to pipeline and why?
\hru
\hru
\hru
\hru

Q3b:
Explain the different kinds of pipelining hazards and how they are overcome.
Explain how good compiler design mitigates, or partially mitigates pipeline
stalls.  Use clearly designed examples, and explain clearly, using
diagrams, equations, and text, as appropriate.
\hru
\hru
\hru
\vspace{3in}
.
\hru
\hru
\hru

\hunew{Q4:}  You are to make a prototype eyeglass-mounted display, for teaching
purposes.  It does not need to actually work really well, but merely
illustrates how a display works.
Your display will use 64 light-emitting diodes (LEDs),
in a linear array, together
with a vibrating mirror.  The mirror vibrates in a sinusoidal fashion,
undergoing simple harmonic motion, due to a mass+spring arrangement
(including a counterweight for balance), similar to the \$2.00 Active Surplus
apparatus that was passed around in class one day.
Assume that the mirror will keep vibrating enough due to the bouncing around
of the device in ordinary day-to-day life.  In other words, assume that the
mass+spring arrangement will continue to stay excited due to energy it
randomly receives from the environment.  Assume that the amplitude of the
oscillations rises and falls at random, but is never less that that required.
Assume you have access to the same small magnets and magnetic sensors you had
in Q1c and the components of Q1d.

Q4a: Design a circuit to display time-varying visual information
(such as a sequence of two dimensional data)
on the device, so that it can be used as a video
display interfaced to a microprocessor.  Choose either a parallel port
interface, or an ISA bus interface
to a 0x86 microprocessor (e.g. a Pentium processor)
in a typical computer, running
GNU Linux.
Include the physiological perception (visual appearance) of
variable brightness for each LED.  Choose either to generate a two dimensional
array of pixel data, to output, or textual data to output and explain the
merits of your choice, while considering Q4b before making your choice.
\hru
\hru
\hru
\hru
\newpage
.
\hru
\hru
\hru
\hru
\vspace{4in}
.
\hru
\hru
\hru
\hru

Q4b: Write the necessary GNU Linux device drivers,
and other programs that would make
the aforementioned device in Q4a become your console.  Your drivers and other
programs should be such that a GNU Linux login prompt appears in the
eyeglasses when your computer is booted.  Include an explanation of what
startup scripts, and other aspects of your computer might need to be modified,
and how, in order that the system would boot with the aforementioned device of
Q4a being the console.  You may choose not to write out every line of code,
but must indicate in summary, the key elements of the driver, and describe
clearly (and prove that you know) how you would write such a driver.
Choose SVGATextMode or X windows, or your own methodology, as you see fit.
\newpage

\hunew{Q5:} You are to design a hot water heater system, to be interfaced to a
microprocessor, and to program the system.
Assume that you have a hot water heater, as follows,\\
\figc{ece385final2002/hotwater.idraw}\\
where a temperature sensor (denoted TEMP. SENS.) is connected to an 8 bit
analog to digital converter (denoted AtoD).  Assume the temperature is
returned as a number, from 0 to 255, in units of degrees Fahrenheit
(an ancient unit of temperature measurement
proposed by the German physicist who invented the alcohol thermometer
in 1709, and the mercury thermometer 1714, and still used in the United States
where the device is to be shipped for use in Emergency Preparedness and
Homeland Defense after you have finished making it work).
It is desired to regulate the hot water at a chosen temperature (typically
in the region 105 to 140 Fahrenheit), to within plus or minus one degree.
Devise a control circuit, interface, etc., to connect the hot water heater
to a typical microcomputer that runs GNU Linux, and show the steps you
would take to extend the operating system, and other actions necessary
to facilitate the control of the temperature, as well as ignition signal
for the igniter (denoted IGNITER), and valve to turn on the gas,
denoted GAS VALVE.  When temperature falls more than 1 degree below set point,
You are required to sequence operations as follows:
\begin{itemize}
 \item turn on gas;
 \item wait 500 milliseconds (justify your choice of timing method);
 \item ignite gas (this requires a TTL voltage level pulse of duration
       20 milliseconds);
 \item wait 500 milliseconds;
 \item check for presence of flame.  To do this, you may use the
       Rectifire (TM) flame sensor, denoted on the drawing as
       RECTIFIRE (TM).  The Rectifire (TM) uses the property of rectification
       of the flame, namely that electric current travels more easily in one
       direction than in another.  The Rectifire (TM) works in much the
       same way as a vacuum tube rectifier, except that there is no filament:
       the flame takes on the role of filament or heater.
       Thus you are provided with an input and an output, and you must test
       to see if rectification is taking place, in which case you know that
       there is a flame present.
 \item if a flame is not present, turn off the gas and sound an alarm.
       Assume you have an alarm input that accepts a TTL voltage level signal
       that sounds the alarm when it goes high or when it goes low.
       Choose active high or low and explain the reason for your choice;
 \item if a flame is present, keep it burning until the water temperature
       goes one degree above the set point.
\end{itemize}
\hru
\hru
\hru
\hru
\hru
\hru
\hru
\hru
\hru
\hru
\hru
\hru
\hru
\hru
\hru
\hru
\hru
\hru
\hru
\vspace{4in}
.
\hru
\hru
\hru
\hru
\hru
\hru
\hru
\hru
\hru
\hru
\hru
\hru
\hru
\hru
\hru
\hru
\hru
\hru
\hru
\vspace{4in}
.
\hru
\hru
\hru

\end{document}

