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

Subversion Repositories openfire2

[/] [openfire2/] [trunk/] [rtl/] [openfire_fetch.v] - Blame information for rev 8

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

Line No. Rev Author Line
1 3 toni32
/*      MODULE: openfire_fetch
2
 
3
        DESCRIPTION: The fetch module interfaces with the instruction memory and
4
fetches the next instruction.
5
 
6
TO DO:
7
- Add prefetch buffer
8
- Add LMB interface
9
 
10
AUTHOR:
11
Stephen Douglas Craven
12
Configurable Computing Lab
13
Virginia Tech
14
scraven@vt.edu
15
 
16
REVISION HISTORY:
17
Revision 0.2, 8/10/2005 SDC
18
Initial release
19
 
20
Revision 0.3, 12/17/2005 SDC
21
Fixed PC size bug
22
 
23
Revision 0.4  27/03/2007 Antonio J Anton
24
Instruction port wait states
25
 
26
COPYRIGHT:
27
Copyright (c) 2005 Stephen Douglas Craven
28
 
29
Permission is hereby granted, free of charge, to any person obtaining a copy of
30
this software and associated documentation files (the "Software"), to deal in
31
the Software without restriction, including without limitation the rights to
32
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
33
of the Software, and to permit persons to whom the Software is furnished to do
34
so, subject to the following conditions:
35
 
36
The above copyright notice and this permission notice shall be included in all
37
copies or substantial portions of the Software.
38
 
39
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
40
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
41
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
42
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
43
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
44
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
45
SOFTWARE. */
46
 
47
`include "openfire_define.v"
48
 
49
module openfire_fetch(
50
        stall, clock, reset,                                                                    // top level
51
        branch_taken, pc_branch, idata,                                         // inputs
52
        instruction, imem_addr, pc_decode, imem_re              // outputs
53
);
54
 
55
// From top level -- all active high unless otherwise noted
56
input           stall;
57
input           reset;
58
input           clock;
59
 
60
// From EXECUTE module
61
input                   branch_taken;   // strobe for latching in new pc
62
// PCs are A_SPACE + 1 because lower 2 bits are always zero
63
//      A_SPACE is addr space in words ... 2^A_SPACE * 4 = # Bytes
64
input   [`A_SPACE+1:0]   pc_branch;      // PC of branch
65
 
66
// From Instr Mem
67
input   [31:0]           idata;
68
 
69
output  [31:0]           imem_addr;
70
output                                  imem_re;
71
output  [`A_SPACE+1:0]   pc_decode;
72
output  [31:0]           instruction;
73
 
74
reg     [`A_SPACE+1:0]   pc_fetch;       // PCs only need to contain addressable instr mem
75
reg     [`A_SPACE+1:0]   pc_decode;      // delayed PC for DECODE
76
reg     [31:0]                   instruction;
77
reg                                             imem_re;
78
 
79
assign imem_addr[31:`A_SPACE+2] = 0;     // pad unused bits with zeros, 
80
assign imem_addr[`A_SPACE+1:0]  = pc_fetch;
81
 
82
always@(posedge clock)
83
begin
84
        if (reset)
85
        begin
86 4 toni32
                pc_fetch         <= `RESET_PC_ADDRESS;
87
                pc_decode        <= `RESET_PC_ADDRESS;
88 3 toni32
                imem_re          <= 1;
89
                instruction  <= `NoOp;          // Execute NoOp on reset
90
        end
91
        else
92
        begin                                                                   // update PC to branch or increment pc (if stall --> pc on hold)
93
                if(!stall)
94
                begin
95
                  pc_fetch        <= branch_taken ? pc_branch : pc_fetch + 4;
96
                  pc_decode   <= pc_fetch;
97
                  instruction <= idata;
98
`ifdef DEBUG_FETCH
99
                  $display("FETCH : pc_fetch=%x, pc_decode=%x, instruction=%x", pc_fetch, pc_decode, instruction);
100
`endif
101
                end
102
                imem_re <= !stall;
103
        end
104
end
105
 
106
endmodule

powered by: WebSVN 2.1.0

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