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

Subversion Repositories tinycpu

[/] [tinycpu/] [trunk/] [testbench/] [top_tb.vhd] - Blame information for rev 37

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

Line No. Rev Author Line
1 23 earlz
LIBRARY ieee;
2
USE ieee.std_logic_1164.ALL;
3
USE ieee.numeric_std.ALL;
4
 
5
ENTITY top_tb IS
6
END top_tb;
7
 
8
ARCHITECTURE behavior OF top_tb IS
9
 
10
-- Component Declaration for the Unit Under Test (UUT)
11
 
12
  component top is
13
    port(
14
      Reset: in std_logic;
15
      Hold: in std_logic;
16
      HoldAck: out std_logic;
17
      Clock: in std_logic;
18
      DMA: in std_logic; --when high, Address, WriteEnable, and Data are connected to memory
19
      Address: in std_logic_vector(15 downto 0); --memory address (in bytes)
20
      WriteEnable: in std_logic;
21
      Data: inout std_logic_vector(15 downto 0);
22 37 earlz
      Port0: inout std_logic_vector(7 downto 0);
23 23 earlz
      --debug ports
24
      DebugR0: out std_logic_vector(7 downto 0)
25
    );
26
  end component;
27
 
28
 
29
  signal Reset:std_logic:='0';
30
  signal Hold: std_logic:='0';
31
  signal HoldAck: std_logic;
32
  signal DMA: std_logic:='0'; --when high, Address, WriteEnable, and Data are connected to memory
33
  signal Address: std_logic_vector(15 downto 0):=x"0000"; --memory address (in bytes)
34
  signal WriteEnable: std_logic:='0';
35
  signal Data: std_logic_vector(15 downto 0):=x"0000";
36 37 earlz
  signal Port0: std_logic_vector(7 downto 0);
37 23 earlz
  --debug ports
38
  signal DebugR0: std_logic_vector(7 downto 0);
39
 
40
  signal Clock: std_logic;
41
  constant clock_period : time := 10 ns;
42
 
43
BEGIN
44
 
45
  -- Instantiate the Unit Under Test (UUT)
46
  uut: top PORT MAP (
47
    Reset => Reset,
48
    Hold => Hold,
49
    HoldAck => HoldAck,
50
    Clock => Clock,
51
    DMA => DMA,
52
    Address => Address,
53
    WriteEnable => WriteEnable,
54
    Data => Data,
55 37 earlz
    DebugR0 => DebugR0,
56
    Port0 => Port0
57 23 earlz
  );
58
 
59
  -- Clock process definitions
60
  clock_process :process
61
  begin
62
    Clock <= '0';
63
    wait for clock_period/2;
64
    Clock <= '1';
65
    wait for clock_period/2;
66
  end process;
67
 
68
 
69
  -- Stimulus process
70
  stim_proc: process
71
    variable err_cnt: integer :=0;
72
  begin
73
    -- hold reset state for 100 ns.
74
    Reset <= '1';
75
    wait for 20 ns;
76
    Hold <= '1';
77
    wait for 10 ns;
78
    assert (HoldAck ='1') report "HoldAck not becoming high" severity error;
79
    --load memory image
80
    DMA <= '1';
81
    WriteEnable <= '1';
82
    Address <= x"0100";
83
    Data <= x"0057";
84
    wait for 10 ns;
85
    Address <= x"0102";
86
    Data <= x"00F1";
87
    wait for 10 ns;
88
    Address <= x"0104";
89
    Data <= x"00FF";
90
    wait for 10 ns;
91
    Address <= x"0106";
92
    Data <= x"0063";
93
    wait for 10 ns;
94 25 earlz
    --Address <= x"0108";
95
    --wait for 10 ns;
96 23 earlz
    DMA <= '0';
97
    wait for 10 ns;
98
    Hold <= '0';
99
    wait for 10 ns;
100
 
101
    --start the processor
102
    Reset <= '0';
103
    wait for 30 ns; --wait 3 clock cycles for CPU to execute first instruction
104 28 earlz
    wait for 10 ns; --wait 1 clock cycle for first instruction decode
105 23 earlz
    assert(Debugr0 = x"57") report "R0 is not loaded properly for first instruction" severity error;
106
    wait for 10 ns;
107
    assert(DebugR0 = x"F1") report "R0 is not loaded properly for second instruction" severity error;
108
 
109
 
110
 
111
 
112
 
113
 
114
   assert false
115
   report "Testbench of top completed successfully!"
116
   severity note;
117
 
118
    wait;
119
 
120
    -- insert stimulus here 
121
 
122
    wait;
123
  end process;
124
 
125
 
126
END;

powered by: WebSVN 2.1.0

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