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

Subversion Repositories mips32r1

[/] [mips32r1/] [trunk/] [Hardware/] [XUPV5-LX110T_SoC/] [MIPS32-Pipelined-Hw/] [src/] [MIPS32/] [MEMWB_Stage.v] - Blame information for rev 3

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 ayersg
`timescale 1ns / 1ps
2
/*
3
 * File         : MEMWB_Stage.v
4
 * Project      : University of Utah, XUM Project MIPS32 core
5
 * Creator(s)   : Grant Ayers (ayers@cs.utah.edu)
6
 *
7
 * Modification History:
8
 *   Rev   Date         Initials  Description of Change
9
 *   1.0   9-Jun-2011   GEA       Initial design.
10
 *   2.0   26-Jul-2012  GEA       Many updates have been made.
11
 *
12
 * Standards/Formatting:
13
 *   Verilog 2001, 4 soft tab, wide column.
14
 *
15
 * Description:
16
 *   The Pipeline Register to bridge the Memory and Writeback stages.
17
 */
18
module MEMWB_Stage(
19 3 ayersg
    input  clock,
20
    input  reset,
21 2 ayersg
    input  M_Flush,
22
    input  M_Stall,
23 3 ayersg
    input  WB_Stall,
24
    // Control Signals
25
    input  M_RegWrite,
26
    input  M_MemtoReg,
27
    // Data Signals
28
    input  [31:0] M_ReadData,
29
    input  [31:0] M_ALU_Result,
30
    input  [4:0]  M_RtRd,
31
    // ----------------
32
    output reg WB_RegWrite,
33
    output reg WB_MemtoReg,
34
    output reg [31:0] WB_ReadData,
35
    output reg [31:0] WB_ALU_Result,
36
    output reg [4:0]  WB_RtRd
37
    );
38 2 ayersg
 
39 3 ayersg
 
40 2 ayersg
    /***
41
     The purpose of a pipeline register is to capture data from one pipeline stage
42
     and provide it to the next pipeline stage. This creates at least one clock cycle
43
     of delay, but reduces the combinatorial path length of signals which allows for
44
     higher clock speeds.
45
 
46
     All pipeline registers update unless the forward stage is stalled. When this occurs
47
     or when the current stage is being flushed, the forward stage will receive data that
48
     is effectively a NOP and causes nothing to happen throughout the remaining pipeline
49
     traversal. In other words:
50
 
51
     A stall masks all control signals to forward stages. A flush permanently clears
52
     control signals to forward stages (but not certain data for exception purposes).
53
 
54
     Since WB is the final stage in the pipeline, it would normally never stall.
55
     However, because the MEM stage may be using data forwarded from WB, WB must stall
56
     when MEM is stalled. If it didn't, the forward data would not be preserved. If
57
     the processor didn't forward any data, a stall would not be needed.
58
 
59
     In practice, the only time WB stalls is when forwarding for a Lw->Sw sequence, since
60
     MEM doesn't need the data until its stage, but it does not latch the forwarded data.
61
     This means WB_Stall is probably identical to M_Stall. There is no speed difference by
62
     allowing WB to stall.
63
    ***/
64
 
65
    always @(posedge clock) begin
66
        WB_RegWrite   <= (reset) ? 0     : ((WB_Stall) ? WB_RegWrite   : ((M_Stall | M_Flush) ? 0 : M_RegWrite));
67
        WB_MemtoReg   <= (reset) ? 0     : ((WB_Stall) ? WB_MemtoReg                              : M_MemtoReg);
68
        WB_ReadData   <= (reset) ? 32'b0 : ((WB_Stall) ? WB_ReadData                              : M_ReadData);
69
        WB_ALU_Result <= (reset) ? 32'b0 : ((WB_Stall) ? WB_ALU_Result                            : M_ALU_Result);
70
        WB_RtRd       <= (reset) ? 5'b0  : ((WB_Stall) ? WB_RtRd                                  : M_RtRd);
71
    end
72
 
73
endmodule
74 3 ayersg
 

powered by: WebSVN 2.1.0

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