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

Subversion Repositories amber

[/] [amber/] [trunk/] [hw/] [vlog/] [tb/] [tb.v] - Blame information for rev 89

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

Line No. Rev Author Line
1 2 csantifort
//////////////////////////////////////////////////////////////////
2
//                                                              //
3
//  Top Level testbench                                         //
4
//                                                              //
5
//  This file is part of the Amber project                      //
6
//  http://www.opencores.org/project,amber                      //
7
//                                                              //
8
//  Description                                                 //
9
//  Instantiates the system, ddr3 memory model and tb_uart      //
10
//                                                              //
11
//  Author(s):                                                  //
12
//      - Conor Santifort, csantifort.amber@gmail.com           //
13
//                                                              //
14
//////////////////////////////////////////////////////////////////
15
//                                                              //
16
// Copyright (C) 2010 Authors and OPENCORES.ORG                 //
17
//                                                              //
18
// This source file may be used and distributed without         //
19
// restriction provided that this copyright statement is not    //
20
// removed from the file and that any derivative work contains  //
21
// the original copyright notice and the associated disclaimer. //
22
//                                                              //
23
// This source file is free software; you can redistribute it   //
24
// and/or modify it under the terms of the GNU Lesser General   //
25
// Public License as published by the Free Software Foundation; //
26
// either version 2.1 of the License, or (at your option) any   //
27
// later version.                                               //
28
//                                                              //
29
// This source is distributed in the hope that it will be       //
30
// useful, but WITHOUT ANY WARRANTY; without even the implied   //
31
// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      //
32
// PURPOSE.  See the GNU Lesser General Public License for more //
33
// details.                                                     //
34
//                                                              //
35
// You should have received a copy of the GNU Lesser General    //
36
// Public License along with this source; if not, download it   //
37
// from http://www.opencores.org/lgpl.shtml                     //
38
//                                                              //
39
//////////////////////////////////////////////////////////////////
40
 
41 82 csantifort
`include "global_timescale.vh"
42
`include "system_config_defines.vh"
43
`include "global_defines.vh"
44 2 csantifort
 
45
 
46
module tb();
47
 
48 82 csantifort
`include "debug_functions.vh"
49
`include "system_functions.vh"
50
`include "memory_configuration.vh"
51 2 csantifort
 
52
reg                     sysrst;
53
`ifdef XILINX_VIRTEX6_FPGA
54
reg                     clk_533mhz;
55
`endif
56
reg                     clk_200mhz;
57
reg                     clk_25mhz;
58 15 csantifort
reg [31:0]              clk_count = 'd0;
59 2 csantifort
 
60
integer                 log_file;
61
 
62
`ifdef AMBER_LOAD_MAIN_MEM
63
integer                 main_mem_file;
64
reg     [31:0]          main_mem_file_address;
65
reg     [31:0]          main_mem_file_data;
66
reg     [127:0]         main_mem_file_data_128;
67
integer                 main_mem_line_count;
68
reg     [22:0]          mm_ddr3_addr;
69
`endif
70
 
71
integer                 boot_mem_file;
72
reg     [31:0]          boot_mem_file_address;
73
reg     [31:0]          boot_mem_file_data;
74 36 csantifort
reg     [127:0]         boot_mem_file_data_128;
75 2 csantifort
integer                 boot_mem_line_count;
76
integer                 fgets_return;
77
reg     [120*8-1:0]     line;
78
reg     [120*8-1:0]     aligned_line;
79 35 csantifort
integer                 timeout = 0;
80 2 csantifort
 
81
wire [12:0]             ddr3_addr;
82
wire [2:0]              ddr3_ba;
83
wire                    ddr3_ck_p;
84
wire                    ddr3_ck_n;
85
wire [15:0]             ddr3_dq;
86
wire [1:0]              ddr3_dqs_p;
87
wire [1:0]              ddr3_dqs_n;
88
wire [1:0]              ddr3_dm;
89
wire                    ddr3_ras_n;
90
wire                    ddr3_cas_n;
91
wire                    ddr3_we_n;
92
wire                    ddr3_cke;
93
wire                    ddr3_odt;
94
wire                    ddr3_reset_n;
95
 
96
 
97
`ifdef XILINX_SPARTAN6_FPGA
98
wire                    mcb3_rzq;
99
wire                    mcb3_zio;
100
`endif
101
 
102 61 csantifort
tri1                    md;         // bi-directional phy config data
103
wire                    mdc;        // phy config clock
104 2 csantifort
 
105
wire                    uart0_cts;
106
wire                    uart0_rx;
107
wire                    uart0_rts;
108
wire                    uart0_tx;
109
 
110 61 csantifort
wire [3:0]              eth_mtxd;
111
wire                    eth_mtxdv;
112
wire                    eth_mtxerr;
113
wire [3:0]              eth_mrxd;
114
wire                    eth_mrxdv;
115 2 csantifort
 
116 82 csantifort
reg  [7*8-1:0]          core_str;
117 61 csantifort
 
118
 
119 2 csantifort
// ======================================
120
// Instantiate FPGA
121
// ======================================
122
system u_system (
123
    // Clocks and resets
124
    .brd_rst            ( sysrst            ),
125
    .brd_clk_p          ( clk_200mhz        ),
126
    .brd_clk_n          ( ~clk_200mhz       ),
127
 
128
    `ifdef XILINX_VIRTEX6_FPGA
129
    .sys_clk_p          ( clk_533mhz        ),
130
    .sys_clk_n          ( ~clk_533mhz       ),
131
    `endif
132
 
133
    // UART 0 signals
134
    .o_uart0_cts        ( uart0_cts         ),
135
    .o_uart0_rx         ( uart0_rx          ),
136
    .i_uart0_rts        ( uart0_rts         ),
137
    .i_uart0_tx         ( uart0_tx          ),
138
 
139
    // DDR3 signals
140
    .ddr3_dq            ( ddr3_dq           ),
141
    .ddr3_addr          ( ddr3_addr         ),
142
    .ddr3_ba            ( ddr3_ba           ),
143
    .ddr3_ras_n         ( ddr3_ras_n        ),
144
    .ddr3_cas_n         ( ddr3_cas_n        ),
145
    .ddr3_we_n          ( ddr3_we_n         ),
146
    .ddr3_odt           ( ddr3_odt          ),
147
    .ddr3_reset_n       ( ddr3_reset_n      ),
148
    .ddr3_cke           ( ddr3_cke          ),
149
    .ddr3_dm            ( ddr3_dm           ),
150
    .ddr3_dqs_p         ( ddr3_dqs_p        ),
151
    .ddr3_dqs_n         ( ddr3_dqs_n        ),
152
    .ddr3_ck_p          ( ddr3_ck_p         ),
153
    .ddr3_ck_n          ( ddr3_ck_n         ),
154
    `ifdef XILINX_VIRTEX6_FPGA
155
    .ddr3_cs_n          ( ddr3_cs_n         ),
156
    `endif
157
    `ifdef XILINX_SPARTAN6_FPGA
158
    .mcb3_rzq           ( mcb3_rzq          ),
159
    .mcb3_zio           ( mcb3_zio          ),
160
    `endif
161
 
162
    // Ethernet MII signals
163
    .mtx_clk_pad_i      ( clk_25mhz         ),
164 61 csantifort
    .mtxd_pad_o         ( eth_mrxd          ),
165
    .mtxen_pad_o        ( eth_mrxdv         ),
166 2 csantifort
    .mtxerr_pad_o       (                   ),
167
    .mrx_clk_pad_i      ( clk_25mhz         ),
168 61 csantifort
    .mrxd_pad_i         ( eth_mtxd          ),
169
    .mrxdv_pad_i        ( eth_mtxdv         ),
170
    .mrxerr_pad_i       ( eth_mtxerr        ),
171 2 csantifort
    .mcoll_pad_i        ( 1'd0              ),
172
    .mcrs_pad_i         ( 1'd0              ),  // Assert Carrier Sense from PHY
173
    .phy_reset_n        (                   ),
174
 
175 61 csantifort
    // Ethernet Management Data signals
176
    .md_pad_io          ( md                ),
177
    .mdc_pad_o          ( mdc               ),
178
 
179
    // LEDs
180
    .led                (                   )
181
);
182 2 csantifort
 
183 61 csantifort
 
184
 
185
// ======================================
186
// Instantiate Ethernet Test Device
187
// ======================================
188
eth_test u_eth_test(
189
    .md_io              ( md                ),
190
    .mdc_i              ( mdc               ),
191
    .mtx_clk_i          ( clk_25mhz         ),
192
    .mtxd_o             ( eth_mtxd          ),
193
    .mtxdv_o            ( eth_mtxdv         ),
194
    .mtxerr_o           ( eth_mtxerr        ),
195
    .mrxd_i             ( eth_mrxd          ),
196
    .mrxdv_i            ( eth_mrxdv         )
197 2 csantifort
);
198
 
199
 
200 61 csantifort
 
201 2 csantifort
// ======================================
202
// Instantiate DDR3 Memory Model
203
// ======================================
204
`ifdef XILINX_FPGA
205
    ddr3_model_c3 #(
206
          .DEBUG      ( 0                   )   // Set to 1 to enable debug messages
207
          )
208
    u_ddr3_model (
209
          .ck         ( ddr3_ck_p           ),
210
          .ck_n       ( ddr3_ck_n           ),
211
          .cke        ( ddr3_cke            ),
212
          `ifdef XILINX_VIRTEX6_FPGA
213
          .cs_n       ( ddr3_cs_n           ),
214
          `else
215
          .cs_n       ( 1'b0                ),
216
          `endif
217
          .ras_n      ( ddr3_ras_n          ),
218
          .cas_n      ( ddr3_cas_n          ),
219
          .we_n       ( ddr3_we_n           ),
220
          .dm_tdqs    ( ddr3_dm             ),
221
          .ba         ( ddr3_ba             ),
222
          .addr       ( {1'd0, ddr3_addr}   ),
223 11 csantifort
          .dq         ( ddr3_dq             ),
224
          .dqs        ( ddr3_dqs_p          ),
225
          .dqs_n      ( ddr3_dqs_n          ),
226 2 csantifort
          .tdqs_n     (                     ),
227
          .odt        ( ddr3_odt            ),
228
          .rst_n      ( ddr3_reset_n        )
229
          );
230
`endif
231
 
232
 
233 61 csantifort
 
234 2 csantifort
// ======================================
235
// Instantiate Testbench UART
236
// ======================================
237
tb_uart u_tb_uart (
238
    .i_uart_cts_n   ( uart0_cts ),          // Clear To Send
239
    .i_uart_rxd     ( uart0_rx  ),
240
    .o_uart_rts_n   ( uart0_rts ),          // Request to Send
241
    .o_uart_txd     ( uart0_tx  )
242
 
243
);
244
 
245
 
246 61 csantifort
 
247 2 csantifort
// ======================================
248
// Global module for xilinx hardware simulations
249
// ======================================
250
`ifdef XILINX_FPGA
251
    `define GLBL
252
    glbl glbl();
253
`endif
254
 
255
 
256
// ======================================
257
// Clock and Reset
258
// ======================================
259
 
260
// 200 MHz clock
261
initial
262
    begin
263
    clk_200mhz = 1'd0;
264
    // Time unit is pico-seconds
265
    forever #2500 clk_200mhz = ~clk_200mhz;
266
    end
267
 
268
 
269
`ifdef XILINX_VIRTEX6_FPGA
270
// 400 MHz clock
271
initial
272
    begin
273
    clk_533mhz = 1'd0;
274
    // Time unit is pico-seconds
275
    forever #938 clk_533mhz = ~clk_533mhz;
276
    end
277
`endif
278
 
279
 
280
// 25 MHz clock
281
initial
282
    begin
283
    clk_25mhz = 1'd0;
284
    forever #20000 clk_25mhz = ~clk_25mhz;
285
    end
286
 
287
initial
288
    begin
289
    sysrst = 1'd1;
290 15 csantifort
    #40000
291 2 csantifort
    sysrst = 1'd0;
292
    end
293
 
294
 
295
// ======================================
296
// Counter of system clock ticks        
297
// ======================================
298
always @ ( posedge `U_SYSTEM.sys_clk )
299 15 csantifort
    clk_count <= clk_count + 1'd1;
300 2 csantifort
 
301
 
302
 
303
// ======================================
304
// Initialize Boot Memory
305
// ======================================
306
    initial
307
        begin
308 36 csantifort
`ifndef XILINX_FPGA
309 2 csantifort
        $display("Load boot memory from %s", `BOOT_MEM_FILE);
310
        boot_mem_line_count   = 0;
311
        boot_mem_file         = $fopen(`BOOT_MEM_FILE,    "r");
312
        if (boot_mem_file == 0)
313
            begin
314
            `TB_ERROR_MESSAGE
315
            $display("ERROR: Can't open input file %s", `BOOT_MEM_FILE);
316 82 csantifort
            $finish;
317 2 csantifort
            end
318
 
319
        if (boot_mem_file != 0)
320
            begin
321
            fgets_return = 1;
322
            while (fgets_return != 0)
323
                begin
324
                fgets_return        = $fgets(line, boot_mem_file);
325
                boot_mem_line_count = boot_mem_line_count + 1;
326
                aligned_line        = align_line(line);
327
 
328
                // if the line does not start with a comment
329
                if (aligned_line[120*8-1:118*8] != 16'h2f2f)
330
                    begin
331
                    // check that line doesnt start with a '@' or a blank
332
                    if (aligned_line[120*8-1:119*8] != 8'h40 && aligned_line[120*8-1:119*8] != 8'h00)
333
                        begin
334
                        $display("Format ERROR in input file %s, line %1d. Line must start with a @, not %08x",
335
                                 `BOOT_MEM_FILE, boot_mem_line_count, aligned_line[118*8-1:117*8]);
336
                        `TB_ERROR_MESSAGE
337
                        end
338
 
339
                    if (aligned_line[120*8-1:119*8] != 8'h00)
340
                        begin
341
                        boot_mem_file_address  =   hex_chars_to_32bits (aligned_line[119*8-1:111*8]);
342
                        boot_mem_file_data     =   hex_chars_to_32bits (aligned_line[110*8-1:102*8]);
343
 
344 36 csantifort
                        `ifdef AMBER_A25_CORE
345 61 csantifort
                            boot_mem_file_data_128 = `U_BOOT_MEM.u_mem.mem[boot_mem_file_address[BOOT_MSB:4]];
346
                            `U_BOOT_MEM.u_mem.mem[boot_mem_file_address[BOOT_MSB:4]] =
347 36 csantifort
                                    insert_32_into_128 ( boot_mem_file_address[3:2],
348
                                                         boot_mem_file_data_128,
349
                                                         boot_mem_file_data );
350
                        `else
351 61 csantifort
                            `U_BOOT_MEM.u_mem.mem[boot_mem_file_address[BOOT_MSB:2]] = boot_mem_file_data;
352 36 csantifort
                        `endif
353
 
354 2 csantifort
                        `ifdef AMBER_LOAD_MEM_DEBUG
355
                            $display ("Load Boot Mem: PAddr: 0x%08x, Data 0x%08x",
356
                                        boot_mem_file_address, boot_mem_file_data);
357
                        `endif
358
                        end
359
                    end
360
                end
361
 
362
            $display("Read in %1d lines", boot_mem_line_count);
363
            end
364 36 csantifort
`endif
365 35 csantifort
 
366
        // Grab the test name from memory    
367 82 csantifort
        timeout   = `AMBER_TIMEOUT   ;
368
        `ifdef AMBER_A25_CORE
369
        core_str = "amber25";
370
        `else
371
        core_str = "amber23";
372
        `endif
373
        $display("Core %s, log file %s, timeout %0d, test name %0s ", core_str, `AMBER_LOG_FILE, timeout, `AMBER_TEST_NAME );
374 35 csantifort
        log_file = $fopen(`AMBER_LOG_FILE, "a");
375 2 csantifort
        end
376
 
377
 
378
 
379
// ======================================
380
// Initialize Main Memory
381
// ======================================
382
`ifdef AMBER_LOAD_MAIN_MEM
383
    initial
384
        begin
385
        $display("Load main memory from %s", `MAIN_MEM_FILE);
386
        `ifdef XILINX_FPGA
387
        // Wait for DDR3 initialization to complete
388
        $display("Wait for DDR3 initialization to complete before loading main memory");
389
        #70000000
390
        $display("Done waiting at %d ticks", `U_TB.clk_count);
391
        `endif
392
        main_mem_file   = $fopen(`MAIN_MEM_FILE, "r");
393
 
394
        // Read RAM File
395
        main_mem_line_count   = 0;
396
 
397
        if (main_mem_file == 0)
398
            begin
399
            $display("ERROR: Can't open input file %s", `MAIN_MEM_FILE);
400
            `TB_ERROR_MESSAGE
401
            end
402
 
403
 
404
        if (main_mem_file != 0)
405
            begin
406
            fgets_return = 1;
407
            while (fgets_return != 0)
408
                begin
409
                fgets_return        = $fgets(line, main_mem_file);
410
                main_mem_line_count = main_mem_line_count + 1;
411
                aligned_line        = align_line(line);
412
 
413
                // if the line does not start with a comment
414
                if (aligned_line[120*8-1:118*8] != 16'h2f2f)
415
                    begin
416
                    // check that line doesnt start with a '@' or a blank
417
                    if (aligned_line[120*8-1:119*8] != 8'h40 && aligned_line[120*8-1:119*8] != 8'h00)
418
                        begin
419
                        $display("Format ERROR in input file %s, line %1d. Line must start with a @, not %08x",
420
                                 `MAIN_MEM_FILE, main_mem_line_count, aligned_line[118*8-1:117*8]);
421
                        `TB_ERROR_MESSAGE
422
                        end
423
 
424
                    if (aligned_line[120*8-1:119*8] != 8'h00)
425
                        begin
426
                        main_mem_file_address =   hex_chars_to_32bits (aligned_line[119*8-1:111*8]);
427
                        main_mem_file_data    =   hex_chars_to_32bits (aligned_line[110*8-1:102*8]);
428
 
429
                        `ifdef XILINX_FPGA
430
                            mm_ddr3_addr = {main_mem_file_address[13:11], main_mem_file_address[26:14], main_mem_file_address[10:4]};
431
 
432 11 csantifort
                            main_mem_file_data_128 = tb.u_ddr3_model.memory [mm_ddr3_addr];
433
                            tb.u_ddr3_model.memory [mm_ddr3_addr] =
434 2 csantifort
                                    insert_32_into_128 ( main_mem_file_address[3:2],
435
                                                         main_mem_file_data_128,
436
                                                         main_mem_file_data );
437
 
438
                            `ifdef AMBER_LOAD_MEM_DEBUG
439 11 csantifort
                                main_mem_file_data_128 = tb.u_ddr3_model.memory [mm_ddr3_addr];
440 2 csantifort
                                $display ("Load DDR3: PAddr: 0x%08x, DDR3 Addr 0x%08h, Data 0x%032x",
441
                                          main_mem_file_address, mm_ddr3_addr, main_mem_file_data_128);
442
                            `endif
443
 
444
                        `else
445
                            // Fast simulation model of main memory
446
 
447
                            // U_RAM - Can either point to simple or Xilinx DDR3 model. 
448
                            // Set in hierarchy_defines.v
449
 
450
                            main_mem_file_data_128 = `U_RAM [main_mem_file_address[31:4]];
451
                            `U_RAM [main_mem_file_address[31:4]] =
452
                                insert_32_into_128 ( main_mem_file_address[3:2],
453
                                                     main_mem_file_data_128,
454
                                                     main_mem_file_data );
455
 
456
                            `ifdef AMBER_LOAD_MEM_DEBUG
457
                                $display ("Load RAM: PAddr: 0x%08x, Data 0x%08x",
458
                                           main_mem_file_address, main_mem_file_data);
459
                            `endif
460
 
461
                        `endif
462
 
463
                        end
464
                    end
465
                end
466
 
467
            $display("Read in %1d lines", main_mem_line_count);
468
            end
469
        end
470
`endif
471
 
472
 
473
dumpvcd u_dumpvcd();
474
 
475
// ======================================
476
// Terminate Test  
477
// ======================================
478 15 csantifort
`ifdef AMBER_A25_CORE
479 82 csantifort
    `include "a25_localparams.vh"
480
    `include "a25_functions.vh"
481 15 csantifort
`else
482 82 csantifort
    `include "a23_localparams.vh"
483
    `include "a23_functions.vh"
484 15 csantifort
`endif
485 2 csantifort
 
486 35 csantifort
reg             testfail;
487
wire            test_status_set;
488
wire [31:0]     test_status_reg;
489 2 csantifort
 
490
initial
491 35 csantifort
    begin
492
    testfail  = 1'd0;
493
    end
494 2 csantifort
 
495
assign test_status_set = `U_TEST_MODULE.test_status_set;
496
assign test_status_reg = `U_TEST_MODULE.test_status_reg;
497
 
498
always @*
499
        begin
500
        if ( test_status_set || testfail )
501
            begin
502
            if ( test_status_reg == 32'd17 && !testfail )
503
                begin
504
                display_registers;
505
                $display("++++++++++++++++++++");
506 36 csantifort
                $write("Passed %s %0d ticks\n", `AMBER_TEST_NAME, `U_TB.clk_count);
507 2 csantifort
                $display("++++++++++++++++++++");
508 36 csantifort
                $fwrite(`U_TB.log_file,"Passed %s %0d ticks\n", `AMBER_TEST_NAME, `U_TB.clk_count);
509 2 csantifort
                $finish;
510
                end
511
            else
512
                begin
513
                display_registers;
514
                if ( testfail )
515
                    begin
516
                    $display("++++++++++++++++++++");
517 36 csantifort
                    $write("Failed %s\n", `AMBER_TEST_NAME);
518 2 csantifort
                    $display("++++++++++++++++++++");
519 36 csantifort
                    $fwrite(`U_TB.log_file,"Failed %s\n", `AMBER_TEST_NAME);
520 2 csantifort
                    $finish;
521
                    end
522
                else
523
                    begin
524
                    $display("++++++++++++++++++++");
525
                    if (test_status_reg >= 32'h8000)
526 36 csantifort
                        $write("Failed %s - with error 0x%08x\n", `AMBER_TEST_NAME, test_status_reg);
527 2 csantifort
                    else
528 36 csantifort
                        $write("Failed %s - with error on line %1d\n", `AMBER_TEST_NAME, test_status_reg);
529 2 csantifort
                    $display("++++++++++++++++++++");
530
                    if (test_status_reg >= 32'h8000)
531 36 csantifort
                        $fwrite(`U_TB.log_file,"Failed %s - with error 0x%08h\n", `AMBER_TEST_NAME, test_status_reg);
532 2 csantifort
                    else
533 36 csantifort
                        $fwrite(`U_TB.log_file,"Failed %s - with error on line %1d\n", `AMBER_TEST_NAME, test_status_reg);
534 2 csantifort
                    $finish;
535
                    end
536
                end
537
            end
538
        end
539
 
540
 
541
// ======================================
542 15 csantifort
// Timeout
543
// ======================================
544
always @ ( posedge `U_SYSTEM.sys_clk )
545 35 csantifort
    if ( timeout != 0 )
546
        if (`U_TB.clk_count >= timeout)
547 15 csantifort
            begin
548
            `TB_ERROR_MESSAGE
549 49 csantifort
            $display("Timeout Error. Edit $AMBER_BASE/hw/tests/timeouts.txt to change the timeout");
550 15 csantifort
            end
551
 
552
// ======================================
553 2 csantifort
// Tasks
554
// ======================================
555
task display_registers;
556
begin
557
    $display("");
558
    $display("----------------------------------------------------------------------------");
559
    $display("Amber Core");
560
 
561
    case (`U_EXECUTE.status_bits_mode)
562
        FIRQ:    $display("         User       > FIRQ         IRQ          SVC");
563
        IRQ:     $display("         User         FIRQ       > IRQ          SVC");
564
        SVC:     $display("         User         FIRQ         IRQ        > SVC");
565
        default: $display("       > User         FIRQ         IRQ          SVC");
566
    endcase
567
 
568
    $display("r0       0x%08x", `U_REGISTER_BANK.r0);
569
    $display("r1       0x%08x", `U_REGISTER_BANK.r1);
570
    $display("r2       0x%08x", `U_REGISTER_BANK.r2);
571
    $display("r3       0x%08x", `U_REGISTER_BANK.r3);
572
    $display("r4       0x%08x", `U_REGISTER_BANK.r4);
573
    $display("r5       0x%08x", `U_REGISTER_BANK.r5);
574
    $display("r6       0x%08x", `U_REGISTER_BANK.r6);
575
    $display("r7       0x%08x", `U_REGISTER_BANK.r7);
576
    $display("r8       0x%08x   0x%08x ", `U_REGISTER_BANK.r8,  `U_REGISTER_BANK.r8_firq);
577
    $display("r9       0x%08x   0x%08x ", `U_REGISTER_BANK.r9,  `U_REGISTER_BANK.r9_firq);
578
    $display("r10      0x%08x   0x%08x ", `U_REGISTER_BANK.r10, `U_REGISTER_BANK.r10_firq);
579
    $display("r11      0x%08x   0x%08x ", `U_REGISTER_BANK.r11, `U_REGISTER_BANK.r11_firq);
580
    $display("r12      0x%08x   0x%08x ", `U_REGISTER_BANK.r12, `U_REGISTER_BANK.r12_firq);
581
 
582
    $display("r13      0x%08x   0x%08x   0x%08x   0x%08x",
583
                                               `U_REGISTER_BANK.r13,
584
                                               `U_REGISTER_BANK.r13_firq,
585
                                               `U_REGISTER_BANK.r13_irq,
586
                                               `U_REGISTER_BANK.r13_svc);
587
    $display("r14 (lr) 0x%08x   0x%08x   0x%08x   0x%08x",
588
                                               `U_REGISTER_BANK.r14,
589
                                               `U_REGISTER_BANK.r14_firq,
590
                                               `U_REGISTER_BANK.r14_irq,
591
                                               `U_REGISTER_BANK.r14_svc);
592
 
593
 
594
    $display("r15 (pc) 0x%08x", {6'd0,`U_REGISTER_BANK.r15,2'd0});
595
    $display("");
596
    $display("Status Bits: N=%d, Z=%d, C=%d, V=%d, IRQ Mask %d, FIRQ Mask %d, Mode = %s",
597
       `U_EXECUTE.status_bits_flags[3],
598
       `U_EXECUTE.status_bits_flags[2],
599
       `U_EXECUTE.status_bits_flags[1],
600
       `U_EXECUTE.status_bits_flags[0],
601
       `U_EXECUTE.status_bits_irq_mask,
602
       `U_EXECUTE.status_bits_firq_mask,
603
       mode_name (`U_EXECUTE.status_bits_mode) );
604
    $display("----------------------------------------------------------------------------");
605
    $display("");
606
 
607
end
608
endtask
609
 
610
 
611
// ======================================
612
// Functions
613
// ======================================
614
function [127:0] insert_32_into_128;
615
input [1:0]   pos;
616
input [127:0] word128;
617
input [31:0]  word32;
618
begin
619
     case (pos)
620
         2'd0: insert_32_into_128 = {word128[127:32], word32};
621
         2'd1: insert_32_into_128 = {word128[127:64], word32, word128[31:0]};
622
         2'd2: insert_32_into_128 = {word128[127:96], word32, word128[63:0]};
623
         2'd3: insert_32_into_128 = {word32, word128[95:0]};
624
     endcase
625
end
626
endfunction
627
 
628
 
629 15 csantifort
endmodule
630 2 csantifort
 

powered by: WebSVN 2.1.0

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