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 162

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

powered by: WebSVN 2.1.0

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