Teach Remote lab lessons

Teach lesson

Digital Logic on the DE1-SoC with VHDL (1/6): Your first gates on real hardware

Students write VHDL for basic logic gates, synthesize and upload to the DE1-SoC, and verify truth tables on real switches and LEDs.

  • Altera DE1-SoC
  • 50 min
  • Undergraduate, introductory
  • English
  • Digital systems & FPGA
Altera DE1-SoC
Altera DE1-SoC

Learning Outcomes

  • Explain that VHDL describes hardware, not a program that runs step by step.

  • Use the LabsLand DE1-SoC VHDL workflow: edit, Synthesize, Upload, observe.

  • Build the six basic logic gates and verify their truth table on real hardware.

  • Recognize active-high LEDs and active-low pushbuttons on the DE1-SoC.

Student activity preview

Activity Content

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

1

What you are about to do

12 min

Most programming you have seen runs on a processor: instructions execute one after another. In this course you will do something different. You will describe a digital circuit in a language called VHDL, and a real chip will be configured to become that circuit. There is no processor running your lines one by one — your description becomes actual wires and gates that all operate at once.

The chip is an FPGA (Field-Programmable Gate Array): an integrated circuit containing a large grid of logic blocks whose connections can be reconfigured. The board is a Terasic DE1-SoC with an Intel/Altera Cyclone V FPGA — the same board used in many university digital-design courses. You reach a real one through your browser with LabsLand: a server runs Intel Quartus to turn your VHDL into a configuration file, programs the physical board, and streams a live camera so you can see the real LEDs respond.

The board parts you will use in this course:

- SW(9 downto 0) — 10 slide switches you control on screen. A switch up is logic 1.
- KEY(3 downto 0) — 4 pushbuttons. These are active-low: a button reads 0 when pressed and 1 when released.
- CLOCK_50 — a 50 MHz clock signal (used from Lesson 3 on).
- LEDR(9 downto 0) — 10 red LEDs, with LEDR0 at the right end of the row and LEDR9 at the left. These are active-high: an LED lights when you drive it 1.
- HEX0HEX5 — six 7-segment displays. These are active-low: a segment lights when you drive it 0.

The workflow (the same every lesson): the LabsLand VHDL editor opens with one file, blink.vhd, containing a top-level entity called blink. You will replace the contents of that file with the design for the exercise (always keeping the entity named blink), then click Synthesize, wait for it to finish, click Upload to FPGA, and use the on-screen switches while watching the camera. If a guided tour or help overlay covers the editor buttons, close or skip the tour before continuing.

LabsLand DE1-SoC VHDL workflow: edit the blink.vhd top-level entity, click Synthesize to run Quartus on the server, click Upload to FPGA to program the real board, then use on-screen switches and read the live camera.

The course workflow: edit blink.vhd, Synthesize (server-side Quartus), Upload to FPGA, then drive the on-screen switches and read the live camera. Your VHDL entity is synthesized directly as the top-level design, so you only ever edit this one file.

Which statement best describes what your VHDL does in this lab?

On this board, an LED lights when you drive it to which value, and a pushbutton KEY reads which value when it is pressed? (One sentence.)

2

The six basic gates

12 min

A logic gate takes one or more binary inputs and produces a binary output. Six gates cover almost everything in this course. With inputs A and B:

Truth table for A, B:

- A=0, B=0 -> AND 0, OR 0, NOT A 1, NAND 1, NOR 1, XOR 0
- A=0, B=1 -> AND 0, OR 1, NOT A 1, NAND 1, NOR 0, XOR 1
- A=1, B=0 -> AND 0, OR 1, NOT A 0, NAND 1, NOR 0, XOR 1
- A=1, B=1 -> AND 1, OR 1, NOT A 0, NAND 0, NOR 0, XOR 0

In VHDL these gates are written with the logic operators and, or, not, and xor. The design below connects switch SW(0) to A, SW(1) to B, and sends each gate result to one LED. A concurrent signal assignment such as LEDR(0) <= A and B; means the output continuously follows that expression, just like a wire connected to gates.

-- Student starter: fill the TODO lines before synthesizing.
-- Lesson 1 - basic gates. Replace ALL contents of blink.vhd with this design.
library ieee;
use ieee.std_logic_1164.all;

entity blink is
    port (
        SW   : in  std_logic_vector(9 downto 0);  -- SW(0)=A, SW(1)=B
        LEDR : out std_logic_vector(9 downto 0)
    );
end entity blink;

architecture rtl of blink is
    signal A, B : std_logic;
begin
    A <= SW(0);
    B <= SW(1);

    LEDR(0) <= TODO_AND;          -- TODO: expression for AND
    LEDR(1) <= TODO_OR;           -- TODO: expression for OR
    LEDR(2) <= TODO_NOT_A;      -- TODO: expression for NOT A
    LEDR(3) <= TODO_NAND;        -- TODO: expression for NAND
    LEDR(4) <= TODO_NOR;         -- TODO: expression for NOR
    LEDR(5) <= TODO_XOR;         -- TODO: expression for XOR
    LEDR(9 downto 6) <= (others => '0');  -- unused LEDs off
end architecture rtl;

Before you run it, work out the initial LED pattern yourself. With both switches down, A=0 and B=0 — find that row in the truth table above and decide, for each of the six gates, whether its output is 1. You will check your prediction against the live board in the next step.

With both switches down (A=0, B=0), which of LEDR(0)LEDR(5) do you predict will be lit? List them before you run the design.

3

Synthesize, upload, and verify

16 min

Now build the circuit on the real board and check it against the truth table.

  1. Open the DE1-SoC VHDL lab. The editor shows a file blink.vhd.

  2. Select all of the contents of blink.vhd and replace them with the basic-gates starter above. Fill every TODO line, then keep the entity named blink.

  3. Click Synthesize. If a guided tour covers the button, close or skip the tour first. Wait for it to finish (about 1-3 minutes). If it reports an error, check for a missing semicolon or mismatched parenthesis, fix it, and Synthesize again. A build can show many warnings; continue only when the final status says the build succeeded with 0 errors.

  4. Click Upload to FPGA and wait for the live board session and camera.

  5. With both on-screen switches SW(0) and SW(1) down (A=0, B=0), read the lit LEDs on the camera and compare with your prediction.

  6. Set SW(1) up and SW(0) down (A=0, B=1), then set SW(1) down and SW(0) up (A=1, B=0), then set both switches up (A=1, B=1), reading the six LEDs each time.

For each input row, set the switches and record what the six LEDs show on the camera (1 = lit, 0 = off). Compare with the truth table in the previous step.

A = SW(0) B = SW(1) LEDR0 AND LEDR1 OR LEDR2 NOT A LEDR3 NAND LEDR4 NOR LEDR5 XOR

Upload your evidence. Capture a camera screenshot with both switches up (SW = 11) — LEDR0 (AND) and LEDR1 (OR) lit, the others off — and attach it in the response box below.

Which single gate outputs 1 for exactly one input combination — the row A=1, B=1?

Which single gate outputs 1 for exactly one input combination — the row A=0, B=0?

In plain English, what do NAND and NOR mean in terms of AND/OR plus NOT? Use your recorded data to justify your answer.

4

Workflow check

10 min

Which sequence matches what you just did?

In three sentences, explain what "Synthesize" did, what "Upload to FPGA" did, and how you knew the gates were working. Mention one place where active-high or active-low polarity mattered.