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

Subversion Repositories openmsp430

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

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

Line No. Rev Author Line
1 80 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: 37 $
35
// $LastChangedBy: olivier.girard $
36
// $LastChangedDate: 2009-12-29 21:58:14 +0100 (Tue, 29 Dec 2009) $
37
//----------------------------------------------------------------------------
38
`include "timescale.v"
39
`include "openMSP430_defines.v"
40
 
41
module  tb_openMSP430_fpga;
42
 
43
//
44
// Wire & Register definition
45
//------------------------------
46
 
47
// Clock & Reset
48
reg               oscclk;
49
reg               porst_n;
50
reg               pbrst_n;
51
 
52
// Slide Switches
53
reg         [9:0] switch;
54
 
55
// LEDs
56
wire        [9:0] led;
57
 
58
// UART
59
reg               uart_rx;
60
wire              uart_tx;
61
 
62
// Core debug signals
63
wire   [8*32-1:0] i_state;
64
wire   [8*32-1:0] e_state;
65
wire       [31:0] inst_cycle;
66
wire   [8*32-1:0] inst_full;
67
wire       [31:0] inst_number;
68
wire       [15:0] inst_pc;
69
wire   [8*32-1:0] inst_short;
70
 
71
// Testbench variables
72
integer           i;
73
integer           error;
74
reg               stimulus_done;
75
wire       [11:0] vout_x;
76
wire       [11:0] vout_y;
77
 
78
//
79
// Include files
80
//------------------------------
81
 
82
// CPU & Memory registers
83
`include "registers.v"
84
 
85
// Verilog stimulus
86
`include "stimulus.v"
87
 
88
//
89
// Initialize Program Memory
90
//------------------------------
91
 
92
initial
93
   begin
94
      // Read memory file
95 94 olivier.gi
      #10 $readmemh("./pmem.mem", pmem);
96 80 olivier.gi
 
97
      // Update Actel memory banks
98
      for (i=0; i<512; i=i+1)
99
        begin
100
           dut.dmem_hi.dmem_128B_R0C0.MEM_512_9[i] = {1'b0, 8'h00};
101
           dut.dmem_lo.dmem_128B_R0C0.MEM_512_9[i] = {1'b0, 8'h00};
102
 
103
           dut.pmem_hi.pmem_2kB_R0C0.MEM_512_9[i] = {1'b0, pmem[i*4+3][9:8],   pmem[i*4+2][9:8],   pmem[i*4+1][9:8],   pmem[i*4+0][9:8]};
104
           dut.pmem_hi.pmem_2kB_R0C1.MEM_512_9[i] = {1'b0, pmem[i*4+3][11:10], pmem[i*4+2][11:10], pmem[i*4+1][11:10], pmem[i*4+0][11:10]};
105
           dut.pmem_hi.pmem_2kB_R0C2.MEM_512_9[i] = {1'b0, pmem[i*4+3][13:12], pmem[i*4+2][13:12], pmem[i*4+1][13:12], pmem[i*4+0][13:12]};
106
           dut.pmem_hi.pmem_2kB_R0C3.MEM_512_9[i] = {1'b0, pmem[i*4+3][15:14], pmem[i*4+2][15:14], pmem[i*4+1][15:14], pmem[i*4+0][15:14]};
107
 
108
           dut.pmem_lo.pmem_2kB_R0C0.MEM_512_9[i] = {1'b0, pmem[i*4+3][1:0],   pmem[i*4+2][1:0],   pmem[i*4+1][1:0],   pmem[i*4+0][1:0]};
109
           dut.pmem_lo.pmem_2kB_R0C1.MEM_512_9[i] = {1'b0, pmem[i*4+3][3:2],   pmem[i*4+2][3:2],   pmem[i*4+1][3:2],   pmem[i*4+0][3:2]};
110
           dut.pmem_lo.pmem_2kB_R0C2.MEM_512_9[i] = {1'b0, pmem[i*4+3][5:4],   pmem[i*4+2][5:4],   pmem[i*4+1][5:4],   pmem[i*4+0][5:4]};
111
           dut.pmem_lo.pmem_2kB_R0C3.MEM_512_9[i] = {1'b0, pmem[i*4+3][7:6],   pmem[i*4+2][7:6],   pmem[i*4+1][7:6],   pmem[i*4+0][7:6]};
112
        end
113
  end
114
 
115
//
116
// Generate Clock & Reset
117
//------------------------------
118
initial
119
  begin
120
     oscclk = 1'b0;
121
     forever #10.4 oscclk <= ~oscclk; // 48 MHz
122
  end
123
 
124
initial
125
  begin
126
     porst_n       = 1'b1;
127
     pbrst_n       = 1'b1;
128
     #100;
129
     porst_n       = 1'b0;
130
     pbrst_n       = 1'b0;
131
     #600;
132
     porst_n       = 1'b1;
133
     pbrst_n       = 1'b1;
134
  end
135
 
136
//
137
// Global initialization
138
//------------------------------
139
initial
140
  begin
141
     error         = 0;
142
     stimulus_done = 1;
143
     switch        = 10'h000;
144
     uart_rx       = 1'b0;
145
  end
146
 
147
//
148
// openMSP430 FPGA Instance
149
//----------------------------------
150
 
151
openMSP430_fpga dut (
152
 
153
// OUTPUTs
154
    .din_x        (din_x),          // SPI Serial Data
155
    .din_y        (din_y),          // SPI Serial Data
156
    .led          (led),            // Board LEDs
157
    .sclk_x       (sclk_x),         // SPI Serial Clock
158
    .sclk_y       (sclk_y),         // SPI Serial Clock
159
    .sync_n_x     (sync_n_x),       // SPI Frame synchronization signal (low active)
160
    .sync_n_y     (sync_n_y),       // SPI Frame synchronization signal (low active)
161
    .uart_tx      (uart_tx),        // Board UART TX pin
162
 
163
// INPUTs
164
    .oscclk       (oscclk),         // Board Oscillator (?? MHz)
165
    .porst_n      (porst_n),        // Board Power-On reset (active low)
166
    .pbrst_n      (pbrst_n),        // Board Push-Button reset (active low)
167
    .uart_rx      (uart_rx),        // Board UART RX pin
168
    .switch       (switch)          // Board Switches
169
);
170
 
171
 
172
//
173
// 12 BIT DACs
174
//----------------------------------------
175
 
176
DAC121S101 DAC121S101_x (
177
 
178
// OUTPUTs
179
    .vout         (vout_x),        // Peripheral data output
180
 
181
// INPUTs
182
    .din          (din_x),         // SPI Serial Data
183
    .sclk         (sclk_x),        // SPI Serial Clock
184
    .sync_n       (sync_n_x)       // SPI Frame synchronization signal (low active)
185
);
186
 
187
DAC121S101 DAC121S101_y (
188
 
189
// OUTPUTs
190
    .vout         (vout_y),        // Peripheral data output
191
 
192
// INPUTs
193
    .din          (din_y),         // SPI Serial Data
194
    .sclk         (sclk_y),        // SPI Serial Clock
195
    .sync_n       (sync_n_y)       // SPI Frame synchronization signal (low active)
196
);
197
 
198
 
199
//
200
// Debug utility signals
201
//----------------------------------------
202
msp_debug msp_debug_0 (
203
 
204
// OUTPUTs
205
    .e_state      (e_state),       // Execution state
206
    .i_state      (i_state),       // Instruction fetch state
207
    .inst_cycle   (inst_cycle),    // Cycle number within current instruction
208
    .inst_full    (inst_full),     // Currently executed instruction (full version)
209
    .inst_number  (inst_number),   // Instruction number since last system reset
210
    .inst_pc      (inst_pc),       // Instruction Program counter
211
    .inst_short   (inst_short),    // Currently executed instruction (short version)
212
 
213
// INPUTs
214
    .mclk         (mclk),          // Main system clock
215
    .puc          (puc)            // Main system reset
216
);
217
 
218
//
219
// Generate Waveform
220
//----------------------------------------
221
initial
222
  begin
223
   `ifdef VPD_FILE
224
     $vcdplusfile("tb_openMSP430_fpga.vpd");
225
     $vcdpluson();
226
   `else
227
     $dumpfile("tb_openMSP430_fpga.vcd");
228
     $dumpvars(0, tb_openMSP430_fpga);
229
   `endif
230
  end
231
 
232
//
233
// End of simulation
234
//----------------------------------------
235
 
236
initial // Timeout
237
  begin
238
     #500000;
239
     $display(" ===============================================");
240
     $display("|               SIMULATION FAILED               |");
241
     $display("|              (simulation Timeout)             |");
242
     $display(" ===============================================");
243
     $finish;
244
  end
245
 
246
initial // Normal end of test
247
  begin
248
     @(inst_pc===16'hffff)
249
     $display(" ===============================================");
250
     if (error!=0)
251
       begin
252
          $display("|               SIMULATION FAILED               |");
253
          $display("|     (some verilog stimulus checks failed)     |");
254
       end
255
     else if (~stimulus_done)
256
       begin
257
          $display("|               SIMULATION FAILED               |");
258
          $display("|     (the verilog stimulus didn't complete)    |");
259
       end
260
     else
261
       begin
262
          $display("|               SIMULATION PASSED               |");
263
       end
264
     $display(" ===============================================");
265
     $finish;
266
  end
267
 
268
 
269
//
270
// Tasks Definition
271
//------------------------------
272
 
273
   task tb_error;
274
      input [65*8:0] error_string;
275
      begin
276
         $display("ERROR: %s %t", error_string, $time);
277
         error = error+1;
278
      end
279
   endtask
280
 
281
 
282
endmodule

powered by: WebSVN 2.1.0

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