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

Subversion Repositories rise

[/] [rise/] [trunk/] [vhdl/] [tb_barrel.vhd] - Blame information for rev 149

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

Line No. Rev Author Line
1 75 cwalter
-------------------------------------------------------------------------------
2
-- File: tb_barrel.vhd
3
-- Author: Jakob Lechner, Urban Stadler, Harald Trinkl, Christian Walter
4
-- Created: 2007-01-24
5
-- Last updated: 2006-11-29
6
 
7
-- Description:
8
-- Execute stage
9
-------------------------------------------------------------------------------
10
library ieee;
11
use ieee.std_logic_1164.all;
12
use ieee.std_logic_unsigned.all;
13
use ieee.numeric_std.all;
14
 
15
entity tb_barrel_vhd is
16
end tb_barrel_vhd;
17
 
18
architecture behavior of tb_barrel_vhd is
19
 
20
  -- Component Declaration for the Unit Under Test (UUT)
21
  component barrel_shifter
22
    port(
23
      reg_a      : in  std_logic_vector(15 downto 0);
24
      reg_b      : in  std_logic_vector(15 downto 0);
25
      left       : in  std_logic;
26
      arithmetic : in  std_logic;
27
      reg_q      : out std_logic_vector(15 downto 0)
28
      );
29
  end component;
30
 
31
  --Inputs
32
  signal left       : std_logic                     := '0';
33
  signal arithmetic : std_logic                     := '0';
34
  signal reg_a      : std_logic_vector(15 downto 0) := (others => '0');
35
  signal reg_b      : std_logic_vector(15 downto 0) := (others => '0');
36
 
37
  --Outputs
38
  signal reg_q : std_logic_vector(15 downto 0);
39
 
40
begin
41
 
42
  -- Instantiate the Unit Under Test (UUT)
43
  uut : barrel_shifter port map(
44
    reg_a      => reg_a,
45
    reg_b      => reg_b,
46
    left       => left,
47
    arithmetic => arithmetic,
48
    reg_q      => reg_q
49
    );
50
 
51
  tb : process
52
  begin
53
 
54
    -- Wait 100 ns for global reset to finish
55
    wait for 100 ns;
56
 
57
    -- shift left one bit
58
    left       <= '1';
59
    arithmetic <= '0';
60
    reg_a      <= x"0020";
61
    reg_b      <= x"0001";
62
    wait for 10 ns;
63
    assert reg_q = x"0040";
64
 
65
    -- shift left four bits
66
    left       <= '1';
67
    arithmetic <= '0';
68
    reg_a      <= x"0021";
69
    reg_b      <= x"0004";
70
    wait for 10 ns;
71
    assert reg_q = x"0210";
72
 
73
    -- shift right two bits
74
    left       <= '0';
75
    arithmetic <= '0';
76
    reg_a      <= x"0300";
77
    reg_b      <= x"0002";
78
    wait for 10 ns;
79
    assert reg_q = x"00C0";
80
 
81
    -- shift right two bits with arithmetic shift
82
    left       <= '0';
83
    arithmetic <= '1';
84
    reg_a      <= x"8010";
85
    reg_b      <= x"0002";
86
    wait for 10 ns;
87
    assert reg_q = x"E004";
88
    wait;                               -- will wait forever
89
 
90
  end process;
91
 
92
end;

powered by: WebSVN 2.1.0

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