Assignment #4

NOTE
For this assignment you are to use a state machine built from MUXs as the assignment says. The state machine is not mentioned in the following. What follows is what was explained in the labs. To use your MUX-state machine is quite easy, specially since there are very few state. In essence, there is a state machine in the design talked about briefly in the lab (The purpose of the lab was to show the stack pointer, not the whole assignment). The state machine in this example comprised of everything from the pushputtons to the 'register' of the stack pointer. Though the logic used 2 MUX's, these were not the state machine MUXs. Remember the two D flip-flops, these, and the logic immediatly following them comprise of the logic needed to take care of all cases (ie: push, pop, push and pop at the same time, or push or pop while an operation is already in progress) act as the state machine themselves.

Ya, a stack pointer is a register. A register is anything which stores it value. Most registers also have an 'increament' line along with a clear and set. The stack pointer is just a register which will add 1 or subtract 1 when you want. This was done in the last lab.

You can use any circuts you want which are in the libraries, so you could use a counter if one exists which will also decrement on command. I am told that there are some of those in the libraries. You will need to add additional logic to make sure your stackpointer/register/counter does not go from 1111 to 0000 or 0000 to 1111 (or 11 to 00 and 00 to 11 depending on how many bits you are using)

As for the memory, we bascilly use 4 registers. As you remember we had a read/write, clear, and clock, and of course 4 data bits. So lets just draw it like this....

           | | | |  Data In
      _____|_|_|_|_______
r/w--|                   |
clk--|                   |
clr--|___________________|
           | | | |
           | | | |  Data Out


And hook it up like this.....
 ____
|1234|-----------------------------------,
|5678|---------------------------------, |
|90AB|-------------------------------, | |
|CDEF|-----------------------------, | | |
 ````                              | | | |  Data In
 _______       ______         _____|_|_|_|_______
|       |     |      |--r/w--|                   |
| Stack |-----|      |  clk--|       R0          | 
|Pointer|     |Dcoder|  clr--|___________________|
|       |-----|      |             | | | |  
|       |     |      |             | | | |  Data Out
|       |     |      |--
|       |     |      |--
|_______|     |______|--
 __  ||           | 
|  \_||___________| 
|__/  | Push
 __   |
|  \__|____
|__/    Pop

Notice only that one of the 4 registers are shown here in the memory. The Data In lines would go to each register, as well as one decoder line per register into the read/write port.

So here the stack pointer gets decoded IF the push button is pressed since only when it is pressed does the enable light up. Also remember that the push and pop buttons are connected to 2 D flip flops as was shown in the lab and not drawn here. Clocks have not been drawn here either and if you remember we had lots of clock signals going into most everything. I beleive there was also some logic comming from the push/pop buttons before entering the stack pointer as well, (going though 2 MUXs) but that logic could be combined in the pointer. A slight variation on this would be to hook the strobe signal from the keypad into the push button (that is remove the button and just connect the signal line) Thus you do not need to hit a keypad then his a push button, but it may be advantageous to do it this way. Also, instead of running the clock to the stackpointer you can use the strobe signal as the clock. Though this may cause asyncronous signal problems, also the strobe signal may not last long enough in all cases.

So we have the write part down, but we still need to work on the read. Since we have 16 data out lines now, we need to choose the correct 4 lines to send out to the hex display.

 __|||||||||||||||__
|                   |
|___________________|
         ||||
It will look something like that.
This is a 16x4 MUX (or 4 4x1 MUXs) Take 4 MUXs and use the output from the stackpointer as the selector lines. Connect the 0th output of each register to the 0th port on each MUX. Connect the 1st output of each register to the 1st port on each MUX and so on.