You are on page 1of 12

My Account | Sign In support@allaboutfpga.

com | +91-9789377039

 Menu 

BCD to 7 Segment Decoder VHDL Code


July 9, 2017 by shahul akthar

BCD to 7 Segment
Table of Contents 
Decoder
BCD to 7 Segment Decoder
The BCD to 7 Segment BCD to 7 segment display Decoder Truth Table
Decoder converts 4 bit BCD to 7 segment display Decoder Circuit
binary to 7 bit control VHDL Code for BCD to 7 segment display using Combinatorial logic
signal which can be VHDL Code for BCD to 7 segment display using Case Statement
displayed on 7 segment VHDL Testbench Code for BCD to 7 segment display
Flat Seven
display. 10% OFF on all
display Testbench waveform for BCD to 7 Segment Display Decoder
the EDGE FPGA kits. Now Shipping. Coupon Code: 
STAY@HOME
consist of 7 led segments to display 0 to 9 and A to F.

VHDL Code BCD to 7 Segment Display decoder can be implemented in 2 ways. By


simplifying Boolean expression to implement structural design and behavioral design.

For constructing BCD to 7 segment display, rst construct truth table and simplify them to
Boolean expression using K Map and nally build the combinational circuit.

BCD to 7 segment display Decoder Truth Table

Flat 10% OFF on all the EDGE FPGA kits. Now Shipping. Coupon Code:
STAY@HOME
BCD to 7 segment display Decoder Circuit

The boolean expression for the logic circuit is

A = B0 + B2 + B1B3 + B1’B3′

B = B1′ + B2’B3′ + B2B3

C = B1 + B2′ + B3

Flat 10% OFF on all the EDGE FPGA kits. Now Shipping. Coupon Code:
D = B1’B3′ + B2B3′ + B1B2’B3 + B1’B2 + B0
STAY@HOME
E = B1’B3′ + B2B3′

F = B0 + B2’B3′ + B1B2′ + B1B3′

G = B0 + B1B2′ + B1’B2 + b2b3′

VHDL Code for BCD to 7 segment display using Combinatorial logic


library IEEE;
use IEEE.STD_LOGIC_1164.ALL;

entity bcd_7seg is
Port ( B0,B1,B2,B3 : in STD_LOGIC;
A,B,C,D,E,F,G : out STD_LOGIC);
end bcd_7seg;

architecture Behavioral of bcd_7seg is

begin

A <= B0 OR B2 OR (B1 AND B3) OR (NOT B1 AND NOT B3);


B <= (NOT B1) OR (NOT B2 AND NOT B3) OR (B2 AND B3);
C <= B1 OR NOT B2 OR B3;
D <= (NOT B1 AND NOT B3) OR (B2 AND NOT B3) OR (B1 AND NOT B2 AND B3) OR
(NOT B1 AND B2) OR B0;
E <= (NOT B1 AND NOT B3) OR (B2 AND NOT B3);
F <= B0 OR (NOT B2 AND NOT B3) OR (B1 AND NOT B2) OR (B1 AND NOT B3);
G <= B0 OR (B1 AND NOT B2) OR ( NOT B1 AND B2) OR (B2 AND NOT B3);

end Behavioral;

VHDL Code for BCD to 7 segment display using Case Statement


library IEEE;
use IEEE.STD_LOGIC_1164.ALL;

entity bcd_7segment is
Port ( BCDin : in STD_LOGIC_VECTOR (3 downto 0);
Seven_Segment : out STD_LOGIC_VECTOR (6 downto 0));
end bcd_7segment;

architecture Behavioral of bcd_7segment is

begin

process(BCDin)
begin

case BCDin is
Flat"0000"
when => on all the EDGE FPGA kits. Now
10% OFF Shipping. Coupon Code:
Seven_Segment <= "0000001"; ---0
when "0001" => STAY@HOME
Seven_Segment <= "1001111"; ---1
when "0010" =>
Seven_Segment <= "0010010"; ---2
when "0011" =>
Seven_Segment <= "0000110"; ---3
when "0100" =>
Seven_Segment <= "1001100"; ---4
when "0101" =>
Seven_Segment <= "0100100"; ---5
when "0110" =>
Seven_Segment <= "0100000"; ---6
when "0111" =>
Seven_Segment <= "0001111"; ---7
when "1000" =>
Seven_Segment <= "0000000"; ---8
when "1001" =>
Seven_Segment <= "0000100"; ---9
when others =>
Seven_Segment <= "1111111"; ---null
end case;

end process;

end Behavioral;

VHDL Testbench Code for BCD to 7 segment display


LIBRARY ieee;
USE ieee.std_logic_1164.ALL;

ENTITY tb_bcd_7seg IS
END tb_bcd_7seg;

ARCHITECTURE behavior OF tb_bcd_7seg IS

-- Component Declaration for the Unit Under Test (UUT)

COMPONENT bcd_7segment
PORT(
BCDin : IN std_logic_vector(3 downto 0);
Seven_Segment : OUT std_logic_vector(6 downto 0)
);
END COMPONENT;

--Inputs
signal BCDin : std_logic_vector(3 downto 0) := (others => '0');

--Outputs
signal Seven_Segment : std_logic_vector(6 downto 0);

BEGIN

Flat
-- Instantiate
10% OFF the Unit
on all theUnder
EDGETest (UUT)
FPGA kits. Now Shipping. Coupon Code:
uut: bcd_7segment PORT MAP (
BCDin => BCDin, STAY@HOME
Seven_Segment => Seven_Segment
);

-- Stimulus process
stim_proc: process
begin

BCDin <= "0000";


wait for 100 ns;
BCDin <= "0001";
wait for 100 ns;
BCDin <= "0010";
wait for 100 ns;
BCDin <= "0011";
wait for 100 ns;
BCDin <= "0100";
wait for 100 ns;
BCDin <= "0101";
wait for 100 ns;
BCDin <= "0110";
wait for 100 ns;
BCDin <= "0111";
wait for 100 ns;
BCDin <= "1000";
wait for 100 ns;
BCDin <= "1001";
wait for 100 ns;
end process;

END;

Testbench waveform for BCD to 7 Segment Display Decoder

Share this:

    

Related

Flat 10% OFF on all the EDGE FPGA kits. Now Shipping. Coupon Code:
STAY@HOME
Tutorial 2: BCD to 7 Segment VHDL Code for 2 to 4 decoder VHDL Code for Binary to BCD
FPGA Implementation February 6, 2016 Converter
November 4, 2018 In "VHDL" November 30, 2014
In "FPGA" In "VHDL"

 VHDL
 BCD to seven segment Decoder, VHDL BCD to 7 segment display
 Sequence Detector using Mealy and Moore State Machine VHDL Codes
 Introducing EDGE Spartan 6 FPGA Development Board!

1 thought on “BCD to 7 Segment Decoder VHDL Code”

Patrick Lehmann
July 28, 2017 at 1:13 pm

According to the truth table of this 7 segment decoder, the BCD input “0” is
encoded as a dash, because segment G is active. Please not that people assume
high-active logic unless stated otherwise. So you should either correct your truth
table and equations or state that you are using a low-active 7-segment display.
Please note further, that the display itself it not low-active. The low-activeness is
mostly caused by switching transistors to drive the 7-segment inputs. These
transistors cause a polarity inversion.

Reply

Flat 10% OFF on all the EDGE FPGA kits. Now Shipping. Coupon Code:
Leave a Reply STAY@HOME
Enter your comment here...

NEW PRODUCT

t EDGE ZYNQ SoC FPGA K

ork Feature rich and high performance sing


Flat 10% OFF on all the EDGE FPGA kits. Now Shipping. Coupon Code:
e. board computer
STAY@HOME
Starting at
16500 INR / 233 USD
More info >

Top Posts & Pages

VHDL Code for 4-Bit Shift Register

BCD to 7 Segment Decoder VHDL Code

VHDL 4 to 1 Mux (Multiplexer)

VHDL Code for Flip op - D,JK,SR,T

VHDL Code for Clock Divider (Frequency Divider)

VHDL Code for 2 to 4 decoder

VHDL Code for Full Adder

Sequence Detector using Mealy and Moore State Machine


VHDL Codes

VHDL code for 4-bit ALU

VHDL Code for 4-bit Adder / Subtractor

Recent Posts
Flat 10% OFF on all the EDGE FPGA kits. Now Shipping. Coupon Code:
Introduction and Advantages of Digital Sensor Addon for EDGE FPGA kit
STAY@HOME
Introducing Motor Drive Addon for EDGE FPGA kit
FPGA Implementation of Internet of Things (IoT)
Tutorial 3: ALU Structural Modelling FPGA Implementation
Tutorial 2: BCD to 7 Segment FPGA Implementation
Tutorial 1: Binary Counter FPGA Implementation
Introducing EDGE Spartan 6 FPGA Development Board!
BCD to 7 Segment Decoder VHDL Code
Sequence Detector using Mealy and Moore State Machine VHDL Codes
Carry Select Adder VHDL Code

Flat 10% OFF on all the EDGE FPGA kits. Now Shipping. Coupon Code:
STAY@HOME
About Us
AllAboutFPGA.com is commercial site for selling FPGA development products and it
is part of Invent Logics. We are the developers of high quality and low cost FPGA
development kits. Our aim is to provide the best FPGA learning platform to the
students, research scholars and young engineers.

All About FPGA


3,929 likes

Like Page Shop Now

Be the first of your friends to like this

All About FPGA

163 YouTube

Get Noti ed on New Products and Tutorials!

Email Address

Notify Me

   

INVENT LOGICS

#3/165, Pandiyan
Flat 10% OFF onSalai,
all the EDGE FPGA kits. Now Shipping. Coupon Code:
STAY@HOME
Saraswathi Nagar, Neelangarai,
Chennai, India – 600115

support@allaboutfpga.com
+91-9789377039

My account Terms of Service Privacy Policy Return and Refund Policy

© 2019 • INVENT LOGICS

Flat 10% OFF on all the EDGE FPGA kits. Now Shipping. Coupon Code:
STAY@HOME

You might also like