CPEN 230L: Introduction to Digital Logic lab.

Spring 2018 - Claudio Talarico, Gonzaga University

Grading

The lowest score will be dropped

Letter Percentage
A 100-94
A– 93-90
B+ 89-86
B 85-82
B– 81-78
C+ 77-74
C 73-70
C– 69-66
D+ 65-62
D 61-58
F 57-0

Assignments

Important documents to read thoroughly:

One stop link for the ICs datasheets needed for the class:

Lab no. Topic Instructions Supporting Files Location
T0 Installing and getting familiar with the pre-lab tools (Icarus and GTKWave) Tutorial 0
Instructions to set up the PATH
Instructions for MAC users
simple.v
simple_tb.v
mux.v
mux_tb.v
HRK 100
1 Logic Trainer Lab 1
Breadboard Tutorial
74F08 data sheet
74F32 data sheet
muxgate.v
muxgate_tb.v
HRK 214
2 Basic Gates Lab 2
74F00 data sheet
74F02 data sheet
74F04 data sheet
74F08 data sheet
74F32 data sheet
74F86 data sheet
HRK 214
3 One Gate Type Lab 3
74F02 data sheet
74F27 data sheet
74F00 data sheet
74LS10 data sheet
74F20 data sheet
A few useful hints HRK 214
4 Full Adder Design Lab 4 The One Bit Full Adder HRK 214
T1 Verilog Tutorial using the in-lab tools (Quartus and ModelSim) Tutorial 1
Quartus II Verilog Design Flow: Basic Steps Summary
Quartus II Introduction Using Verilog
light.v
light_tb.v
light.csv

(ModelSim to Simulate Logic Circuits in Verilog)
(Quartus II Design Flow with Verilog: Cheatsheet)
HRK 100
5 Quartus schematic entry and FPGA Programming Lab 5 Quartus II Introduction Using Schematic
DE2-115 User Manual
DE2-115 Overview
Altera EP4CE115F29C7
HRK 100
6 Quartus Verilog entry and FPGA Programming, and ModelSim Verilog Simulation Lab 6 (ModelSim User's Manual) HRK 100
7 Mux, Decoder, 7-segment Displays Lab 7

cmdfile.txt
(order in which to compile the verilog files)
mux51_3bit.v (template)
mux51_3bit.sdc
mux51_3bit.tcl

oct7segDecoder.v (template)
displayDriver.v
displayDriver.sdc
displayDriver.tcl

muxdisp_top.v (template)
muxdisp_top.sdc
muxdisp_top.tcl
muxdisp_top_tb.v (template)
HRK 100
8 Numbers and Displays Lab 8 dec7seg.v (template)
bin2bcd.v (template)
bin2bcd_tb.v (template)
bin2bcd_top.v (template)
bin2bcd_top.sdc
bin2bcd_top.tcl
HRK 100
9 Latches, Flip-Flops, and Counters Lab 9 SR_Latch.v (template)
SR_Latch_top.v (template)
SR_Latch_top.sdc
SR_Latch_top.tcl

JK_FlipFlop.v
JK_FlipFlop_top.v (template)
JK_FlipFlop_top.sdc
JK_FlipFlop_top.tcl

counter4bit.v (template)
counter4bit_tb.v (template)
hex7seg.v (template)
counter4bit_top.v
counter4bit_top.sdc
counter4bit_top.tcl
HRK 100
10 Switch Debouncing, and Counters Lab 10 T_FlipFlop.v
debouncer.v
debouncer_tb.v
debouncer_wave.jpeg
debouncer_top.v
debouncer_top.sdc
debouncer_top.tcl

cntrStage.v
cascadeCounter.v
cascadeCounter_tb.v
cascadeCounter_table.jpeg
cascadeCounter_wave.jpeg
oct7seg.v
cascadeCounter_top.v
cascadeCounter_top.sdc
cascadeCounter_top.tcl

dec7seg.v
timerModN_top.v (template)
timerModN_top.sdc
timerModN_top.tcl
HRK 100
11 State Machines Lab 11 FSM.v (template)
FSM_tb.v (template)
debouncer.v
int2alpha7seg.v (template)
FSM_top.v (template)
FSM_top.sdc
FSM_top.tcl
HRK 100
12a Final Project Lab 12 timer_top.sdc
timer_top.tcl
HRK 100
12b Final Project Lab 12 HRK 100

Free Tools

  • For PC users only: MobaXterm free Home edition (website)

  • Visual Studio Code or any other text editor you are already familiar with (including gedit, emacs, vi, notepad++, etc.)

  • Icarus Verilog (website)

  • GTKWave (website and documentation)

Check Icarus installation with this simple example:

hello.v
//hello.v
module main;
  initial
    begin
      $display("Hello, World");
      $finish ;
    end
endmodule
Run the following commands:
iverilog -o design hello.v
vvp design

Hello, World

Check GTKWave installation with this simple example:

simple.v
// file: simple.v
// flipping the input bits
module simple(A, B);

   input  [3:0] A;
   output [3:0] B;

   // mix up the input bits
   assign B = { A[0], A[1], A[2], A[3] };

endmodule
simple_tb.v
// file: simple_tb.v
// check the functionality of simple.v is correct

`timescale 1ns / 1ns

module simple_tb;

   reg [3:0] A = 4'b1010;

   wire [3:0] B;

   initial
     begin
        $dumpfile("simple.vcd");
        $dumpvars(0);
        $monitor("A is %b, B is %b.", A, B);
        #50 A = 4'b1100;
        #50 $finish;
     end

   simple dut(A, B);

endmodule
Run the following commands:
iverilog -o design simple.v simple_tb.v
vvp design
gtkwave simple.vcd

VCD info: dumpfile simple.vcd opened for output.
A is 1010, B is 0101.
A is 1100, B is 0011.

alt text 

Commercial Tools

  • Quartus Prime (by Altera/Intel)

  • ModelSim (by Mentor Graphics)

  • A tutorial on how to use Quartus Prime and Modelsim with Verilog

Altera's original Tutorial (skip section 6 and section 7-2).
instead of section 6 of the original Tutorial please follow section “7: Simulation” of the condensed tutorial

A condensed version of the Tutorial

A very terse summary of the Tutorial

RTL code (exor gate):

light.v
// File: light.v
// A simple exor gate
module light(x1,x2,f);
input x1,x2;
output f;
assign f= (x1 & ~x2) | (~x1 & x2);
endmodule

Testbench:

light_tb.v
// File: light_tb.v
// Test Bench for the light module
// author: Claudio Talarico

`timescale 1ns / 1ns

module light_tb;
// inputs to DUT (RTL Hardware)
reg ain;
reg bin;
//outputs from DUT
wire cout;

// instantiate the DUT
light dut(
.x1( ain ),
.x2( bin ),
.f( cout )
);

// output the simulation in graphical format
initial
begin
  $dumpfile("light.vcd");
  $dumpvars(0);
end

//initialize inputs
initial
begin
  ain = 0;
  bin = 0;
end

// generate ain values
always
begin
# 20 ain = ~ain;
end

// generate bin values
always
begin
# 40 bin = ~bin;
end

// output the simulation in textual format
initial
begin
  $monitor("At time %t, X1 is = %b, X2 is %b, F is %b",
          $time, ain, bin, cout);
end

// stop the simulation from running forever
initial
begin
  # 200 $stop;
end

endmodule

Pins Assignment:

light.csv
# File: light.csv
# Pin Assignments
To, Direction, Location
x1, input, PIN_AB28
x2, input, PIN_AC28
f, output, PIN_E21

or alternatively:

light.tcl
set_location_assignment PIN_AB28 -to x1
set_location_assignment PIN_AC28 -to x2
set_location_assignment PIN_E21 -to f

QuickStart on Verilog

  • A concise document on how to write good quality Verilog for synthesis by Cliff Cummings