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

Subversion Repositories sv_dir_tb

[/] [sv_dir_tb/] [trunk/] [tb_gen/] [tb_mod_template.sv] - Blame information for rev 2

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

Line No. Rev Author Line
1 2 sckoarn
/////////////////////////////////////////////////////////////////
2
//   Copyright  2014 Ken Campbell
3
//
4
//   Licensed under the Apache License, Version 2.0 (the "License");
5
//   you may not use this file except in compliance with the License.
6
//   You may obtain a copy of the License at
7
//
8
//     http://www.apache.org/licenses/LICENSE-2.0
9
//
10
//   Unless required by applicable law or agreed to in writing, software
11
//   distributed under the License is distributed on an "AS IS" BASIS,
12
//   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
//   See the License for the specific language governing permissions and
14
//   limitations under the License.
15
//
16
//   test bench module file  template.
17
////////////////////////////////////////////////////////////////
18
>>header
19
//  The package.
20
  `include "../sv/tb_pkg.sv"
21
 
22
module tb_mod (dut_if.tb_conn tif);
23
 
24
  import tb_pkg::*;
25
 
26
  //  package and container
27
  cmd_lst  cmds;
28
  tb_trans r;
29
 
30
  integer  in_fh;
31
  integer  stat;
32
  logic    clock;
33
 
34
  //////////////////////////////////////////////
35
  //   DUT signals
36
>>insert sigs
37
 
38
  ////////////////////////////////////////////////////////
39
  //  drive DUT  signals through interface
40
>>drive sigs
41
 
42
  ////////////////////////////////////////////////////
43
  //  instruction variables
44
  integer  was_def     = 0;
45
  string   cmd_string;
46
  logic  [31:0]  tmp_vec;
47
 
48
  ////////////////////////////////////////////////////////////////////
49
  //   clock driver
50
  initial begin
51
    while(1) begin
52
      #10 clock = 0;
53
      #10 clock = 1;
54
    end
55
  end
56
 
57
  //////////////////////////////////////////////////////////
58
  //  stimulus_file processing
59
  initial begin : Process_STM
60
    cmds = new();
61
    r    = new();
62
    //  define the default instructions
63
    cmds.define_defaults();
64
    //  User instructions
65
    cmds.define_instruction("RESET", 0);
66
    //cmds.define_instruction("READ", 1);
67
    //cmds.define_instruction("WRITE", 2);
68
    //cmds.define_instruction("VERIFY", 1);
69
 
70
    //  load the stimulus file
71
    cmds.load_stm(`STM_FILE);
72
 
73
    r.cmd = cmds;
74
    /////////////////////////////////////////////////////
75
    //  the main loop.
76
    while (r.cmd != null) begin
77
      r      = r.cmd.get(r);
78
      r.next++;
79
 
80
      //  process default instructions
81
      was_def  =  r.cmd.exec_defaults(r);
82
      if(was_def) begin
83
        continue;
84
      end
85
 
86
      ///////////////////////////////////////////////////////
87
      //   Process User  instructions.
88
      // get the command string
89
      cmd_string = r.cmd.lst_cmds.cmd;
90
      //  output the dynamic text if there is some. (Note:  before command runs.)
91
      r.cmd.print_str_wvar();
92
 
93
      ///////////////////////////////////////////////////////////////////////////
94
      //  RESET
95
      if (cmd_string == "RESET") begin
96
        @(posedge clock)
97
      ///////////////////////////////////////////////////////////////////////////
98
      //  READ
99
      //end else if (cmd_string == "READ") begin
100
      //  @(posedge clock)
101
      ///////////////////////////////////////////////////////////////////////////
102
      //  WRITE
103
      //end else if (cmd_string == "WRITE") begin
104
      //////////////////////////////////////////////////////////////////////////
105
      //  VERIFY
106
      //end else if (cmd_string == "VERIFY") begin
107
      //  verify_command : assert (tmp_vec == r.rtn_val.par1) else begin
108
      //    $fatal(0,"VERIFY failed expected: %x  Got: %x", r.rtn_val.par1, tmp_vec);
109
      //  end
110
      end else begin
111
        $display("ERROR:  Command not found in the else if chain. Is it spelled correctly in the else if?");
112
      end //  end of else if chain
113
    end  //  end main while loop
114
    //  should never end up outside the while loop.
115
    $display("ERROR:  Some how, a run off the beginning or end of the instruction sequence, has not been caught!!");
116
  end   //  end Process_STM
117
 
118
endmodule // tb_mod

powered by: WebSVN 2.1.0

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