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

Subversion Repositories sv_dir_tb

[/] [sv_dir_tb/] [trunk/] [examples/] [standard/] [sv/] [tb_mod.sv] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 sckoarn
 
2
  `include "../sv/tb_pkg.sv"
3
 
4
module tb_mod (dut_if.tb_conn tif);
5
 
6
  import tb_pkg::*;
7
 
8
  integer  in_fh;
9
  integer  stat;
10
  integer  idx = 0;
11
  logic    clock;
12
 
13
  //////////////////////////////////////////////
14
  //   DUT signals
15
  logic  rst_n;
16
  logic  clk;
17
  logic  sel;
18
  logic  ack;
19
  logic  [31:0] out1;
20
  logic  [31:0] out2;
21
  logic  [31:0] addr;
22
  logic  [31:0] data_in;
23
  logic  [31:0] data_out;
24
 
25
  ////////////////////////////////////////////////////
26
  //  instruction variables
27
  integer  was_def     = 0;
28
  string   cmd_string;
29
  logic  [31:0]  tmp_vec;
30
 
31
  //  package and container
32
  cmd_lst  cmds;
33
  tb_trans r;
34
 
35
  ////////////////////////////////////////////////////////////////////
36
  //   clock driver
37
  initial begin
38
    while(1) begin
39
      #10 clock = 0;
40
      #10 clock = 1;
41
    end
42
  end
43
 
44
  ////////////////////////////////////////////////////////
45
  //  drive DUT  signals through interface
46
  assign tif.clk = clock;
47
  assign tif.sel = sel;
48
  assign tif.rst_n = rst_n;
49
  assign tif.addr  = addr;
50
  assign tif.data_in  =  data_in;
51
  assign data_out  = tif.data_out;
52
  assign ack  =  tif.ack;
53
  assign out1 =  tif.out1;
54
  assign out2 =  tif.out2;
55
 
56
  //////////////////////////////////////////////////////////
57
  //  stimulus_file processing
58
  initial begin : Process_STM
59
    cmds = new();
60
    r    = new();
61
    //  define the default instructions
62
    cmds.define_defaults();
63
    //  User instructions
64
    cmds.define_instruction("RESET", 0);
65
    cmds.define_instruction("READ", 1);
66
    cmds.define_instruction("WRITE", 2);
67
    cmds.define_instruction("VERIFY", 1);
68
    cmds.define_instruction("TEST_CMD", 7);
69
 
70
    //  load the stimulus file
71
    cmds.load_stm(tb_top.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
      //  output any dynamic string
89
      r.cmd.print_str_wvar();
90
      // get the command string
91
      cmd_string = r.cmd.lst_cmds.cmd;
92
 
93
      ///////////////////////////////////////////////////////////////////////////
94
      //  RESET
95
      if (cmd_string == "RESET") begin
96
        @(posedge clock)
97
          #1;
98
          rst_n  =  0;
99
          sel    =  0;
100
          addr   =  0;
101
          data_in  =  0;
102
        @(posedge clock)
103
        @(posedge clock)
104
           rst_n  =  1;
105
        //@(posedge clock)
106
      ///////////////////////////////////////////////////////////////////////////
107
      //  READ
108
      end else if (cmd_string == "READ") begin
109
        @(posedge clock)
110
          #1;
111
          if(r.rtn_val.par1 == 0) begin
112
            tmp_vec  =  out1;
113
          end else begin
114
            tmp_vec  =  out2;
115
          end
116
          #1;
117
      ///////////////////////////////////////////////////////////////////////////
118
      //  WRITE
119
      end else if (cmd_string == "WRITE") begin
120
        @(posedge clock)
121
          addr    = r.rtn_val.par1;
122
          data_in = r.rtn_val.par2;
123
          sel  =  1;
124
        @(posedge ack)
125
          #1;
126
          sel  =  0;
127
      //////////////////////////////////////////////////////////////////////////
128
      //  VERIFY
129
      end else if (cmd_string == "VERIFY") begin
130
        verify_command : assert (tmp_vec == r.rtn_val.par1) else begin
131
          $warning("VERIFY failed expected: %x  Got: %x", r.rtn_val.par1, tmp_vec);
132
        end
133
      //////////////////////////////////////////////////////////////////////////
134
      //  TEST_CMD
135
      end else if (cmd_string == "TEST_CMD") begin
136
        //#1;
137
      end else begin
138
        $display("ERROR:  Command  %s not found in the else if chain. Is it spelled correctly in the else if?", cmd_string);
139
      end //  end of else if chain
140
    end  //  end main while loop
141
    //  should never end up outside the while loop.
142
    $display("ERROR:  Some how, a run off the beginning or end of the instruction sequence, has not been caught!!");
143
  end   //  end Process_STM
144
 
145
endmodule // tb_mod

powered by: WebSVN 2.1.0

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