FPGA设计的SPI自动发送模块技术

[09-12 18:30:48]   来源:http://www.88dzw.com  EDA/PLD   阅读:8462

文章摘要:signal DB24BIT_reg :std_logic_vector(23 downto 0);--24bit 数据移位寄存器signal counter4 :std_logic_vector(3 downto 0); --移位脉冲产生计数器signal counter4s :std_logic_vector(1 downto 0); --SPI 时钟生成计数器signal counter8 :std_logic_vector(4 downto 0); --8bit SPI 时钟控制计数器signal counter16 :std_logic_vector(5 downto 0); --1

FPGA设计的SPI自动发送模块技术,标签:eda技术,eda技术实用教程,http://www.88dzw.com

  signal DB24BIT_reg :std_logic_vector(23 downto 0);--24bit 数据移位寄存器

  signal counter4 :std_logic_vector(3 downto 0); --移位脉冲产生计数器

  signal counter4s :std_logic_vector(1 downto 0); --SPI 时钟生成计数器

  signal counter8 :std_logic_vector(4 downto 0); --8bit SPI 时钟控制计数器

  signal counter16 :std_logic_vector(5 downto 0); --16bit SPI 时钟控制计数器

  signal counter24 :std_logic_vector(5 downto 0); --24bit SPI 时钟控制计数器

  signal shift :std_logic;--移位时钟脉冲

  signal LCD_SCLSS :std_logic;--SPI 时钟采集信号

  signal LCD_SCLSSS :std_logic;--无相移的SPI 基准时钟

  signal LCD_SCLSS8 :std_logic;--8bit SPI 时钟信号

  signal LCD_SCLSS16 :std_logic;--16bit SPI 时钟信号

  signal LCD_SCLSS24 :std_logic;--24bit SPI 时钟信号

  signal LCD_SDIS_8BIT :std_logic;--8bit SPI 数据信号

  signal LCD_SDIS_16BIT :std_logic;--16bit SPI 数据信号

  signal LCD_SDIS_24BIT :std_logic;--24bit SPI 数据信号

  begin

  --串行数据输出选择模块

  u1:process(LCD_SDIS_8BIT,LCD_SDIS_16BIT,LCD_SDIS_24BIT,SPI_MODES)

  begin

  if SPI_MODES="01" then --选择8bit 串行数据输出

  LCD_SDIS<=LCD_SDIS_8BIT;

  elsif SPI_MODES="10" then --选择16bit 串行数据输出

  LCD_SDIS<=LCD_SDIS_16BIT;

  elsif SPI_MODES="11" then --选择24bit 串行数据输出

  LCD_SDIS<=LCD_SDIS_24BIT;

  else LCD_SDIS<='1';

  end if;

  end process;

  --移位脉冲产生模块

  u2:process(CLKS)

  begin

  if CLKS='1' and CLKS'event then

  if counter4="0011" then

  counter4<="0000";

  shift <='1';

  else counter4<=counter4+1;

  shift <='0';

  end if;

  end if;

  end process;

  --SPI 时钟采集信号和无相移的SPI 基准时钟产生模块

  u3:process(CLKS)

  begin

  if CLKS='1' and CLKS'event then

  if counter4s<"11" then

  counter4s<=counter4s+1;

  else counter4s<="00";

  end if;

  end if;

  LCD_SCLSS<=counter4s(0); --SPI 时钟采集信号

  LCD_SCLSSS<=counter4s(1); --无相移的SPI 基准时钟

  end process;

  --SPI 时钟输出选择模块

  u4:process(LCD_SCLSS8,LCD_SCLSS16,LCD_SCLSS24,SPI_MODES)

  begin

  if SPI_MODES="01" then

  LCD_SCLS<=LCD_SCLSS8; --选择8bit SPI 时钟模式

  elsif SPI_MODES="10" then

  LCD_SCLS<=LCD_SCLSS16; --选择16bit SPI 时钟模式

  elsif SPI_MODES="11" then

  LCD_SCLS<=LCD_SCLSS24; --选择24bit SPI 时钟模式

  else LCD_SCLS<='1';

  end if;

  end process;

  --8bit SPI 时钟采集生成模块

  counter8_u:process(LCD_SCLSS)

  begin

  if SPI_WR='1' then

  counter8<="10001";

  elsif LCD_SCLSS='1' and LCD_SCLSS'event then

  if counter8>0 then

  counter8<=counter8-1;

  LCD_SCLSS8<=LCD_SCLSSS;

  end if;

  end if;

  end process;

  --16bit SPI 时钟采集生成模块

  counter16_u:process(LCD_SCLSS)

  begin

  if SPI_WR='1' then

  counter16<="100001";

  elsif LCD_SCLSS='1' and LCD_SCLSS'event then

  if counter16>0 then

  counter16<=counter16-1;

  LCD_SCLSS16<=LCD_SCLSSS;

上一页  [1] [2] [3]  下一页


Tag:EDA/PLDeda技术,eda技术实用教程EDA/PLD
分类导航
最新更新
热门排行