Tuesday, December 12, 2023

XC9536 Counter with Two-Digit Multiplexing Display Using VHDL

In this VHDL example, I use a Xilinx XC9536 CPLD to create a digital up counter with a two-digit multiplexing seven-segment display. This counter will count up to 99 before it rolls down to 0. This CPLD has limited resource so we can not create more digits or temporary variable to process this circuit, even a three-digit digital up counter.

XC9536 Counter with Two-Digit Multiplexing Display Using VHDL
XC9536 CPLD Hardware Experiment







In this design there are three inputs, clock, reset, and count push button. Clock signal is activated from low to high transition while reset and count signal are active low signals.

  1. ----------------------------------------------------------------------------------
  2. -- Company:
  3. -- Engineer:
  4. --
  5. -- Create Date: 19:32:59 12/12/2023
  6. -- Design Name:
  7. -- Module Name: counter_mux - Behavioral
  8. -- Project Name:
  9. -- Target Devices:
  10. -- Tool versions:
  11. -- Description:
  12. --
  13. -- Dependencies:
  14. --
  15. -- Revision:
  16. -- Revision 0.01 - File Created
  17. -- Additional Comments:
  18. --
  19. ----------------------------------------------------------------------------------
  20. library IEEE;
  21. use IEEE.STD_LOGIC_1164.ALL;
  22.  
  23. -- Uncomment the following library declaration if using
  24. -- arithmetic functions with Signed or Unsigned values
  25. --use IEEE.NUMERIC_STD.ALL;
  26.  
  27. -- Uncomment the following library declaration if instantiating
  28. -- any Xilinx primitives in this code.
  29. --library UNISIM;
  30. --use UNISIM.VComponents.all;
  31.  
  32. entity counter_mux is
  33. Port ( CLK : in STD_LOGIC;
  34. RST : in STD_LOGIC;
  35. CNT : in STD_LOGIC;
  36. COM : out STD_LOGIC_VECTOR (1 downto 0);
  37. DAT : out STD_LOGIC_VECTOR (7 downto 0));
  38. end counter_mux;
  39.  
  40. architecture Behavioral of counter_mux is
  41. type array_1 is array(0 to 9) of STD_LOGIC_VECTOR (7 downto 0);
  42. signal display : array_1 :=(x"3F",x"06",x"5B",x"4F",x"66",x"6D",x"7D",x"07",x"7F",x"6F");
  43.  
  44. begin
  45. process(CLK,RST)
  46. variable freq_count : INTEGER RANGE 0 TO 1:=0;
  47. variable press_count : INTEGER RANGE 0 TO 9:=0;
  48. variable press_10 : INTEGER RANGE 0 TO 9:=0;
  49. variable press_sw : INTEGER RANGE 0 TO 10:=0;
  50. begin
  51. if(RST='0') then
  52. press_count:=0;
  53. press_10:=0;
  54. DAT<=x"00";
  55. elsif(CLK'EVENT AND CLK='1') then
  56. freq_count:=freq_count+1;
  57. -- 7-Segment Process
  58. CASE freq_count IS
  59. WHEN 0 =>
  60. DAT<=display(press_count); COM<="01";
  61. WHEN 1 =>
  62. DAT<=display(press_10); COM<="10";
  63. -- Push Button Process
  64. press_sw:=press_sw+1;
  65. if(CNT='0' AND press_sw>=7) then
  66. press_count:=press_count+1;
  67. press_sw:=0;
  68. if(press_count>9) then
  69. press_count:=0;
  70. press_10:=press_10+1;
  71. end if;
  72. if(press_10>9) then
  73. press_count:=0;
  74. press_10:=0;
  75. end if;
  76. end if;
  77. WHEN OTHERS => NULL;
  78. END CASE;
  79. end if;
  80. end process;
  81.  
  82. end Behavioral;
  83.  
  84.  

After the design implementation this circuit consume a lot of the SX9536's resource. So we can not add more features into this design. I assigned its I/O pins using Xilinx PACE as follow.

XC9536 Counter with Two-Digit Multiplexing Display Using VHDL
Xilinx PACE

Its generated user constraint file listed below.

#PACE: Start of Constraints generated by PACE
#PACE: Start of PACE I/O Pin Assignments
NET "CLK"  LOC = "P5"  ;
NET "CNT"  LOC = "P18"  ;
NET "COM<0>"  LOC = "P44"  ;

NET "COM<1>"  LOC = "P43"  ;
NET "DAT<0>"  LOC = "P33"  ;

NET "DAT<1>"  LOC = "P34"  ;
NET "DAT<2>"  LOC = "P35"  ;
NET "DAT<3>"  LOC = "P36"  ;
NET "DAT<4>"  LOC = "P37"  ;
NET "DAT<5>"  LOC = "P38"  ;
NET "DAT<6>"  LOC = "P39"  ;
NET "DAT<7>"  LOC = "P40"  ;
NET "RST"  LOC = "P25"  ;
#PACE: Start of PACE Area Constraints
#PACE: Start of PACE Prohibit Constraints
#PACE: End of Constraints generated by PACE

Then we will need to run the Implement Design again to get its programming file.

XC9536 Counter with Two-Digit Multiplexing Display Using VHDL
CPLD Reports

After the Implement Design is finished we can see the reports.

I still use Parallel Cable III in iMPACT tool to program this device.

XC9536 Counter with Two-Digit Multiplexing Display Using VHDL
Xilinx iMPACT



Click here to download its source file.

No comments:

Post a Comment

Labels

ADC (10) Analog (14) Arduino (12) Atmega16 (19) Audio (2) AVR (20) Charger (1) Cortex-M0 (1) Counter (10) CPLD (25) Digital I/O (22) Display (34) EEPROM (2) Environment Sensor (1) esp8266 (2) Experiment Board (10) I2C (4) Interrupt (7) LCD (1) LDmicro (29) measurement and instrumentation (7) Microchip Studio (3) MikroC (1) One-Shot (3) OpAmp (1) PCB (31) PIC16 Microcontrollers (16) PIC16F877A (2) PIC16F887 MikroC (22) PLC (35) PWM (11) Regulator (1) RTC (2) Sensor (8) Shift Registers (5) SPI (5) Timer (34) UART (2) ultra-sonic sensor (1) USB (1) VHDL (21) xc8 (1) XC95108 (9) XC9536 (15) XC9572 (1) Xilinx (23) Xilinx ISE (22)