You are currently viewing Seven Segment Display  Interface with CPLD

Seven Segment Display Interface with CPLD

Spread the love


Seven Segment Display is most commonly used to display Alpha Numeric character set. Each segment is capable of displaying values 0-9 and A-F. There are two types of seven segment display commonly used in CPLD development board. They are common anode display and common cathode display.

Interfacing with CPLD Development Kit

CPLD I/O lines can be easily connected with seven segment display.

Each digit shares eight common control signals to light individual LED segments. Each individual character has a separate anode control input. The pin number for each CPLD Pin connected to the LED display. To light an individual signal, drive the individual segment control signal Low along with the associated anode control signal for the individual character.

Schematics to interface Seven segment with CPLD Development Kit

VHDL Code description

VHDL Code describes counting values from 0-9 in all the segments at the same time. Clock source in the CPLD run at 50 MHz i.e. 20ns. In order to achieve the clock speed at 1s clock divider is used. High value on all Selection line activates all the display. To display one in the segment “11111001” value need to be sent as shown in figure.

VHDL code for displaying 1-9 in all seven segments

library ieee;

use ieee.std_logic_1164.all;

use ieee.std_logic_arith.all;  

use ieee.std_logic_unsigned.all;


entity seven_segment  is


port(clk    : in  std_logic;    

     y      : out std_logic_vector(7 downto 0);

    sel     : out std_logic_vector(3 downto 0)


end seven_segment;


architecture bhv of seven_segment  is

type state is (state0,state1,state2,state3,state4,state5,state6,state7,state8,state9);

signal next_state,ps: state := state0;


sel <= "1111";

process(clk,next_state) ---

variable i : integer := 0 ;


if clk'event and clk = '1' then

if i <= 50000000 then

i := i + 1;

elsif i > 50000000 then

i := 0 ;

next_state <= ps ;

end if;

if next_state = state0 then

y <= x"c0" ;

ps <= state1;

elsif next_state = state1 then

y <= x"f9";

ps <= state2;

elsif next_state = state2 then

y <= X"a4";

ps <= state3;

elsif next_state = state3 then

y <= X"b0";

ps <= state4;

elsif next_state = state4 then

y <= X"99";

ps <= state5;

elsif next_state = state5 then

y <= X"92";

ps <= state6;

elsif next_state = state6 then

y <= X"82";

ps <= state7;

elsif next_state = state7 then

y <= X"f8";

ps <= state8;

elsif next_state = state8 then

y <= X"80";

ps <= state9;

elsif next_state = state9 then

y <= X"98";

ps <= state1;

end if;

end if;

end process;

end bhv;

User Constraint File

NET "clk"  LOC = "p3"  ;

NET "sel"  LOC = "p142"  ;

NET "sel"  LOC = "p140"  ;

NET "sel"  LOC = "p139"  ;

NET "sel"  LOC = "p138"  ;

NET "sel"  LOC = "p137"  ;

NET "sel"  LOC = "p136"  ;

NET "y"  LOC = "p135"  ;

NET "y"  LOC = "p134"  ;

NET "y"  LOC = "p133"  ;

NET "y"  LOC = "p131"  ;

NET "y"  LOC = "p128"  ;

NET "y"  LOC = "p127"  ;

NET "y"  LOC = "p126"  ;

NET "y"  LOC = "p125"  ;

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.