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

Subversion Repositories mips32

[/] [mips32/] [trunk/] [Classic-MIPS/] [source/] [src/] [PipelineMIPS_tb.v] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 jjf
`timescale 1ns / 1ps
2
//////////////////////////////////////////////////////////////////////////////////
3
// Company: 
4
// Engineer: 
5
// 
6
// Create Date:    20:21:07 12/29/2016 
7
// Design Name: 
8
// Module Name:    SimpleMIPS_tb 
9
// Project Name: 
10
// Target Devices: 
11
// Tool versions: 
12
// Description: 
13
//
14
// Dependencies: 
15
//
16
// Revision: 
17
// Revision 0.01 - File Created
18
// Additional Comments: 
19
//
20
//////////////////////////////////////////////////////////////////////////////////
21
`include "macros.v"
22
module PipelineMIPS_tb(
23
    );
24
 
25
         localparam             integer         NUM = 64;
26
         localparam     integer     RAM_NUM = 64;
27
 
28
         reg                                clk, rst;
29
         reg [31:0]                              instructions [NUM - 1:0];
30
         wire [31:0]                     instruction;
31
         wire [31:0]                     pc;
32
         wire [12:0]             user_addr;
33
         reg                   user_we;
34
         reg [31:0]            user_din;
35
         wire signed [31:0]         user_dout;
36
         integer                                index;
37
         integer                srand;
38
         integer                cosumed_time;
39
         reg [20:0]  addr_tag;
40
     reg [5:0]   addr_index;
41
     reg [2:0]   addr_offset;
42
     wire [31:0] addr;
43
 
44
         assign instruction = instructions[ pc>>2 ];
45
 
46
         /* set the address */
47
         assign addr = {addr_tag, addr_index, addr_offset, 2'b00};
48
         assign user_addr = addr[14:2];
49
 
50
         always #5 clk = ~clk;
51
 
52
 
53
         initial
54
         begin
55
                clk = 1;
56
                rst = 1;
57
                user_we = 0;
58
                user_din = 0;
59
                index = 0;
60
 
61
//`ifdef _RAM_INIT__
62
                srand = 898989;
63
                /* write some data to the Main Memory */
64
                #5;
65
                for( index = 0; index < 20; index = index + 1)
66
                begin
67
                addr_tag = 21'd0; addr_index = index/8; addr_offset = index%8;
68
                user_din = {$random(srand)}%50 + 1;
69
                user_we = 1;
70
                #10;
71
                end
72
                user_we = 0;
73
//`endif
74
 
75
                //read the TESTBENCH
76
                $readmemb("E:/PR2016/MIPS_CPU/TestBenchs/instruct.txt", instructions);
77
                $display("%b", instructions[0]);
78
                $display("%b", instructions[1]);
79
 
80
                repeat(3) @(posedge clk)
81
                #1;
82
                rst = 0;
83
 
84
                /* the testbench time */
85
                repeat(3) @(posedge clk);
86
                /* wait for the NOP instruction */
87
                wait( instruction == `NOP);
88
                cosumed_time = $time;
89
                $display("The process is over with time = %t.", $time);
90
                /* wait for the cache flush done */
91
                repeat(1000) @(posedge clk);
92
 
93
                $display("The ram output...");
94
                for( index = 0; index < RAM_NUM; index = index + 1)
95
                        begin
96
                                #2;
97
                                addr_tag = 21'd0; addr_index = (index/8); addr_offset = index%8;
98
                                @(posedge clk);
99
                                #1;
100
                                $strobe("ARRAY addr=%d, value=%d", user_addr, user_dout);
101
                        end
102
                $display("The testbench is over with time = %t (%d).", $time, cosumed_time);
103
                $finish;
104
         end
105
 
106
         PipelineMIPS PipelineMIPS_inst (
107
    .clk(clk),
108
    .rst(rst),
109
    .pc(pc),
110
    .instruction(instruction),
111
         .user_addr( user_addr ),
112
         .user_we( user_we ),
113
         .user_din( user_din ),
114
         .user_dout( user_dout )
115
    );
116
 
117
 
118
endmodule

powered by: WebSVN 2.1.0

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