Ecet146 Lab4 F24
Ecet146 Lab4 F24
Grading Scheme
Page 1 of 10
Important Notes:
- Any attempt at plagiarism or cheating will be reported. All ACM handbook academic misconduct rules will be applied.
- It is the responsibility of the student to submit this online assessment paper to the instructed online platform (Moodle,
Turnitin) if applicable.
1. Objectives
1. To learn how to write structural descriptions Verilog code
2. To learn how to simulate Verilog code and generate the corresponding waveform 3.
To learn how to interpret the output of Verilog code simulation
2. Equipment
Simulator: Quartus II
FPGA Board
3. Pre-Lab Preparation
1. Lecture 3
2. Follow carefully the explanation of the instructor
3. Read the given manuals regarding Quartus II software
4. Read this document in its entirety
Page 2 of 10
Question 1. Consider the below Full Subtractor combinational logic circuit. This circuit
performs the subtraction between the two 1-bit binary numbers (minuend A and
subtrahend B) and considers the borrow of the previous bit (Bin). There are two
outputs, one corresponds to the difference (Diff) output and the other borrow output
(Bout).
module HalfSubtractor(x,y,b,d);
input x,y; output d,b; wire w1; xor gate1(d,x,y); not gate2 (w1, x);
and gate3 (b, y, w1);
endmodule
Page 3 of 10
a. Write the structural description Verilog code for the Full Subtractor.
Page 4 of 10
HalfSubtractor Hs1 (.x(A), .y(B), .d(w1), .b(w2));
endmodule
b. Perform the waveform simulation of your circuit. All the possible combinations
between the 3 inputs to be considered. Order of pins should be: A, B, Bin, Diff, Bout.
Page 5 of 10
Question 2.
Consider below circuit.
Page 6 of 10
module HalfAdder (x,y,cout,s); module FullAdder (x,y,cin,cout,s);
input x,y; output s,cout; input x, y,cin; output s, cout;
assign s = x^y; wire c1,c2,s1;
assign cout = x&y; endmodule
HalfAdder HA1 (x,y,c1,s1);
HalfAdder HA2 (s1,cin,c2,s);
assign cout = c1|c2; endmodule
a. Write the structural level Verilog code for the top level.
module HalfAdder (x,y,cout,s);
input x,y;
output s,cout;
assign s = x^y;
endmodule
input x, y,cin;
output s, cout;
wire c1,c2,s1;
endmodule
endmodule
Perform the waveform simulation of your circuit and insert a clear screenshot with the
below requirements:
Page 8 of 10
Follow the instructions given in the manual (4. Pin Planner) for configuring the pins
of the circuit with the FPGA board.
A0 SW1
B0 SW0
sum2 LDR2
sum1 LDR1
sum0 LDR0
Page 9 of 10
* Upload the configuration on the FPGA board. (Graded as part of the experiment).
Call your instructor to show your work
Page 10 of 10