Report 2
Report 2
Computer Science
Group Members
Muhammad
345834
Umer
The purpose of this exercise is to learn how to connect simple input and output devices to an FPGA
chip and implement a circuit that uses these devices. We will use the switches on the DE-series
boards as inputs to the circuit. We will use light emitting diodes (LEDs) and 7-segment displays as
output devices.
2.2 Introduction
The field of digital design has been revolutionized by the advent of Field-Programmable Gate
Arrays (FPGAs), which allow designers to create complex digital circuits using programmable
logic. In this lab exercise, we will be using Intel's Quartus Prime software to design and implement
a circuit that utilizes switches, lights, and multiplexers. The objective of this exercise is to gain
hands-on experience in designing and implementing digital circuits using FPGAs, and to understand
how switches, lights, and multiplexers can be used in a digital circuit. By the end of this lab, we will
have a deeper understanding of the basic components of digital circuits and how they can be used to
create complex systems. Additionally, we will have gained valuable experience in using Intel's
Quartus Prime software, which is a leading platform for digital design.
2.3 Software
Quartus Prime is a comprehensive design software developed by Intel Corporation for designing
digital circuits using Field-Programmable Gate Arrays (FPGAs). It is a leading software platform in
the field of digital design, offering a range of advanced tools and features that enable users to easily
create, debug, and verify complex digital circuits. With Quartus Prime, users can benefit from a
streamlined design flow that facilitates the creation of digital circuits from concept to
implementation. It provides an intuitive graphical user interface that allows users to easily design,
test, and debug their circuits. Additionally, Quartus Prime supports a variety of popular
programming languages, making it a versatile platform for digital designers of all levels.
The objective of this part is to display a character on a 7-segment display. The specific character
displayed depends on a two-bit input. Figure 1 shows a 7-segment decoder module that has the two-
bit input c 1 c 0. This decoder produces seven outputs that are used to display a character on a 7-
segment display. Table 1 lists the characters that should be displayed for each valuation of c 1 c 0 for
your DE-series board. Note that in some cases the ‘blank’ character is selected for code 11.
module standard (
input [9:0] SW,
output [6:0] HEX0
);
task_1 dut (
.c1 (SW[1]),
.c0 (SW[0]),
.hex(HEX0)
);
module task_1 (
input c1,
c0,
output [6:0] hex
);
endmodule
Consider the circuit shown in Figure 2. It uses a two-bit wide 4-to-1 multiplexer to enable the
selection of four characters that are displayed on a 7-segment display. Using the 7-segment decoder
from Part IV this circuit can display the characters d, E, 0, 1, 2, or ‘blank’ depending on your DE-
series board. The character codes are set according to Table 1 by using the switches SW7−0, and a
specific character is selected for display by setting the switches SW9−8.
module standard (
input [9:0] SW,
output [6:0] HEX0,
task_2 dut (
.switch(SW),
.hex(HEX)
);
endmodule
module task_2 (
input [ 9:0] switch,
output [27:0] hex
);
wire [7:0] s;
wire [7:0] m;
genvar i;
generate
for (i = 1; i < 8; i = i + 2) begin : mux
mux_2b_4to1 muxstage (
.s(s[i:i-1]),
.u(u),
.v(v),
.w(w),
.x(x),
.m(m[i:i-1])
);
end
endgenerate
generate
for (i = 1; i < 8; i = i + 2) begin : seg_decoder
task_1 decoderstage (
.c1 (m[i]),
.c0 (m[i-1]),
.hex(hex[7*((i+1)/2)-1:7*((i-1)/2)])
);
end
endgenerate
endmodule
module mux_2b_4to1 (
input [1:0] s,
EE-421: Digital System Design Page 8
input [1:0] u,
input [1:0] v,
input [1:0] w,
input [1:0] x,
endmodule
To test the functional relationship between the switches and the 7-segment displays, we implement
the following testbench:
module t2_testbench ();
task_2 dut (
.switch(switch),
.hex(hex)
);
integer i;
initial begin
for (i = 0; i < 2 ** 10; i = i + 1) begin
{switch} = i;
#10;
end
end
endmodule
Extend your design from Part V so that it uses all 7-segment displays on your DE-series board.
Your circuit needs to display a three- or four-letter word, corresponding to Table 2, using ’blank’
characters for unused displays. Implement rotation of this word from right-to-left as indicated in
Table 3 and Table 4. To do this, you will need to connect 6-to-1 multiplexers to each of six 7-
segment display decoders for the DE10-Lite, DE0-CV and DE1-SoC. Note that for the DE10-Lite
you will need to use 3-bit codes for your characters, because five characters are needed when
including the ’blank’ character (your 7-segment decoder will have to use 3-bit codes, and you will
need to use 3-bit wide 6-to-1 multiplexers).
module standard (
input [9:0] SW,
output [6:0] HEX0,
output [6:0] HEX1,
output [6:0] HEX2,
output [6:0] HEX3,
output [6:0] HEX4,
output [6:0] HEX5
);
task_3 dut (
.switch(SW),
.hex(HEX)
);
endmodule
module task_3 (
input [ 9:0] switch,
output [41:0] hex
);
wire [17:0] m;
wire [17:0] s;
wire [2:0] s1, s2, s3, s4, s5, s6;
assign s1 = switch[9:7] + 5,
s2 = switch[9:7] + 4,
s3 = switch[9:7],
s4 = switch[9:7] + 1,
s5 = switch[9:7] + 2,
s6 = switch[9:7] + 3;
genvar i;
generate
for (i = 2; i < 18; i = i + 3) begin : mux
mux_3b_6to1 muxstage (
.s(s[i:i-2]),
.u(u), .v(v),
.w(w), .x(x),
.y(y), .z(z),
.m(m[i:i-2])
);
end
endgenerate
generate
for (i = 2; i < 18; i = i + 3) begin : seg_decoder
t3_decoder decoderstage (
.c2 (m[i]),
.c1 (m[i-1]),
.c0 (m[i-2]),
.hex(hex[7*((i+1)/3)-1:7*((i-1)/3)])
);
end
endgenerate
endmodule
module mux_3b_6to1 (
input [2:0] s,
input [2:0] u,
input [2:0] v,
input [2:0] w,
input [2:0] x,
input [2:0] y,
input [2:0] z,
endmodule
module t3_decoder (
input c2,
c1,
c0,
output reg [6:0] hex
);
wire [2:0] c = {c2, c1, c2};
task_3 dut (
.switch(switch),
.hex(hex)
);
integer i;
initial begin
for (i = 0; i < 2 ** 3; i = i + 1) begin
{switch[9:7]} = i;
#10;
end
end
endmodule