http://wenku.baidu.com/link?url=SsRPUVQAOKDR8yWfDhQlceCwfZQkI-KQMLFKTDGAh3KAPr2NwEgvj0d_EZjdnsB99Upp6hLzqWdxqHGGNZQcRJQCQpVBF8H8qkACAJY7A4_
這篇文章里說Function和Package中不能有時序電路,只能是組合邏輯電路。
任務:把常用的邏輯編譯成庫(不知道這個要干啥)
不理解庫是干嘛用的
把當前理解做下筆記
1 這個是頂層模塊
library ieee;
use ieee.std_logic_1164.all;
library work;
use work.nd2_pkg.all;
entity lib_test is
port(a,b:in std_logic;
c,d:out std_logic);
end lib_test;
architecture behv of lib_test is
begin
u1:entity work.h_adder port map(a,b,d);//component模塊
c <= max(a,b);//package中包含的function
end behv;
2 h_adder模塊
一個單獨的模塊,頂層通過u1:entity work.h_adder port map(a,b,d);這句話調用,編譯是h_adder.vhd這個文件要在工程目錄下並且編譯前要add source到ISE里;
library ieee;
use ieee.std_logic_1164.all;
entity h_adder is
port(a,b:in std_logic;
c:out std_logic);
end entity h_adder;
architecture f1 of h_adder is
begin
c <= a xor b;
end architecture f1;
3 package文件.好像package只能包含function之類的組合邏輯,並且
頂層加入
library work;
use work.nd2_pkg.all;
后能自動找到該文件,不用加add source在工程里。
library ieee;
use ieee.std_logic_1164.all;
package nd2_pkg is
function max(a,b:in std_logic) return std_logic;
end nd2_pkg;
package body nd2_pkg is
function max(a,b:in std_logic) return std_logic is
begin
if a > b then
return a;
else
return b;
end if;
end function max;
end nd2_pkg;