Department of Electrical Engineering: Ee-421: Digital Sysem Design
Department of Electrical Engineering: Ee-421: Digital Sysem Design
Department of Electrical Engineering: Ee-421: Digital Sysem Design
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.
Introduction:
Quartus Prime (Software) - The Intel® Quartus® Prime software GUI supports easy
design entry, fast design processing, straightforward device programming, and
integration with other industry-standard EDA tools.
The Intel® Quartus® Prime Standard Edition software offers a full range of
features some of which are following:
• Design Planning Tools — plan for initial I/O pin layout, power consumption, and
area utilization in the Early Power Estimator, the Power Analyzer Tool, and the
Pin Planner. Refer to Design Planning for more information.
• Design Constraint Entry — specify timing, placement, and other constraints
with the Settings dialog box, Assignment Editor, Pin Planner, and Timing
Analyzer. Visualize and modify logic placement within a view of the device
floorplan in the Chip Planner and Timing Closure Floorplan. Refer to Intel
Quartus Prime Standard Edition User Guide: Design Constraints for more
information.
• Integrated Synthesis — provides efficient synthesis support for VHDL (1987,
1993, 2008), Verilog HDL (1995, 2001), and SystemVerilog (2005) design entry
languages. Refer to Intel Quartus Prime Standard Edition User Guide:
Compiler for more information.
• Incremental Compilation — preserve the results and performance for
unchanged logic in your design as you make changes elsewhere, facilitating top-
down or bottom-up team-based design methodologies. Refer to Intel Quartus
Prime Standard Edition User Guide: Compiler for more information.
• Design Debugging — The Signal Tap logic analyzer captures and displays real-
time signal behavior in an FPGA design, allowing to examine the behavior of
internal signals during normal device operation without the need for extra I/O pins
or external lab equipment. The Transceiver Toolkit provides real-time control,
LAB TASKS:
Part I
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 c1c0. 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 c1c0 for your DE-series board. Note that in some
cases the ‘blank’ character is selected for code 11.
The seven segments in the display are identified by the indices 0 to 6 shown in the figure. Each segment is
illuminated by driving it to the logic value 0. You are to write a Verilog module that implements logic functions to
activate each of the seven segments. Use only simple Verilog assign statements in your code to specify each
logic function using a Boolean expression.
endmodule
RTL view:
reg [1:0]SW;
wire [6:0] HEX0;
initial
begin
SW=2'b00;
#10;
SW=2'b01;
#10;
SW=2'b10;
#10;
SW=2'b11;
#10;
end
endmodule
SIMULATION:
An outline of the Verilog code that represents this circuit is provided in Figure 3. Note that we have used the
circuits from Parts III and IV as subcircuits in this code. You are to extend the code in Figure 3 so that it uses four 7-
segment displays rather than just one. You will need to use four instances of each of the subcircuits. The purpose
of your circuit is to display any word on the four 7-segment displays that is composed of the characters in Table 1,
and be able to rotate this word in a circular fashion across the displays when the switches SW9−8 are toggled. As
an example, if the displayed word is dE10, then your circuit should produce the output patterns illustrated in Table
2.
endmodule
// implements a 2-bit wide 4-to-1 multiplexer
module mux_2bit_4to1 (S, U, V, W, X, M);
input [1:0] S, U, V, W, X;
output reg [1:0] M;
always @(*)
begin
case(S)
2'b00 : M = U;
2'b01: M = V;
2'b10: M = W;
2'b11: M = X;
endcase
end
endmodule
// implements a 7-segment decoder for d, E, 1 and “blank” (D10-SoC)
module char_7seg (SW, HEX0);
input [0:1] SW; // input code
output [0:6] HEX0; // output 7-seg code
assign HEX0[0] = (~SW[1]&~SW[0] | SW[1]&~SW[0] | SW[1]&SW[0]);
assign HEX0[1] = (~SW[1]&SW[0] | SW[1]&SW[0]);
assign HEX0[2] = (~SW[1]&SW[0] | SW[1]&SW[0]);
assign HEX0[3] = (SW[1]&~SW[0] | SW[1]&SW[0]);
assign HEX0[4] = (SW[1]&~SW[0] | SW[1]&SW[0]);
assign HEX0[5] = (~SW[1]&~SW[0] | SW[1]&~SW[0] |
SW[1]&SW[0]);
assign HEX0[6] = (SW[1]&~SW[0] | SW[1]&SW[0]);
endmodule
module testbench_l2t2m();
reg [9:0] SW; // slide switches
wire [6:0] HEX0,HEX1,HEX2,HEX3;
lab2task2m ins0 (SW, LEDR, HEX0,HEX1,HEX2,HEX3);
initial
begin
SW = 10'b0000011011;
#10;
SW = 10'b0100011011;
#10;
SW = 10'b1000011011;
#10;
SW = 10'b1100011011;
#10;
end
endmodule
SIMULATION:
TABLE:
seg_7 first(M0,HEX0);
seg_7 second(M1,HEX1);
seg_7 seventh(M6,HEX6);
endmodule
input [2:0] S;
always@(*)
begin
case(S)
3'b000 : begin
M0=3'b100;
M1=3'b100;
M2=3'b000;
M3=3'b001;
M4=3'b010;
M5=3'b011;
3'b001 : begin
M0=3'b100;
M1=3'b000;
M2=3'b001;
M3=3'b010;
M4=3'b011;
M5=3'b100;
end
3'b010 : begin
M0=3'b000;
M1=3'b001;
M2=3'b010;
M3=3'b011;
M4=3'b100;
M5=3'b100;
end
3'b011 : begin
M0=3'b001;
M1=3'b010;
M2=3'b011;
M3=3'b100;
M4=3'b100;
M5=3'b000;
end
3'b100 : begin
M0=3'b010;
M1=3'b011;
M2=3'b100;
M3=3'b100;
M4=3'b000;
end
3'b101 :begin
M0=3'b011;
M1=3'b100;
M2=3'b100;
M3=3'b000;
M4=3'b001;
M5=3'b010;
end
3'b110 : begin
M0=3'b100;
M1=3'b100;
M2=3'b000;
M3=3'b001;
M4=3'b010;
M5=3'b011;
end
3'b111 : begin
M0=3'b100;
M1=3'b000;
M2=3'b001;
M3=3'b010;
M4=3'b011;
M5=3'b100;
end
endcase
end
endmodule
RTL VIEW:
reg [2:0]SW;
wire [6:0] HEX0,HEX1,HEX2,HEX3,HEX4,HEX5;
initial
begin
SW=3'b000;
#10;
SW=3'b001;
#10;
SW=3'b010;
#10;
SW=3'b011;
#10;
SW=3'b100;
#10;
SW=3'b101;
#10;
end
endmodule
SIMULATION:
CODE:
seg_7 first(M0,HEX0);
seg_7 second(M1,HEX1);
seg_7 third (M2,HEX2);
seg_7 fourth(M3,HEX3);
seg_7 fifth (M4,HEX4);
seg_7 sixth (M5,HEX5);
seg_7 seventh(M6,HEX6);
seg_7 eigth (M7,HEX7);
endmodule
// implements a 3-bit wide 8-to-1 multiplexer
module mux_3bit_8to1 (S, M0,M1,M2,M3,M4,M5,M6,M7);
input [2:0] S;
output reg [1:0] M0,M1,M2,M3,M4,M5,M6,M7;
always@(*)
begin
case(S)
3'b000 : begin
M0=2'b11;
M1=2'b11;
M2=2'b11;
M3=2'b11;
M4=2'b11;
M5=2'b00;
M6=2'b01;
M7=2'b10;
endcase
end
endmodule
// implements a 7-segment decoder for d, E, 2 and 0
module seg_7 (input [1:0] SW, output [6:0] HEX0);
endmodule
RTL VIEW:
reg [2:0]SW;
wire [6:0] HEX0,HEX1,HEX2,HEX3,HEX4,HEX5,HEX6,HEX7;
initial
begin
SW=3'b000;
#10;
SW=3'b001;
#10;
SW=3'b010;
#10;
SW=3'b011;
#10;
SW=3'b100;
#10;
SW=3'b101;
#10;
SW=3'b110;
#10;
SW=3'b111;
#10;
end
endmodule
SIMULATION:
In this lab we learnt how to connect simple input and output devices to an FPGA chip and
implement a circuit that uses these devices. We used the switches on the DE-series boards
as inputs to the circuit. We implemened various multiplexers ( 2 bit wide 4-1 , 3 bit wide 8
-1 ) to accomplish our tasks .We will used light emitting diodes (LEDs) and 7-segment
displays as output devices. Then we created a testbench of the tasks listed and simulated
our design and we observed that we got the results as expected.