一個典型的使用ISE設計的數字系統一般包含以下步驟:
工程的建立
模塊設計
設計綜合和查看綜合結果
工程設計仿真
分頻器的設計
用戶約束的添加和設計是實現
佈局佈線結果查看
設計下載到FPGA芯片
PROM文件的生成和下載到PROM中
源文件類型
如上圖,在添加新的源文件時候,會根據我們目的的不同選擇文件類型。這些文件類型從上往下依次是:
塊存儲器映像文件
在線邏輯分析儀Chipscope定義和連接文件
實現約束文件
IP生成嚮導
存儲器文件
原理圖文件
用戶文檔文件
Verilog模塊模板文件
Verilog測試平臺模板文件
VHDL模塊模板文件
VHDL庫模板文件
VHDL包模板文件
VHDL測試平臺模板文件
片上系統設計嚮導
three-bit-counter
新建一個VHDL模塊模板文件之後,根據我們要設計的3位計數器設計邏輯:
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
-- Uncomment the following library declaration if using
-- arithmetic functions with Signed or Unsigned values
--use IEEE.NUMERIC_STD.ALL;
-- Uncomment the following library declaration if instantiating
-- any Xilinx primitives in this code.
--library UNISIM;
--use UNISIM.VComponents.all;
entity top is
//此處添加端口聲明語句
port(
clk : in std_logic;
rst : in std_logic;
counter : out std_logic_vector(2 downto 0)
);
end top;
architecture Behavioral of top is
//內部信號量聲明語句
signal counter_tmp : std_logic_vector(2 downto 0);
begin
//添加信號連接
counter<=counter_tmp;
process(clk,rst)
//3bit 8進制計數器模塊
begin
if(rst='0')then
counter_tmp<="000";
elsif rising_edge(clk)then
counter_tmp<=counter_tmp+1;
end if;
end process;
end Behavioral;
設計的綜合
ISE綜合工具在對設計的綜合過程中,主要執行以下三個步驟:
語法檢查過程,檢查設計文件語法是否有錯誤
編譯過程,翻譯和優化HDL代碼,將其轉化爲綜合工具可以識別的元件序列。
映射過程,將這些可以識別的元件序列轉化爲可識別的目標技術的基本原件。
在ISEden主頁面的處理子串口的Synthesis工具可以完成:
查看RTL原理圖
查看技術原理圖
檢查語法
產生綜合後仿真模型
進行行爲仿真
在ISE主頁面的Design區域選中Simulation選項.選中已經添加的邏輯模塊右鍵添加測試文件.
LIBRARY ieee;
USE ieee.std_logic_1164.ALL;
-- Uncomment the following library declaration if using
-- arithmetic functions with Signed or Unsigned values
--USE ieee.numeric_std.ALL;
ENTITY test IS
END test;
ARCHITECTURE behavior OF test IS
-- Component Declaration for the Unit Under Test (UUT)
COMPONENT top
PORT(
clk : IN std_logic;
rst : IN std_logic;
counter : OUT std_logic_vector(2 downto 0)
);
END COMPONENT;
--Inputs
signal clk : std_logic := '0';
signal rst : std_logic := '0';
--Outputs
signal counter : std_logic_vector(2 downto 0);
-- Clock period definitions
constant clk_period : time := 10 ns;
BEGIN
-- Instantiate the Unit Under Test (UUT)
uut: top PORT MAP (
clk => clk,
rst => rst,
counter => counter
);
//添加rst信號
process
begin
rst<='0';
wait for 100 ns;
rst<='1';
wait for 1 ms;
end process;
//生成clk信號
process
begin
clk<='0';
wait for 20 ns;
clk<='1';
wait for 20 ns;
end process;
END;
完成之後點擊子任務區域的SImulate Behavioral Model,手動Zoom Out測試。
爲了在硬件上看到燈的變化所反映的計數器工作狀態,需要在top.vhd文件添加分頻時鐘代碼。