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

Subversion Repositories edge

[/] [edge/] [trunk/] [HW/] [Verilog/] [regfile.v] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 heshamelma
//////////////////////////////////////////////////////////////////
2
//                                                              //
3
//  Register file for Edge core.                                //
4
//                                                              //
5
//  This file is part of the Edge project                       //
6
//  http://www.opencores.org/project,edge                       //
7
//                                                              //
8
//  Description                                                 //
9
//  General purpose 32 x 32 bit register file                   //
10
//                                                              //
11
//  Author(s):                                                  //
12
//      - Hesham AL-Matary, heshamelmatary@gmail.com            //
13
//                                                              //
14
//////////////////////////////////////////////////////////////////
15
//                                                              //
16
// Copyright (C) 2014 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
module regfile
42
(
43
  clk,
44
  reset,
45
  ra1,
46
  ra2,
47
  wa3,
48
  we3,
49
  wd3,
50
  rd1,
51
  rd2
52
);
53
/* Bus size in bits for data */
54
parameter N = 32;
55
/* Bus size in bits for Addresses, the register file size should be 2**addr_size */
56
parameter addr_size = 5;
57
 
58
/* Specify IO sizes */
59
input wire clk;
60
input wire reset;
61
input wire[addr_size-1:0] ra1;
62
input wire[addr_size-1:0]ra2;
63
input wire[addr_size-1:0]wa3;
64
input wire we3;
65
input wire[N-1:0] wd3;
66
output reg[N-1:0] rd1;
67
output reg[N-1:0] rd2;
68
integer i;
69
 
70
/* Define register file*/
71
reg[N-1:0] rf [(2**addr_size)-1:0];
72
 
73
initial
74
begin
75
  for(i=0; i<32; i=i+1)
76
    rf[i] = 0;
77
end
78
 
79
always @(posedge clk)
80
  if (we3)
81
    rf[wa3] = wd3;
82
 
83
always @(negedge clk)
84
begin
85
  rd1 = (ra1 != 0)? rf[ra1]:0;
86
  rd2 = (ra2 != 0)? rf[ra2]:0;
87
end
88
 
89
endmodule
90
 

powered by: WebSVN 2.1.0

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