This is an exam. You may consult your notes, any book, and the internet. You may not speak with any person other than Jeff Ondich, electronically or otherwise, about the content of this exam. If you obtain relevant information from any source other than yourself, cite your sources clearly.
(4 points) Consider this C program. Get yourself to a Unix terminal (say, on one of the Macs in the CMC labs or Weitz 138). Follow the instructions in the comment to compile and run the program. This program runs for kind of a long time, so just let it run until it completes. Read a book or something.
(8 points) Write a MIPS subroutine called convert whose job is to convert a string encoded in UTF-16LE to UTF-16BE. At the time convert is invoked (via jal convert), register a0 should contain the memory address of a null-terminated UTF-16LE string. After convert returns (via jr $ra), the string (i.e. in the exact same memory addresses) should be a null-terminated UTF-16BE string with the same characters in it.
Note that this is not really as complicated as it might sound. The convert subroutine just needs to swap the first and second bytes, then swap the third and fourth bytes, etc. until it encounters two bytes containing zero.
(6 points) Consider the 32-bit number 0x80470007. What does this number represent if you interpret it as:
(8 points) Consider the MIPS instruction
(8 points) Consider the following boolean function of three variables:
(6 points) Consider the following story about D latches and flip-flops.
Assuming there was a long enough pause between each step to enable the whole circuit to stabilize, draw a timing diagram for this story for each of the following:
This D latch
This D flip-flop
(2 points) I'm looking for a TV show to watch. Any suggestions? (Don't watch TV? I'm always looking for book recommendations, too.)
(8 points) I was at a lunch yesterday, talking to my friend Julie from the Psychology department, and she told me about a digital circuit she needed to build a few years ago in her research into the behavior and cognition of monkeys. I don't remember the exact circuit, but it was something like this.
You start with a button, of the kind where you can push it down, but when you take your hand off it it pops up again. This button has a line coming out of it that has value 0 when the button is in its normal state, and value 1 when you're pushing the button down. In addition to the button, this circuit has two lights (L1 and L2), each with a single input line. Each light is on if its input line has value 1, and off if its input line has value 0.
Julie wants these devices to behave like so:
Your job is to design a circuit that does this. Your circuit should have one button, two lights, and any of the digital components we have discussed in class (i.e. gates, multiplexers, decoders, adders, D latches, and D flip-flops). You definitely won't need all of those components, but you'll need some. Keep your circuit as simple as possible.