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

Subversion Repositories nanoblaze

[/] [nanoblaze/] [trunk/] [Testbench/] [nanoblaze_tester.vhd] - Blame information for rev 5

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 5 fcorthay
--##############################################################################
2
--
3
--  nanoblaze_tb
4
--      Stimuli generator for the NanoBlaze processor testbench
5
--
6
--      Provides clock and reset to the DUT.
7
--      Inverts I/O data out to I/O data in for test purpose.
8
--
9
--      Waits for the end of the test signalled by the processor by writing
10
--      at I/O address 0. The data signals if the tests were successful or not.
11
--
12
--------------------------------------------------------------------------------
13
--
14
--  Versions / Authors
15
--      1.0 Francois Corthay    first implementation
16
--
17
--  Provided under GNU LGPL licence: <http://www.gnu.org/copyleft/lesser.html>
18
--
19
--  by the electronics group of "HES-SO//Valais Wallis", in Switzerland:
20
--  <http://www.hevs.ch/en/rad-instituts/institut-systemes-industriels/>.
21
--
22
--------------------------------------------------------------------------------
23
--
24
--  Hierarchy
25
--      Used by "nanoblaze_tb".
26
--
27
--##############################################################################
28
 
29
LIBRARY ieee;
30
  USE ieee.std_logic_1164.all;
31
  USE ieee.numeric_std.all;
32
 
33
ENTITY nanoBlaze_tester IS
34
  GENERIC(
35
    addressBitNb : positive := 8;
36
    dataBitNb    : positive := 8
37
  );
38
  PORT(
39
    reset       : OUT std_ulogic
40
    clock       : OUT std_uLogic;
41
    en          : OUT std_uLogic;
42
    dataAddress : IN  unsigned(addressBitNb-1 DOWNTO 0);
43
    dataOut     : IN  std_ulogic_vector(dataBitNb-1 DOWNTO 0);
44
    dataIn      : OUT std_ulogic_vector(dataBitNb-1 DOWNTO 0);
45
    readStrobe  : IN  std_uLogic;
46
    writeStrobe : IN  std_uLogic;
47
    int         : OUT std_uLogic;
48
    intAck      : IN  std_uLogic;
49
  );
50
 
51
END nanoBlaze_tester ;
52
 
53
--==============================================================================
54
 
55
ARCHITECTURE test OF nanoBlaze_tester IS
56
 
57
  constant clockFrequency: real := 100.0E6;
58
  constant clockPeriod: time := (1.0/clockFrequency) * 1 sec;
59
  signal clock_int: std_uLogic := '1';
60
 
61
  signal dataReg: std_ulogic_vector(dataOut'range);
62
 
63
BEGIN
64
  ------------------------------------------------------------------------------
65
                                                              -- reset and clock
66
  reset <= '1', '0' after 2*clockPeriod;
67
 
68
  clock_int <= not clock_int after clockPeriod/2;
69
  clock <= transport clock_int after clockPeriod*9.0/10.0;
70
 
71
  ------------------------------------------------------------------------------
72
                                                                       -- enable
73
  en <= '1';
74
 
75
  ------------------------------------------------------------------------------
76
                                                                         -- data
77
  storeData: process(clock_int)
78
  begin
79
    if rising_edge(clock_int) then
80
      if writeStrobe = '1' then
81
        dataReg <= dataOut;
82
      end if;
83
    end if;
84
  end process storeData;
85
 
86
  dataIn <= not dataReg;
87
 
88
  ------------------------------------------------------------------------------
89
                                                               -- error checking
90
  checkBus: process(clock_int)
91
  begin
92
    if rising_edge(clock_int) then
93
      if writeStrobe = '1' then
94
        if (dataAddress = 0) and (unsigned(dataOut) = 0) then
95
          assert false
96
            report "Testbench reports error (output value 0 at address 0)"
97
            severity failure;
98
        end if;
99
        if (dataAddress = 0) and (unsigned(dataOut) = 1) then
100
          assert false
101
            report
102
              cr & cr &
103
              "--------------------------------------------------------------------------------" & cr &
104
              "Testbench reports successful end of simulation (output value 1 at address 0)" & cr &
105
              "--------------------------------------------------------------------------------" & cr &
106
              cr
107
            severity failure;
108
        end if;
109
      end if;
110
    end if;
111
  end process checkBus;
112
 
113
END ARCHITECTURE test;

powered by: WebSVN 2.1.0

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