test-harness.vh 1.8 KB
Newer Older
1
2
3
//
// Copyright (C) 2014 Jens Korinth, TU Darmstadt
//
4
// This file is part of Tapasco (TPC).
5
//
6
// Tapasco is free software: you can redistribute it and/or modify
7
8
9
10
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
11
// Tapasco is distributed in the hope that it will be useful,
12
13
14
15
16
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
17
// along with Tapasco.  If not, see <http://www.gnu.org/licenses/>.
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
//
`ifndef __TEST_HARNESS_VH__ 
`define __TEST_HARNESS_VH__ 1
  `define CLK_PERIOD 			8
  `define TIMEOUT			1000000000		// 1000 ms
  `define PROGRESS			100000			// cycles

  reg clk;
  reg rst;
  reg [95:0] progress;

  // clock generation
  initial clk <= 1;
  always #(`CLK_PERIOD >> 1) clk <= ~clk;

  // timeout process
  initial begin
    repeat (`TIMEOUT/`CLK_PERIOD) @(posedge clk);
    $display("--- SIMULATION TIMEOUT @ %0d ---", $time);
    $display("--- TEST FAILED @ %d ---", $time);
    $finish;
  end

  // progress process
  initial progress <= `PROGRESS;

  always @(posedge clk) begin
    if (rst) begin
      progress <= progress - 1;
      if (progress == 0) begin
        $display("--- PROGRESS: %d cycles @ %0d ---", `PROGRESS, $time);
        progress <= `PROGRESS;
      end
    end
  end

  // reset generation
  initial begin
    #100 rst <= 0;
    repeat (1000) @(posedge clk);
    rst <= 1;
    repeat (100) @(posedge clk);
    $display("--- RESET PHASE FINISHED @ %0d ---", $time);
  end

  system system_i(
    clk,
    rst
  );

`endif /* __TEST_HARNESS_VH__ */