📄 proto_chk.tb
字号:
--------------------------------------------------------------------------------
--
-- File : proto_chk.tb
-- Last Modification: May/13/2002
--
-- Created In SpDE Version: SpDE 9.3
-- Author : Richard Yuan, QuickLogic Corporation
-- Copyright (C) 2001, Licensed customers of QuickLogic may copy and modify
-- this file for use in designing with QuickLogic devices only.
--
-- Description :
-- PCI protocol checker simulation model.
--
-- Hierarchy:
-- The proto_chk entity is to be used in pci5(3/4)32_208.tb.
--
-- History:
-- Date Author Version
-- 06/26/01 Richard Yuan 1.0
-- - Header added to conform to coding standard.
-- May/13/2002 Bernhard Andretzky 1.1
-- - modified for Ql5632
--
--------------------------------------------------------------------------------
LIBRARY ieee;
USE ieee.std_logic_1164.all;
USE ieee.numeric_std.all;
LIBRARY std;
USE std.textio.all;
ENTITY proto_chk IS
PORT (
CLK : in std_logic;
RSTN : in std_logic;
FRAMEN : in std_logic;
IRDYN : in std_logic;
TRDYN : in std_logic;
DEVSELN : in std_logic;
STOPN : in std_logic;
SERRN : in std_logic;
PERRN : in std_logic;
Clear_SERR : in std_logic;
SERRN_Detected : out std_logic;
Clear_PERR : in std_logic;
PERRN_Detected : out std_logic;
Set_Master_Abort: in std_logic;
Master_Abort : out std_logic;
Clear_Disconnect : in std_logic;
Disconnect_Detected : out std_logic;
Status : in boolean
);
END proto_chk;
ARCHITECTURE test_bench OF proto_chk IS
TYPE INTMEM is ARRAY (0 to 4095) of std_logic_vector(15 downto 0);
SIGNAL proto_mem : INTMEM;
SIGNAL transfers : integer;
SIGNAL disconnects : integer;
SIGNAL retries : integer;
SIGNAL target_aborts : integer;
BEGIN
READ_BUSCHK : PROCESS
FILE buschk_vhdl: text open read_mode is "bus_chk.mem";
VARIABLE buschk_line : line;
VARIABLE i,j : integer;
variable buschk_string : string (1 to 4);
variable nibble : std_logic_vector(3 downto 0);
variable buschk_vec : std_logic_vector(15 downto 0);
BEGIN
i := 0;
while not endfile(buschk_vhdl) loop
readline (buschk_vhdl, buschk_line);
read (buschk_line, buschk_string);
for j in 1 to 4 loop
case buschk_string(j) is
when '0' => nibble := "0000";
when '1' => nibble := "0001";
when '2' => nibble := "0010";
when '3' => nibble := "0011";
when '4' => nibble := "0100";
when '5' => nibble := "0101";
when '6' => nibble := "0110";
when '7' => nibble := "0111";
when '8' => nibble := "1000";
when '9' => nibble := "1001";
when 'A' | 'a' => nibble := "1010";
when 'B' | 'b' => nibble := "1011";
when 'C' | 'c' => nibble := "1100";
when 'D' | 'd' => nibble := "1101";
when 'E' | 'e' => nibble := "1110";
when 'F' | 'f' => nibble := "1111";
when others => nibble := "0000";
end case;
buschk_vec(((j-1)*4)+3 downto ((j-1)*4)) := nibble;
end loop;
proto_mem(i) <= buschk_vec;
i := i + 1;
end loop;
WAIT;
END PROCESS READ_BUSCHK;
proto_checker : PROCESS (CLK, RSTN)
VARIABLE lst_st : std_logic_vector (5 downto 0);
VARIABLE cur_st : std_logic_vector (5 downto 0);
VARIABLE st_index : integer;
variable tmp_index : std_logic_vector(11 downto 0);
VARIABLE eccode : std_logic_vector (15 downto 0);
VARIABLE errcount : integer;
variable outline : line;
CONSTANT ERRIDLE : integer := 8;
CONSTANT ERRFRAME : integer := 9;
CONSTANT ERRIRDY : integer := 10;
CONSTANT ERRTRDY : integer := 11;
CONSTANT ERRDEVSEL : integer := 12;
CONSTANT ERRSTOP : integer := 13;
BEGIN
IF (RSTN = '0') THEN
lst_st := "000000";
cur_st := "000000";
errcount := 0;
SERRN_Detected <= '0';
PERRN_Detected <= '0';
ELSIF (RISING_EDGE(CLK)) THEN
lst_st := cur_st;
cur_st := ("0" & NOT(FRAMEN) & NOT(TRDYN) & NOT(IRDYN) & NOT(DEVSELN) & NOT(STOPN));
tmp_index := (lst_st & cur_st);
st_index := to_integer(unsigned(tmp_index));
eccode := proto_mem(st_index);
if eccode(ERRIDLE) = '1' then
errcount := errcount + 1;
--report "IDLE Protocol Error. Protocol Error Count: " & integer'image(errcount);
write(outline, string'("["));
write(outline, now);
write(outline, string'("] PROTO_CHK: "));
write(outline, string'("IDLE Protocol Error. Protocol Error Count: "));
write(outline, integer'image(errcount));
writeline(output, outline);
elsif eccode(ERRFRAME) = '1' then
errcount := errcount + 1;
--report "IDLE Protocol Error. Protocol Error Count: " & integer'image(errcount);
write(outline, string'("["));
write(outline, now);
write(outline, string'("] PROTO_CHK: "));
write(outline, string'("IDLE Protocol Error. Protocol Error Count: "));
write(outline, integer'image(errcount));
writeline(output, outline);
elsif eccode(ERRIRDY) = '1' then
errcount := errcount + 1;
--report "IDLE Protocol Error. Protocol Error Count: " & integer'image(errcount);
write(outline, string'("["));
write(outline, now);
write(outline, string'("] PROTO_CHK: "));
write(outline, string'("IDLE Protocol Error. Protocol Error Count: "));
write(outline, integer'image(errcount));
writeline(output, outline);
elsif eccode(ERRTRDY) = '1' then
errcount := errcount + 1;
--report "IDLE Protocol Error. Protocol Error Count: " & integer'image(errcount);
write(outline, string'("["));
write(outline, now);
write(outline, string'("] PROTO_CHK: "));
write(outline, string'("IDLE Protocol Error. Protocol Error Count: "));
write(outline, integer'image(errcount));
writeline(output, outline);
elsif eccode(ERRDEVSEL) = '1' then
errcount := errcount + 1;
--report "IDLE Protocol Error. Protocol Error Count: " & integer'image(errcount);
write(outline, string'("["));
write(outline, now);
write(outline, string'("] PROTO_CHK: "));
write(outline, string'("IDLE Protocol Error. Protocol Error Count: "));
write(outline, integer'image(errcount));
writeline(output, outline);
elsif eccode(ERRSTOP) = '1' then
errcount := errcount + 1;
--report "IDLE Protocol Error. Protocol Error Count: " & integer'image(errcount);
write(outline, string'("["));
write(outline, now);
write(outline, string'("] PROTO_CHK: "));
write(outline, string'("IDLE Protocol Error. Protocol Error Count: "));
write(outline, integer'image(errcount));
writeline(output, outline);
end if;
if SERRN = '0' then
SERRN_Detected <= '1';
--report "PCI System Error (SERR) Detected";
write(outline, string'("["));
write(outline, now);
write(outline, string'("] PROTO_CHK: "));
write(outline, string'("PCI System Error (SERR) Detected"));
writeline(output, outline);
elsif Clear_SERR = '1' then
SERRN_Detected <= '0';
end if;
if PERRN = '0' then
PERRN_Detected <= '1';
--report "PCI Data Parity Error (PERR) Detected";
write(outline, string'("["));
write(outline, now);
write(outline, string'("] PROTO_CHK: "));
write(outline, string'("PCI Data Parity Error (PERR) Detected"));
writeline(output, outline);
elsif Clear_PERR = '1' then
PERRN_Detected <= '0';
end if;
END IF;
END PROCESS proto_checker;
recordevents : PROCESS (CLK, RSTN, Status)
VARIABLE incycle : boolean;
BEGIN
IF (RSTN = '0') THEN
transfers <= 0;
disconnects <= 0;
Disconnect_Detected <= '0';
retries <= 0;
target_aborts <= 0;
Master_Abort <= '1';
incycle := FALSE;
ELSIF (RISING_EDGE(CLK)) THEN
IF (NOT(IRDYN) AND NOT(TRDYN)) = '1' THEN
transfers <= transfers + 1;
END IF;
IF (NOT(IRDYN) AND NOT(TRDYN) AND NOT(STOPN)) = '1' THEN
disconnects <= disconnects + 1;
Disconnect_Detected <= '1';
END IF;
IF (NOT(IRDYN) AND TRDYN AND NOT(STOPN)) = '1' THEN
retries <= retries + 1;
Disconnect_Detected <= '1';
END IF;
IF (NOT(STOPN) AND DEVSELN) = '1' THEN
target_aborts <= target_aborts + 1;
END IF;
IF (NOT(FRAMEN)) = '1' THEN
incycle := TRUE;
ELSIF (FRAMEN AND IRDYN) = '1' THEN
incycle := FALSE;
END IF;
IF incycle AND ((NOT(TRDYN) OR NOT(STOPN) OR NOT(DEVSELN)) = '1') THEN
Master_Abort <= '0';
END IF;
IF (set_Master_Abort = '1') THEN
Master_Abort <= '1';
END IF;
IF (Clear_Disconnect = '1') THEN
Disconnect_Detected <= '0';
END IF;
END IF;
END PROCESS recordevents;
last_results: process (Status)
variable outline : line;
begin
IF (Status) THEN
--report "Number of Transfers: " & integer'image(transfers);
write(outline, string'("Number of Transfers: "));
write(outline, integer'image(transfers));
writeline(output, outline);
--report "Number of Target Disconnects with Data: " & integer'image(disconnects);
write(outline, string'("Number of Target Disconnects with Data: "));
write(outline, integer'image(disconnects));
writeline(output, outline);
--report "Number of Target Disconnects without Data: " & integer'image(retries);
write(outline, string'("Number of Target Disconnects without Data: "));
write(outline, integer'image(retries));
writeline(output, outline);
--report "Number of Target Aborts: " & integer'image(target_aborts);
write(outline, string'("Number of Target Aborts: "));
write(outline, integer'image(target_aborts));
writeline(output, outline);
END IF;
end process last_results;
END test_bench;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -