📄 rece11.vhd
字号:
-- Copyright (C) 1991-2006 Altera Corporation
-- Your use of Altera Corporation's design tools, logic functions
-- and other software and tools, and its AMPP partner logic
-- functions, and any output files any of the foregoing
-- (including device programming or simulation files), and any
-- associated documentation or information are expressly subject
-- to the terms and conditions of the Altera Program License
-- Subscription Agreement, Altera MegaCore Function License
-- Agreement, or other applicable license agreement, including,
-- without limitation, that your use is for the sole purpose of
-- programming logic devices manufactured by Altera and sold by
-- Altera or its authorized distributors. Please refer to the
-- applicable agreement for further details.
-- *****************************************************************************
-- This file contains a Vhdl test bench with test vectors .The test vectors
-- are exported from a vector file in the Quartus Waveform Editor and apply to
-- the top level entity of the current Quartus project .The user can use this
-- testbench to simulate his design using a third-party simulation tool .
-- *****************************************************************************
-- Generated on "09/12/2008 08:42:13"
-- Vhdl Self-Checking Test Bench (with test vectors) for design : receiver
--
-- Simulation tool : 3rd Party
--
LIBRARY ieee;
USE ieee.std_logic_1164.all;
LIBRARY STD;
USE STD.textio.ALL;
PACKAGE receiver_vhd_tb_types IS
-- input port types
SUBTYPE i1_type IS STD_LOGIC;
SUBTYPE i2_type IS STD_LOGIC;
SUBTYPE i3_type IS STD_LOGIC;
SUBTYPE i4_type IS STD_LOGIC;
-- output port types
SUBTYPE o1_type IS STD_LOGIC;
SUBTYPE o2_type IS STD_LOGIC;
SUBTYPE o3_type IS STD_LOGIC_VECTOR(7 DOWNTO 0);
SUBTYPE o4_type IS STD_LOGIC;
SUBTYPE o5_type IS STD_LOGIC;
SUBTYPE o6_type IS STD_LOGIC;
SUBTYPE o7_type IS STD_LOGIC;
-- output port names
CONSTANT o1_name : STRING (1 TO 5) := "clk46";
CONSTANT o2_name : STRING (1 TO 10) := "data_ready";
CONSTANT o3_name : STRING (1 TO 4) := "dout";
CONSTANT o4_name : STRING (1 TO 13) := "framing_error";
CONSTANT o5_name : STRING (1 TO 3) := "IQR";
CONSTANT o6_name : STRING (1 TO 13) := "overrun_error";
CONSTANT o7_name : STRING (1 TO 12) := "parity_error";
-- n(outputs)
CONSTANT o_num : INTEGER := 7;
-- mismatches vector type
TYPE mmvec IS ARRAY (0 to (o_num - 1)) OF INTEGER;
-- exp o/ first change track vector type
TYPE trackvec IS ARRAY (1 to o_num) OF BIT;
-- sampler type
SUBTYPE sample_type IS STD_LOGIC;
-- utility functions
FUNCTION std_logic_to_char (a: STD_LOGIC) RETURN CHARACTER;
FUNCTION std_logic_vector_to_string (a: STD_LOGIC_VECTOR) RETURN STRING;
PROCEDURE write (l:INOUT LINE; value:IN STD_LOGIC; justified: IN SIDE:= RIGHT; field:IN WIDTH:=0);
PROCEDURE write (l:INOUT LINE; value:IN STD_LOGIC_VECTOR; justified: IN SIDE:= RIGHT; field:IN WIDTH:=0);
PROCEDURE throw_error(output_port_name: IN STRING; expected_value : IN STD_LOGIC; real_value : IN STD_LOGIC);
PROCEDURE throw_error(output_port_name: IN STRING; expected_value : IN STD_LOGIC_VECTOR; real_value : IN STD_LOGIC_VECTOR);
END receiver_vhd_tb_types;
PACKAGE BODY receiver_vhd_tb_types IS
FUNCTION std_logic_to_char (a: STD_LOGIC)
RETURN CHARACTER IS
BEGIN
CASE a IS
WHEN 'U' =>
RETURN 'U';
WHEN 'X' =>
RETURN 'X';
WHEN '0' =>
RETURN '0';
WHEN '1' =>
RETURN '1';
WHEN 'Z' =>
RETURN 'Z';
WHEN 'W' =>
RETURN 'W';
WHEN 'L' =>
RETURN 'L';
WHEN 'H' =>
RETURN 'H';
WHEN '-' =>
RETURN 'D';
END CASE;
END;
FUNCTION std_logic_vector_to_string (a: STD_LOGIC_VECTOR)
RETURN STRING IS
VARIABLE result : STRING(1 TO a'LENGTH);
VARIABLE j : NATURAL := 1;
BEGIN
FOR i IN a'RANGE LOOP
result(j) := std_logic_to_char(a(i));
j := j + 1;
END LOOP;
RETURN result;
END;
PROCEDURE write (l:INOUT LINE; value:IN STD_LOGIC; justified: IN SIDE:=RIGHT; field:IN WIDTH:=0) IS
BEGIN
write(L,std_logic_to_char(VALUE),JUSTIFIED,field);
END;
PROCEDURE write (l:INOUT LINE; value:IN STD_LOGIC_VECTOR; justified: IN SIDE:= RIGHT; field:IN WIDTH:=0) IS
BEGIN
write(L,std_logic_vector_to_string(VALUE),JUSTIFIED,field);
END;
PROCEDURE throw_error(output_port_name: IN STRING; expected_value : IN STD_LOGIC; real_value : IN STD_LOGIC) IS
VARIABLE txt : LINE;
BEGIN
write(txt,string'("ERROR! Vector Mismatch for output port "));
write(txt,output_port_name);
write(txt,string'(" :: @time = "));
write(txt,NOW);
write(txt,string'(", Expected value = "));
write(txt,expected_value);
write(txt,string'(", Real value = "));
write(txt,real_value);
writeline(output,txt);
END;
PROCEDURE throw_error(output_port_name: IN STRING; expected_value : IN STD_LOGIC_VECTOR; real_value : IN STD_LOGIC_VECTOR) IS
VARIABLE txt : LINE;
BEGIN
write(txt,string'("ERROR! Vector Mismatch for output port "));
write(txt,output_port_name);
write(txt,string'(" :: @time = "));
write(txt,NOW);
write(txt,string'(", Expected value = "));
write(txt,expected_value);
write(txt,string'(", Real value = "));
write(txt,real_value);
writeline(output,txt);
END;
END receiver_vhd_tb_types;
LIBRARY ieee;
USE ieee.std_logic_1164.all;
USE WORK.receiver_vhd_tb_types.ALL;
ENTITY receiver_vhd_sample_tst IS
PORT (
s1 : IN i1_type;
s2 : IN i2_type;
s3 : IN i3_type;
s4 : IN i4_type;
sampler : OUT sample_type
);
END receiver_vhd_sample_tst;
ARCHITECTURE sample_arch OF receiver_vhd_sample_tst IS
SIGNAL clk : sample_type := '1';
BEGIN
t_prcs_sample : PROCESS ( s1 , s2 , s3 , s4 )
BEGIN
IF (NOW > 0 ps) AND (NOW < 300000000 ps) THEN
clk <= NOT clk ;
END IF;
END PROCESS t_prcs_sample;
sampler <= clk;
END sample_arch;
LIBRARY ieee;
USE ieee.std_logic_1164.all;
LIBRARY STD;
USE STD.textio.ALL;
USE WORK.receiver_vhd_tb_types.ALL;
ENTITY receiver_vhd_check_tst IS
GENERIC (
debug_tbench : BIT := '0'
);
PORT (
o1 : IN o1_type;
o2 : IN o2_type;
o3 : IN o3_type;
o4 : IN o4_type;
o5 : IN o5_type;
o6 : IN o6_type;
o7 : IN o7_type;
sampler : IN sample_type
);
END receiver_vhd_check_tst;
ARCHITECTURE ovec_arch OF receiver_vhd_check_tst IS
SIGNAL t_sig_o1_expected,t_sig_o1_expected_prev,t_sig_o1_prev : o1_type;
SIGNAL t_sig_o2_expected,t_sig_o2_expected_prev,t_sig_o2_prev : o2_type;
SIGNAL t_sig_o3_expected,t_sig_o3_expected_prev,t_sig_o3_prev : o3_type;
SIGNAL t_sig_o4_expected,t_sig_o4_expected_prev,t_sig_o4_prev : o4_type;
SIGNAL t_sig_o5_expected,t_sig_o5_expected_prev,t_sig_o5_prev : o5_type;
SIGNAL t_sig_o6_expected,t_sig_o6_expected_prev,t_sig_o6_prev : o6_type;
SIGNAL t_sig_o7_expected,t_sig_o7_expected_prev,t_sig_o7_prev : o7_type;
SIGNAL trigger : BIT := '0';
SIGNAL trigger_e : BIT := '0';
SIGNAL trigger_r : BIT := '0';
SIGNAL trigger_i : BIT := '0';
SIGNAL num_mismatches : mmvec := (OTHERS => 0);
BEGIN
-- Update history buffers expected /o
t_prcs_update_o_expected_hist : PROCESS (trigger)
BEGIN
t_sig_o1_expected_prev <= t_sig_o1_expected;
t_sig_o2_expected_prev <= t_sig_o2_expected;
t_sig_o3_expected_prev <= t_sig_o3_expected;
t_sig_o4_expected_prev <= t_sig_o4_expected;
t_sig_o5_expected_prev <= t_sig_o5_expected;
t_sig_o6_expected_prev <= t_sig_o6_expected;
t_sig_o7_expected_prev <= t_sig_o7_expected;
END PROCESS t_prcs_update_o_expected_hist;
-- Update history buffers real /o
t_prcs_update_o_real_hist : PROCESS (trigger)
BEGIN
t_sig_o1_prev <= o1;
t_sig_o2_prev <= o2;
t_sig_o3_prev <= o3;
t_sig_o4_prev <= o4;
t_sig_o5_prev <= o5;
t_sig_o6_prev <= o6;
t_sig_o7_prev <= o7;
END PROCESS t_prcs_update_o_real_hist;
-- expected clk46
t_prcs_clk46: PROCESS
BEGIN
t_sig_o1_expected <= '0';
WAIT FOR 9008000 ps;
FOR i IN 1 TO 15
LOOP
t_sig_o1_expected <= '1';
WAIT FOR 9200000 ps;
t_sig_o1_expected <= '0';
WAIT FOR 9200000 ps;
END LOOP;
t_sig_o1_expected <= '1';
WAIT FOR 9200000 ps;
t_sig_o1_expected <= '0';
WAIT;
END PROCESS t_prcs_clk46;
-- expected data_ready
t_prcs_data_ready: PROCESS
BEGIN
t_sig_o2_expected <= '0';
WAIT FOR 227008000 ps;
t_sig_o2_expected <= '1';
WAIT;
END PROCESS t_prcs_data_ready;
-- expected dout[7]
t_prcs_dout_7: PROCESS
BEGIN
t_sig_o3_expected(7) <= '0';
WAIT;
END PROCESS t_prcs_dout_7;
-- expected dout[6]
t_prcs_dout_6: PROCESS
BEGIN
t_sig_o3_expected(6) <= '0';
WAIT FOR 227008000 ps;
t_sig_o3_expected(6) <= '1';
WAIT;
END PROCESS t_prcs_dout_6;
-- expected dout[5]
t_prcs_dout_5: PROCESS
BEGIN
t_sig_o3_expected(5) <= '0';
WAIT;
END PROCESS t_prcs_dout_5;
-- expected dout[4]
t_prcs_dout_4: PROCESS
BEGIN
t_sig_o3_expected(4) <= '0';
WAIT FOR 227008000 ps;
t_sig_o3_expected(4) <= '1';
WAIT;
END PROCESS t_prcs_dout_4;
-- expected dout[3]
t_prcs_dout_3: PROCESS
BEGIN
t_sig_o3_expected(3) <= '0';
WAIT;
END PROCESS t_prcs_dout_3;
-- expected dout[2]
t_prcs_dout_2: PROCESS
BEGIN
t_sig_o3_expected(2) <= '0';
WAIT FOR 227008000 ps;
t_sig_o3_expected(2) <= '1';
WAIT;
END PROCESS t_prcs_dout_2;
-- expected dout[1]
t_prcs_dout_1: PROCESS
BEGIN
t_sig_o3_expected(1) <= '0';
WAIT;
END PROCESS t_prcs_dout_1;
-- expected dout[0]
t_prcs_dout_0: PROCESS
BEGIN
t_sig_o3_expected(0) <= '0';
WAIT FOR 227008000 ps;
t_sig_o3_expected(0) <= '1';
WAIT;
END PROCESS t_prcs_dout_0;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -