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 167

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

powered by: WebSVN 2.1.0

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