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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [orp/] [orp_soc/] [rtl/] [verilog/] [or1200.old/] [or1200_operandmuxes.v] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 746 lampret
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
////  OR1200's register file read operands mux                    ////
4
////                                                              ////
5
////  This file is part of the OpenRISC 1200 project              ////
6
////  http://www.opencores.org/cores/or1k/                        ////
7
////                                                              ////
8
////  Description                                                 ////
9
////  Mux for two register file read operands.                    ////
10
////                                                              ////
11
////  To Do:                                                      ////
12
////   - make it smaller and faster                               ////
13
////                                                              ////
14
////  Author(s):                                                  ////
15
////      - Damjan Lampret, lampret@opencores.org                 ////
16
////                                                              ////
17
//////////////////////////////////////////////////////////////////////
18
////                                                              ////
19
//// Copyright (C) 2000 Authors and OPENCORES.ORG                 ////
20
////                                                              ////
21
//// This source file may be used and distributed without         ////
22
//// restriction provided that this copyright statement is not    ////
23
//// removed from the file and that any derivative work contains  ////
24
//// the original copyright notice and the associated disclaimer. ////
25
////                                                              ////
26
//// This source file is free software; you can redistribute it   ////
27
//// and/or modify it under the terms of the GNU Lesser General   ////
28
//// Public License as published by the Free Software Foundation; ////
29
//// either version 2.1 of the License, or (at your option) any   ////
30
//// later version.                                               ////
31
////                                                              ////
32
//// This source is distributed in the hope that it will be       ////
33
//// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
34
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
35
//// PURPOSE.  See the GNU Lesser General Public License for more ////
36
//// details.                                                     ////
37
////                                                              ////
38
//// You should have received a copy of the GNU Lesser General    ////
39
//// Public License along with this source; if not, download it   ////
40
//// from http://www.opencores.org/lgpl.shtml                     ////
41
////                                                              ////
42
//////////////////////////////////////////////////////////////////////
43
//
44
// CVS Revision History
45
//
46
// $Log: not supported by cvs2svn $
47
// Revision 1.1  2002/01/03 08:16:15  lampret
48
// New prefixes for RTL files, prefixed module names. Updated cache controllers and MMUs.
49
//
50
// Revision 1.9  2001/11/12 01:45:40  lampret
51
// Moved flag bit into SR. Changed RF enable from constant enable to dynamic enable for read ports.
52
//
53
// Revision 1.8  2001/10/21 17:57:16  lampret
54
// Removed params from generic_XX.v. Added translate_off/on in sprs.v and id.v. Removed spr_addr from dc.v and ic.v. Fixed CR+LF.
55
//
56
// Revision 1.7  2001/10/14 13:12:09  lampret
57
// MP3 version.
58
//
59
// Revision 1.1.1.1  2001/10/06 10:18:36  igorm
60
// no message
61
//
62
// Revision 1.2  2001/08/09 13:39:33  lampret
63
// Major clean-up.
64
//
65
// Revision 1.1  2001/07/20 00:46:05  lampret
66
// Development version of RTL. Libraries are missing.
67
//
68
//
69
 
70
// synopsys translate_off
71
`include "timescale.v"
72
// synopsys translate_on
73
`include "or1200_defines.v"
74
 
75
module or1200_operandmuxes(
76
        // Clock and reset
77
        clk, rst,
78
 
79
        // Internal i/f
80
        id_freeze, ex_freeze, rf_dataa, rf_datab, ex_forw, wb_forw,
81
        simm, sel_a, sel_b, operand_a, operand_b, muxed_b
82
);
83
 
84
parameter width = `OR1200_OPERAND_WIDTH;
85
 
86
//
87
// I/O
88
//
89
input                           clk;
90
input                           rst;
91
input                           id_freeze;
92
input                           ex_freeze;
93
input   [width-1:0]              rf_dataa;
94
input   [width-1:0]              rf_datab;
95
input   [width-1:0]              ex_forw;
96
input   [width-1:0]              wb_forw;
97
input   [width-1:0]              simm;
98
input   [`OR1200_SEL_WIDTH-1:0]  sel_a;
99
input   [`OR1200_SEL_WIDTH-1:0]  sel_b;
100
output  [width-1:0]              operand_a;
101
output  [width-1:0]              operand_b;
102
output  [width-1:0]              muxed_b;
103
 
104
//
105
// Internal wires and regs
106
//
107
reg     [width-1:0]              operand_a;
108
reg     [width-1:0]              operand_b;
109
reg     [width-1:0]              muxed_a;
110
reg     [width-1:0]              muxed_b;
111
reg                             saved_a;
112
reg                             saved_b;
113
 
114
//
115
// Operand A register
116
//
117
always @(posedge clk or posedge rst) begin
118
        if (rst) begin
119
                operand_a <= #1 32'd0;
120
                saved_a <= #1 1'b0;
121
        end else if (!ex_freeze && id_freeze && !saved_a) begin
122
                operand_a <= #1 muxed_a;
123
                saved_a <= #1 1'b1;
124
        end else if (!ex_freeze && !saved_a) begin
125
                operand_a <= #1 muxed_a;
126
        end else if (!ex_freeze && !id_freeze)
127
                saved_a <= #1 1'b0;
128
end
129
 
130
//
131
// Operand B register
132
//
133
always @(posedge clk or posedge rst) begin
134
        if (rst) begin
135
                operand_b <= #1 32'd0;
136
                saved_b <= #1 1'b0;
137
        end else if (!ex_freeze && id_freeze && !saved_b) begin
138
                operand_b <= #1 muxed_b;
139
                saved_b <= #1 1'b1;
140
        end else if (!ex_freeze && !saved_b) begin
141
                operand_b <= #1 muxed_b;
142
        end else if (!ex_freeze && !id_freeze)
143
                saved_b <= #1 1'b0;
144
end
145
 
146
//
147
// Forwarding logic for operand A register
148
//
149
always @(ex_forw or wb_forw or rf_dataa or sel_a) begin
150
        casex (sel_a)   // synopsys full_case parallel_case infer_mux
151
                `OR1200_SEL_EX_FORW:
152
                        muxed_a = ex_forw;
153
                `OR1200_SEL_WB_FORW:
154
                        muxed_a = wb_forw;
155
                default:
156
                        muxed_a = rf_dataa;
157
        endcase
158
end
159
 
160
//
161
// Forwarding logic for operand B register
162
//
163
always @(simm or ex_forw or wb_forw or rf_datab or sel_b) begin
164
        casex (sel_b)   // synopsys full_case parallel_case infer_mux
165
                `OR1200_SEL_IMM:
166
                        muxed_b = simm;
167
                `OR1200_SEL_EX_FORW:
168
                        muxed_b = ex_forw;
169
                `OR1200_SEL_WB_FORW:
170
                        muxed_b = wb_forw;
171
                default:
172
                        muxed_b = rf_datab;
173
        endcase
174
end
175
 
176
endmodule

powered by: WebSVN 2.1.0

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