差别
这里会显示出您选择的修订版和当前版本之间的差别。
两侧同时换到之前的修订记录 前一修订版 后一修订版 | 前一修订版 | ||
start [2016/05/25 10:35] gongyu [数字逻辑、可编程逻辑及FPGA] |
start [2019/08/09 11:40] (当前版本) xiefan [Media] |
||
---|---|---|---|
行 1: | 行 1: | ||
- | ====数字逻辑、可编程逻辑及FPGA==== | + | #FPGA related resources |
- | ===数字逻辑基础=== | + | |
- | ===可编程逻辑=== | + | |
- | ===FPGA的构成及应用=== | + | |
- | ===[[FPGA设计流程]]=== | + | |
- | ====小脚丫FPGA学习平台介绍==== | + | |
- | 小脚丫FPGA学习平台是摩尔吧孵化器专门针对[[FPGA]]初学者打造的一款性价比最高、学习门槛最低的学习模块,它以[[Lattice Semiconductor]]公司[[XO2-4000]]器件为核心,具有开关、按键输入以及单色LED、三色[[LED]]以及2个发光数码馆进行显示。其封装方式兼容标准的[[DIP40]]封装,能够直接插在面包板上或以模块的方式放置在其它电路板上以即插即用的方式,大大简化系统的设计。 | + | |
- | {{ :step_fpga.jpg?600|}} | + | |
- | {{ :xo2_selection.png |}} | + | |
- | ===功能介绍=== | + | |
- | - 食指大小——目前最小的FPGA开发板,尺寸52mm*18mm,即插即用; | + | |
- | - USB供电,自带板载编程器,无需额外配置FPGA下载线 | + | |
- | - LCMXO2-1200,性价比最高最适合的FPGA芯片 | + | |
- | - 既可作学习数字逻辑的FPGA开饭,也可作核心功能模块使用,适合各种DIY和原型设计 | + | |
- | - 丰富的实例、代码支持 | + | |
- | ===硬件连接=== | + | |
- | {{ :stepfpga_v1_connection.png |}} | + | |
- | - FPGA芯片:LCMXO2-1200HC-4MG132 | + | |
- | - USB 5V供电 | + | |
- | - 25MHz时钟 | + | |
- | - 3个LED,一路电源指示,两路用户LED | + | |
- | - 2个按键 | + | |
- | - 2个RGB LED | + | |
- | - 一路I2C接口 | + | |
- | - SPI接口(可设主从模式) | + | |
- | - JTAG接口 | + | |
- | - 29个GPIO接口 | + | |
- | {{ :stepfpga_connection_table.png |}} | + | |
- | {{ :stepfpga_v1_connection_led.png |}} | + | |
- | ===使用方法=== | + | ##Vendors |
- | 上电测试。Step FPGA开发板通过USB供电,采用了常见Micro USB接口。一般的安卓手机USB线均可使用。开发板出厂内置测试程序,上电后: | + | |
- | - Step FPGA开发板连接USB电源,电源指示灯点亮。 | + | |
- | - 两个用户LED灯交替闪烁,间隔0.5秒。 | + | |
- | - RGB LED闪烁分两种模式,上电默认流水灯模式。 | + | |
- | - 流水灯:RGB LED交替闪烁红绿蓝。 | + | |
- | - 交通灯:两个RGB LED异步闪烁红绿蓝,如同交通信号。 | + | |
- | - 按键K2切换RGB LED显示模式。 | + | |
- | - 按键K1用于复位功能。 | + | |
- | {{ :stepfpga_v1_powerup.jpg |}} | + | |
- | ===扩展应用=== | + | |
- | ====Lattice Diamond综合开发环境==== | + | |
- | ===软件安装及配置=== | + | |
- | Step FPGA开发板支持Lattice的Diamond开发环境,首先我们需要到官网下载Diamond进行安装,非常简单。下载Diamond安装包: | + | |
- | http://www.latticesemi.com/zh-CN/Products/DesignSoftwareAndIP/FPGAandLDS/LatticeDiamond.aspx | + | |
- | 开始安装: | + | |
- | - 双击打开下载好的软件,3.5.0.102_Diamond_x64.exe。 | + | |
- | - 进入安装首页。{{ :diamond1.png |}} | + | |
- | - 点击Next,进入协议界面,同意,Next{{ :diamond2.png |}} | + | |
- | - 修改安装路径,默认是C盘,本例程软件安装到D盘。{{ :diamond3.png |}} | + | |
- | - 修改完路径后,点击Next,进入工具选项界面。{{ :diamond4.png |}} | + | |
- | - 选择默认设置,即全部安装。注意叉叉是表示选择。点击Next,进入文件夹名设置。当然你可以根据自己喜好,修改文件夹的名字。{{ :diamond5.png |}} | + | |
- | - 接下来就是认证设置。没有USB key,就只能选择Node-Lock License。{{ :diamond6.png |}} | + | |
- | - 点击Next,选择是否创建桌面快捷键。{{ :diamond7.png |}} | + | |
- | - 点击Next,选择是否安装USB驱动,这个必须同意!!!{{ :diamond8.png |}} | + | |
- | - 完成这一系列设置后,软件列出所有设置内容。{{ :diamond9.png |}} | + | |
- | - 点击Next,正式进入安装环节。软件会评估一下本机系统,决定是否继续安装。{{ :diamond10.png |}} | + | |
- | - 一般配置的PC机都可以通过评估。进入安装。{{ :diamond11.png |}} | + | |
- | - 耐心等待=========>{{ :diamond12.png |}} | + | |
- | - 点击Finish,完成安装。 | + | |
- | + | ||
- | 相比于一般的FPGA开发工具,Lattice的Diamond更加简洁,占用资源更少,速度更快。而且Lattice提供完全免费的版本,只需要在官网注册后申请一个免费的License。 | + | |
- | ==安装License== | + | |
- | - 获取License:登陆Lattice官网:http://www.latticesemi.com/,没有账户则先注册账户, 依次Support →Licensing →Lattice Software Licenses →Request a Free License(获取一个免费许可证){{ :diamond13.png |}} 将安装软件的电脑MAC地址(physical address)填写,勾选required field,并Generate License。 注:如何获取MAC地址? 打开cmd.exe,输入命令 ipconfig/all,找到物理地址(physical address),共12位数。 | + | |
- | - 软件注册 将之前获取的license.dat文件拷贝到安装目录下的license文件夹中,例如将软件安装在D盘下:D:\lscc\diamond\3.5_x64\license\ ,注册完成, 运行Diamond,界面如下 {{ :diamond14.png |}} 界面中,右侧User Guides、Reference Guides、Tutorials、FPGA Design Guide等有大量文档链接,如果有时间建议大家尝试阅读,很有指导性。若运行Diamond时报错 License checkout failed,说明软件注册有问题,请检查: | + | |
- | - 检查用于注册License的MAC地址是否正确! | + | |
- | - 检查获取到的License文件被放置在软件安装目录下!D:\lscc\diamond\3.5_x64\license\ | + | |
- | - 检查环境变量是否正确! | + | |
- | - 我的电脑 →右键选择属性 →高级系统设置 →高级 →环境变量 →系统变量 ,变量和值分别为 | + | |
- | - LM_LICENSE_FILE | + | |
- | - D:\lscc\diamond\3.5_x64\license\license.dat;{{ :diamond15.png |}} | + | |
- | - USB驱动: 在包装盒中的编程模块需要USB驱动,通常情况下Diamond安装好了之后能够自动识别编程模块。如果不能自动安装驱动程序,需要先下载驱动程序:http://www.ftdichip.com/Drivers/VCP.htm根据不同的系统下载驱动版本。 | + | |
- | 硬件连线 | + | https://www.altera.com – Altera FPGA supplier site |
- | Step FPGA的编程模块也是通过Micro USB线和电脑相连,因此准备Step FPGA开发环境需要两根Micro USB连接线。驱动安装好以后就可以开始编译下载程序了。 | + | |
- | 下面我们可以开始可编程逻辑的开发,我们以控制LED交替闪烁为例,完成自己的第一个程序: | + | |
- | - 运行Diamond软件,选择File →New →Project →Next {{ :diamond16.png |}} | + | |
- | - 我们将新工程命名为LED_shining,工程目录G:/LED_shining,然后Next{{ :diamond17.png |}} | + | |
- | - 添加相关设计文件或约束文件,这里我们新建工程,不需添加,直接Next{{ :diamond18.png |}} | + | |
- | - 器件选择:按照Step FPGA开发板器件LCMXO2-1200HC-4MG132C配置,Next{{ :diamond19.png |}} | + | |
- | - 选择综合工具,Synplify Pro(第三方)和Lattice LSE(原厂)都可以,我们就使用Lattice LSE,直接Next{{ :diamond20.png |}} | + | |
- | - 工程信息,上面选择的所有信息都在这,直接Finish{{ :diamond21.png |}} | + | |
- | - 工程已经建好,我们下面添加设计文件, 选择File →New →File{{ :diamond22.png |}} | + | |
- | - 选择Verilog Files,Name填写LED_shining,然后New,这是软件打开的设计文件,LED_shining.v,我们就可以编程了{{ :diamond23.png |}} | + | |
- | - 程序源码如下,复制到设计文件LED_shining.v中,并保存。 | + | |
- | - 综合,在软件左侧Process栏,选择Process,双击Synthesis Design,对设计进行综合,综合完成后Synthesis Design显示绿色对勾,如图{{ :diamond24.png |}} | + | |
- | - 分配管脚,选择Tools →Spreadsheet View,界面如下{{ :diamond25.png |}} | + | |
- | - 我们将管脚分配,并设置IO_TYPE为LVCMOS33,保存,如下图{{ :diamond26.png |}} | + | |
- | - 在软件左侧Process栏,选择Process,勾选所有选项,直接双击Export Files,所有布局布线输出依次完成,结束后,所有选项显示绿色对勾。{{ :diamond27.png |}} | + | |
- | 到这里完成了第一个程序流文件的生成,下面可以下载到FPGA中。 | + | https://www.altera.com/events/northamerica/intel-soc-fpga-developer-forum/overview.html - SoC Developers Forum |
- | ==工程仿真== | + | https://www.altera.com/content/dam/altera-www/global/en_US/pdfs/literature/tt/tt_my_first_fpga.pdf - First FPGA design tutorial |
- | 上面我们走了整个工程开发的过程,例程较为简单,对于复杂的工程开发需要预仿真和后仿真等,保证最终的程序设计逻辑和时序符合我们的设计要求。 | + | |
- | 仿真软件很多,这里我们使用软件自带的Active-HDL软件进行仿真 | + | |
- | 首先我们添加testbench文件,和前面添加设计文件一样,File →New→File →Verilog Files,Name填写,然后New,{{ :diamond28.png |}} | + | |
- | 测试源码如下,复制到LED_test.v文件并保存: | + | |
- | 然后在软件左侧Process栏,选择File List,找到LED_test.v,右键选择Include for →Simulation | + | |
- | 为了方便仿真,我们将LED_shining.v文件中的时钟分频周期缩短,更改并保存 | + | |
- | parameter CLK_DIV_PERIOD=50;//25000000;//related with clk_div's frequency | + | |
- | 仿真结束,编译下载时再恢复。 | + | |
- | 重新编译整个工程,然后选择Tools →SimulationWizard →Next, | + | |
- | 建立仿真工程,ModelSim和QuestaSim需要自行安装并与Diamond关联,才能直接调用,我们使用Active-HDL | + | |
- | 这里我们选择Active-HDL(默认),工程名称:LED_test,工程路径在Diamond工程路径下新建LED_test 文件夹:**/LED_shining/LED_test,然后Next, | + | |
- | RTL,Next | + | |
- | 勾选Copy Source toSimulation Directory,Next | + | |
- | Next | + | |
- | Finish | + | |
- | 等待=====Active-HDL软件自动运行并显示仿真时序,查看仿真结果。 | + | |
- | 下载程序 | + | |
- | 将编译完成的程序加载到Step FPGA开发板 | + | |
- | 选择Tools →Programmer,选择下载器HW-USBN-2B(FTDI),然后点击OK,进入Programmer界面 | + | |
- | 将Step FPGA开发板、下载器和电脑连接,如图 | + | |
- | 在Programmer界面,点击右侧Detect Cable,下面Cable 显示HW-USBN-2B(FTDI),否则点击Cable,自行选择HW-USBN-2B(FTDI),然后点击下图中Program | + | |
- | 显示PASS,加载完成,观察StepFPGA的LED交替闪烁,成功了。 | + | |
- | 实验案例--时钟分频 | + | |
- | 这是一个基础的模块,可以作为后续编程中的子模块使用 | + | |
- | 本程序实现时钟分频,输出两路不同占空比的分频信号 | + | |
- | 程序源码如下: | + | |
- | 测试源码如下: | + | |
- | 仿真结果如下图所示: | + | |
- | 实际编译分配管脚信息如下: | + | |
- | 最后加载到开发板上,因为占空比较小的信号不易使用LED等效果观察,我们这里分配给了N3(GPIO1)和P2(GPIO2)管脚,我们使用示波器测量开发板标注1和2的管脚,观察波形。 | + | |
+ | http://www.microsemi.com/products/fpga-soc/fpga-and-soc Microsemi FPGA supplier site | ||
- | ===设计流程=== | + | http://www.latticesemi.com/en/Products.aspx - Lattice Semiconductor FPGA supplier site |
- | ===综合=== | + | |
- | ===仿真=== | + | |
- | ===资源报告=== | + | |
- | ====经典案例==== | + | |
- | ===点亮LED灯=== | + | |
- | ===轮流点亮的流水灯=== | + | |
- | ===能够控制亮度的呼吸灯=== | + | |
- | ===旋转编码器控制=== | + | |
- | ==设计要求== | + | |
- | FPGA接收编码器的信号,控制LED颜色的变换,编码器采用HRPG-AD32编码器。 | + | |
- | {{ :rotate_encoder_system.jpg |}} | + | |
- | ==方案设计== | + | |
- | - 增量型旋转编码器有两路相位不同的信号输出,Phase A 和 Phase B,FPGA需要对这两路输入信号进行分析,判断出旋转的动作,输出一个加(up)或减(down)的脉冲信号。 | + | |
- | - 同时,很多旋转编码器都有按键功能,除了旋转以外可以按下,这个按键和旋转是独立的。FPGA内部对按键进行了消抖动,并响应动作产生一个脉冲信号(key_out) | + | |
- | - 改代码加入了现象的验证,输出为6位数据,可接上LED观看现象,旋转和按键会使LED产生流水灯效果 | + | |
- | - 在小脚丫开发板上的现象如下图,两个三色LED会按照如图方式进行切换轮流显示。视频中可以观看到 | + | |
- | {{ :rotate_encoder_state.png |}} | + | |
- | ==硬件设计== | + | |
- | 连接图中,主要有电源和GND,两路信号,按键信号(如果有按键),大地(接机壳,Avago HRPG-AD32#16F上没有按键,多了一个接机壳的地脚,仍然是5个脚) | + | |
- | {{ :rotate_encoder_connection.png |}} | + | |
- | ==软件设计== | + | |
- | FPGA程序结构 | + | |
- | {{ :rotate_encoder_flow.png |}} | + | |
- | ==FPGA资源占用情况== | + | |
- | {{ :rotate_encoder_report.png |}} | + | |
- | 项目视频演示: | + | |
- | ==本设计中用到的主要芯片== | + | http://www.xilinx.com – Xilinx FPGA supplier Site |
- | - LCMXO2-1200:Lattice FPGA,主频133Mhz,PBGA132封装(LCMXO2-1200数据手册) | + | |
- | - Avago Technologies:HRPG AD32 16F,旋转编码器,(Avago HRPG-AD32#16F数据手册) | + | |
- | - 小脚丫开发板:DIP40封装形式,小巧精悍的FPGA开发板,(小脚丫开发板相关信息) | + | |
- | - 小脚丫FPGA开发板【自带编译器】至爱板网商城购买:点击购买 | + | |
- | - 电路相关文件下载:http://www.cirmall.com/circuit/2704 | + | |
- | ===交通灯控制=== | + | http://www.cypress.com/products/programmable-system-chip-psoc - Cypress PSoC supplier site |
- | ===简单的电子琴=== | + | |
- | ===7段数码管=== | + | |
- | ===LED点阵显示屏=== | + | |
- | ===数字钟=== | + | |
- | ===LCD显示控制=== | + | |
- | ===DAC产生直流电压=== | + | |
- | ===DAC生成正弦波=== | + | |
- | ===基于DDS的任意波形产生=== | + | |
- | ===直流电压测量=== | + | |
- | ===简易示波器=== | + | |
- | ===数字频率计=== | + | |
- | ===超声波测距=== | + | |
- | ===通用红外遥控=== | + | |
- | ===MICO8单片机=== | + | |
- | ===MICO32处理器=== | + | |
+ | http://www.quicklogic.com – Quicklogic programmable logic supplier site | ||
+ | http://www.achronix.com/?url=sourcetech411 – Achronix FPGA supplier site | ||
+ | |||
+ | http://www.atmel.com/products/programmable-logic/field-programmable-gate-array/default.aspx - Atmel FPGA supplier site | ||
+ | |||
+ | http://www.e2v-us.com – e2V site, military FPGAs | ||
+ | |||
+ | ##Media | ||
+ | |||
+ | Magazines: [[http://www.edn.com/|EDN]] . [[http://www.electronicdesign.com/|Electronic Design]. [[http://www.eetimes.com/|EETimes]] . [[http://www.circuitcellar.com/|Circuit Cellar Ink]] . [[http://www.popsci.com/|Popular Science]] . [[http://www.ddj.com/|Dr. Dobbs Journal ]]. [[http://www.ieee.org/|IEEE]] | ||
+ | |||
+ | Magazines: [[http://www.embedded.com/|Embedded Systems Design]]. [[http://www.embedded-control-europe.com/magazine|Embedded Control Europe ]]. [[http://www.embedded-computing.com/|Embedded Computing Design]] . [[http://www.mil-embedded.com/|Military Embedded Systems]] | ||
+ | |||
+ | http://www.eetimes.com/programmable-logic-designline.asp - Programmable Logic Designline | ||
+ | |||
+ | http://www.eetimes.com/soc-designline.asp - SoC Designline | ||
+ | |||
+ | http://www.eetimes.com/document.asp?doc_id=1274593 – how to design an FPGA from scratch | ||
+ | |||
+ | http://www.eetimes.com/author.asp?section_id=216&doc_id=1326502 – FPGAs for MCU designers | ||
+ | |||
+ | |||
+ | ##Design Tools | ||
+ | |||
+ | http://www.mathworks.com/solutions/fpga-design/ - FPGA design with Matlab | ||
+ | |||
+ | http://www.mathworks.com/products/?s_tid=gn_ps – MATLAB/Simulink for FPGA Design | ||
+ | |||
+ | http://www.altium.com/files/training/module5fpgadesign.pdf - Altium Tool for FPGA design | ||
+ | |||
+ | http://www.synopsys.com/tools/implementation/fpgaimplementation/Pages/default.aspx - Synposis Tools for FPGA Design (Synplicity) | ||
+ | |||
+ | http://www.mentor.com/products/fpga/ - Mentor tools for FPGA Design | ||
+ | |||
+ | https://www.cadence.com/rl/resources/white_papers/fpga_wp.pdf - Cadence FPGA design guidance article | ||
+ | |||
+ | https://www.aldec.com/en/solutions/fpga_design - Aldec Tools for FPGA design | ||
+ | |||
+ | http://opencores.org/projects - Open Source IP blocks for FPGAs | ||
+ | |||
+ | ##Tutorials | ||
+ | |||
+ | http://www.design-reuse.com/articles/18067/fpga-system-designs-methodology.html - FPGA design guide | ||
+ | |||
+ | https://embeddedmicro.com/tutorials/mojo/ - FPGA tutorial | ||
+ | |||
+ | www.fpga4fun.com/ and http://www.fpga4fun.com/FPGAsoftware1.html - FPGA HDL tools and code | ||
+ | |||
+ | http://www.fpgadeveloper.com – mostly a consultant site. | ||
+ | |||
+ | http://www.arrow.com/bemicro/ - Arrow FPGA kits | ||
+ | |||
+ | https://www.arrow.com/en/design-center - Arrow Design portal | ||
+ | |||
+ | http://www.siliconexpert.com - component search tool | ||
+ | |||
+ | https://www.sparkfun.com/news/1203 - FPGA Design Tutorial | ||
+ | |||
+ | https://electronics.stackexchange.com/questions/41528/fpga-programming-where-to-begin - FPGA FAQ | ||
+ | |||
+ | ##Embedded | ||
+ | |||
+ | http://www.embedded.com – Essential site for all things embedded | ||
+ | |||
+ | http://www.embedded.com/design/prototyping-and-development/4006429/FPGA-programming-step-by-step - Programming FPGAs | ||
+ | |||
+ | http://www.embedded.com/education-training/courses - free classes to learn more | ||
+ | |||
+ | http://www.embedded.com/magazines - 20 years of industry articles on the best of embedded design | ||
+ | |||
+ | http://www.embedded.com/education-training/tech-papers - embedded papers | ||
+ | |||
+ | http://www.ganssle.com – Jack Ganssle, embedded guru “Perfecting the Art of Building Embedded Systems” | ||
+ | |||
+ | http://www.ganssle.com/bkreviews.htm - best books on embedded | ||
+ | |||
+ | http://www.ganssle.com/tools.htm#texteditor – best tools for embedded | ||
+ | |||
+ | http://www.barrgroup.com/Embedded-Systems/Books - more embedded books | ||
+ | |||
+ | http://www.barrgroup.com/Embedded-Systems/How-To - articles on embedded | ||
+ | |||
+ | http://www.koopman.us/embsys/books/ - even more best books | ||
+ | |||
+ | |||
+ | ##Software Tools | ||
+ | |||
+ | http://mbed.org/ - site for online tools to use with ARM processors | ||
+ | |||
+ | http://freerangefactory.org – open embedded projects site | ||
+ | |||
+ | http://www.freertos.org/ - site for FreeRTOS | ||
+ | |||
+ | http://opensource.org – initiative for open source software | ||
+ | |||
+ | https://www.96boards.org – open source hardware and software together | ||
+ | |||
+ | https://www.linaro.org – ARM ecosystem organizer | ||
+ | |||
+ | http://sourceforge.net – repository of open source software | ||
+ | |||
+ | http://www.fsf.org – Free software foundation | ||
+ | |||
+ | http://www.gnu.org - central site for free software, which is not the same as open see http://www.gnu.org/philosophy/open-source-misses-the-point.en.html | ||
+ | |||
+ | https://gcc.gnu.org – the GNU compiler | ||
+ | |||
+ | http://www.gnu.org/software/gdb/ - the GNU Debugger | ||
+ | |||
+ | https://launchpad.net/gcc-arm-embedded - GCC for ARM embedded | ||
+ | |||
+ | https://www.iar.com - IAR dev tool site | ||
+ | |||
+ | http://www.keil.com - Keil dev tool site | ||
+ | |||
+ | http://www.lauterbach.com/frames.html?home.html - Lauterbach dev tool site | ||
+ | |||
+ | http://www.isystem.com/products/software/winidea - WinIdea IDE site | ||
+ | |||
+ | https://www.eclipse.org - Eclipse IDE site | ||
+ | |||
+ | http://bpmmicro.com/programmers/ BPMicro programmer site | ||
+ | |||
+ | http://www.macraigor.com - MacGreigor programmer site | ||
+ | |||
+ | http://micrium.com - Micrium OS site | ||
+ | |||
+ | http://www.qnx.com - QNX OS site | ||
+ | |||
+ | http://www.windriver.com/products/vxworks/ - VxWorks OS Site | ||
+ | |||
+ | http://www.linux.com – Main Linux OS Site | ||
+ | |||
+ | https://www.yoctoproject.org - Yocto embedded linux package | ||
+ | |||
+ | http://www.angstrom-distribution.org – Angstrom embedded linux distribution | ||
+ | |||
+ | http://elinux.org/Main_Page - Embedded Linux site | ||
+ | |||
+ | http://www.timesys.com – commercial embedded Linux | ||
+ | |||
+ | http://www.uclinux.org – Linux for processors without an MMU | ||
+ | |||
+ | http://www.openembedded.org/wiki/Main_Page - build framework for embedded linux | ||
+ | |||
+ | [[http://cslibrary.stanford.edu/|Essential C (Tutorial/Refresher), Programming Information]] | ||
+ | |||
+ | [[http://publications.gbdirect.co.uk/c_book/|The C Book (free on-line book)]] . [[http://ecee.colorado.edu/~mcclurel/the_c_book.pdf|PDF Version]] | ||