Register output to bus
The goal of this entry is to make the first version of our register, "Quad D flip-flop" (see entry 9), "bus-friendly" by completing the following schematics we looked at in entry 12:
Each of the four tri-state buffers has an "enable", and all of them will be connected. This will make them all enabled or none of them enabled:
Quad three state switch
I combined four three state switches into a component QuadThreeStateSwitch.
- Four D input pins: D[4] (by this I mean D[0], D[1], D[2], D[3])
- Input pin: Enable (connected to all switches)
- Four W output pins: W[4] (that is, W[0], W[1], W[2], W[3])
The data bus
The data bus is simply four wires that can be connected to various components. Each wire is tri-state, that is, it can be either connected to ground, to +5V, or be disconnected / floating (Z). I created a component with four wires, BusLineFour. To set and read the state of each wire, it has
- Four connections X[4]. These are used when a component puts data onto the bus.
- Four connections W[4]. These are used when a component reads data from the bus.
Building and testing
We will use these three components:
- QuadDFlipFlop, our first version register from entry 9.
- QuadThreeStateSwitches.
- BusLineFour.
To test this out:
- Connect 4 DIP switches to the D-inputs of QuadDFlipFlop.
- Connect a button to QuadDFlipFlop Clock
- Connect the Q-outputs of QuadDFlipFlop to D-inputs of QuadThreeStateSwitches
- Connect a button to QuadThreeStateSwitches Enable
- Connect QuadThreeStateSwitches W-outputs to BusLineFour X-inputs. (we will not use the BusLineFour W-outputs in this example).
This will allow as to latch a number (0 to 15) into the flip-flops. When we set Enable = 1, this value will go onto the bus. When we set Enable = 0, the bus will be "disconnected", ZZZZ. We can check the state of the data bus using "Print".
Making four connections
Many of the connections that we need to make are in "sets of four". Instead of writing four "Connection", I created a "ConnectionFour". For example, if we define
then the four connections between the register and the switches can be written
new ConnectionFour(reg->Q, switches->D),
This is equivalent to four connections, Q[0] to D[0], and so on. Connection4 can also be used with Arduino pins. For example,
new ConnectionFour(ard, 2, reg->D, 0),
will connect Arduino pin 2 to D[0], ..., Arduino pin 5 to D[3].
new ConnectionFour(ard, 2, reg->D, 1),
will reverse the order, Arduino pin 2 to D[3], ..., Arduino pin 5 to D[0]. Here are all the connections:
No comments:
Post a Comment