Pages

Wednesday, January 24, 2024

XC95108 Two-Digit BCD to 7-Segment Display VHDL

In this VHDL example, I use an XC95108 CPLD to read and convert two digits BCD variable to two distinct 7-Segment display. The input is an active low push button without de-bouncing or delay circuit. So the input press counting is unstable. I create two BCD variable to hold the 1'S and the 10's values.

XC95108 Two-Digit BCD to 7-Segment Display VHDL
Circuit Testing on the XC95108 Prototype Board

The 7-Segment display is a 0.56 Inch individual digit command cathode type. This VHDL code create a digital counter that counts up to 99 before its rolls down to 0.

  1. --XC95108 Two-Digit 7-Segment Counter With Pusth Button
  2. --Circuit Design with VHDL
  3. LIBRARY IEEE;
  4. USE IEEE.STD_LOGIC_1164.ALL;
  5.  
  6. ENTITY counter IS
  7. PORT( CLK,RESET: IN STD_LOGIC;
  8. DIGIT1, DIGIT2: OUT STD_LOGIC_VECTOR(7 DOWNTO 0)
  9. );
  10. END counter;
  11.  
  12. ARCHITECTURE counter of counter IS
  13. BEGIN
  14. PROCESS(CLK,RESET)
  15. VARIABLE temp1: INTEGER RANGE 0 TO 10;
  16. VARIABLE temp2: INTEGER RANGE 0 TO 10;
  17. BEGIN
  18. if(RESET='1') then temp1:=0; temp2:=0;
  19. elsif(CLK'EVENT AND CLK='0') then
  20. temp1:=temp1+1;
  21. if(temp1>=10) then temp1:=0; temp2:=temp2+1;
  22. if(temp2>=10) then temp2:=0; end if;
  23. end if;
  24. end if;
  25. --BCD TO SSD Conversion--
  26. --DIGIT 1--
  27. CASE temp1 IS
  28. WHEN 0 => DIGIT1<=x"3F";
  29. WHEN 1 => DIGIT1<=x"06";
  30. WHEN 2 => DIGIT1<=x"5B";
  31. WHEN 3 => DIGIT1<=x"4F";
  32. WHEN 4 => DIGIT1<=x"66";
  33. WHEN 5 => DIGIT1<=x"6D";
  34. WHEN 6 => DIGIT1<=x"7D";
  35. WHEN 7 => DIGIT1<=x"07";
  36. WHEN 8 => DIGIT1<=x"7F";
  37. WHEN 9 => DIGIT1<=x"6F";
  38. WHEN OTHERS => NULL;
  39. END CASE;
  40. --DIGIT 2--
  41. CASE temp2 IS
  42. WHEN 0 => DIGIT2<=x"3F";
  43. WHEN 1 => DIGIT2<=x"06";
  44. WHEN 2 => DIGIT2<=x"5B";
  45. WHEN 3 => DIGIT2<=x"4F";
  46. WHEN 4 => DIGIT2<=x"66";
  47. WHEN 5 => DIGIT2<=x"6D";
  48. WHEN 6 => DIGIT2<=x"7D";
  49. WHEN 7 => DIGIT2<=x"07";
  50. WHEN 8 => DIGIT2<=x"7F";
  51. WHEN 9 => DIGIT2<=x"06";
  52. WHEN OTHERS => NULL;
  53. END CASE;
  54. END PROCESS;
  55. END counter;

I use VHDL sequential code to make this circuit. It contains IF and CASE statements. I got this sample VHDL code from "Circuit Design with VHDL, Volnei A. Prdroni".

The XC95108, switches and 7-Segment display are connected as follow.

#PACE: Start of Constraints generated by PACE
#PACE: Start of PACE I/O Pin Assignments
NET "CLK"  LOC = "P53"  ; 
NET "DIGIT1<7>"  LOC = "P37"  ; 
NET "DIGIT1<6>"  LOC = "P35"  ; 
NET "DIGIT1<5>"  LOC = "P21"  ; 
NET "DIGIT1<4>"  LOC = "P33"  ; 
NET "DIGIT1<3>"  LOC = "P34"  ; 
NET "DIGIT1<2>"  LOC = "P36"  ; 
NET "DIGIT1<1>"  LOC = "P24"  ; 
NET "DIGIT1<0>"  LOC = "P23"  ; 
NET "DIGIT2<7>"  LOC = "P32"  ;
NET "DIGIT2<6>"  LOC = "P18"  ;
NET "DIGIT2<5>"  LOC = "P17"  ;
NET "DIGIT2<4>"  LOC = "P26"  ;
NET "DIGIT2<3>"  LOC = "P25"  ;
NET "DIGIT2<2>"  LOC = "P31"  ;
NET "DIGIT2<1>"  LOC = "P20"  ;
NET "DIGIT2<0>"  LOC = "P19"  ;
NET "RESET"  LOC = "P48"  ; 
#PACE: Start of PACE Area Constraints
#PACE: Start of PACE Prohibit Constraints
#PACE: End of Constraints generated by PACE

The two-digit 7-Segment display schematic is shown below.

XC95108 Two-Digit BCD to 7-Segment Display VHDL
Common Cathode 7-Segment Display


XC95108 Two-Digit BCD to 7-Segment Display VHDL
XC9500 CPLD Reports

This circuit design requires 45 macro cells. Click here to download its source file.




No comments:

Post a Comment