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

Subversion Repositories mips32

[/] [mips32/] [trunk/] [Classic-MIPS/] [source/] [src/] [PipelineMIPS.v] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 jjf
`timescale 1ns / 1ps
2
//////////////////////////////////////////////////////////////////////////////////
3
// Company: 
4
// Engineer: 
5
// 
6
// Create Date: 2017/01/11 19:01:08
7
// Design Name: 
8
// Module Name: PipelineMIPS
9
// Project Name: 
10
// Target Devices: 
11
// Tool Versions: 
12
// Description: 
13
// 
14
// Dependencies: 
15
// 
16
// Revision:
17
// Revision 0.01 - File Created
18
// Additional Comments:
19
// 
20
//////////////////////////////////////////////////////////////////////////////////
21
 
22
 
23
module PipelineMIPS(
24
input wire                  clk,
25
input wire                  rst,
26
output wire [31:0]          pc,
27
input wire [31:0]           instruction,
28
input wire [12:0]                    user_addr,
29
input wire                  user_we,
30
input wire [31:0]           user_din,
31
output wire [31:0]                user_dout
32
    );
33
 
34
    /* the IF stage */
35
    wire [31:0]             if_reg_pc;
36
    wire [31:0]             if_reg_instruction;
37
    wire [1:0]              if_reg_bht_token;
38
 
39
    /* the ID stage */
40
     wire [31:0]             id_reg1_data;
41
     wire [31:0]             id_reg2_data;
42
     wire [31:0]             id_reg_immediate;
43
     wire [4:0]              id_reg_rt;
44
     wire [4:0]              id_reg_rd;
45
     wire [31:0]             id_reg_pc;
46
     wire [31:0]             id_reg_instruction;
47
     wire [3:0]              id_reg_ctr_ex;
48
     wire [5:0]              id_reg_ctr_m;
49
     wire [1:0]              id_reg_ctr_wb;
50
     wire                    isHazard;
51
     wire [1:0]              id_reg_forward_a;
52
     wire [1:0]              id_reg_forward_b;
53
     wire [3:0]              id_reg_ALUcmd;
54
     wire [1:0]              id_reg_bht_token;
55
 
56
     /* the EX stage */
57
     wire [31:0]             ex_reg_ALU_out;
58
     wire [31:0]             ex_reg_reg2_data;
59
     wire [4:0]              ex_reg_write_reg;
60
     wire [5:0]              ex_reg_ctr_m;
61
     wire [1:0]              ex_reg_ctr_wb;
62
     wire [4:0]              ex_write_reg;
63
     wire                    ex_regwrite_flag;
64
     wire [1:0]              ex_reg_bht_token;
65
     wire [31:0]             ex_reg_pc;
66
 
67
 
68
     /* the MEM stage */
69
     wire [31:0]             m_reg_mem_out;
70
     wire [31:0]             m_reg_ALU_out;
71
     wire [4:0]              m_reg_write_reg;
72
     wire [1:0]              m_reg_ctr_wb;
73
     wire                    isFlush;
74
     wire [31:0]             pc_branch;
75
     wire [31:0]             pc_jump;
76
     wire [31:0]             pc_next;
77
     wire                    real_token;
78
     wire                    jump_token;
79
     wire                    isCacheStall;
80
     wire [9:0]              bht_write_addr;
81
     wire                    bht_we;
82
     wire [33:0]             bht_din;
83
 
84
     /* the WB stage */
85
     wire [31:0]             wb_write_data;
86
     wire                    wb_regwrite_flag;
87
 
88
     assign pc = if_reg_pc;
89
    /* the IF stage */
90
    fetch fetch_inst(
91
        .clk(               clk                 ),
92
        .rst(               rst                 ),
93
        .instruction(       instruction         ),
94
        .pc_branch(         pc_branch           ),
95
        .pc_jump(           pc_jump             ),
96
        .pc_next(           pc_next             ),
97
        .real_token(        real_token          ),
98
        .jump_token(        jump_token          ),
99
        .isHazard(          isHazard            ),
100
        .isFlush(           isFlush             ),
101
        .isCacheStall(      isCacheStall        ),
102
        .reg_pc(            if_reg_pc           ),
103
        .reg_instruction(   if_reg_instruction  ),
104
        .reg_bht_token(     if_reg_bht_token    ),
105
        .bht_write_addr(    bht_write_addr      ),
106
        .bht_we(            bht_we              ),
107
        .bht_din(           bht_din             )
108
    );
109
 
110
 
111
    /* the ID stage */
112
    decode decode_inst(
113
        .clk(               clk                 ),
114
        .rst(               rst                 ),
115
        .pc(                if_reg_pc           ),
116
        .instruction(       if_reg_instruction  ),
117
        .regwrite_flag(     wb_regwrite_flag    ),
118
        .write_reg(         m_reg_write_reg     ),
119
        .write_data(        wb_write_data       ),
120
        .isFlush(           isFlush             ),
121
        .isCacheStall(      isCacheStall        ),
122
        .reg1_data(         id_reg1_data        ),
123
        .reg2_data(         id_reg2_data        ),
124
        .reg_immediate(     id_reg_immediate    ),
125
        .reg_instruction(   id_reg_instruction  ),
126
        .reg_rt(            id_reg_rt           ),
127
        .reg_rd(            id_reg_rd           ),
128
        .reg_pc(            id_reg_pc           ),
129
        .reg_ctr_ex(        id_reg_ctr_ex       ),
130
        .reg_ctr_m(         id_reg_ctr_m        ),
131
        .reg_ctr_wb(        id_reg_ctr_wb       ),
132
        .isHazard(          isHazard            ),
133
        .ex_write_reg(      ex_write_reg        ),
134
        .ex_regwrite_flag(  ex_regwrite_flag    ),
135
        .mem_write_reg(     ex_reg_write_reg    ),
136
        .mem_regwrite_flag( ex_reg_ctr_wb[1]    ),
137
        .reg_forward_a(     id_reg_forward_a    ),
138
        .reg_forward_b(     id_reg_forward_b    ),
139
        .reg_ALUcmd(        id_reg_ALUcmd       ),
140
        .bht_token(         if_reg_bht_token    ),
141
        .reg_bht_token(     id_reg_bht_token    )
142
    );
143
 
144
 
145
    /* the EX stage */
146
    execute execute_inst(
147
        .clk(               clk                 ),
148
        .rst(               rst                 ),
149
        .ctr_ex(            id_reg_ctr_ex       ),
150
        .ctr_m(             id_reg_ctr_m        ),
151
        .ctr_wb(            id_reg_ctr_wb       ),
152
        .pc(                id_reg_pc           ),
153
        .instruction(       id_reg_instruction  ),
154
        .reg1_data(         id_reg1_data        ),
155
        .reg2_data(         id_reg2_data        ),
156
        .immediate(         id_reg_immediate    ),
157
        .rt(                id_reg_rt           ),
158
        .rd(                id_reg_rd           ),
159
        .isFlush(           isFlush             ),
160
        .isCacheStall(      isCacheStall        ),
161
        .ALUcmd(            id_reg_ALUcmd       ),
162
        .reg_ALU_out(       ex_reg_ALU_out      ),
163
        .reg_reg2_data(     ex_reg_reg2_data    ),
164
        .reg_write_reg(     ex_reg_write_reg    ),
165
        .reg_ctr_m(         ex_reg_ctr_m        ),
166
        .reg_ctr_wb(        ex_reg_ctr_wb       ),
167
        .ex_mem_data(       ex_reg_ALU_out      ),
168
        .mem_wb_data(       wb_write_data       ),
169
        .forward_a(         id_reg_forward_a    ),
170
        .forward_b(         id_reg_forward_b    ),
171
        .ex_write_reg(      ex_write_reg        ),
172
        .ex_regwrite_flag(  ex_regwrite_flag    ),
173
        .bht_token(         id_reg_bht_token    ),
174
        .reg_bht_token(     ex_reg_bht_token    ),
175
        .reg_pc(            ex_reg_pc           ),
176
        .reg_pc_branch(     pc_branch           ),
177
        .reg_pc_jump(       pc_jump             ),
178
        .reg_pc_next(       pc_next             )
179
    );
180
 
181
    /* the MEM stage */
182
    mem     mem_inst(
183
        .clk(               clk                 ),
184
        .rst(               rst                 ),
185
        .ctr_m(             ex_reg_ctr_m        ),
186
        .ctr_wb(            ex_reg_ctr_wb       ),
187
        .ALU_out(           ex_reg_ALU_out      ),
188
        .reg2_data(         ex_reg_reg2_data    ),
189
        .write_reg(         ex_reg_write_reg    ),
190
        .reg_mem_out(       m_reg_mem_out       ),
191
        .reg_ALU_out(       m_reg_ALU_out       ),
192
        .reg_write_reg(     m_reg_write_reg     ),
193
        .reg_ctr_wb(        m_reg_ctr_wb        ),
194
        .isFlush(           isFlush             ),
195
        .isCacheStall(      isCacheStall        ),
196
        .pc(                ex_reg_pc           ),
197
        .pc_branch(         pc_branch           ),
198
        .pc_jump(           pc_jump             ),
199
        .real_token(        real_token          ),
200
        .jump_token(        jump_token          ),
201
        .bht_token(         ex_reg_bht_token    ),
202
        .bht_write_addr(    bht_write_addr      ),
203
        .bht_we(            bht_we              ),
204
        .bht_din(           bht_din             ),
205
        .user_addr(         user_addr           ),
206
        .user_we(           user_we             ),
207
        .user_din(          user_din            ),
208
        .user_dout(         user_dout           )
209
    );
210
 
211
    /* the WB stage */
212
    writeback   writeback_inst(
213
        .ctr_wb(            m_reg_ctr_wb        ),
214
        .mem_out(           m_reg_mem_out       ),
215
        .ALU_out(           m_reg_ALU_out       ),
216
        .write_data(        wb_write_data       ),
217
        .regwrite_flag(     wb_regwrite_flag    )
218
    );
219
 
220
 
221
endmodule

powered by: WebSVN 2.1.0

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