Class MockRegister
java.lang.Object
io.zucchini.circuitsimtester.api.MockRegister
Represents a "ghost" register: a register component replaced with Pin
components for easier testing. Useful for testing the combinational
logic in a sequential circuit by getting/setting the Pins contained
in it.
Idea: Suppose we want to test a circuit that looks like this
______ .-------|D Q|------. | | | | | |_/\___| | | | '--[ combinational ]--' [ logic ]
but we want to test that combinational logic — who cares about the register? So rewire the circuit to look like this instead, where d is an output pin, and q is an input pin:
.-------(d) [q]------. | | | | | | '--[ combinational ]--' [ logic ]
This way, we can test that combinational logic on its own by
setting the value of q and then checking the value of d. In fact, a
MockRegister
contains a new input/output pin for every
Register Port so you can test the student connected all register
ports correctly.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptiongetClk()
Returns the Pin which replaced the clock port of the register.getD()
Returns the Pin which replaced the in port of the register.getEn()
Returns the Pin which replaced the write enable port of the register.getQ()
Returns the Pin which replaced the out port of the register.getRst()
Returns the Pin which replaced the reset port of the register.Returns theSubcircuit
where the Pins which make up thisMockRegister
live.
-
Method Details
-
getQ
Returns the Pin which replaced the out port of the register. This is the only input Pin inMockRegister
since you shouldInputPin.set(int)
this to the value you want the "ghost" register to contain in the test.- Returns:
- the
InputPin
for the Q register port
-
getD
Returns the Pin which replaced the in port of the register. This is an output Pin because the student's code will set it to something.- Returns:
- the
OutputPin
for the D register port
-
getEn
Returns the Pin which replaced the write enable port of the register. This is an output Pin because the student's code will set it to something.- Returns:
- the
OutputPin
for the write enable register port
-
getClk
Returns the Pin which replaced the clock port of the register. This is an output Pin because the student's code will set it to something.- Returns:
- the
OutputPin
for the clock register port
-
getRst
Returns the Pin which replaced the reset port of the register. This is an output Pin because the student's code will set it to something.- Returns:
- the
OutputPin
for the reset register port
-
getSubcircuit
Returns theSubcircuit
where the Pins which make up thisMockRegister
live.- Returns:
- the subcircuit where this mock register lives
-