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 6

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 6 sckoarn
  //  some handy defs
26
  `define PAR1 r.rtn_val.par1
27
  `define PAR2 r.rtn_val.par2
28
  `define PAR3 r.rtn_val.par3
29
  `define PAR4 r.rtn_val.par4
30 2 sckoarn
  //  package and container
31
  cmd_lst  cmds;
32
  tb_trans r;
33
 
34
  integer  in_fh;
35
  integer  stat;
36
  logic    clock;
37
 
38
  //////////////////////////////////////////////
39
  //   DUT signals
40
>>insert sigs
41
 
42
  ////////////////////////////////////////////////////////
43
  //  drive DUT  signals through interface
44
>>drive sigs
45
 
46
  ////////////////////////////////////////////////////
47
  //  instruction variables
48
  integer  was_def     = 0;
49
  string   cmd_string;
50
  logic  [31:0]  tmp_vec;
51
 
52
  ////////////////////////////////////////////////////////////////////
53
  //   clock driver
54
  initial begin
55
    while(1) begin
56
      #10 clock = 0;
57
      #10 clock = 1;
58
    end
59
  end
60
 
61
  //////////////////////////////////////////////////////////
62
  //  stimulus_file processing
63
  initial begin : Process_STM
64
    cmds = new();
65
    r    = new();
66
    //  define the default instructions
67
    cmds.define_defaults();
68
    //  User instructions
69
    cmds.define_instruction("RESET", 0);
70
    //cmds.define_instruction("READ", 1);
71
    //cmds.define_instruction("WRITE", 2);
72
    //cmds.define_instruction("VERIFY", 1);
73
 
74
    //  load the stimulus file
75 6 sckoarn
    cmds.load_stm(tb_top.STM_FILE);
76 2 sckoarn
 
77
    r.cmd = cmds;
78
    /////////////////////////////////////////////////////
79
    //  the main loop.
80
    while (r.cmd != null) begin
81
      r      = r.cmd.get(r);
82
      r.next++;
83
 
84
      //  process default instructions
85
      was_def  =  r.cmd.exec_defaults(r);
86
      if(was_def) begin
87
        continue;
88
      end
89
 
90
      ///////////////////////////////////////////////////////
91
      //   Process User  instructions.
92
      // get the command string
93
      cmd_string = r.cmd.lst_cmds.cmd;
94
      //  output the dynamic text if there is some. (Note:  before command runs.)
95
      r.cmd.print_str_wvar();
96
 
97
      ///////////////////////////////////////////////////////////////////////////
98
      //  RESET
99
      if (cmd_string == "RESET") begin
100 6 sckoarn
        @(posedge clock);
101 2 sckoarn
      ///////////////////////////////////////////////////////////////////////////
102
      //  READ
103
      //end else if (cmd_string == "READ") begin
104
      //  @(posedge clock)
105
      ///////////////////////////////////////////////////////////////////////////
106
      //  WRITE
107
      //end else if (cmd_string == "WRITE") begin
108
      //////////////////////////////////////////////////////////////////////////
109
      //  VERIFY
110
      //end else if (cmd_string == "VERIFY") begin
111
      //  verify_command : assert (tmp_vec == r.rtn_val.par1) else begin
112
      //    $fatal(0,"VERIFY failed expected: %x  Got: %x", r.rtn_val.par1, tmp_vec);
113
      //  end
114
      end else begin
115
        $display("ERROR:  Command not found in the else if chain. Is it spelled correctly in the else if?");
116
      end //  end of else if chain
117
    end  //  end main while loop
118
    //  should never end up outside the while loop.
119
    $display("ERROR:  Some how, a run off the beginning or end of the instruction sequence, has not been caught!!");
120
  end   //  end Process_STM
121
 
122
endmodule // tb_mod

powered by: WebSVN 2.1.0

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