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

Subversion Repositories tinycpu

[/] [tinycpu/] [trunk/] [testbench/] [registerfile_tb.vhd] - Blame information for rev 28

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

Line No. Rev Author Line
1 2 earlz
LIBRARY ieee;
2
USE ieee.std_logic_1164.ALL;
3
USE ieee.numeric_std.ALL;
4 12 earlz
use work.tinycpu.all;
5
 
6 2 earlz
ENTITY registerfile_tb IS
7
END registerfile_tb;
8
 
9
ARCHITECTURE behavior OF registerfile_tb IS
10
 
11
-- Component Declaration for the Unit Under Test (UUT)
12
 
13
  component registerfile
14 12 earlz
  port(
15
    WriteEnable: in regwritetype;
16
    DataIn: in regdatatype;
17
    Clock: in std_logic;
18
    DataOut: out regdatatype
19 5 earlz
  );
20 2 earlz
  end component;
21
 
22
 
23
  --Inputs
24 12 earlz
  signal WriteEnable : regwritetype := (others => '0');
25
  signal DataIn: regdatatype := (others => "00000000");
26 2 earlz
 
27
  --Outputs
28 12 earlz
  signal DataOut: regdatatype := (others => "00000000");
29 2 earlz
 
30
  signal Clock: std_logic;
31
  constant clock_period : time := 10 ns;
32
 
33
BEGIN
34
 
35
  -- Instantiate the Unit Under Test (UUT)
36
  uut: registerfile PORT MAP (
37 12 earlz
    WriteEnable => WriteEnable,
38
    DataIn => DataIn,
39 2 earlz
    Clock => Clock,
40 12 earlz
    DataOut => DataOut
41 2 earlz
  );
42
 
43
  -- Clock process definitions
44
  clock_process :process
45
  begin
46
    Clock <= '0';
47
    wait for clock_period/2;
48
    Clock <= '1';
49
    wait for clock_period/2;
50
  end process;
51
 
52
 
53
  -- Stimulus process
54
  stim_proc: process
55
    variable err_cnt: integer :=0;
56
  begin
57
    -- hold reset state for 100 ns.
58
    wait for 100 ns;
59
 
60
    wait for clock_period*10;
61
 
62
    -- case 1
63 12 earlz
    WriteEnable(1) <= '1';
64
    DataIn(1) <= "11110000";
65 2 earlz
    wait for 10 ns;
66 12 earlz
    WriteEnable(1) <= '0';
67 2 earlz
    wait for 10 ns;
68 12 earlz
    assert (DataOut(1)="11110000") report "Storage error case 1" severity error;
69 2 earlz
 
70
    -- case 2
71 12 earlz
    WriteEnable(5) <= '1';
72
    DataIn(5) <= "11110001";
73 2 earlz
    wait for 10 ns;
74 12 earlz
    WriteEnable(5) <= '0';
75 2 earlz
    wait for 10 ns;
76 12 earlz
    assert (DataOut(5)="11110001") report "Storage selector error case 2" severity error;
77 2 earlz
 
78 12 earlz
    -- case 3;
79 2 earlz
    wait for 10 ns;
80 12 earlz
    assert (DataOut(1)="11110000") report "Storage selector(remembering) error case 3" severity error;
81 5 earlz
 
82
    --case 4
83 12 earlz
    DataIn(0) <= x"12";
84
    DataIn(1) <= x"34";
85
    WriteEnable(0) <= '1';
86
    WriteEnable(1) <= '1';
87 5 earlz
    wait for 10 ns;
88 12 earlz
    DataIn(0) <= x"90";
89
    WriteEnable(0) <= '0';
90
    WriteEnable(1) <= '0';
91 5 earlz
    wait for 10 ns;
92 12 earlz
    assert (DataOut(0)=x"12" and DataOut(1)=x"34") report "simultaneous write and read error case 4" severity error;
93 14 earlz
 
94
    --case 5
95
    DataIn(0) <= x"55";
96
    WriteEnable(0) <= '1';
97
    wait for 10 ns;
98
    DataIn(0) <= x"77";
99
    assert (DataOut(0)=x"55") report "Write during read error case 5" severity error;
100
    wait for 10 ns;
101 2 earlz
 
102 5 earlz
 
103
 
104
 
105 2 earlz
    -- summary of testbench
106 5 earlz
    assert false
107
    report "Testbench of registerfile completed successfully!"
108
    severity note;
109
 
110 2 earlz
    wait;
111
 
112
    -- insert stimulus here 
113
 
114
    wait;
115
  end process;
116
 
117
 
118
END;

powered by: WebSVN 2.1.0

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