Set the simulation time to a suitable value, such as 100ms.
Run the simulation.
To operate the lock in the simulation, we can follow these steps:
Momentarily activate the RESET switch.
Set the switches SWA, SWB, and SWC to the first part of the combination.
Momentarily toggle the ENTER switch back and forth.
Set the switches to the second part of the combination.
Toggle the ENTER switch again.
If the correct combination is entered, the LED will turn on. Otherwise, the LED will remain off.
Here is an example of a PSpice simulation of the circuit:
* Simulation of sequential combination lock circuit
* Components
D flip-flops: U1, U2, and U3
Switches: SWA, SWB, and SWC
Push-button switch: ENTER
AND gate: U4
OR gate: U5
NOT gate: U6
LED: D1
* Subcircuit
subckt combination_lock_subcircuit
input SWA, SWB, SWC, ENTER
output Q
reg [2:0] state;
always @(posedge ENTER) begin
if (state == 3'b000) begin
if (SWA == 1'b1 && SWB == 1'b1 && SWC == 1'b1) begin
state <= 3'b001;
end else begin
state <= 3'b000;
end
end else if (state == 3'b001) begin
if (SWA == 1'b0 && SWB == 1'b0 && SWC == 1'b0) begin
Q <= 1'b1;
end else begin
state <= 3'b000;
end
end else begin
state <= 3'b000;
end
end
endsubckt
* Circuit
V1 5 0 DC 5V
SWA 1 0 SW
SWB 2 0 SW
SWC 3 0 SW
ENTER 4 0 SW
U1 5 6 DFF
U2 7 8 DFF
U3 9 10 DFF
U4 11 12 13 AND
U5 14 15 16 OR
U6 17 18 NOT
D1 19 20 LED
* Connections
SWA 1 11
SWB 2 12
SWC 3 13
ENTER 4 15
U1.Q 6 17
U2.Q 8 14
U3.Q 1
There are currently no comments