milan hdl l3
milan hdl l3
Seven-segment displays (SSD) are commonly found on computers, watches, VCRs, and other
electronic devices to display numbers and characters. The seven-segment displays in the lab consist
of seven Light Emitting Diodes (LEDs) in the configuration of a number “8”. Different segments can
be illuminated to display different numbers and letters. The segments of a seven-segment display are
illustrated in the figure below. The SSDs, in general, come in packages with either a common anode
a A 1
B 2 a
f b
g C 3
f b
D 4
e c
E 5
g
d F 6 Comm on
Anode
e c
Vcc
G 7
d
Common-anode SSD
1 04-09-2023 Dr. M. B. Thacker
or a common cathode. The SSDs on the DE10 board are common-anode. In this format the LED turns
on with negative logic – i.e. low.
2) Instructions
Take a 4 bit input from the switches SW[3], SW[2], SW[1], and SW[0]. Display the binary number as
a BCD number on right most seven segment display HEX[0]. If the binary input number is greater
than 9, the letter E should be displayed.
a) Create a truth table and Karnaugh maps for the BCD-seven segment display
0 0 0 0 0 0 0 0 0 0 0 1
1 0 0 0 1 1 0 0 1 1 1 1
2 0 0 1 0 0 0 1 0 0 1 0
3 0 0 1 1 0 0 0 0 1 1 0
4 0 1 0 0 1 0 0 1 1 0 0
5 0 1 0 1 0 1 0 0 1 0 0
6 0 1 1 0 0 1 0 0 0 0 0
7 0 1 1 1 0 0 0 1 1 1 1
8 1 0 0 0 0 0 0 0 0 0 0
9 1 0 0 1 0 0 0 0 1 0 0
10 1 0 1 0 0 1 1 0 0 0 0
11 1 0 1 1 0 1 1 0 0 0 0
12 1 1 0 0 0 1 1 0 0 0 0
13 1 1 0 1 0 1 1 0 0 0 0
14 1 1 1 0 0 1 1 0 0 0 0
15 1 1 1 1 0 1 1 0 0 0 0
s3 s2 00 01 11 10 s3 s2 00 01 11 10
00
0 1 0 0 00
0 0 0 0
1 0 0 0 0 1 0 1
01 01
0 0 0 0 1 1 1 1
11 11
0 0 0 0 0 0 1 1
10 10
𝑎= 𝑏=
0 0 0 1
1 0 0 0
1 1 1 1
0 0 1 1
0 1 0 0
1 0 1 0
0 0 0 0
0 0 0 0
c s1 s0 d s1 s0
s3 s2 00 01 11 10 s3 s2 00 01 11 10
10 𝑐= 10 𝑑=
e s1 s0 f s1 s0
s3 s2 00 00 01
01 11 10 s3 s2 11 10
0 1 1 0 0 0 1 1 1
1 1 1 0 01 1 0 1 0
0 0 0 0 11 0 0 0 0
00
01
11
10 10
𝑒= 𝑓=
g s1 s0
00 01 11 10
s3 s2
00 1 1 0 0
01 1 0 1 0
11 0 0 0 0
10
0 0 0 0
𝑔=
Sign of Faculty
b) Create the VHDL code to perform this BCD function and output using
simple combinational logic using dataflow style of modeling (i.e. AND,
OR, NOT, etc.) Compile your code and download it to the DE-10 board.
library IEEE;
use IEEE.std_logic_1164.ALL;
NOT s1 AND s0) OR (NOT s3 AND s2 AND NOT s1 AND NOT s0); b <= (s3 AND s2) OR (s3 AND
s1) OR (s2 AND NOT s1 AND s0) OR (s2 AND s1 AND NOT s0); c <= (s3 AND s2) OR (s3 AND s1)
d <= (NOT s3 AND s2 AND NOT s1 AND NOT s0) OR (NOT s3 AND NOT s2 AND NOT s1 AND s0) OR
(NOT s3 AND s2 AND s1 AND s0); e <= (NOT s3 AND s0) OR (NOT s2 AND NOT s1 AND s0) OR
(NOT s3 AND s2 AND NOT s1); f <= (NOT s3 AND s1 AND s0) OR (NOT s3 AND NOT s2 AND s0) OR
(NOT s3 AND NOT s2 AND s1); g <= (NOT s3 AND NOT s2 AND NOT s1) OR (NOT s3 AND s2 AND
Entity declaration
entity gate is
port(
x : in std_logic_vector(3 downto 0);
z : out std_logic_vector(6 downto 0)
);
end gate;
-- Architecture definition
Sign of Faculty
d) Again using a case statement, re-write the code to display the hexadecimal
representations of the input switches. Comment on the two VHDL implementations
(dataflow style and using case statement).
library IEEE;
use IEEE.std_logic_1164.all;
-- Entity declaration
entity gate is
port(
x : in std_logic_vector(3 downto 0);
z : out std_logic_vector(6 downto 0)
);
end gate;
-- Architecture definition
ENTITY washingmachine IS
PORT(W_POWER,X_DOOR,Y_WATER,Z_OVERFLOW:IN STD_LOGIC;
EM_BTN:IN STD_LOGIC;
F_MOTOR:OUT STD_LOGIC);
END washingmachine;
END BEHAV;
1