Wednesday, January 24, 2024

XC95108 Rotates LED Example using VHDL

The VHDL Rotate Left (ROL) and Rotate Right (ROR) with carry operators are used for shifting the data left or right with a specific position. Unlike the VHDL Shift operators, it has carry bit. These operators are useful for serial data transmitting or receiving. 

XC95108 Rotates LED Example using VHDL
XC95108 Hardware Testing

In this example, I use these operators to make a simple LED chasing circuit. I created two digital output port, PORTA and PORTB. These two ports rotates their output bits in an opposite direction.

XC95108 Rotates LED Example using VHDL
XC95108 CPLD and LED Schematic

The shifting rate is 100 Millis seconds. I use a clock divider circuit that divide a 25.175MHz signal source to a 100Hz clock frequency.

  1. ----------------------------------------------------------------------------------
  2. -- Company:
  3. -- Engineer:
  4. --
  5. -- Create Date: 19:44:09 01/24/2024
  6. -- Design Name:
  7. -- Module Name: led_shift - 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 led_shift is
  33. Generic ( FREQ : INTEGER :=25175000;
  34. FREQ_H: INTEGER :=12587500);
  35. Port ( PORTA : out BIT_VECTOR (7 downto 0);
  36. PORTB : out BIT_VECTOR (7 downto 0);
  37. CLK : in STD_LOGIC);
  38. end led_shift;
  39.  
  40. architecture Behavioral of led_shift is
  41. SIGNAL RA,RB: BIT_VECTOR(7 DOWNTO 0):=X"01";
  42.  
  43. begin
  44.  
  45. PROCESS(CLK)
  46. VARIABLE COUNTER: INTEGER RANGE 0 TO 2517500;
  47.  
  48. BEGIN
  49. IF(CLK'EVENT AND CLK='1') THEN
  50. COUNTER:=COUNTER+1;
  51. IF(COUNTER=2517500) THEN
  52. RA<=RA ROR 1;
  53. RB<=RB ROL 1;
  54. END IF;
  55. END IF;
  56.  
  57. PORTA<=RA;
  58. PORTB<=RB;
  59. END PROCESS;
  60.  
  61. end Behavioral;
  62.  
  63.  

This digital circuit needs about 28 macro cells and 86 input function block of the XC95108 CPLD.

XC95108 Rotates LED Example using VHDL
XC95108 CPLD Reports

The user constraints for I/O pins selection is listed below.

#PACE: Start of Constraints generated by PACE
#PACE: Start of PACE I/O Pin Assignments
NET "CLK"  LOC = "P9"  ;
NET "PORTA<0>"  LOC = "P63"  ;
NET "PORTA<1>"  LOC = "P62"  ;
NET "PORTA<2>"  LOC = "P61"  ;
NET "PORTA<3>"  LOC = "P58"  ;
NET "PORTA<4>"  LOC = "P57"  ;
NET "PORTA<5>"  LOC = "P56"  ;
NET "PORTA<6>"  LOC = "P55"  ;
NET "PORTA<7>"  LOC = "P54"  ;
NET "PORTB<0>"  LOC = "P65"  ;
NET "PORTB<1>"  LOC = "P66"  ;
NET "PORTB<2>"  LOC = "P67"  ;
NET "PORTB<3>"  LOC = "P68"  ;
NET "PORTB<4>"  LOC = "P69"  ;
NET "PORTB<5>"  LOC = "P70"  ;
NET "PORTB<6>"  LOC = "P71"  ;
NET "PORTB<7>"  LOC = "P72"  ;
#PACE: Start of PACE Area Constraints
#PACE: Start of PACE Prohibit Constraints
#PACE: End of Constraints generated by PACE

The XC9572 can be used in this simple circuit. I use the Xilinx ISE Design 14.7 running on Windows 10. The Xilinx Parallel Cable III still work very nice in this Xilinx ISE version. 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)