?? top_1.vhdl
字號:
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
-- Uncomment the following lines to use the declarations that are
-- provided for instantiating Xilinx primitive components.
--library UNISIM;
--use UNISIM.VComponents.all;
entity top is
port( clk : in std_logic;
reset: in std_logic;
slwr: buffer std_logic;
pktend: out std_logic;
fifoaddr: out std_logic_vector(1 downto 0);
fifodata: out std_logic_vector(7 downto 0);
full_flag : in std_logic; -- FLAGB pin
led: out std_logic;
addr_SRAM: out std_logic_vector(15 downto 0);
data_SRAM: inout std_logic_vector(7 downto 0);
WE_SRAM: out std_logic;
OE_SRAM: out std_logic;
CE_SRAM: out std_logic;
LB_SRAM: out std_logic;
UB_SRAM: out std_logic
) ;
end top;
architecture Behavioral of top is
signal count : std_logic_vector(10 downto 0);
signal inclk: std_logic;
signal flag: std_logic;
begin
process(clk)
begin
if clk'event and clk='1' then
count<=count+'1';
end if;
end process;
fifoaddr<="10"; -- EP6
inclk<=count(10);
pktend<='1';
flag<=full_flag; --and start;
process(inclk, reset)
variable temp_addr_SRAM: std_logic_vector(15 downto 0); -- 地址變量
variable data_out: std_logic_vector(7 downto 0); -- 數據變量
variable state: integer range 0 to 2; -- 狀態變量
variable is_end: std_logic; -- 讀數據結束標志
begin
if(inclk'event and inclk='0') then
if reset='1' then -- 復位
OE_SRAM<='0'; -- 輸出使能
CE_SRAM<='0'; -- 芯片使能
WE_SRAM<='1'; -- 寫禁能
LB_SRAM<='1'; -- 低位禁能
UB_SRAM<='1'; -- 高位禁能
is_end:='0'; -- 寫結束標芯初始化
temp_addr_SRAM:=(others=>'0'); -- 地址初始化
state:=0; -- 狀態變量初始化
led<='1'; -- LED 暗
slwr<='1';
else
if is_end='0' then -- 讀數據沒有結束
case state is
when 0 =>
slwr<='1'; -- deassert SLWR, 地址加1
LB_SRAM<='0'; -- 低位使能
data_SRAM<=(others=>'Z'); -- 給數據線上送高阻
addr_SRAM<=temp_addr_SRAM; -- 送地址
state:=1; -- 轉到狀態1
when 1 =>
data_out:=data_SRAM; -- 送數據
temp_addr_SRAM:= temp_addr_SRAM+1; -- 地址變量加1
state:=2; -- 轉到狀態2
if temp_addr_SRAM="0000000000000000" then -- 已讀完
is_end:='1'; -- 寫結束標志置位
end if;
when 2 =>
if flag='1' then -- check full flag
fifodata<=data_out; -- not full, drive data to bus
slwr<='0'; -- assert SLWR
state:=0;
led<='0'; -- 傳數時,led亮
else
state:=2;
led<='1';
end if;
end case;
end if;
end if;
end if;
end process;
end Behavioral;
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -