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

Subversion Repositories mips_enhanced

[/] [mips_enhanced/] [trunk/] [grlib-gpl-1.0.19-b3188/] [lib/] [gaisler/] [vlog/] [forward.v] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 dimamali
/******************************************************************
2
 *                                                                *
3
 *    Author: Liwei                                               *
4
 *                                                                *
5
 *    This file is part of the "mips789" project.                 *
6
 *    Downloaded from:                                            *
7
 *    http://www.opencores.org/pdownloads.cgi/list/mips789        *
8
 *                                                                *
9
 *    If you encountered any problem, please contact me via       *
10
 *    Email:mcupro@opencores.org  or mcupro@163.com               *
11
 *                                                                *
12
 ******************************************************************/
13
 
14
`include "mips789_defs.v"
15
 
16
 
17
module fw_latch5(input clk,input[4:0]d,input hold,output reg  [4:0]q);
18
    always @ (posedge clk) if (hold==1) q<=d; else ;
19
endmodule
20
 
21
module fw_latch1(input clk,input d,input hold,output reg q);
22
    always @ (posedge clk) if(hold==1) q<=d; else ;
23
endmodule
24
 
25
module forward_node (
26
        input [4:0]rn,
27
        input [4:0]alu_wr_rn,
28
        input alu_we,
29
        input [4:0]mem_wr_rn,
30
        input mem_we,
31
        output  wire[2:0]mux_fw
32
    );
33
    assign mux_fw = ((alu_we)&&(alu_wr_rn==rn)&&(alu_wr_rn!=0))?`FW_ALU:
34
           ((mem_we)&&(mem_wr_rn==rn)&&(mem_wr_rn!=0))?`FW_MEM:
35
           `FW_NOP;
36
endmodule
37
 
38
module fwd_mux(
39
        input [31:0]din,
40
        output reg [31:0]dout,
41
        input [31:0]fw_alu       ,
42
        input [2:0]fw_ctl,
43
        input [31:0]fw_dmem
44
    );
45
    always@(*)
46
    case (fw_ctl)
47
        `FW_ALU :dout=fw_alu;
48
        `FW_MEM :dout=fw_dmem;
49
         default
50
            /*`FW_NOP :dout=din;*/
51
         dout=din;
52
    endcase
53
endmodule
54
 
55
module forward  (
56
alu_we,clk,mem_We,fw_alu_rn,
57
fw_mem_rn,rns_i,rnt_i,alu_rs_fw,
58
alu_rt_fw,cmp_rs_fw,cmp_rt_fw,dmem_fw,hold
59
) ;
60
 
61
    input alu_we;
62
    wire alu_we;
63
    input clk;
64
    wire clk;
65
    input mem_We;
66
    wire mem_We;
67
    input [4:0] fw_alu_rn;
68
    wire [4:0] fw_alu_rn;
69
    input [4:0] fw_mem_rn;
70
    wire [4:0] fw_mem_rn;
71
    input [4:0] rns_i;
72
    wire [4:0] rns_i;
73
    input [4:0] rnt_i;
74
    wire [4:0] rnt_i;
75
    output [2:0] alu_rs_fw;
76
    wire [2:0] alu_rs_fw;
77
    output [2:0] alu_rt_fw;
78
    wire [2:0] alu_rt_fw;
79
    output [2:0] cmp_rs_fw;
80
    wire [2:0] cmp_rs_fw;
81
    output [2:0] cmp_rt_fw;
82
    wire [2:0] cmp_rt_fw;
83
    output [2:0] dmem_fw;
84
    wire [2:0] dmem_fw;
85
         input hold;
86
         wire hold;
87
 
88
    wire [2:0] BUS1345;
89
    wire [4:0] BUS82;
90
    wire [4:0] BUS937;
91
 
92
    forward_node fw_alu_rs
93
                 (
94
                     .alu_we(alu_we),
95
                     .alu_wr_rn(fw_alu_rn),
96
                     .mem_we(mem_We),
97
                     .mem_wr_rn(fw_mem_rn),
98
                     .mux_fw(alu_rs_fw),
99
                     .rn(BUS82)
100
                 );
101
 
102
 
103
 
104
    forward_node fw_alu_rt
105
                 (
106
                     .alu_we(alu_we),
107
                     .alu_wr_rn(fw_alu_rn),
108
                     .mem_we(mem_We),
109
                     .mem_wr_rn(fw_mem_rn),
110
                     .mux_fw(BUS1345),
111
                     .rn(BUS937)
112
                 );
113
 
114
 
115
 
116
    forward_node fw_cmp_rs
117
                 (
118
                     .alu_we(alu_we),
119
                     .alu_wr_rn(fw_alu_rn),
120
                     .mem_we(mem_We),
121
                     .mem_wr_rn(fw_mem_rn),
122
                     .mux_fw(cmp_rs_fw),
123
                     .rn(rns_i)
124
                 );
125
 
126
 
127
 
128
    forward_node fw_cmp_rt
129
                 (
130
                     .alu_we(alu_we),
131
                     .alu_wr_rn(fw_alu_rn),
132
                     .mem_we(mem_We),
133
                     .mem_wr_rn(fw_mem_rn),
134
                     .mux_fw(cmp_rt_fw),
135
                     .rn(rnt_i)
136
                 );
137
 
138
 
139
 
140
    fw_latch5 fw_reg_rns
141
              (   .hold(hold),
142
                  .clk(clk),
143
                  .d(rns_i),
144
                  .q(BUS82)
145
              );
146
 
147
 
148
 
149
    fw_latch5 fw_reg_rnt
150
              (.hold(hold),
151
                  .clk(clk),
152
                  .d(rnt_i),
153
                  .q(BUS937)
154
              );
155
 
156
 
157
    assign alu_rt_fw[2:0] = BUS1345[2:0];
158
    assign dmem_fw[2:0] = BUS1345[2:0];
159
 
160
endmodule
161
 
162
 

powered by: WebSVN 2.1.0

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