I want you to email me your assignment this week. You can either zip together a set of files, or send them separately. My address: fickas@cs.uoregon.edu.
We have been looking at what are called "combinatorial" circuits. General idea is that these type of circuits compute truth tables. If you know what values your inputs are, you know what your output should be. However, there is another type of circuit that does not have this property. They are called "sequential" circuits. Sequential circuits "keep state". They have a memory. So when you provide input values, the output depends on what state the memory is in. As you might expect, we can build up a computer memory this way. When you went to "store" a value in a variable, you eventually use a sequential circuit to remember that value.
Read chapter 38 in Dewdney.
Part a. Using the xLogicCircuit tool, build a 3 bit register patterned after figure 38.5. First build a NAND gate and store it as a component. Then build a clocked flip-flop and store it as a component. Then design and build the 3 bit register. The register should have 3 input lines x1,x2,x3. It should also have the LOAD,CLOCK and CLEAR lines shown. It should have three output lines. Save your components - you will need them for next problem.
Part b (EXTRA CREDIT). Build a memory cell as in figure 38.6. Use the NAND gate and clocked flip-flop from part a as building blocks. Store the memory cell as a component. Now build a 2 by 2 memory, where each word is 2 bits in length and the entire memory is 2 words long. Use figure 38.7 as a guide.
Note that figure 38.7 has a component called a Decoder (a 3x8 decoder). The general idea is that you need to select which word in memory to read or write. The memory in figure 38.7 consists of 8 words (of 4 bits each). The output of the decoder has 8 lines (labeled 0-7). These do the selecting. It is expected that only one of the 8 is ever on (has value 1) at any one time. The three input lines to the decoder are meant to represent a binary number. There are 3 lines. This should give us 8 combinations, e.g., 000, 001, ... 111. What the decoder does is take the 3 input lines, treats them as a binary number, and then puts a 1 out on the corresponding output line. So if I wanted to select word 6 in memory (selected by line 5), I would put 101 on the input lines. Given that you only have 2 words of memory, you can get rid of the decoder. You can replace the three input lines with one: if it is 0 then select the first word of memory; if it is 1 then select the second word of memory.
Points for part b. I'll give you 50 points to add on to your total homework score. Reminder: part b is optional and will not affect your score on this specific assignment.
Hint: I would do problem 2 before tackling part b; problem 2 is a tough one.
Turn-in: For both parts a and b, I would like a file that I can load into xLogicCircuit and then test your circuits.
I'd like you to do some more practice with arrays. I'd like you to write a program that will reverse an array of ints. Thus,
A problem like this is best worked out using paper and pencil before trying to program. Start simple. Solve for an array of 3 items. Then try with 4 items. At some point, you should begin to see an algorithm on paper. At this point, you can think about coding it.
My preference is for you to use just the single array I have defined, and not define a second one. However, if that is the only way you can see to solve the problem, go ahead and use a second array.
Turn-in: send me your Java file. I will run it with my own array data.