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

Subversion Repositories openmsp430

[/] [openmsp430/] [trunk/] [fpga/] [xilinx_avnet_lx9microbard/] [bench/] [verilog/] [tb_openMSP430_fpga.v] - Blame information for rev 157

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

Line No. Rev Author Line
1 157 olivier.gi
//----------------------------------------------------------------------------
2
// Copyright (C) 2001 Authors
3
//
4
// This source file may be used and distributed without restriction provided
5
// that this copyright statement is not removed from the file and that any
6
// derivative work contains the original copyright notice and the associated
7
// disclaimer.
8
//
9
// This source file is free software; you can redistribute it and/or modify
10
// it under the terms of the GNU Lesser General Public License as published
11
// by the Free Software Foundation; either version 2.1 of the License, or
12
// (at your option) any later version.
13
//
14
// This source is distributed in the hope that it will be useful, but WITHOUT
15
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
16
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
17
// License for more details.
18
//
19
// You should have received a copy of the GNU Lesser General Public License
20
// along with this source; if not, write to the Free Software Foundation,
21
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
22
//
23
//----------------------------------------------------------------------------
24
// 
25
// *File Name: tb_openMSP430_fpga.v
26
// 
27
// *Module Description:
28
//                      openMSP430 FPGA testbench
29
//
30
// *Author(s):
31
//              - Olivier Girard,    olgirard@gmail.com
32
//
33
//----------------------------------------------------------------------------
34
// $Rev: 111 $
35
// $LastChangedBy: olivier.girard $
36
// $LastChangedDate: 2011-05-20 22:39:02 +0200 (Fri, 20 May 2011) $
37
//----------------------------------------------------------------------------
38
`include "timescale.v"
39
`ifdef OMSP_NO_INCLUDE
40
`else
41
`include "openMSP430_defines.v"
42
`endif
43
 
44
module  tb_openMSP430_fpga;
45
 
46
//
47
// Wire & Register definition
48
//------------------------------
49
 
50
// Clock & Reset
51
reg               CLK_40MHz;
52
reg               CLK_66MHz;
53
reg               CLK_100MHz;
54
reg               USER_RESET;
55
 
56
// Slide Switches
57
reg               SW4;
58
reg               SW3;
59
reg               SW2;
60
reg               SW1;
61
 
62
// LEDs
63
wire              LED4;
64
wire              LED3;
65
wire              LED2;
66
wire              LED1;
67
 
68
// UART
69
reg               UART_RXD;
70
wire              UART_TXD;
71
 
72
// UART
73
wire              PMOD1_P1;
74
reg               PMOD1_P4;
75
reg               PMOD1_P8;
76
 
77
// Core debug signals
78
wire   [8*32-1:0] i_state;
79
wire   [8*32-1:0] e_state;
80
wire       [31:0] inst_cycle;
81
wire   [8*32-1:0] inst_full;
82
wire       [31:0] inst_number;
83
wire       [15:0] inst_pc;
84
wire   [8*32-1:0] inst_short;
85
 
86
// Testbench variables
87
integer           i;
88
integer           error;
89
reg               stimulus_done;
90
 
91
 
92
//
93
// Include files
94
//------------------------------
95
 
96
// CPU & Memory registers
97
`include "registers.v"
98
 
99
// Verilog stimulus
100
`include "stimulus.v"
101
 
102
//
103
// Initialize Program Memory
104
//------------------------------
105
 
106
initial
107
   begin
108
      // Read memory file
109
      #10 $readmemh("./pmem.mem", pmem);
110
 
111
      // Update Xilinx memory banks
112
      for (i=0; i<2048; i=i+1)
113
        begin
114
           dut.ram_16x2k_pmem.ram_inst.mem[i] = pmem[i];
115
        end
116
  end
117
 
118
//
119
// Generate Clock & Reset
120
//------------------------------
121
initial
122
  begin
123
     CLK_40MHz = 1'b0;
124
     forever #12.5 CLK_40MHz <= ~CLK_40MHz; // 40 MHz
125
  end
126
 
127
initial
128
  begin
129
     CLK_66MHz = 1'b0;
130
     forever #7.57 CLK_66MHz <= ~CLK_66MHz;   // 66 MHz
131
  end
132
 
133
initial
134
  begin
135
     CLK_100MHz = 1'b0;
136
     forever #5 CLK_100MHz <= ~CLK_100MHz;  // 100 MHz
137
  end
138
 
139
initial
140
  begin
141
     USER_RESET         = 1'b0;
142
     #100 USER_RESET    = 1'b1;
143
     #600 USER_RESET    = 1'b0;
144
  end
145
 
146
//
147
// Global initialization
148
//------------------------------
149
initial
150
  begin
151
     error         = 0;
152
     stimulus_done = 1;
153
     SW4           = 1'b0;  // Slide Switches
154
     SW3           = 1'b0;
155
     SW2           = 1'b0;
156
     SW1           = 1'b0;
157
     UART_RXD      = 1'b1;  // UART
158
     PMOD1_P4      = 1'b1;
159
     PMOD1_P8      = 1'b0;
160
  end
161
 
162
//
163
// openMSP430 FPGA Instance
164
//----------------------------------
165
 
166
openMSP430_fpga dut (
167
 
168
     //----------------------------------------------
169
     // User Reset Push Button
170
     //----------------------------------------------
171
     .USER_RESET      (USER_RESET),
172
 
173
     //----------------------------------------------
174
     // Micron N25Q128 SPI Flash
175
     //   This is a Multi-I/O Flash.  Several pins
176
     //  have dual purposes depending on the mode.
177
     //----------------------------------------------
178
     .SPI_SCK         (),
179
     .SPI_CS_n        (),
180
     .SPI_MOSI_MISO0  (),
181
     .SPI_MISO_MISO1  (),
182
     .SPI_Wn_MISO2    (),
183
     .SPI_HOLDn_MISO3 (),
184
 
185
     //----------------------------------------------
186
     // TI CDCE913 Triple-Output PLL Clock Chip
187
     //   Y1: 40 MHz, USER_CLOCK can be used as
188
     //              external configuration clock
189
     //   Y2: 66.667 MHz
190
     //   Y3: 100 MHz 
191
     //----------------------------------------------
192
     .USER_CLOCK      (CLK_40MHz),
193
     .CLOCK_Y2        (CLK_66MHz),
194
     .CLOCK_Y3        (CLK_100MHz),
195
 
196
     //----------------------------------------------
197
     // The following oscillator is not populated
198
     // in production but the footprint is compatible
199
     // with the Maxim DS1088LU                 
200
     //----------------------------------------------
201
     .BACKUP_CLK      (1'b0),
202
 
203
     //----------------------------------------------
204
     // User DIP Switch x4
205
     //----------------------------------------------
206
     .GPIO_DIP1       (SW1),
207
     .GPIO_DIP2       (SW2),
208
     .GPIO_DIP3       (SW3),
209
     .GPIO_DIP4       (SW4),
210
 
211
     //----------------------------------------------
212
     // User LEDs                       
213
     //----------------------------------------------
214
     .GPIO_LED1       (LED1),
215
     .GPIO_LED2       (LED2),
216
     .GPIO_LED3       (LED3),
217
     .GPIO_LED4       (LED4),
218
 
219
     //----------------------------------------------
220
     // Silicon Labs CP2102 USB-to-UART Bridge Chip
221
     //----------------------------------------------
222
     .USB_RS232_RXD   (UART_RXD),
223
     .USB_RS232_TXD   (UART_TXD),
224
 
225
     //----------------------------------------------
226
     // Texas Instruments CDCE913 programming port
227
     //----------------------------------------------
228
     .SCL             (),
229
     .SDA             (),
230
 
231
     //----------------------------------------------
232
     // Micron MT46H32M16LFBF-5 LPDDR                   
233
     //----------------------------------------------
234
 
235
     // Addresses
236
     .LPDDR_A0        (),
237
     .LPDDR_A1        (),
238
     .LPDDR_A2        (),
239
     .LPDDR_A3        (),
240
     .LPDDR_A4        (),
241
     .LPDDR_A5        (),
242
     .LPDDR_A6        (),
243
     .LPDDR_A7        (),
244
     .LPDDR_A8        (),
245
     .LPDDR_A9        (),
246
     .LPDDR_A10       (),
247
     .LPDDR_A11       (),
248
     .LPDDR_A12       (),
249
     .LPDDR_BA0       (),
250
     .LPDDR_BA1       (),
251
 
252
     // Data                                                                  
253
     .LPDDR_DQ0       (),
254
     .LPDDR_DQ1       (),
255
     .LPDDR_DQ2       (),
256
     .LPDDR_DQ3       (),
257
     .LPDDR_DQ4       (),
258
     .LPDDR_DQ5       (),
259
     .LPDDR_DQ6       (),
260
     .LPDDR_DQ7       (),
261
     .LPDDR_DQ8       (),
262
     .LPDDR_DQ9       (),
263
     .LPDDR_DQ10      (),
264
     .LPDDR_DQ11      (),
265
     .LPDDR_DQ12      (),
266
     .LPDDR_DQ13      (),
267
     .LPDDR_DQ14      (),
268
     .LPDDR_DQ15      (),
269
     .LPDDR_LDM       (),
270
     .LPDDR_UDM       (),
271
     .LPDDR_LDQS      (),
272
     .LPDDR_UDQS      (),
273
 
274
     // Clock
275
     .LPDDR_CK_N      (),
276
     .LPDDR_CK_P      (),
277
     .LPDDR_CKE       (),
278
 
279
     // Control
280
     .LPDDR_CAS_n     (),
281
     .LPDDR_RAS_n     (),
282
     .LPDDR_WE_n      (),
283
     .LPDDR_RZQ       (),
284
 
285
     //----------------------------------------------
286
     // National Semiconductor DP83848J 10/100 Ethernet PHY                     
287
     //   Pull-ups on RXD are necessary to set the PHY AD to 11110b.
288
     //   Must keep the PHY from defaulting to PHY AD = 00000b      
289
     //   because this is Isolate Mode                              
290
     //----------------------------------------------
291
     .ETH_COL         (1'b0),
292
     .ETH_CRS         (1'b0),
293
     .ETH_MDC         (),
294
     .ETH_MDIO        (),
295
     .ETH_RESET_n     (),
296
     .ETH_RX_CLK      (1'b0),
297
     .ETH_RX_D0       (1'b0),
298
     .ETH_RX_D1       (1'b0),
299
     .ETH_RX_D2       (1'b0),
300
     .ETH_RX_D3       (1'b0),
301
     .ETH_RX_DV       (1'b0),
302
     .ETH_RX_ER       (1'b0),
303
     .ETH_TX_CLK      (1'b0),
304
     .ETH_TX_D0       (),
305
     .ETH_TX_D1       (),
306
     .ETH_TX_D2       (),
307
     .ETH_TX_D3       (),
308
     .ETH_TX_EN       (),
309
 
310
     //----------------------------------------------
311
     // Peripheral Modules (PMODs) and GPIO
312
     //     https://www.digilentinc.com/PMODs
313
     //----------------------------------------------
314
 
315
     // Connector J5
316
     .PMOD1_P1        (PMOD1_P1),    // Serial Debug Interface TX
317
     .PMOD1_P2        (),
318
     .PMOD1_P3        (),
319
     .PMOD1_P4        (PMOD1_P4),    // Serial Debug Interface RX
320
     .PMOD1_P7        (),
321
     .PMOD1_P8        (PMOD1_P8),    // Serial Debug Interface enable
322
     .PMOD1_P9        (),
323
     .PMOD1_P10       (),
324
 
325
     // Connector J4
326
     .PMOD2_P1        (),
327
     .PMOD2_P2        (),
328
     .PMOD2_P3        (),
329
     .PMOD2_P4        (),
330
     .PMOD2_P7        (),
331
     .PMOD2_P8        (),
332
     .PMOD2_P9        (),
333
     .PMOD2_P10       ()
334
);
335
 
336
 
337
// Debug utility signals
338
//----------------------------------------
339
msp_debug msp_debug_0 (
340
 
341
// OUTPUTs
342
    .e_state      (e_state),       // Execution state
343
    .i_state      (i_state),       // Instruction fetch state
344
    .inst_cycle   (inst_cycle),    // Cycle number within current instruction
345
    .inst_full    (inst_full),     // Currently executed instruction (full version)
346
    .inst_number  (inst_number),   // Instruction number since last system reset
347
    .inst_pc      (inst_pc),       // Instruction Program counter
348
    .inst_short   (inst_short),    // Currently executed instruction (short version)
349
 
350
// INPUTs
351
    .mclk         (mclk),          // Main system clock
352
    .puc_rst      (puc_rst)        // Main system reset
353
);
354
 
355
//
356
// Generate Waveform
357
//----------------------------------------
358
initial
359
  begin
360
   `ifdef VPD_FILE
361
     $vcdplusfile("tb_openMSP430_fpga.vpd");
362
     $vcdpluson();
363
   `else
364
     `ifdef TRN_FILE
365
        $recordfile ("tb_openMSP430_fpga.trn");
366
        $recordvars;
367
     `else
368
        $dumpfile("tb_openMSP430_fpga.vcd");
369
        $dumpvars(0, tb_openMSP430_fpga);
370
     `endif
371
   `endif
372
  end
373
 
374
//
375
// End of simulation
376
//----------------------------------------
377
 
378
initial // Timeout
379
  begin
380
     #500000;
381
     $display(" ===============================================");
382
     $display("|               SIMULATION FAILED               |");
383
     $display("|              (simulation Timeout)             |");
384
     $display(" ===============================================");
385
     $finish;
386
  end
387
 
388
initial // Normal end of test
389
  begin
390
     @(inst_pc===16'hffff)
391
     $display(" ===============================================");
392
     if (error!=0)
393
       begin
394
          $display("|               SIMULATION FAILED               |");
395
          $display("|     (some verilog stimulus checks failed)     |");
396
       end
397
     else if (~stimulus_done)
398
       begin
399
          $display("|               SIMULATION FAILED               |");
400
          $display("|     (the verilog stimulus didn't complete)    |");
401
       end
402
     else
403
       begin
404
          $display("|               SIMULATION PASSED               |");
405
       end
406
     $display(" ===============================================");
407
     $finish;
408
  end
409
 
410
 
411
//
412
// Tasks Definition
413
//------------------------------
414
 
415
   task tb_error;
416
      input [65*8:0] error_string;
417
      begin
418
         $display("ERROR: %s %t", error_string, $time);
419
         error = error+1;
420
      end
421
   endtask
422
 
423
 
424
endmodule

powered by: WebSVN 2.1.0

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