FPGA-ARM通信代码.doc_第1页
FPGA-ARM通信代码.doc_第2页
FPGA-ARM通信代码.doc_第3页
FPGA-ARM通信代码.doc_第4页
FPGA-ARM通信代码.doc_第5页
已阅读5页,还剩2页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

libraryieee; useieee.std_logic_1164.all; useieee.std_logic_arith.all; useieee.std_logic_unsigned.all; -FPGA内部寄存器地址定义: packageinterfaceis constantaddr_reg1:std_logic_vector(9downto0):=0000000000; constantaddr_reg2:std_logic_vector(9downto0):=0000000001; constantaddr_reg3:std_logic_vector(9downto0):=0000000010; constantaddr_reg4:std_logic_vector(9downto0):=0000000011; end; libraryieee; useieee.std_logic_1164.all; useieee.std_logic_arith.all; useieee.std_logic_unsigned.all; erface.all; entityarm_fpgais port( mcudata:inoutstd_logic_vector(7downto0);-8位数据 mcuaddress:instd_logic_vector(9downto0);-10位地址 wr:instd_logic;-写信号 rd:instd_logic; cs:instd_logic; led:outstd_logic_vector(7downto0); end; architecturearmfpgaofarm_fpgais signaladdresstemp:std_logic_vector(9downto0);-内部寄存器 signaldatatemp1,datatemp2,datatemp3,datatemp4:std_logic_vector(7downto0); signalwr_en,rd_en:std_logic;-读写使能 begin addresstemp=mcuaddress; wr_en=(wrandrd)orwr; rd_en datatemp1 datatemp2 datatemp3 datatemp4null; endcase; endif; endif; endprocess; -ARM从FPGA读取数据: process(rd,rd_en) begin ifrdeventandrd=0then ifcs=0andrd_en=0then caseaddresstempis whenaddr_reg1= mcudata mcudata mcudata mcudatanull; endcase; endif; endif; endprocess; led=mcudata;-验证传输数据,LED显示 end;-mcufpga.vhd libraryieee; useieee.std_logic_1164.all; useieee.std_logic_arith.all; useieee.std_logic_unsigned.all; -FPGA内部寄存器地址定义: packageinterfaceis constantaddr_reg1:std_logic_vector(9downto0):=0000000000; constantaddr_reg2:std_logic_vector(9downto0):=0000000001; constantaddr_reg3:std_logic_vector(9downto0):=0000000010; constantaddr_reg4:std_logic_vector(9downto0):=0000000011; end; libraryieee; useieee.std_logic_1164.all; useieee.std_logic_arith.all; useieee.std_logic_unsigned.all; erface.all; entityarm_fpgais port( mcudata:inoutstd_logic_vector(7downto0);-8位数据 mcuaddress:instd_logic_vector(9downto0);-10位地址 wr:instd_logic;-写信号 rd:instd_logic; cs:instd_logic; led:outstd_logic_vector(7downto0); end; architecturearmfpgaofarm_fpgais signaladdresstemp:std_logic_vector(9downto0);-内部寄存器 signaldatatemp:std_logic_vector(31downto0); -signalwr_en,rd_en:std_logic;-读写使能 begin addresstemp=mcuaddress; -ARM写数据到FPGA: process(wr,cs) begin -datatemp1datatemp(7downto0)datatemp(15downto8)datatemp(23downto16)datatemp(31downto24)null; endcase; endif; endprocess; -ARM从FPGA读取数据: process(rd,cs) begin ifrdeventandrd=0andcs=0then -caseaddresstempis -whenaddr_reg1=mcudatamcudatamcudatamcudatamcudata=ZZZZZZZZ; mcudata= datatemp(7downto0)when(addresstemp=addr_reg1)else datatemp(15downto8)when(addresstemp=addr_reg2)else datatemp(23downto16)when(addresstemp=addr_reg3)else datatemp(31downto24)when(addresstemp=addr_reg4)else ZZZZZZZZ; endcase; endif; endprocess; led=mcudata; end;-mcufpga.vhd libraryieee; useieee.std_logic_1164.all; useieee.std_logic_arith.all; useieee.std_logic_unsigned.all; entityarm_fpgais port( mcudata:inoutstd_logic_vector(7downto0);-8位数据 mcuaddress:instd_logic_vector(9downto0);-10位地址 wr:instd_logic;-写信号 rd:instd_logic; cs:instd_logic; led:outstd_logic_vector(7downto0); end; architecturearmfpgaofarm_fpgais signaladdresstemp:std_logic_vector(1downto0);-内部寄存器 signaldatatemp:std_logic_vector(31downto0); begin addresstemp=mcuaddress(1downto0); -ARM写数据到FPGA: datatemp(7downto0)=mcudatawhen(cs=0andwr=0andaddresstemp=00); datatemp(15downto8)=mcudatawhen(cs=0andwr=0andaddresstemp=01); datatemp(23downto16)=mcudatawhen(cs=0andwr=0andaddresstemp=10); datatemp(31downto24)=mcudatawhen(cs=0andwr=0andaddresstemp=11); -ARM从FPGA读取数据: mcudata=datatemp(7downto0)when(cs=0andrd=0andaddresstemp=00)else datatemp(15downto8)when(cs=0andrd=0andaddresstemp=01)else datatemp(23downto16)when(cs=0andrd=0andaddresstemp=10)else datatemp(31downto24)when(cs=0andrd=0andaddresstemp=11)else ZZZZZZZZ;-ZZ不可少,否则总线被FPGA锁死. led=mcudata; endarmfpga;libraryieee; useieee.std_logic_1164.all; useieee.std_logic_arith.all; useieee.std_logic_unsigned.all; entityarm_fpgais port( mcudata:inoutstd_logic_vector(7downto0);-8位数据 mcuaddress:instd_logic_vector(9downto0);-10位地址 wr:instd_logic;-写信号 rd:instd_logic; cs:instd_logic; led:outstd_logic_vector(7downto0); end; architecturearmfpgaofarm_fpgais constantaddr_reg1:std_logic_vector(9downto0):=0000000000; constantaddr_reg2:std_logic_vector(9downto0):=0000000001; constantaddr_reg3:std_logic_vector(9downto0):=0000000010; constantaddr_reg4:std_logic_vector(9downto0):=0000000011; signaladdresstemp:std_logic_vector(9downto0);-内部寄存器 signaldatatemp:std_logic_vector(31downto0); -signalwr_en,rd_en:std_logic;-读写使能 begin addresstempdatatemp(7downto0)datatemp(15downto8)datatemp(23downto16)datatemp(31downto24) datatemp0); endcase; else datatemp0); endif;

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论