CPEN 230L: Introduction to Digital Logic lab.Spring 2018 - Claudio Talarico, Gonzaga University
GradingThe lowest score will be dropped
AssignmentsImportant documents to read thoroughly: One stop link for the ICs datasheets needed for the class: Free Tools
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. Commercial Tools
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
|