第一次接触新东西的时候,难免会磕磕碰碰,不过遇到问题不要着急,慢慢来。原因总归是我们自己引起的,一步步找到问题的根源,然后彻底解决它,避免下次再犯。
好了,进入正题
开发环境:Quartus II 15.0.0.145 64Bit
FPGA芯片:EP4CE6E22C8N
第一步:创建工程
打开Quartus II软件,选择 File->New Project Wizard,如下图:
直接Next下一步
下面选择创建一个空的工程
工程创建完毕,接下来就是添加代码文件,在菜单栏选择 File->New
这里我选择的是Verilog HDL语言,文件创建完成后,向文件中添加代码,并保存。注意:保存的时候文件名必须和工程名一致。我们都知道在单片机中程序入口函数是main函数,但是Quartus II不一样,在Quartus II的工程中必须要有一个顶层设计文件,并且顶层设计文件中的模块名必须和工程名一致,顶层设计文件名也必须和工程名一致,而这个顶层设计文件中和工程同名的模块就是程序入口。
问:OK,至此可以编译了吗?
答:No!No!No!还没结束。
在单片机中要控制LED就必须要指定IO,并初始化IO,在这里IO不需要我们去初始化,我们只要指定就好了。
使用快捷键 Ctrl + Shift + N 打开引脚分配窗口,或者菜单栏 Assignments -> Pin Planner 打开引脚分配窗口。
好了,代码写完,IO分配完是不是可以编译了呢,如果此时编译的话程序是可以运行的,但是会报很多警告。
我写此博客的原因就是要记录以往所掉过的坑,避免以后再被同样的问题困扰。所以在此处编译,然后慢慢去解决问题。
编译结果:Info (293000): Quartus II Full Compilation was successful. 0 errors, 6 warnings
迫于程序猿的强迫症,接下来我们一个个警告去解决它。
第一个警告:Warning (15714): Some pins have incomplete I/O assignments. Refer to the I/O Assignment Warnings report for details
这个警告的意思是IO参数配置不完整,解决如下:
OK,接下来再编译。发现少了一个警告,还有五个警告。
剩余警告信息如下:
1、Critical Warning (332012): Synopsys Design Constraints File file not found: ‘led.sdc‘. A Synopsys Design Constraints File is required by the TimeQuest Timing Analyzer to get proper timing constraints. Without it, the Compiler will not properly optimize the design.
2、Critical Warning (332012): Synopsys Design Constraints File file not found: ‘led.sdc‘. A Synopsys Design Constraints File is required by the TimeQuest Timing Analyzer to get proper timing constraints. Without it, the Compiler will not properly optimize the design.
3、Critical Warning (332148): Timing requirements not met
4、Critical Warning (332148): Timing requirements not met
5、Critical Warning (332148): Timing requirements not met
以上警告信息其实是一个时钟约束的问题导致,只要解决了时钟约束问题,那么警告就没有了。时钟约束问题解决如下:
然后关闭窗口,再编译一次。
编译后发现结果与理想中的不一样,警告信息如下:
1、Critical Warning (332168): The following clock transfers have no clock uncertainty assignment. For more accurate results, apply clock uncertainty assignments or use the derive_clock_uncertainty command.
2、 Critical Warning (332169): From led (Rise) to led (Rise) (setup and hold)
警告提示:时钟传输没有时钟不确定性分配。要获得更精确的结果,请应用时钟不确定性分配或使用derive_clock_uncertainty命令。
该警告解决如下:
打开我们刚保存的 led.sdc 文件,该文件就在工程目录下,然后添加两行信息,并将修改点该为自己的 Clock Name。
最后保存文件再编译
最后烧写代码至开发板运行测试。然后下载发现一切正常,代码实际运行效果也是正常的。
至此第一个 FPGA 工程开发完毕 O(∩_∩)O~~
原文:https://www.cnblogs.com/icode-wzc/p/11943974.html