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

Subversion Repositories amber

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

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
`timescale  1 ps / 1 ps
42
 
43
`include "system_config_defines.v"
44
`include "global_defines.v"
45
 
46
 
47
module tb();
48
 
49
`include "debug_functions.v"
50 35 csantifort
`include "system_functions.v"
51 61 csantifort
`include "memory_configuration.v"
52 2 csantifort
 
53
reg                     sysrst;
54
`ifdef XILINX_VIRTEX6_FPGA
55
reg                     clk_533mhz;
56
`endif
57
reg                     clk_200mhz;
58
reg                     clk_25mhz;
59 15 csantifort
reg [31:0]              clk_count = 'd0;
60 2 csantifort
 
61
integer                 log_file;
62
 
63
`ifdef AMBER_LOAD_MAIN_MEM
64
integer                 main_mem_file;
65
reg     [31:0]          main_mem_file_address;
66
reg     [31:0]          main_mem_file_data;
67
reg     [127:0]         main_mem_file_data_128;
68
integer                 main_mem_line_count;
69
reg     [22:0]          mm_ddr3_addr;
70
`endif
71
 
72
integer                 boot_mem_file;
73
reg     [31:0]          boot_mem_file_address;
74
reg     [31:0]          boot_mem_file_data;
75 36 csantifort
reg     [127:0]         boot_mem_file_data_128;
76 2 csantifort
integer                 boot_mem_line_count;
77
integer                 fgets_return;
78
reg     [120*8-1:0]     line;
79
reg     [120*8-1:0]     aligned_line;
80 35 csantifort
integer                 timeout = 0;
81 2 csantifort
 
82
wire [12:0]             ddr3_addr;
83
wire [2:0]              ddr3_ba;
84
wire                    ddr3_ck_p;
85
wire                    ddr3_ck_n;
86
wire [15:0]             ddr3_dq;
87
wire [1:0]              ddr3_dqs_p;
88
wire [1:0]              ddr3_dqs_n;
89
wire [1:0]              ddr3_dm;
90
wire                    ddr3_ras_n;
91
wire                    ddr3_cas_n;
92
wire                    ddr3_we_n;
93
wire                    ddr3_cke;
94
wire                    ddr3_odt;
95
wire                    ddr3_reset_n;
96
 
97
 
98
`ifdef XILINX_SPARTAN6_FPGA
99
wire                    mcb3_rzq;
100
wire                    mcb3_zio;
101
`endif
102
 
103 61 csantifort
tri1                    md;         // bi-directional phy config data
104
wire                    mdc;        // phy config clock
105 2 csantifort
 
106
wire                    uart0_cts;
107
wire                    uart0_rx;
108
wire                    uart0_rts;
109
wire                    uart0_tx;
110
 
111 61 csantifort
wire [3:0]              eth_mtxd;
112
wire                    eth_mtxdv;
113
wire                    eth_mtxerr;
114
wire [3:0]              eth_mrxd;
115
wire                    eth_mrxdv;
116 2 csantifort
 
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
            end
317
 
318
        if (boot_mem_file != 0)
319
            begin
320
            fgets_return = 1;
321
            while (fgets_return != 0)
322
                begin
323
                fgets_return        = $fgets(line, boot_mem_file);
324
                boot_mem_line_count = boot_mem_line_count + 1;
325
                aligned_line        = align_line(line);
326
 
327
                // if the line does not start with a comment
328
                if (aligned_line[120*8-1:118*8] != 16'h2f2f)
329
                    begin
330
                    // check that line doesnt start with a '@' or a blank
331
                    if (aligned_line[120*8-1:119*8] != 8'h40 && aligned_line[120*8-1:119*8] != 8'h00)
332
                        begin
333
                        $display("Format ERROR in input file %s, line %1d. Line must start with a @, not %08x",
334
                                 `BOOT_MEM_FILE, boot_mem_line_count, aligned_line[118*8-1:117*8]);
335
                        `TB_ERROR_MESSAGE
336
                        end
337
 
338
                    if (aligned_line[120*8-1:119*8] != 8'h00)
339
                        begin
340
                        boot_mem_file_address  =   hex_chars_to_32bits (aligned_line[119*8-1:111*8]);
341
                        boot_mem_file_data     =   hex_chars_to_32bits (aligned_line[110*8-1:102*8]);
342
 
343 36 csantifort
                        `ifdef AMBER_A25_CORE
344 61 csantifort
                            boot_mem_file_data_128 = `U_BOOT_MEM.u_mem.mem[boot_mem_file_address[BOOT_MSB:4]];
345
                            `U_BOOT_MEM.u_mem.mem[boot_mem_file_address[BOOT_MSB:4]] =
346 36 csantifort
                                    insert_32_into_128 ( boot_mem_file_address[3:2],
347
                                                         boot_mem_file_data_128,
348
                                                         boot_mem_file_data );
349
                        `else
350 61 csantifort
                            `U_BOOT_MEM.u_mem.mem[boot_mem_file_address[BOOT_MSB:2]] = boot_mem_file_data;
351 36 csantifort
                        `endif
352
 
353 2 csantifort
                        `ifdef AMBER_LOAD_MEM_DEBUG
354
                            $display ("Load Boot Mem: PAddr: 0x%08x, Data 0x%08x",
355
                                        boot_mem_file_address, boot_mem_file_data);
356
                        `endif
357
                        end
358
                    end
359
                end
360
 
361
            $display("Read in %1d lines", boot_mem_line_count);
362
            end
363 36 csantifort
`endif
364 35 csantifort
 
365
        // Grab the test name from memory    
366 36 csantifort
        timeout   = `AMBER_TIMEOUT   ;
367
        $display("log file %s, timeout %0d, test name %0s ", `AMBER_LOG_FILE, timeout, `AMBER_TEST_NAME );
368 35 csantifort
        log_file = $fopen(`AMBER_LOG_FILE, "a");
369 2 csantifort
        end
370
 
371
 
372
 
373
// ======================================
374
// Initialize Main Memory
375
// ======================================
376
`ifdef AMBER_LOAD_MAIN_MEM
377
    initial
378
        begin
379
        $display("Load main memory from %s", `MAIN_MEM_FILE);
380
        `ifdef XILINX_FPGA
381
        // Wait for DDR3 initialization to complete
382
        $display("Wait for DDR3 initialization to complete before loading main memory");
383
        #70000000
384
        $display("Done waiting at %d ticks", `U_TB.clk_count);
385
        `endif
386
        main_mem_file   = $fopen(`MAIN_MEM_FILE, "r");
387
 
388
        // Read RAM File
389
        main_mem_line_count   = 0;
390
 
391
        if (main_mem_file == 0)
392
            begin
393
            $display("ERROR: Can't open input file %s", `MAIN_MEM_FILE);
394
            `TB_ERROR_MESSAGE
395
            end
396
 
397
 
398
        if (main_mem_file != 0)
399
            begin
400
            fgets_return = 1;
401
            while (fgets_return != 0)
402
                begin
403
                fgets_return        = $fgets(line, main_mem_file);
404
                main_mem_line_count = main_mem_line_count + 1;
405
                aligned_line        = align_line(line);
406
 
407
                // if the line does not start with a comment
408
                if (aligned_line[120*8-1:118*8] != 16'h2f2f)
409
                    begin
410
                    // check that line doesnt start with a '@' or a blank
411
                    if (aligned_line[120*8-1:119*8] != 8'h40 && aligned_line[120*8-1:119*8] != 8'h00)
412
                        begin
413
                        $display("Format ERROR in input file %s, line %1d. Line must start with a @, not %08x",
414
                                 `MAIN_MEM_FILE, main_mem_line_count, aligned_line[118*8-1:117*8]);
415
                        `TB_ERROR_MESSAGE
416
                        end
417
 
418
                    if (aligned_line[120*8-1:119*8] != 8'h00)
419
                        begin
420
                        main_mem_file_address =   hex_chars_to_32bits (aligned_line[119*8-1:111*8]);
421
                        main_mem_file_data    =   hex_chars_to_32bits (aligned_line[110*8-1:102*8]);
422
 
423
                        `ifdef XILINX_FPGA
424
                            mm_ddr3_addr = {main_mem_file_address[13:11], main_mem_file_address[26:14], main_mem_file_address[10:4]};
425
 
426 11 csantifort
                            main_mem_file_data_128 = tb.u_ddr3_model.memory [mm_ddr3_addr];
427
                            tb.u_ddr3_model.memory [mm_ddr3_addr] =
428 2 csantifort
                                    insert_32_into_128 ( main_mem_file_address[3:2],
429
                                                         main_mem_file_data_128,
430
                                                         main_mem_file_data );
431
 
432
                            `ifdef AMBER_LOAD_MEM_DEBUG
433 11 csantifort
                                main_mem_file_data_128 = tb.u_ddr3_model.memory [mm_ddr3_addr];
434 2 csantifort
                                $display ("Load DDR3: PAddr: 0x%08x, DDR3 Addr 0x%08h, Data 0x%032x",
435
                                          main_mem_file_address, mm_ddr3_addr, main_mem_file_data_128);
436
                            `endif
437
 
438
                        `else
439
                            // Fast simulation model of main memory
440
 
441
                            // U_RAM - Can either point to simple or Xilinx DDR3 model. 
442
                            // Set in hierarchy_defines.v
443
 
444
                            main_mem_file_data_128 = `U_RAM [main_mem_file_address[31:4]];
445
                            `U_RAM [main_mem_file_address[31:4]] =
446
                                insert_32_into_128 ( main_mem_file_address[3:2],
447
                                                     main_mem_file_data_128,
448
                                                     main_mem_file_data );
449
 
450
                            `ifdef AMBER_LOAD_MEM_DEBUG
451
                                $display ("Load RAM: PAddr: 0x%08x, Data 0x%08x",
452
                                           main_mem_file_address, main_mem_file_data);
453
                            `endif
454
 
455
                        `endif
456
 
457
                        end
458
                    end
459
                end
460
 
461
            $display("Read in %1d lines", main_mem_line_count);
462
            end
463
        end
464
`endif
465
 
466
 
467
dumpvcd u_dumpvcd();
468
 
469
// ======================================
470
// Terminate Test  
471
// ======================================
472 15 csantifort
`ifdef AMBER_A25_CORE
473
    `include "a25_localparams.v"
474
    `include "a25_functions.v"
475
`else
476
    `include "a23_localparams.v"
477
    `include "a23_functions.v"
478
`endif
479 2 csantifort
 
480 35 csantifort
reg             testfail;
481
wire            test_status_set;
482
wire [31:0]     test_status_reg;
483 2 csantifort
 
484
initial
485 35 csantifort
    begin
486
    testfail  = 1'd0;
487
    end
488 2 csantifort
 
489
assign test_status_set = `U_TEST_MODULE.test_status_set;
490
assign test_status_reg = `U_TEST_MODULE.test_status_reg;
491
 
492
always @*
493
        begin
494
        if ( test_status_set || testfail )
495
            begin
496
            if ( test_status_reg == 32'd17 && !testfail )
497
                begin
498
                display_registers;
499
                $display("++++++++++++++++++++");
500 36 csantifort
                $write("Passed %s %0d ticks\n", `AMBER_TEST_NAME, `U_TB.clk_count);
501 2 csantifort
                $display("++++++++++++++++++++");
502 36 csantifort
                $fwrite(`U_TB.log_file,"Passed %s %0d ticks\n", `AMBER_TEST_NAME, `U_TB.clk_count);
503 2 csantifort
                $finish;
504
                end
505
            else
506
                begin
507
                display_registers;
508
                if ( testfail )
509
                    begin
510
                    $display("++++++++++++++++++++");
511 36 csantifort
                    $write("Failed %s\n", `AMBER_TEST_NAME);
512 2 csantifort
                    $display("++++++++++++++++++++");
513 36 csantifort
                    $fwrite(`U_TB.log_file,"Failed %s\n", `AMBER_TEST_NAME);
514 2 csantifort
                    $finish;
515
                    end
516
                else
517
                    begin
518
                    $display("++++++++++++++++++++");
519
                    if (test_status_reg >= 32'h8000)
520 36 csantifort
                        $write("Failed %s - with error 0x%08x\n", `AMBER_TEST_NAME, test_status_reg);
521 2 csantifort
                    else
522 36 csantifort
                        $write("Failed %s - with error on line %1d\n", `AMBER_TEST_NAME, test_status_reg);
523 2 csantifort
                    $display("++++++++++++++++++++");
524
                    if (test_status_reg >= 32'h8000)
525 36 csantifort
                        $fwrite(`U_TB.log_file,"Failed %s - with error 0x%08h\n", `AMBER_TEST_NAME, test_status_reg);
526 2 csantifort
                    else
527 36 csantifort
                        $fwrite(`U_TB.log_file,"Failed %s - with error on line %1d\n", `AMBER_TEST_NAME, test_status_reg);
528 2 csantifort
                    $finish;
529
                    end
530
                end
531
            end
532
        end
533
 
534
 
535
// ======================================
536 15 csantifort
// Timeout
537
// ======================================
538
always @ ( posedge `U_SYSTEM.sys_clk )
539 35 csantifort
    if ( timeout != 0 )
540
        if (`U_TB.clk_count >= timeout)
541 15 csantifort
            begin
542
            `TB_ERROR_MESSAGE
543 49 csantifort
            $display("Timeout Error. Edit $AMBER_BASE/hw/tests/timeouts.txt to change the timeout");
544 15 csantifort
            end
545
 
546
// ======================================
547 2 csantifort
// Tasks
548
// ======================================
549
task display_registers;
550
begin
551
    $display("");
552
    $display("----------------------------------------------------------------------------");
553
    $display("Amber Core");
554
 
555
    case (`U_EXECUTE.status_bits_mode)
556
        FIRQ:    $display("         User       > FIRQ         IRQ          SVC");
557
        IRQ:     $display("         User         FIRQ       > IRQ          SVC");
558
        SVC:     $display("         User         FIRQ         IRQ        > SVC");
559
        default: $display("       > User         FIRQ         IRQ          SVC");
560
    endcase
561
 
562
    $display("r0       0x%08x", `U_REGISTER_BANK.r0);
563
    $display("r1       0x%08x", `U_REGISTER_BANK.r1);
564
    $display("r2       0x%08x", `U_REGISTER_BANK.r2);
565
    $display("r3       0x%08x", `U_REGISTER_BANK.r3);
566
    $display("r4       0x%08x", `U_REGISTER_BANK.r4);
567
    $display("r5       0x%08x", `U_REGISTER_BANK.r5);
568
    $display("r6       0x%08x", `U_REGISTER_BANK.r6);
569
    $display("r7       0x%08x", `U_REGISTER_BANK.r7);
570
    $display("r8       0x%08x   0x%08x ", `U_REGISTER_BANK.r8,  `U_REGISTER_BANK.r8_firq);
571
    $display("r9       0x%08x   0x%08x ", `U_REGISTER_BANK.r9,  `U_REGISTER_BANK.r9_firq);
572
    $display("r10      0x%08x   0x%08x ", `U_REGISTER_BANK.r10, `U_REGISTER_BANK.r10_firq);
573
    $display("r11      0x%08x   0x%08x ", `U_REGISTER_BANK.r11, `U_REGISTER_BANK.r11_firq);
574
    $display("r12      0x%08x   0x%08x ", `U_REGISTER_BANK.r12, `U_REGISTER_BANK.r12_firq);
575
 
576
    $display("r13      0x%08x   0x%08x   0x%08x   0x%08x",
577
                                               `U_REGISTER_BANK.r13,
578
                                               `U_REGISTER_BANK.r13_firq,
579
                                               `U_REGISTER_BANK.r13_irq,
580
                                               `U_REGISTER_BANK.r13_svc);
581
    $display("r14 (lr) 0x%08x   0x%08x   0x%08x   0x%08x",
582
                                               `U_REGISTER_BANK.r14,
583
                                               `U_REGISTER_BANK.r14_firq,
584
                                               `U_REGISTER_BANK.r14_irq,
585
                                               `U_REGISTER_BANK.r14_svc);
586
 
587
 
588
    $display("r15 (pc) 0x%08x", {6'd0,`U_REGISTER_BANK.r15,2'd0});
589
    $display("");
590
    $display("Status Bits: N=%d, Z=%d, C=%d, V=%d, IRQ Mask %d, FIRQ Mask %d, Mode = %s",
591
       `U_EXECUTE.status_bits_flags[3],
592
       `U_EXECUTE.status_bits_flags[2],
593
       `U_EXECUTE.status_bits_flags[1],
594
       `U_EXECUTE.status_bits_flags[0],
595
       `U_EXECUTE.status_bits_irq_mask,
596
       `U_EXECUTE.status_bits_firq_mask,
597
       mode_name (`U_EXECUTE.status_bits_mode) );
598
    $display("----------------------------------------------------------------------------");
599
    $display("");
600
 
601
end
602
endtask
603
 
604
 
605
// ======================================
606
// Functions
607
// ======================================
608
function [127:0] insert_32_into_128;
609
input [1:0]   pos;
610
input [127:0] word128;
611
input [31:0]  word32;
612
begin
613
     case (pos)
614
         2'd0: insert_32_into_128 = {word128[127:32], word32};
615
         2'd1: insert_32_into_128 = {word128[127:64], word32, word128[31:0]};
616
         2'd2: insert_32_into_128 = {word128[127:96], word32, word128[63:0]};
617
         2'd3: insert_32_into_128 = {word32, word128[95:0]};
618
     endcase
619
end
620
endfunction
621
 
622
 
623 15 csantifort
endmodule
624 2 csantifort
 

powered by: WebSVN 2.1.0

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