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

Subversion Repositories mips789

[/] [mips789/] [branches/] [mcupro/] [verilog/] [mips_core/] [regfile.v] - Blame information for rev 59

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

Line No. Rev Author Line
1 2 mcupro
/////////////////////////////////////////////////////////////////////
2
////  Author: Liwei                                              ////
3
////                                                             ////
4
////                                                             ////
5
////  If you encountered any problem, please contact :           ////
6
////  Email: mcupro@yahoo.com.hk or mcupro@opencores.org         ////
7
////                                                             ////
8
////  Downloaded from:                                           ////
9
////     http://www.opencores.org/pdownloads.cgi/list/mips789    ////
10
/////////////////////////////////////////////////////////////////////
11
////                                                             ////
12
//// Copyright (C) 2006-2007 Liwei                               ////
13
////                         mcupro@yahoo.com.hk                 ////
14
////                                                             ////
15
////                                                             ////
16
//// This source file may be used and distributed freely without ////
17
//// restriction provided that this copyright statement is not   ////
18
//// removed from the file and any derivative work contains the  ////
19
//// original copyright notice and the associated disclaimer.    ////
20
////                                                             ////
21
//// Please let the author know if it is used                    ////
22
//// for commercial purpose.                                     ////
23
////                                                             ////
24
////     THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY     ////
25
//// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED   ////
26
//// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS   ////
27
//// FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL THE AUTHOR      ////
28
//// OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,         ////
29
//// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES    ////
30
//// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE   ////
31
//// GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR        ////
32
//// BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF  ////
33
//// LIABILITY, WHETHER IN  CONTRACT, STRICT LIABILITY, OR TORT  ////
34
//// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT  ////
35
//// OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE         ////
36
//// POSSIBILITY OF SUCH DAMAGE.                                 ////
37
////                                                             ////
38
/////////////////////////////////////////////////////////////////////
39
////                                                             ////
40
////                                                             ////
41
//// Date of Creation: 2007.8.1                                  ////
42
////                                                             ////
43
//// Version: 0.0.1                                              ////
44
////                                                             ////
45
//// Description:                                                ////
46
////                                                             ////
47
////                                                             ////
48
/////////////////////////////////////////////////////////////////////
49
////                                                             ////
50
//// Change log:                                                 ////
51
////                                                             ////
52
/////////////////////////////////////////////////////////////////////
53
 
54
module reg_array2(
55
        data,
56
        wraddress,
57
        rdaddress_a,
58
        rdaddress_b,
59
        wren,
60
        clock,
61
        qa,
62
        qb,
63
        rd_clk_cls
64
    );
65
 
66
    input       [31:0]  data;
67
    input       [4:0]  wraddress;
68
    input       [4:0]  rdaddress_a;
69
    input       [4:0]  rdaddress_b;
70
 
71
    reg [31:0]  r_data;
72
    reg [4:0]  r_wraddress;
73
    reg [4:0]  r_rdaddress_a;
74
    reg [4:0]  r_rdaddress_b;
75
    input rd_clk_cls;
76
    input       wren;
77
    reg r_wren;
78
    input       clock;
79
    output      [31:0]  qa;
80
    output      [31:0]  qb;
81
    reg [31:0]reg_bank[0:31];
82
 
83
    assign qa=(r_rdaddress_a==0)?0:
84
           ((r_wraddress==r_rdaddress_a)&&(r_wren))?r_data:
85
           reg_bank[r_rdaddress_a];
86
 
87
    assign qb=(r_rdaddress_b==0)?0:
88
           ((r_wraddress==r_rdaddress_b)&&(r_wren))?r_data:
89
           reg_bank[r_rdaddress_b];
90
 
91
    always@(posedge clock)
92
        if (~rd_clk_cls)
93
        begin
94
            r_rdaddress_a <=rdaddress_a;
95
            r_rdaddress_b<=rdaddress_b;
96
        end
97
    always@(posedge clock)
98
    begin
99
        r_data <=data;
100
        r_wraddress<=wraddress;
101
        r_wren<=wren;
102
    end
103
    always@(posedge clock)
104
        if (r_wren)
105
            reg_bank[r_wraddress] <= r_data ;
106
endmodule

powered by: WebSVN 2.1.0

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