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

Subversion Repositories socgen

[/] [socgen/] [trunk/] [common/] [opencores.org/] [Testbench/] [bfms/] [micro_bus16_model/] [rtl/] [verilog/] [top.sim] - Blame information for rev 131

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

Line No. Rev Author Line
1 131 jt_eaton
/**********************************************************************/
2
/*                                                                    */
3
/*             -------                                                */
4
/*            /   SOC  \                                              */
5
/*           /    GEN   \                                             */
6
/*          /     SIM    \                                            */
7
/*          ==============                                            */
8
/*          |            |                                            */
9
/*          |____________|                                            */
10
/*                                                                    */
11
/*  Microprocessor bus functional model (BFM) for simulations         */
12
/*                                                                    */
13
/*                                                                    */
14
/*  Author(s):                                                        */
15
/*      - John Eaton, jt_eaton@opencores.org                          */
16
/*                                                                    */
17
/**********************************************************************/
18
/*                                                                    */
19
/*    Copyright (C) <2010>                     */
20
/*                                                                    */
21
/*  This source file may be used and distributed without              */
22
/*  restriction provided that this copyright statement is not         */
23
/*  removed from the file and that any derivative work contains       */
24
/*  the original copyright notice and the associated disclaimer.      */
25
/*                                                                    */
26
/*  This source file is free software; you can redistribute it        */
27
/*  and/or modify it under the terms of the GNU Lesser General        */
28
/*  Public License as published by the Free Software Foundation;      */
29
/*  either version 2.1 of the License, or (at your option) any        */
30
/*  later version.                                                    */
31
/*                                                                    */
32
/*  This source is distributed in the hope that it will be            */
33
/*  useful, but WITHOUT ANY WARRANTY; without even the implied        */
34
/*  warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR           */
35
/*  PURPOSE.  See the GNU Lesser General Public License for more      */
36
/*  details.                                                          */
37
/*                                                                    */
38
/*  You should have received a copy of the GNU Lesser General         */
39
/*  Public License along with this source; if not, download it        */
40
/*  from http://www.opencores.org/lgpl.shtml                          */
41
/*                                                                    */
42
/**********************************************************************/
43
 
44
 
45
 
46
 
47
 
48
 
49
module micro_bus16_model_def
50
#(parameter OUT_DELAY    = 15,
51
  parameter OUT_WIDTH    = 10
52
  )
53
 
54
 
55
 (
56
  input wire                  clk,
57
  input wire                  reset,
58
 
59
  output reg [23:0]           addr,
60
  output reg [15:0]           wdata,
61
  output reg [1:0]            cs,
62
  output reg                  rd,
63
  output reg                  wr,
64
  output reg                  ub,
65
  output reg                  lb,
66
 
67
 
68
  inout  wire [15:0]           rdata
69
);
70
 
71
 
72
   reg [15:0]  exp_rdata;
73
   reg [15:0]  mask_rdata;
74
 
75
always@(posedge clk)
76
  if(reset)
77
    begin
78
      addr  <= 24'h0000;
79
      wdata <=  16'h0000;
80
      wr    <=  1'b0;
81
      rd    <=  1'b0;
82
      cs    <=  2'b00;
83
      ub    <=  1'b0;
84
      lb    <=  1'b0;
85
      exp_rdata    <=  16'h0000;
86
      mask_rdata    <=  16'h0000;
87
   end
88
 
89
 
90
 
91
io_probe_def
92
 #(.MESG         ("micro rdata Error"),
93
   .WIDTH        (16),
94
   .RESET        ({16{1'bz}}),
95
   .OUT_DELAY    (OUT_DELAY),
96
   .OUT_WIDTH    (OUT_WIDTH)
97
  )
98
rdata_tpb
99
  (
100
  .clk            (  clk        ),
101
  .drive_value    (16'bzzzzzzzzzzzzzzzz  ),
102
  .expected_value (  exp_rdata  ),
103
  .mask           (  mask_rdata ),
104
  .signal         (  rdata      )
105
  );
106
 
107
 
108
  // Tasks
109
 
110
 
111
 
112
task automatic next;
113
  input [31:0] num;
114
  repeat (num)       @ (posedge clk);
115
endtask // next
116
 
117
 
118
 
119
 
120
  // idle cycle
121
  task u_idle;
122
    begin
123
      addr  <= 24'h000000;
124
      wdata <= 16'h0000;
125
      rd    <= 1'b0;
126
      cs    <= 2'b00;
127
      wr    <= 1'b0;
128
      ub    <= 1'b0;
129
      lb    <= 1'b0;
130
      mask_rdata <= 16'h0000;
131
      next(1);
132
    end
133
  endtask
134
 
135
 
136
 
137
 
138
  // write cycle
139
  task u_write;
140
    input [23:0] a;
141
    input  [15:0] d;
142
 
143
    begin
144
 
145
      $display("%t %m cycle %x %x",$realtime,a,d );
146
 
147
      addr  <= a;
148
      wdata <= d;
149
      rd    <= 1'b0;
150
      cs    <= 2'b01;
151
      wr    <= 1'b1;
152
      ub    <= 1'b1;
153
      lb    <= 1'b1;
154
      next(4);
155
      rd    <= 1'b0;
156
      cs    <= 2'b00;
157
      wr    <= 1'b0;
158
      ub    <= 1'b0;
159
      lb    <= 1'b0;
160
      next(1);
161
 
162
    end
163
  endtask
164
 
165
  // read cycle
166
  task u_read;
167
    input   [23:0]  a;
168
    output  [15:0]   d;
169
 
170
     begin
171
 
172
      addr  <= a;
173
      wdata <= 16'h0000;
174
      rd    <= 1'b1;
175
      cs    <= 2'b01;
176
      wr    <= 1'b0;
177
      ub    <= 1'b1;
178
      lb    <= 1'b1;
179
 
180
      next(4);
181
 
182
      d     <= rdata;
183
      $display("%t %m  cycle %x %x",$realtime,a,rdata );
184
      rd    <= 1'b1;
185
      next(1);
186
      rd    <= 1'b0;
187
      ub    <= 1'b0;
188
      lb    <= 1'b0;
189
      cs    <= 2'b00;
190
      next(1);
191
    end
192
  endtask
193
 
194
  // Compare cycle (read data from location and compare with expected data)
195
  task u_cmp;
196
    input  [23:0] a;
197
    input  [15:0] d_exp;
198
 
199
     begin
200
      addr      <= a;
201
      wdata     <= 16'h0000;
202
      rd        <= 1'b1;
203
      ub        <= 1'b1;
204
      lb        <= 1'b1;
205
      cs        <= 2'b01;
206
      wr        <= 1'b0;
207
      exp_rdata <= d_exp;
208
 
209
      next(5);
210
      mask_rdata  <= 16'hffff;
211
 
212
 
213
      next(1);
214
      $display("%t %m   cycle %x %x",$realtime,a,d_exp );
215
      mask_rdata <= 16'h0000;
216
      rd         <= 1'b0;
217
      ub         <= 1'b0;
218
      lb         <= 1'b0;
219
      cs         <= 2'b00;
220
      next(1);
221
   end
222
  endtask
223
 
224
 
225
 
226
 
227
 
228
endmodule
229
 

powered by: WebSVN 2.1.0

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