Teach Remote lab lessons

Teach lesson

Two switches, two decisions · Verilog

A machine needs a green light when both guards are closed and a warning when exactly one is closed. Build those two decisions on two physical LEDs.

  • RealDigital BooleanBoard FPGA
  • 40 min
  • Upper secondary, technical college or first-year engineering
  • English
  • Electronics · Technology

Sign in with an educator account to prepare a class session. Students join with a class code.

RealDigital BooleanBoard FPGA
RealDigital BooleanBoard FPGA

Learning Outcomes

  • Implement AND and XOR and distinguish them with a four-row physical truth table.

Student activity preview

Activity Content

Preview only. In a class session, students can fill in responses and submit their work to the teacher.

1

Predict

8 min

A machine needs a green light when both guards are closed and a warning when exactly one is closed. Build those two decisions on two physical LEDs.

Treat a closed guard as 1. An AND gate asks whether both inputs are 1. Exclusive OR (XOR) asks whether they differ. SW1 and SW0 stand in for the guards. LED0 is the green-light command and LED1 the warning. In a pair of written bits, read LED1 first and LED0 second.

For SW1 SW0 = 01 and then 11, predict LED1 LED0 for each pair. Which setting would expose a warning accidentally built with inclusive OR?

2

Build and test

25 min

Starting circuit

The starter already implements permission. Its warning lights whenever either guard is closed, including when both are closed. Change the warning to mean exactly one.

In Verilog, & combines single bits with AND, | with OR and ^ with XOR. A continuous assign describes a connection that is active all the time.

Start with this complete file. The marked line is the part to change.

module leds_mirror(input wire [15:0] sw, output wire [15:0] led);
    assign led[0] = sw[1] & sw[0];
    assign led[1] = sw[1] | sw[0]; // *
    assign led[15:2] = 14'd0;
endmodule
  1. Open the editable Boolean Board lab. Paste the starting circuit into the main file (leds_mirror.v) and keep leds_mirror as the top-level design.

  2. Change the warning expression. Leave LED0 connected to AND and all unused LEDs at zero.

  3. Check that the interface is Standard. Wait for the edit to save, choose Synthesize, wait for success, then choose Upload to FPGA. The board can open directly. If the board picker stays open, choose Upload now under Boolean Board. If it reports temporary unavailability, wait briefly and retry there. Your saved HDL stays in the editor. Find the numbered switches and the board camera.

  4. Set SW1 SW0 to 00, 01, 11 and 10 in that order. Change just one switch each time. Write LED1 LED0 from the camera for each setting.

  5. After your last reading, leave the board and return to this activity. Choose Attach saved code and check that a file appears. Select Mark practice as done and confirm. After filling in your bench notes and explanation, choose Submit work and confirm your submission.

Available in a class session

Bench notes

Record two bits per row, LED1 first. Use the actual camera observation.

Test Observed output

Tested source

Capture the project you synthesized using the activity's code snapshot control.

3

Defend your result

7 min

A classmate tested only 00 and 01 and said the warning was correct. Cite the missing decisive row and explain how its two LEDs distinguish permission from warning.

Turn this preview into a live class session

Continue to LabsLand Teach to use this lesson with your students and review the access available to your account.