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

Subversion Repositories mips32r1

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

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

Line No. Rev Author Line
1 2 ayersg
`timescale 1ns / 1ps
2
/*
3
 * File         : IFID_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 Instruction Fetch
17
 *   and Instruction Decode stages.
18
 */
19
module IFID_Stage(
20
        input  clock,
21
        input  reset,
22
        input  IF_Flush,
23
    input  IF_Stall,
24
        input  ID_Stall,
25
        // Control Signals
26
        input  [31:0] IF_Instruction,
27
        // Data Signals
28
        input  [31:0] IF_PCAdd4,
29
    input  [31:0] IF_PC,
30
    input  IF_IsBDS,
31
        // ------------------
32
        output reg [31:0] ID_Instruction,
33
        output reg [31:0] ID_PCAdd4,
34
    output reg [31:0] ID_RestartPC,
35
    output reg ID_IsBDS,
36
    output reg ID_IsFlushed
37
        );
38
 
39
    /***
40
     The purpose of a pipeline register is to capture data from one pipeline stage
41
     and provide it to the next pipeline stage. This creates at least one clock cycle
42
     of delay, but reduces the combinatorial path length of signals which allows for
43
     higher clock speeds.
44
 
45
     All pipeline registers update unless the forward stage is stalled. When this occurs
46
     or when the current stage is being flushed, the forward stage will receive data that
47
     is effectively a NOP and causes nothing to happen throughout the remaining pipeline
48
     traversal. In other words:
49
 
50
     A stall masks all control signals to forward stages. A flush permanently clears
51
     control signals to forward stages (but not certain data for exception purposes).
52
    ***/
53
 
54
 
55
    /***
56
     The signal 'ID_IsFlushed' is needed because of interrupts. Normally, a flushed instruction
57
     is a NOP which will never cause an exception and thus its restart PC will never be needed
58
     or used. However, interrupts are detected in ID and may occur when any instruction, flushed
59
     or not, is in the ID stage. It is an error to save the restart PC of a flushed instruction
60
     since it was never supposed to execute (such as the "delay slot" after ERET or the branch
61
     delay slot after a canceled Branch Likely instruction). A simple way to prevent this is to
62
     pass a signal to ID indicating that its instruction was flushed. Interrupt detection is then
63
     masked when this signal is high, and the interrupt will trigger on the next instruction load to ID.
64
    ***/
65
 
66
    always @(posedge clock) begin
67
        ID_Instruction <= (reset) ? 32'b0 : ((ID_Stall) ? ID_Instruction : ((IF_Stall | IF_Flush) ? 32'b0 : IF_Instruction));
68
        ID_PCAdd4      <= (reset) ? 32'b0 : ((ID_Stall) ? ID_PCAdd4                                       : IF_PCAdd4);
69
        ID_IsBDS       <= (reset) ? 0     : ((ID_Stall) ? ID_IsBDS                                        : IF_IsBDS);
70
        ID_RestartPC   <= (reset) ? 32'b0 : ((ID_Stall | IF_IsBDS) ? ID_RestartPC                         : IF_PC);
71
        ID_IsFlushed   <= (reset) ? 0     : ((ID_Stall) ? ID_IsFlushed                                    : IF_Flush);
72
    end
73
 
74
endmodule

powered by: WebSVN 2.1.0

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