?? 35_bus_test.vhd
字號(hào):
library ieee;
use ieee.std_logic_1164.all;
use work.bit_pack.all;
use std.textio.all;
entity tester is
port ( address,w_data:out bit_vector(31 downto 0);
r_data:in bit_vector(31 downto 0):=(others =>'0');
clk,wr,br:out bit;
std,done:in bit:='0');
end tester;
architecture test1 of tester is
--設(shè)定時(shí)鐘周期為20 ns
constant half_period: time:=10 ns;
signal testclk :bit :='1';
begin
testclk<=not testclk after half_period;
clk<=testclk after 1 ns;
read_test_file :process(testclk)
--已讀的方式打開(kāi)test類(lèi)型文件"test2.dat"
--文件名為test_file
file test_file:text is in "test2.dat";
variable buff:line;
variable dataint,addrint:integer;
variable new_wr,new_br :bit;
begin
--當(dāng)總線處理完成且信號(hào)穩(wěn)定后
if testclk='1' and done='1' then
if std='1' then
assert dataint =vec2int(r_data)
report "read data doesn't match data file!"
severity error;
end if;
if not endfile(test_file) then
readline(test_file,buff);
read(buff,new_br);
read(buff,new_wr);
read(buff,addrint);
read(buff,dataint);
br<=new_br;
wr<=new_wr;
address<=int2vec(addrint,32);
if new_wr='1' and new_br='1' then
--寫(xiě)操作
w_data<=int2vec(dataint,32);
else
--讀操作
w_data<=(others=>'0');
end if;
end if;
end if;
end process read_test_file;
end test1;
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -