|
楼主 |
发表于 2007-10-17 09:09:39
|
显示全部楼层
entity FIFOcnt is
port (
ClkIn : in Std_Logic;
Reset : in Std_Logic;
Enable : in Std_Logic;
CntOut : out Std_Logic_Vector(3 downto 0));--4为格类码
end FIFOcnt;
-----------------------------------------------------------------------
-- Architecture for 16-bit GRAY counter - generates the internal clock
-----------------------------------------------------------------------
architecture Behaviour of FIFOcnt is
---------------------------------------------------------------------
-- Signals
---------------------------------------------------------------------
type CNT_Array is array(0 to 15) of Std_Logic_Vector(3 downto 0);
constant Cnt_Code : CNT_Array := ("0000","0010","0011","0001", --格雷码初始化
"1000","1010","1011","1001",
"1100","1110","1111","1101",
"0100","0110","0111","0101");
signal binidx : Unsigned(3 downto 0);
begin --======================== Architecture =======================--
process(ClkIn,Reset,Enable) --地址指针计数
begin
if Reset = '1' then
binidx <= (others => '0');
elsif ClkIn'Event and ClkIn = '1' then
if Enable = '1' then
binidx <= binidx + "1";
end if;
end if;
end process;
CntOut <= Cnt_Code(ToInteger(binidx)); --调用函数转换数据其中Cnt_Code(格雷码)作为地址
end Behaviour; --================ End of architecture ================--
这个是地址的计算,他用的是格雷码,但是Cnt_Code 的地址的设置就不明白了???? |
|