Sunday, December 10, 2023

XC9536 CPLD 8-Bit Serial In Parallel Out Shift Registers using VHDL

Overview

A serial in parallel out shift registers is very useful for I/O expanding. For instance, they can use it for driving multiple seven segments display, a dot matrix display, multiple output relays, etc. Standard serial-in-parallel-out shift registers ICs usage are the SN74HC595 and SN74HC164. They are very easy to find at very low cost. The controller uses only a few output pins to control these chips.







XC9536 CPLD 8-Bit Serial In Parallel Out Shift Registers using VHDL
A 4-Digit Common Anode SN74HC595N Serial Display

In this example, I designed an 8-bit serial-in-parallel-out shift registers using an XC9536 CPLD. All components are already placed on board. Its inputs outputs are listed below,

  1. Reset
  2. Clock
  3. Data
  4. Output

There's no output enable signal, or a 8th bit output for cascading. This circuit receive the least significant bit (LSB) first. So it shifts from left to right.

XC9536 CPLD 8-Bit Serial In Parallel Out Shift Registers using VHDL
XC9536 Prototyping Board


VHDL Code

Its VHDL code is quite simple. I added one 8-bit signal to process serial data reception. This design a sequential process.

  1. ----------------------------------------------------------------------------------
  2. -- Company:
  3. -- Engineer:
  4. --
  5. -- Create Date: 09:36:04 12/11/2023
  6. -- Design Name:
  7. -- Module Name: shift_registers_8 - 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 shift_registers_8 is
  33. Port ( RST : in STD_LOGIC;
  34. CLK : in STD_LOGIC;
  35. DAT : in STD_LOGIC;
  36. D : out STD_LOGIC_VECTOR (7 downto 0));
  37. end shift_registers_8;
  38.  
  39. architecture Behavioral of shift_registers_8 is
  40. signal Q : STD_LOGIC_VECTOR(7 DOWNTO 0);
  41.  
  42. begin
  43.  
  44. process(CLK,RST)
  45. begin
  46. if(RST='0') then Q<=x"00";
  47. elsif(CLK'EVENT AND CLK='0') then
  48. Q(0)<=DAT;
  49. Q(1)<=Q(0);
  50. Q(2)<=Q(1);
  51. Q(3)<=Q(2);
  52. Q(4)<=Q(3);
  53. Q(5)<=Q(4);
  54. Q(6)<=Q(5);
  55. Q(7)<=Q(6);
  56. end if;
  57. D<=Q;
  58. end process;
  59.  
  60. end Behavioral;
  61.  
  62.  

Pin Assignments

I use the Xilinx PACE Tool to set its I/O pins as follow.

XC9536 CPLD 8-Bit Serial In Parallel Out Shift Registers using VHDL
Xilinx PACE

After we save and close this windows, a user constraint file will be created.

#PACE: Start of Constraints generated by PACE

#PACE: Start of PACE I/O Pin Assignments
NET "CLK"  LOC = "P19"  ;
NET "D<0>"  LOC = "P33"  ;
NET "D<1>"  LOC = "P34"  ;
NET "D<2>"  LOC = "P35"  ;
NET "D<3>"  LOC = "P36"  ;
NET "D<4>"  LOC = "P37"  ;
NET "D<5>"  LOC = "P38"  ;
NET "D<6>"  LOC = "P39"  ;
NET "D<7>"  LOC = "P40"  ;
NET "DAT"  LOC = "P25"  ;
NET "RST"  LOC = "P18"  ;

#PACE: Start of PACE Area Constraints

#PACE: Start of PACE Prohibit Constraints

#PACE: End of Constraints generated by PACE

Device Programming

A parallel port JTAG cable is preferred since I write this code on a desktop computer that has an LPT-25 connector.

XC9536 CPLD 8-Bit Serial In Parallel Out Shift Registers using VHDL
Device Programming Using Xilinx Parallel Cable III JTAG


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)