?? hpi_epp.vhd
字號:
---HPI與EPP接口轉換模塊的設計
---本設計以EPP的時序為基礎,要求以host能夠通過HPI接口可訪問DSP的存儲空間
--程序名稱 :HPI_EPP
--編譯環境 :ISE5.2
--程序版本 :1.0
--主體設計者 : 吳慶洪
--程序編制調試:李思偉
--設計時間 : 2005.4
-------------------------------------------------------------------------------
--entity:count16
--founction:產生16進制的進位脈沖,作為HPI接口控制信號。
--signal:nAstrb,nDstrb,byteflage,HHWIL,HCNTL0,HCNTL1;
--實體count16作為epp_interface的子器件。
--time: 2005.4
--chang time: 2005.4.1
--------------------------------------------------------------------------------
library IEEE;
use IEEE.std_logic_1164.all;
use IEEE.std_logic_unsigned.all;
entity count16 is
port(
nAstrb: in STD_LOGIC; --地址選通信號,作為計數器的清零信號
nDstrb: in STD_LOGIC; --數據選通信號,作為計數器的計數脈沖
Q0: out STD_LOGIC;
Q1: out STD_LOGIC;
Q2: out STD_LOGIC;
Q3: out STD_LOGIC
);
end count16;
architecture count16_arch of count16 is
signal cnt :std_logic_vector(3 downto 0);
signal hostdata:std_logic_vector(15 downto 0);
begin
COUNT:process(nAstrb,nDstrb)
begin
if(nAstrb='0') then
cnt<="0000";
elsif(nDstrb'event and nDstrb='0')then
if(cnt="1011")then
cnt<="1000";
else
cnt<=cnt+'1';
end if;
Q1<=cnt(1);
Q2<=cnt(2);
Q3<=cnt(3);
Q0<=cnt(0);--after 100ns; --用于鎖存從host輸出的八位數據,延時使Q0的邊沿在數據有效時發生
end if;
end process COUNT;
-- <<enter your statements here>>
end count16_arch;
-------------------------------------------------------------------------------------------------------
--entity:latch
--founction:HPI口寫DSP控制寄存器時,nWrite='0'時,用于鎖存低8位的PD信號,在Q0的上升沿送給HD(7 DOWNTO 0)。
--signal:PD(7downto 0),HD(7 downto 0),Q0,nWrite;
--實體latch作為epp_interface的子器件。
--time:2005.4
-------------------------------------------------------------------------------------------------------
library IEEE;
use IEEE.std_logic_1164.all;
entity latch is
port(
d: in STD_LOGIC_VECTOR (7 downto 0);
q: out STD_LOGIC_VECTOR (15 downto 0);
clk: in STD_LOGIC;
Q0: in STD_LOGIC;
oe: in STD_LOGIC
);
end latch;
architecture latch_arch of latch is
signal qint:std_logic_vector(7 downto 0);
begin
process(clk,d,oe)
begin
if(oe='0')then
if(clk'event and clk='0')then --clk的上升沿鎖存低八位數據
qint<=d;
end if;
else
qint<="ZZZZZZZZ";
end if;
if(oe='0'and Q0='1')then
q(7 downto 0)<=qint;
elsif(oe='0'and Q0='0')then
q(15 downto 8)<=qint;
else
q<="ZZZZZZZZZZZZZZZZ";
end if;
end process;
end latch_arch;
---------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------
library IEEE;
use IEEE.std_logic_1164.all;
entity read is
port(
PD: out STD_LOGIC_VECTOR (7 downto 0);
HD: in STD_LOGIC_VECTOR (15 downto 0);
sclk: in STD_LOGIC;
Q0: in std_logic;
nWrite: in STD_LOGIC;
nDstrb: in std_logic
);
end read;
architecture read_arch of read is
signal bufferdata:std_logic_vector(15 downto 0);
begin
process(nWrite,HD,nDstrb,Q0,sclk)
begin
if(nWrite='1')then
if(sclk'event and sclk='1')then --CLK的上升沿鎖存HPI口數據
bufferdata<=HD;
end if;
if((Q0 and (not nDstrb))='1')then
PD<=bufferdata(7 downto 0);
elsif((Q0 or nDstrb)='0')then
PD<=bufferdata(15 downto 8);
else
PD<="ZZZZZZZZ";
end if;
end if;
end process;
end read_arch;
---------------------------------------------------------------------------------------------------
--entity: HPI_EPP
--founction:HPI與EPP接口轉換的主控函數。
--signal:PD(7downto 0),HD(7 downto 0),nWrite,nAstrb,nDstrb,byteflage,HHWIL,HCNTL0,HCNTL1,HCS;
--time:2005.4
---------------------------------------------------------------------------------------------------
library IEEE;
use IEEE.std_logic_1164.all;
use IEEE.std_logic_unsigned.all;
entity HPI_EPP is
port (
nWrite: in STD_LOGIC; --EPP讀寫控制信號,‘0’--寫;‘1’--讀
nAstrb: in STD_LOGIC; --EPP地址選通信號,作為計數器的清零信號
nDstrb: in STD_LOGIC; --EPP的數據選通信號
byteflage: out STD_LOGIC; --數據讀寫高低字節的標志‘1’低,‘0’高
HHWIL: out STD_LOGIC; --HPI讀寫高低半字的控制信號,‘0’低,‘1’高
HCNTL0: out STD_LOGIC; --訪問HPI內部寄存器HPIC、HPIA、HPID的控制信號
HCNTL1: out STD_LOGIC; --以及訪問HPID的方式
HPI_RW: out STD_LOGIC; --HPI讀寫控制信號
PD: inout STD_LOGIC_VECTOR(7 downto 0); --EPP數據地址總線
HD: inout STD_LOGIC_VECTOR(15 downto 0);--HPI數據總線
HCS: out STD_LOGIC --HPI選通信號,下降沿鎖存HPI的控制信號
);
end HPI_EPP;
architecture HPI_EPP_arch of HPI_EPP is
component count16 is --元件聲明
port(
nAstrb: in STD_LOGIC;
nDstrb: in STD_LOGIC;
Q0: out STD_LOGIC;
Q1: out STD_LOGIC;
Q2: out STD_LOGIC;
Q3: out STD_LOGIC
);
end component;
component latch is
port(
d: in STD_LOGIC_VECTOR (7 downto 0);
q: out STD_LOGIC_VECTOR (15 downto 0);
clk: in STD_LOGIC;
Q0: in std_logic;
oe: in STD_LOGIC
);
end component;
component read is
port(
PD: out STD_LOGIC_VECTOR (7 downto 0);
HD: in STD_LOGIC_VECTOR (15 downto 0);
sclk: in STD_LOGIC;
Q0: in std_logic;
nWrite: in STD_LOGIC;
nDstrb: in std_logic
);
end component;
signal Q0,Q1,Q2,Q3:STD_LOGIC;
signal rwselect:std_logic;
signal portdata:std_logic_vector(7 downto 0);
signal sclk:std_logic;
-- signal bufferdata:std_logic_vector(15 downto 0);
begin
byteflage<=Q0;
HPI_RW<=nWrite;
HHWIL<=Q1;
HCNTL0<=Q2;
HCNTL1<=Q3;
HCS<=(not Q0) or nDstrb;
sclk<=nDstrb and Q0 after 200ns;
process(nAstrb)
begin
if(nAstrb='0')then
HD<="ZZZZZZZZZZZZZZZZ";
end if;
end process;
CNT1:COUNT16 PORT MAP(nAstrb,nDstrb,Q0,Q1,Q2,Q3);
Write_data:latch port map(PD,HD(15 downto 0),nDstrb,Q0,nWrite);
read_data:read port map(PD,HD,sclk,Q0,nWrite,nDstrb);
-- process(nWrite,HD,nDstrb,Q0,sclk)
-- begin
-- if(nWrite='1')then
-- if(sclk'event and sclk='1')then --CLK的上升沿鎖存HPI口數據
-- bufferdata<=HD;
-- end if;
-- if((Q0 and (not nDstrb))='1')then
-- PD<=bufferdata(7 downto 0);
-- elsif((Q0 or nDstrb)='0')then
-- PD<=bufferdata(15 downto 8);
-- else
-- PD<="ZZZZZZZZ";
-- end if;
-- end if;
-- end process;
end HPI_EPP_arch;
------------------------------------------------------------------------------------------
---程序結束!
---程序結束日期:2005.4.6
---程序調試日期:2005.4.11
---程序基本功能實現,能夠通過HPI實現對DSP存儲空間的訪問-讀寫。
--------------------------------------------------------------------------------------------
---程序功能完全實現日期:2005.4.21
---程序的穩定性有待進一步的驗證,其他功能要求在上位機由C++Builder實現。
---程序的完美性要求對VHDL語言和CPLD設計有更深的理解,設計水平要求再上新的臺階!!
---程序的完成有賴于吳老師總的指導思想!
---程序補充時間
--------------------------------------------------------------------------------------------
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -