OpenCores
URL https://opencores.org/ocsvn/tinycpu/tinycpu/trunk

Subversion Repositories tinycpu

[/] [tinycpu/] [trunk/] [testbench/] [fetch_tb.vhd] - Blame information for rev 18

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 17 earlz
LIBRARY ieee;
2
USE ieee.std_logic_1164.ALL;
3
USE ieee.numeric_std.ALL;
4
use work.tinycpu.all;
5
 
6
ENTITY fetch_tb IS
7
END fetch_tb;
8
 
9
ARCHITECTURE behavior OF fetch_tb IS
10
 
11
-- Component Declaration for the Unit Under Test (UUT)
12
 
13
  component fetch is
14
    port(
15
      Enable: in std_logic;
16
      AddressIn: in std_logic_vector(15 downto 0);
17
      Clock: in std_logic;
18
      DataIn: in std_logic_vector(15 downto 0); --interface from memory
19
      IROut: out std_logic_vector(15 downto 0);
20
      AddressOut: out std_logic_vector(15 downto 0) --interface to memory
21
    );
22
  end component;
23
 
24
 
25
 
26
  signal Enable: std_logic := '0';
27
  signal AddressIn: std_logic_vector(15 downto 0) := x"0000";
28
  signal DataIn: std_logic_vector(15 downto 0) := x"0000";
29
 
30
  signal IROut: std_logic_vector(15 downto 0);
31
  signal AddressOut: std_logic_vector(15 downto 0);
32
 
33
  signal Clock: std_logic;
34
  constant clock_period : time := 10 ns;
35
 
36
BEGIN
37
 
38
  -- Instantiate the Unit Under Test (UUT)
39
  uut: fetch PORT MAP (
40
    Enable => Enable,
41
    AddressIn => AddressIn,
42
    Clock => Clock,
43
    DataIn => DataIn,
44
    IROut => IROut,
45
    AddressOut => AddressOut
46
  );
47
 
48
  -- Clock process definitions
49
  clock_process :process
50
  begin
51
    Clock <= '0';
52
    wait for clock_period/2;
53
    Clock <= '1';
54
    wait for clock_period/2;
55
  end process;
56
 
57
 
58
  -- Stimulus process
59
  stim_proc: process
60
    variable err_cnt: integer :=0;
61
  begin
62
    -- hold reset state for 20 ns.
63 18 earlz
    wait for 10 ns;
64 17 earlz
 
65
    --wait for clock_period*10;
66
    Enable<= '1';
67
    wait for 10 ns;
68
 
69
    Enable <= '1';
70
    AddressIn <= x"1234";
71
    DataIn <= x"5321";
72
    wait for 10 ns;
73
    assert (IROut = x"5321" and AddressOut = x"1234") report "basic operation failure" severity error;
74
 
75
    AddressIn <= x"5121";
76
    DataIn <= x"1234";
77
    wait for 5 ns;
78
    assert (IROut = x"5321" and AddressOut = x"1234") report "Timing of latching is too early" severity error;
79
    wait for 5 ns;
80
    assert (IROut = x"1234" and AddressOut =x"5121") report "basic operation failure 2" severity error;
81
 
82
 
83
    AddressIn <= x"4278";
84
    DataIn <= x"5213";
85
    Enable <= '0';
86
    wait for 10 ns;
87
    assert (IROut = x"1234" and AddressOut = "ZZZZZZZZZZZZZZZZ") report "Latching doesn't work on disable" severity error;
88
 
89
    -- summary of testbench
90
    assert false
91
    report "Testbench of fetch completed successfully!"
92
    severity note;
93
 
94
    wait;
95
 
96
    -- insert stimulus here 
97
 
98
    wait;
99
  end process;
100
 
101
 
102
END;

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.