音影先锋亚洲天堂网|电影世界尽头的爱完整版播放|国产 熟女 91|高清无码免费观看欧美日韩|韩国一区二区三区黄色录像|美女亚洲加勒比在线|亚洲综合网 开心五月|7x成人在线入口|成人网站免费日韩毛片区|国产黄片?一级?二级?三级

FPGA設(shè)計(jì)的SPI自動(dòng)發(fā)送模塊技術(shù)

出處:yuhh 發(fā)布于:2010-06-21 10:36:28

  一、摘要:

  SPI 接口應(yīng)用十分廣泛,在很多情況下,人們會(huì)用軟件模擬的方法來產(chǎn)生SPI 時(shí)序或是采用帶SPI 功能模塊的MCU。但隨著可編程邏輯技術(shù)的發(fā)展,人們往往需要自己設(shè)計(jì)簡(jiǎn)單的SPI 發(fā)送模塊。本文介紹一種基于FPGA 的將并行數(shù)據(jù)以SPI 串行方式自動(dòng)發(fā)送出去的方法。

  二、關(guān)鍵字:

  VHDL、FPGA、SPI、串行數(shù)據(jù)輸出選擇模塊、移位脈沖產(chǎn)生模塊、SPI 時(shí)鐘采集信號(hào)和無相移的SPI 基準(zhǔn)時(shí)鐘產(chǎn)生模塊、SPI 時(shí)鐘輸出選擇模塊、8bit SPI 時(shí)鐘采集生成模塊、16bit SPI 時(shí)鐘采集生成模塊、24bit SPI 時(shí)鐘采集生成模塊、8bit 數(shù)據(jù)移位模塊、16bit 數(shù)據(jù)移位模塊、24bit 數(shù)據(jù)移位模塊。

  三、功能框圖:

  SPI_MODES 為輸入模式選擇端口:

  --"01"is 8bit 傳輸模式

  --"10"is 16bit 傳輸模式

  --"11"is 24bit 傳輸模式

  CLKS 為整個(gè)模塊的基準(zhǔn)時(shí)鐘

  DBINOUTS 為并行數(shù)據(jù)輸入端口:

  --8bit 模式為DBINOUTS(7 downto 0)

  --16bit 模式為DBINOUTS(15 downto 0)

  --24bit 模式為DBINOUTS(23 downto 0)

  SPI_WR 為啟動(dòng)SPI 傳輸?shù)男盘?hào)

  整個(gè)功能模塊可工作在 8bit、16bit、24bit SPI 猝發(fā)傳輸狀態(tài)。對(duì)其進(jìn)行軟件操作的步驟相當(dāng)簡(jiǎn)單:

  --此模塊軟件操作流程如下

  --1、SPI_MODES="xx" 設(shè)定串口操作模式

  --2、DBINOUTS="xxxxxxxxxxxxxxxxxxxxxxxx" 輸入要發(fā)射的數(shù)據(jù)

  --3、SPI_WR='0'

  --4、SPI_WR='1'

  --5、SPI_WR='0'

  --8bit 模式延時(shí)2*8*4*CLKS

  --16bit 模式延時(shí)2*1**CLKS

  --24bit 模式延時(shí)2*24*4*CLKS

  --6、DBINOUTS="xxxxxxxxxxxxxxxxxxxxxxxx" 輸入下一個(gè)要發(fā)射的數(shù)據(jù)

  四、VHDL 描述解讀

  --以下描述的是一個(gè)SPI 自動(dòng)發(fā)射模塊

  --在很多情況下,人們會(huì)用軟件模擬的方法來產(chǎn)生SPI 時(shí)序

  --這里采用硬件的方法,即使軟件操作更為簡(jiǎn)單,有提高了傳輸?shù)乃俣?/P>

  --------------------------------------------------------------

  --此模塊軟件操作流程如下

  --1、SPI_MODES="xx" 設(shè)定串口操作模式

  --2、DBINOUTS="xxxxxxxxxxxxxxxxxxxxxxxx" 輸入要發(fā)射的數(shù)據(jù)

  --3、SPI_WR='0'

  --4、SPI_WR='1'

  --5、SPI_WR='0'

  --8bit 模式延時(shí)2*8*4*CLKS

  --16bit 模式延時(shí)2*1**CLKS

  --24bit 模式延時(shí)2*24*4*CLKS

  --6、DBINOUTS="xxxxxxxxxxxxxxxxxxxxxxxx" 輸入下一個(gè)要發(fā)射的數(shù)據(jù)

  library ieee;

  use ieee.std_logic_1164.all;

  use ieee.std_logic_unsigned.all;

  entity SPI_interface is

  port(CLKS :in std_logic; --基準(zhǔn)時(shí)鐘

  LCD_SCLS :out std_logic;--SPI 發(fā)射時(shí)鐘,上升沿有效

  LCD_SDIS :out std_logic;--SPI 數(shù)據(jù)串行輸出口

  SPI_MODES :in std_logic_vector(1 downto 0);

  --串口操作模式選擇

  --"01"is 8bit trans mode

  --"10"is 16bit trans mode

  --"11"is 24bit trans mode

  SPI_WR :in std_logic; --啟動(dòng)串口發(fā)送信號(hào)

  DBINOUTS :in std_logic_vector(23 downto 0));

  --背發(fā)送數(shù)據(jù)的并行輸入口

  --8bit mode use DBINOUTS(7 downto 0)

  --16bit mode use DBINOUTS(15 downto 0)

  --24bit mode use DBINOUTS(23 downto 0)

  end;

  architecture SPI_interface_behav of SPI_interface is

  signal DB8BIT_reg :std_logic_vector(7 downto 0); --8bit 數(shù)據(jù)移位寄存器

  signal DB16BIT_reg :std_logic_vector(15 downto 0);--16bit 數(shù)據(jù)移位寄存器

  signal DB24BIT_reg :std_logic_vector(23 downto 0);--24bit 數(shù)據(jù)移位寄存器

  signal counter4 :std_logic_vector(3 downto 0); --移位脈沖產(chǎn)生計(jì)數(shù)器

  signal counter4s :std_logic_vector(1 downto 0); --SPI 時(shí)鐘生成計(jì)數(shù)器

  signal counter8 :std_logic_vector(4 downto 0); --8bit SPI 時(shí)鐘控制計(jì)數(shù)器

  signal counter16 :std_logic_vector(5 downto 0); --16bit SPI 時(shí)鐘控制計(jì)數(shù)器

  signal counter24 :std_logic_vector(5 downto 0); --24bit SPI 時(shí)鐘控制計(jì)數(shù)器

  signal shift :std_logic;--移位時(shí)鐘脈沖

  signal LCD_SCLSS :std_logic;--SPI 時(shí)鐘采集信號(hào)

  signal LCD_SCLSSS :std_logic;--無相移的SPI 基準(zhǔn)時(shí)鐘

  signal LCD_SCLSS8 :std_logic;--8bit SPI 時(shí)鐘信號(hào)

  signal LCD_SCLSS16 :std_logic;--16bit SPI 時(shí)鐘信號(hào)

  signal LCD_SCLSS24 :std_logic;--24bit SPI 時(shí)鐘信號(hào)

  signal LCD_SDIS_8BIT :std_logic;--8bit SPI 數(shù)據(jù)信號(hào)

  signal LCD_SDIS_16BIT :std_logic;--16bit SPI 數(shù)據(jù)信號(hào)

  signal LCD_SDIS_24BIT :std_logic;--24bit SPI 數(shù)據(jù)信號(hào)

  begin

  --串行數(shù)據(jù)輸出選擇模塊

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

  begin

  if SPI_MODES="01" then --選擇8bit 串行數(shù)據(jù)輸出

  LCD_SDIS<=LCD_SDIS_8BIT;

  elsif SPI_MODES="10" then --選擇16bit 串行數(shù)據(jù)輸出

  LCD_SDIS<=LCD_SDIS_16BIT;

  elsif SPI_MODES="11" then --選擇24bit 串行數(shù)據(jù)輸出

  LCD_SDIS<=LCD_SDIS_24BIT;

  else LCD_SDIS<='1';

  end if;

  end process;

  --移位脈沖產(chǎn)生模塊

  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 時(shí)鐘采集信號(hào)和無相移的SPI 基準(zhǔn)時(shí)鐘產(chǎn)生模塊

  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 時(shí)鐘采集信號(hào)

  LCD_SCLSSS<=counter4s(1); --無相移的SPI 基準(zhǔn)時(shí)鐘

  end process;

  --SPI 時(shí)鐘輸出選擇模塊

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

  begin

  if SPI_MODES="01" then

  LCD_SCLS<=LCD_SCLSS8; --選擇8bit SPI 時(shí)鐘模式

  elsif SPI_MODES="10" then

  LCD_SCLS<=LCD_SCLSS16; --選擇16bit SPI 時(shí)鐘模式

  elsif SPI_MODES="11" then

  LCD_SCLS<=LCD_SCLSS24; --選擇24bit SPI 時(shí)鐘模式

  else LCD_SCLS<='1';

  end if;

  end process;

  --8bit SPI 時(shí)鐘采集生成模塊

  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 時(shí)鐘采集生成模塊

  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;

  end if;

  end if;

  end process;

  --24bit SPI 時(shí)鐘采集生成模塊

  counter24_u:process(LCD_SCLSS)

  begin

  if SPI_WR='1' then

  counter24<="110011";

  elsif LCD_SCLSS='1' and LCD_SCLSS'event then

  if counter24>0 then

  counter24<=counter24-1;

  if (counter24="000000")or(counter24="000001")or

  (counter24="110011")or(counter24="000010")then

  LCD_SCLSS24<='0';

  else

  LCD_SCLSS24<=LCD_SCLSSS;

  end if;

  end if;

  end if;

  end process;

  --8bit 數(shù)據(jù)移位模塊

  DB8BIT_U:process(shift,SPI_WR,DBINOUTS)

  begin

  if SPI_WR='1' then

  DB8BIT_reg<=DBINOUTS(7 downto 0);

  else

  if shift='1' and shift'event then

  LCD_SDIS_8BIT<=DB8BIT_reg(0);

  DB8BIT_reg(6 downto 0)<=DB8BIT_reg(7 downto 1);

  end if;

  end if;

  end process;

  --16bit 數(shù)據(jù)移位模塊

  DB16BIT_U:process(shift,SPI_WR,DBINOUTS)

  begin

  if SPI_WR='1' then

  DB16BIT_reg(15 downto 0)<=DBINOUTS(15 downto 0);

  else

  if shift='1' and shift'event then

  LCD_SDIS_16BIT<=DB16BIT_reg(0);

  DB16BIT_reg(14 downto 0)<=DB16BIT_reg(15 downto 1);

  end if;

  end if;

  end process;

  --24bit 數(shù)據(jù)移位模塊

  DB24BIT_U:process(shift,SPI_WR,DBINOUTS)

  begin

  if SPI_WR='1' then

  DB24BIT_reg(23 downto 0)<=DBINOUTS(23 downto 0);

  else

  if shift='1' and shift'event then

  LCD_SDIS_24BIT<=DB24BIT_reg(0);

  DB24BIT_reg(22 downto 0)<=DB24BIT_reg(23 downto 1);

  end if;

  end if;

  end process;

  end;

  五、仿真波形圖

  六、編譯后資源占用情況

  七、結(jié)束語

  本文旨在給學(xué)習(xí)可編程技術(shù)的人們提供一個(gè)參考,起到拋磚引玉的作用。望閱讀過此文的讀者提供更好的方法,與所有的學(xué)習(xí)者共享,共勉!(作者:姚青華)


  
關(guān)鍵詞:FPGA設(shè)計(jì)的SPI自動(dòng)發(fā)送模塊技術(shù)FPGAMCU

版權(quán)與免責(zé)聲明

凡本網(wǎng)注明“出處:維庫電子市場(chǎng)網(wǎng)”的所有作品,版權(quán)均屬于維庫電子市場(chǎng)網(wǎng),轉(zhuǎn)載請(qǐng)必須注明維庫電子市場(chǎng)網(wǎng),http://m.58mhw.cn,違反者本網(wǎng)將追究相關(guān)法律責(zé)任。

本網(wǎng)轉(zhuǎn)載并注明自其它出處的作品,目的在于傳遞更多信息,并不代表本網(wǎng)贊同其觀點(diǎn)或證實(shí)其內(nèi)容的真實(shí)性,不承擔(dān)此類作品侵權(quán)行為的直接責(zé)任及連帶責(zé)任。其他媒體、網(wǎng)站或個(gè)人從本網(wǎng)轉(zhuǎn)載時(shí),必須保留本網(wǎng)注明的作品出處,并自負(fù)版權(quán)等法律責(zé)任。

如涉及作品內(nèi)容、版權(quán)等問題,請(qǐng)?jiān)谧髌钒l(fā)表之日起一周內(nèi)與本網(wǎng)聯(lián)系,否則視為放棄相關(guān)權(quán)利。

1000萬的FPGA芯片長(zhǎng)什么樣?
廣告
OEM清單文件: OEM清單文件
*公司名:
*聯(lián)系人:
*手機(jī)號(hào)碼:
QQ:
有效期:

掃碼下載APP,
一鍵連接廣大的電子世界。

在線人工客服

買家服務(wù):
賣家服務(wù):
技術(shù)客服:

0571-85317607

網(wǎng)站技術(shù)支持

13606545031

客服在線時(shí)間周一至周五
9:00-17:30

關(guān)注官方微信號(hào),
第一時(shí)間獲取資訊。

建議反饋

聯(lián)系人:

聯(lián)系方式:

按住滑塊,拖拽到最右邊
>>
感謝您向阿庫提出的寶貴意見,您的參與是維庫提升服務(wù)的動(dòng)力!意見一經(jīng)采納,將有感恩紅包奉上哦!