QUARTUS+II+使用教程

  • 格式:doc
  • 大小:57.00 KB
  • 文档页数:16

第2 章QUARTUS II 使用教程.................................................................................. ............ 2 2.1 Quartus II 的安装.................................................................................. ............................. 2 2.1.1 安装Quartus II................................................................................... ....................... 2 2.1.2 安装License........................................................................... ................................... 2 2.2 FIFO 设计实例.................................................................................. ................................ 2 2.2.1 新建工程.................................................................................. ................................. 3 2.2.2 创建设计文件.................................................................................. ......................... 3 2.2.3 编译过程.................................................................................. ................................. 6 2.2.4 编译报告与延时分析.................................................................................. ............. 6 2.2.5 运行仿真.................................................................................. ................................. 7 2.3 设计流程.......................................................................................................................... 10 2.3.1 设计输入.................................................................................. ............................... 10 2.3.2 编译.................................................................................. ....................................... 17 2.3.3 延时分析.................................................................................. ............................... 19 2.3.4 仿真.................................................................................. ....................................... 20 2.4 系统级设计.................................................................................. .................................... 20 2.4.1 SOPC 设计.................................................................................. ............................. 20 2.4.1 DSP 设计.................................................................................. ................................ 21 2.5 设计实例.................................................................................. ........................................ 22 2.5.1 UART 控制器.................................................................................. ......................... 22 2.5.2 I 2 C 总线控制器.................................................................................. ...................... 24 2.5.3 USB2.0 控制器........................................................................................................ 26 2 第2 章QUARTUS II 使用教程本章以Quartus II 4.1 版本为例。

所选实例使用的CPLD/FPGA 器件为Cyclone 系列CP1C20F400C7。

2.1 Quartus II 的安装Quartus II 的安装需要较高的系统配置,建议256M以上内存,奔腾II 以上的CPU;配置过低将使得编译过程十分缓慢。

2.1.1 安装Quartus II 安装QuartusII 之前建议浏览一下安装文件夹下的帮助文件及注意事项。

运行选择Install Quartus II Software,以后全部结束 2.1.2 安装License 第一次运行Quartus II 会要求授权码验证,选择菜单Tools/License Setup,弹出图2.1 所示对话框,点击“…”按钮选择License.dat 文件即可。

如果不安装License,也可以试用,但不能使用仿真等功能。

2.2 FIFO 设计实例本节以FIFO (First-In-First-Out 先进先出)缓冲存储器为例,介绍一下Quarstus II 的软件设计基本流程。

图2.2 新建项目3 2.2.1 新建工程选择菜单File\ New Project Wizard,弹出新建项目向导对话框(如图2.2)。

对话框中第一项是项目保存的位置(路径),第二项是项目名称,第三项是项目顶层实体(entity)名。

建议工程名称和顶层实体名一样,需要注意的是,实体名必须和设计中实际的顶层实体名称一致。

本例中,项目所有的文件都保存到E:/qdesign/Fifo 文件夹下。

点击Next,询问该目录不存在是否要创建,选择是。

如图2.3。

图2.3 创建工作目录紧接着的两页不用设置,在第四页,选择所用的PLD(FPGA)系列,这里选Cyclone,如图 2.4。

在图 2.5 中,选择器件为CP1C20F400C7。

点击Next,出现新建项目的设置信息,检查无误后点击Finish 按钮结束。

2.2.2 创建设计文件点击工具栏中“New”按钮(或者选择菜单File\New),选择VHDL File。

如图2.6。

图2.4 器件系列输入Fifo 的VHDL 代码。

如下:-- a first-in first out memory, uses a synchronising clock -- generics allow fifos of different sizes to be instantiated library IEEE; use IEEE.Std_logic_1164.all; entity FIFO is generic(m, n : Positive := 8); --m is fifo depth, n is fifo width 图2.5 器件名称 4 port(RESET, WRREQ, RDREQ, CLOCK : in Std_logic; DATAIN : in Std_logic_vector((n-1) downto 0); DATAOUT : out Std_logic_vector((n-1) downto 0); FULL, EMPTY : inout Std_logic); end FIFO; architecture V2 of FIFO is typeFifo_array is array(0 to (m-1)) of Bit_vector((n-1) downto 0); signal Fifo_memory : Fifo_array; signal Wraddr, Rdaddr, Offset : Natural range 0 to (m-1); signal Rdpulse, Wrpulse, Q1, Q2, Q3, Q4 : Std_logic; signal Databuffer :Bit_vector((n-1) downto 0); 图2.6 设计输入文件begin--pulse synchronisers for WRREQ and RDREQ --modified for Synplify to a process sync_ffs : process begin wait untilrising_edge(CLOCK); Q1 <= WRREQ; Q2 <= Q1; Q3 <= RDREQ; Q4 <= Q3; end process; --concurrent logic to generate pulses Wrpulse <= Q2 and not(Q1); Rdpulse <= Q4 and not(Q3); Fifo_read : process begin 5 wait until rising_edge(CLOCK); if RESET = '1' then Rdaddr <= 0; Databuffer <= (others => '0'); elsif (Rdpulse = '1' and EMPTY = '0') then Databuffer <= Fifo_memory(Rdaddr); Rdaddr <= (Rdaddr + 1) mod m; end if; end process; Fifo_write : process begin wait until rising_edge(CLOCK); if RESET = '1' then Wraddr <= 0; elsif (Wrpulse = '1' and FULL = '0') then Fifo_memory(Wraddr) <=To_Bitvector(DATAIN); Wraddr <= (Wraddr + 1) mod m; end if; end process; Offset <= (Wraddr - Rdaddr) when (Wraddr > Rdaddr) else (m - (Rdaddr - Wraddr)) when (Rdaddr > Wraddr) else 0; EMPTY <= '1' when (Offset = 0) else '0'; FULL <= '1' when (Offset = (m-1)) else '0'; DATAOUT <= To_Stdlogicvector(Databuffer) when RDREQ = '0' else (others => 'Z'); end V2; 对上述程序做以下几点说明:信号用于复位,仿真或运行开始时应使RESET 保持至少一个时钟周期高电平(使CLOCK 上升沿可以检测到RESET 信号)。