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

Subversion Repositories or1k

[/] [or1k/] [tags/] [rel_26/] [or1200/] [rtl/] [verilog/] [or1200_operandmuxes.v] - Blame information for rev 504

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

Line No. Rev Author Line
1 504 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.9  2001/11/12 01:45:40  lampret
48
// Moved flag bit into SR. Changed RF enable from constant enable to dynamic enable for read ports.
49
//
50
// Revision 1.8  2001/10/21 17:57:16  lampret
51
// 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.
52
//
53
// Revision 1.7  2001/10/14 13:12:09  lampret
54
// MP3 version.
55
//
56
// Revision 1.1.1.1  2001/10/06 10:18:36  igorm
57
// no message
58
//
59
// Revision 1.2  2001/08/09 13:39:33  lampret
60
// Major clean-up.
61
//
62
// Revision 1.1  2001/07/20 00:46:05  lampret
63
// Development version of RTL. Libraries are missing.
64
//
65
//
66
 
67
// synopsys translate_off
68
`include "timescale.v"
69
// synopsys translate_on
70
`include "or1200_defines.v"
71
 
72
module or1200_operandmuxes(
73
        // Clock and reset
74
        clk, rst,
75
 
76
        // Internal i/f
77
        id_freeze, ex_freeze, rf_dataa, rf_datab, ex_forw, wb_forw,
78
        simm, sel_a, sel_b, operand_a, operand_b, muxed_b
79
);
80
 
81
parameter width = `OR1200_OPERAND_WIDTH;
82
 
83
//
84
// I/O
85
//
86
input                           clk;
87
input                           rst;
88
input                           id_freeze;
89
input                           ex_freeze;
90
input   [width-1:0]              rf_dataa;
91
input   [width-1:0]              rf_datab;
92
input   [width-1:0]              ex_forw;
93
input   [width-1:0]              wb_forw;
94
input   [width-1:0]              simm;
95
input   [`OR1200_SEL_WIDTH-1:0]  sel_a;
96
input   [`OR1200_SEL_WIDTH-1:0]  sel_b;
97
output  [width-1:0]              operand_a;
98
output  [width-1:0]              operand_b;
99
output  [width-1:0]              muxed_b;
100
 
101
//
102
// Internal wires and regs
103
//
104
reg     [width-1:0]              operand_a;
105
reg     [width-1:0]              operand_b;
106
reg     [width-1:0]              muxed_a;
107
reg     [width-1:0]              muxed_b;
108
reg                             saved_a;
109
reg                             saved_b;
110
 
111
//
112
// Operand A register
113
//
114
always @(posedge clk or posedge rst) begin
115
        if (rst) begin
116
                operand_a <= #1 32'd0;
117
                saved_a <= #1 1'b0;
118
        end else if (!ex_freeze && id_freeze && !saved_a) begin
119
                operand_a <= #1 muxed_a;
120
                saved_a <= #1 1'b1;
121
        end else if (!ex_freeze && !saved_a) begin
122
                operand_a <= #1 muxed_a;
123
        end else if (!ex_freeze && !id_freeze)
124
                saved_a <= #1 1'b0;
125
end
126
 
127
//
128
// Operand B register
129
//
130
always @(posedge clk or posedge rst) begin
131
        if (rst) begin
132
                operand_b <= #1 32'd0;
133
                saved_b <= #1 1'b0;
134
        end else if (!ex_freeze && id_freeze && !saved_b) begin
135
                operand_b <= #1 muxed_b;
136
                saved_b <= #1 1'b1;
137
        end else if (!ex_freeze && !saved_b) begin
138
                operand_b <= #1 muxed_b;
139
        end else if (!ex_freeze && !id_freeze)
140
                saved_b <= #1 1'b0;
141
end
142
 
143
//
144
// Forwarding logic for operand A register
145
//
146
always @(ex_forw or wb_forw or rf_dataa or sel_a) begin
147
        casex (sel_a)   // synopsys full_case parallel_case infer_mux
148
                `OR1200_SEL_EX_FORW:
149
                        muxed_a = ex_forw;
150
                `OR1200_SEL_WB_FORW:
151
                        muxed_a = wb_forw;
152
                default:
153
                        muxed_a = rf_dataa;
154
        endcase
155
end
156
 
157
//
158
// Forwarding logic for operand B register
159
//
160
always @(simm or ex_forw or wb_forw or rf_datab or sel_b) begin
161
        casex (sel_b)   // synopsys full_case parallel_case infer_mux
162
                `OR1200_SEL_IMM:
163
                        muxed_b = simm;
164
                `OR1200_SEL_EX_FORW:
165
                        muxed_b = ex_forw;
166
                `OR1200_SEL_WB_FORW:
167
                        muxed_b = wb_forw;
168
                default:
169
                        muxed_b = rf_datab;
170
        endcase
171
end
172
 
173
endmodule

powered by: WebSVN 2.1.0

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