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

Subversion Repositories tinycpu

[/] [tinycpu/] [trunk/] [testbench/] [carryover_tb.vhd] - Blame information for rev 17

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

Line No. Rev Author Line
1 16 earlz
LIBRARY ieee;
2
USE ieee.std_logic_1164.ALL;
3
USE ieee.numeric_std.ALL;
4
use work.tinycpu.all;
5
 
6
ENTITY carryover_tb IS
7
END carryover_tb;
8
 
9
ARCHITECTURE behavior OF carryover_tb IS
10
 
11
-- Component Declaration for the Unit Under Test (UUT)
12
 
13
  component carryover is
14
    port(
15
      EnableCarry: in std_logic;
16
      DataIn: in std_logic_vector(7 downto 0);
17
      SegmentIn: in std_logic_vector(7 downto 0);
18
      Addend: in std_logic_vector(7 downto 0); --How much to increase DataIn by (as a signed number). Believe it or not, that's the actual word for what we need.
19
      DataOut: out std_logic_vector(7 downto 0);
20
      SegmentOut: out std_logic_vector(7 downto 0)
21
--      Debug: out std_logic_vector(8 downto 0)
22
    );
23
  end component;
24
 
25
 
26
  --Inputs
27
  signal EnableCarry: std_logic := '0';
28
  signal DataIn: std_logic_vector(7 downto 0) := "00000000";
29
  signal Addend: std_logic_vector(7 downto 0) := "00000000";
30
  signal SegmentIn: std_logic_vector(7 downto 0) := "00000000";
31
  --Outputs
32
  signal DataOut: std_logic_vector(7 downto 0);
33
  signal SegmentOut: std_logic_vector(7 downto 0);
34
--  signal Debug: std_logic_vector(8 downto 0);
35
 
36
  signal Clock: std_logic;
37
  constant clock_period : time := 10 ns;
38
 
39
BEGIN
40
 
41
  -- Instantiate the Unit Under Test (UUT)
42
  uut: carryover PORT MAP (
43
    EnableCarry => EnableCarry,
44
    DataIn => DataIn,
45
    Addend => Addend,
46
    SegmentIn => SegmentIn,
47
    DataOut => DataOut,
48
    SegmentOut => SegmentOut
49
--    Debug => Debug
50
  );
51
 
52
  -- Clock process definitions
53
  clock_process :process
54
  begin
55
    Clock <= '0';
56
    wait for clock_period/2;
57
    Clock <= '1';
58
    wait for clock_period/2;
59
  end process;
60
 
61
 
62
  -- Stimulus process
63
  stim_proc: process
64
    variable err_cnt: integer :=0;
65
  begin
66
    -- hold reset state for 20 ns.
67
    wait for 20 ns;
68
 
69
    --wait for clock_period*10;
70
    EnableCarry <= '1';
71
    -- case 1
72
    DataIn <= x"10";
73
    Addend <= x"02";
74
    SegmentIn <= x"00";
75
    wait for 10 ns;
76
    assert (SegmentOut=x"00" and DataOut = x"12") report "Addition Carryover when not appropriate" severity error;
77
    --case 2
78
    DataIn <= x"10";
79
    Addend <= x"FE"; -- -2
80
    SegmentIn <= x"00";
81
    wait for 10 ns;
82
    assert (SegmentOut=x"00" and DataOut = x"0E") report "Subtraction Carryover when not appropriate" severity error;
83
 
84
    DataIn <= x"10";
85
    Addend <= x"EE"; -- -18 (-0x12)
86
    SegmentIn <= x"00";
87
    wait for 10 ns;
88
    assert (SegmentOut=x"FF" and DataOut = x"FE") report "Subtraction Carryover Error" severity error;
89
 
90
    DataIn <= x"FE";
91
    Addend <= x"04";
92
    SegmentIn <= x"00";
93
    wait for 10 ns;
94
    assert (SegmentOut=x"01" and DataOut = x"02") report "Addition Carryover Error" severity error;
95 17 earlz
 
96
    DataIn <= x"7F";
97
    Addend <= x"7F";
98
    SegmentIn <= x"00";
99
    wait for 10 ns;
100
    assert (SegmentOut=x"00" and DataOut = x"FE") report "Carryover when not appropriate case 1" severity error;
101 16 earlz
 
102
    -- summary of testbench
103
    assert false
104
    report "Testbench of carryover completed successfully!"
105
    severity note;
106
 
107
    wait;
108
 
109
    -- insert stimulus here 
110
 
111
    wait;
112
  end process;
113
 
114
 
115
END;

powered by: WebSVN 2.1.0

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