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

Subversion Repositories thor

[/] [thor/] [trunk/] [rtl/] [verilog/] [Thor_regfile2w6rA.v] - Blame information for rev 42

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 42 robfinch
`timescale 1ns / 1ps
2
// ============================================================================
3
//        __
4
//   \\__/ o\    (C) 2013-2016  Robert Finch, Stratford
5
//    \  __ /    All rights reserved.
6
//     \/_//     robfinch<remove>@finitron.ca
7
//       ||
8
//
9
// This source file is free software: you can redistribute it and/or modify 
10
// it under the terms of the GNU Lesser General Public License as published 
11
// by the Free Software Foundation, either version 3 of the License, or     
12
// (at your option) any later version.                                      
13
//                                                                          
14
// This source file is distributed in the hope that it will be useful,      
15
// but WITHOUT ANY WARRANTY; without even the implied warranty of           
16
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            
17
// GNU General Public License for more details.                             
18
//                                                                          
19
// You should have received a copy of the GNU General Public License        
20
// along with this program.  If not, see <http://www.gnu.org/licenses/>.    
21
//
22
//
23
// Register file with two write ports and six read ports.
24
// ============================================================================
25
//
26
module Thor_regfile2w6r(clk, clk2x, regset, wr0, wr1, wa0, wa1, i0, i1,
27
        rclk, ra0, ra1, ra2, ra3, ra4, ra5, o0, o1, o2, o3, o4, o5);
28
parameter WID=64;
29
input clk;
30
input clk2x;
31
input [2:0] regset;
32
input wr0;
33
input wr1;
34
input [5:0] wa0;
35
input [5:0] wa1;
36
input [WID-1:0] i0;
37
input [WID-1:0] i1;
38
input rclk;
39
input [5:0] ra0;
40
input [5:0] ra1;
41
input [5:0] ra2;
42
input [5:0] ra3;
43
input [5:0] ra4;
44
input [5:0] ra5;
45
output [WID-1:0] o0;
46
output [WID-1:0] o1;
47
output [WID-1:0] o2;
48
output [WID-1:0] o3;
49
output [WID-1:0] o4;
50
output [WID-1:0] o5;
51
 
52
reg [WID-1:0] regs [0:511];
53
reg [8:0] wa2;
54
reg wr2;
55
reg [WID-1:0] i2;
56
wire [8:0] wa;
57
wire wr;
58
wire [WID-1:0] i;
59
reg [8:0] rra0,rra1,rra2,rra3,rra4,rra5;
60
 
61
// We only care about what's in the regs to begin with in simulation. In sim
62
// the 'x' values propagate screwing things up. In real hardware there's no such
63
// thing as an 'x'.
64
`define SIMULATION
65
`ifdef SIMULATION
66
integer n;
67
initial begin
68
    for (n = 0; n < 512; n = n + 1)
69
    begin
70
        regs[n] = 0;
71
    end
72
end
73
`endif
74
 
75
 
76
assign o0 = rra0[5:0]==6'd0 ? {WID{1'b0}} :
77
        (wr1 && (rra0==wa1)) ? i1 :
78
        (wr0 && (rra0==wa0)) ? i0 :
79
        regs[rra0];
80
assign o1 = rra1[5:0]==6'd0 ? {WID{1'b0}} :
81
        (wr1 && (rra1==wa1)) ? i1 :
82
        (wr0 && (rra1==wa0)) ? i0 :
83
        regs[rra1];
84
assign o2 = rra2[5:0]==6'd0 ? {WID{1'b0}} :
85
        (wr1 && (rra2==wa1)) ? i1 :
86
        (wr0 && (rra2==wa0)) ? i0 :
87
        regs[rra2];
88
assign o3 = rra3[5:0]==6'd0 ? {WID{1'b0}} :
89
        (wr1 && (rra3==wa1)) ? i1 :
90
        (wr0 && (rra3==wa0)) ? i0 :
91
        regs[rra3];
92
assign o4 = rra4[5:0]==6'd0 ? {WID{1'b0}} :
93
  (wr1 && (rra4==wa1)) ? i1 :
94
  (wr0 && (rra4==wa0)) ? i0 :
95
  regs[rra4];
96
assign o5 = rra5[5:0]==6'd0 ? {WID{1'b0}} :
97
  (wr1 && (rra5==wa1)) ? i1 :
98
  (wr0 && (rra5==wa0)) ? i0 :
99
  regs[rra5];
100
 
101
always @(posedge clk)
102
  wa2 <= wa1;
103
always @(posedge clk)
104
  wr2 <= wr1;
105
always @(posedge clk)
106
  i2 <= i1;
107
 
108
assign wa = clk ? wa2 : wa0;
109
assign wr = clk ? wr2 : wr0;
110
assign i = clk ? i2 : i0;
111
 
112
always @(posedge clk2x)
113
        if (wr) begin
114
                regs[{regset,wa}] <= i;
115
        end
116
 
117
always @(posedge rclk) rra0 <= {regset,ra0};
118
always @(posedge rclk) rra1 <= {regset,ra1};
119
always @(posedge rclk) rra2 <= {regset,ra2};
120
always @(posedge rclk) rra3 <= {regset,ra3};
121
always @(posedge rclk) rra4 <= {regset,ra4};
122
always @(posedge rclk) rra5 <= {regset,ra5};
123
 
124
endmodule

powered by: WebSVN 2.1.0

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