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

Subversion Repositories fluid_core_2

[/] [fluid_core_2/] [trunk/] [rtl/] [IF_Stage.v] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 azmathmoos
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
//// Copyright (C) 2014-2015 Azmath Moosa                         ////
4
////                                                              ////
5
//// This source file may be used and distributed without         ////
6
//// restriction provided that this copyright statement is not    ////
7
//// removed from the file and that any derivative work contains  ////
8
//// the original copyright notice and the associated disclaimer. ////
9
////                                                              ////
10
//// This source file is free software; you can redistribute it   ////
11
//// and/or modify it under the terms of the GNU Lesser General   ////
12
//// Public License as published by the Free Software Foundation; ////
13
//// either version 3 of the License, or (at your option) any     ////
14
//// later version.                                               ////
15
////                                                              ////
16
//// This source is distributed in the hope that it will be       ////
17
//// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
18
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
19
//// PURPOSE.  See the GNU Lesser General Public License for more ////
20
//// details.                                                     ////
21
////                                                              ////
22
//// You should have received a copy of the GNU Lesser General    ////
23
//// Public License along with this source; if not, download it   ////
24
//// from http://www.opencores.org/lgpl.shtml                     ////
25
////                                                              ////
26
//////////////////////////////////////////////////////////////////////
27
`timescale 1ns / 1ps
28
`include "Configuration.v"
29
 
30
module IF_Stage(
31
        input Clk,
32
        input RST,
33
        input stall,
34
        input intr,
35
        input return_back,
36
        input [0:`pc_w] intr_vector,
37
        input [0:`inst_w] exInstruction,
38
        input [0:`pc_w] branch_target,
39
        input branch, linked,
40
        inout [0:3] stkFlag,
41
        output [0:`pc_w] exInstAddr,
42
        output exInstClk,
43
        output [0:`IF_ID_reg_w] IF_ID_reg
44
    );
45
 
46
 
47
        reg [0:`pc_w] PC;
48
        reg [0:`inst_w] IR;
49
        reg [0:`pc_w+4] PCStack [0:3];
50
        reg [0:1] PCStackPtr;
51
        reg HLT;
52
 
53
initial begin
54
PC <= 0;
55
IR <=0;
56
PCStackPtr <= 0;
57
end
58
 
59
always@ (posedge Clk) begin
60
        if (RST) begin
61
                PC <=0;
62
                IR <= 0;
63
                PCStackPtr <= 0;
64
                HLT <= 0;
65
        end else if (~HLT) begin
66
 
67
                if (intr) begin
68
                PCStack[PCStackPtr] <= {PC,stkFlag};
69
                PCStackPtr <= PCStackPtr + 1;
70
                PC <= intr_vector;
71
                end else if (branch) begin
72
                        if (linked) begin
73
                        PCStack[PCStackPtr] <= {PC+1,stkFlag};
74
                        PCStackPtr <= PCStackPtr + 1;
75
                        end
76
                PC <= branch_target;
77
                end else if (return_back) begin
78
                PCStackPtr <= PCStackPtr - 1;
79
                PC <= PCStack[PCStackPtr-1][0:`pc_w];
80
                end else if (~stall) begin
81
                PC <= PC + 1;
82
                IR <= exInstruction;
83
                HLT <= &exInstruction[0:`uop_vector_msb];
84
                end
85
 
86
        end
87
end
88
 
89
assign stkFlag = return_back ? PCStack[PCStackPtr][`pc_w+1:`pc_w+4]:'bz;
90
 
91
assign exInstAddr = PC;
92
assign exInstClk = Clk;
93
 
94
assign IF_ID_reg = IR;
95
 
96
endmodule

powered by: WebSVN 2.1.0

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