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

Subversion Repositories ao486

[/] [ao486/] [trunk/] [rtl/] [ao486/] [memory/] [prefetch.v] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 alfik
/*
2
 * Copyright (c) 2014, Aleksander Osman
3
 * All rights reserved.
4
 *
5
 * Redistribution and use in source and binary forms, with or without
6
 * modification, are permitted provided that the following conditions are met:
7
 *
8
 * * Redistributions of source code must retain the above copyright notice, this
9
 *   list of conditions and the following disclaimer.
10
 *
11
 * * Redistributions in binary form must reproduce the above copyright notice,
12
 *   this list of conditions and the following disclaimer in the documentation
13
 *   and/or other materials provided with the distribution.
14
 *
15
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18
 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
19
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
21
 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
22
 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
23
 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
24
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25
 */
26
 
27
`include "defines.v"
28
 
29
module prefetch(
30
    input               clk,
31
    input               rst_n,
32
 
33
    input               pr_reset,
34
 
35
    input       [1:0]   prefetch_cpl,
36
    input       [31:0]  prefetch_eip,
37
    input       [63:0]  cs_cache,
38
 
39
    //to tlb
40
    output      [31:0]  prefetch_address,
41
    output      [4:0]   prefetch_length,
42
    output              prefetch_su,
43
 
44
    //RESP:
45
    input               prefetched_do,
46
    input       [4:0]   prefetched_length,
47
    //END
48
 
49
    output              prefetchfifo_signal_limit_do
50
);
51
 
52
//------------------------------------------------------------------------------
53
 
54
reg [31:0] linear;
55
reg [31:0] limit;
56
reg        limit_signaled;
57
 
58
//------------------------------------------------------------------------------
59
 
60
wire [4:0] length;
61
 
62
wire [31:0] cs_base;
63
wire [31:0] cs_limit;
64
 
65
assign cs_base     = { cs_cache[63:56], cs_cache[39:16] };
66
assign cs_limit    = cs_cache[`DESC_BIT_G]? { cs_cache[51:48], cs_cache[15:0], 12'hFFF } : { 12'd0, cs_cache[51:48], cs_cache[15:0] };
67
 
68
//------------------------------------------------------------------------------
69
assign prefetch_su = prefetch_cpl == 2'd3; //0=supervisor; 1=user
70
 
71
assign prefetch_address = linear;
72
 
73
assign prefetch_length = (limit > 32'd16)? 5'd16 : limit[4:0];
74
 
75
assign length = (limit < {  27'd0, prefetched_length })? limit[4:0] : prefetched_length;
76
 
77
assign prefetchfifo_signal_limit_do = limit == 32'd0 && limit_signaled == `FALSE;
78
 
79
//------------------------------------------------------------------------------
80
 
81
always @(posedge clk or negedge rst_n) begin
82
    if(rst_n == 1'b0)       limit <= `STARTUP_PREFETCH_LIMIT;
83
    else if(pr_reset)       limit <= (cs_limit >= prefetch_eip)? cs_limit - prefetch_eip + 32'd1 : 32'd0;
84
    else if(prefetched_do)  limit <= limit - { 27'd0, length };
85
end
86
 
87
always @(posedge clk or negedge rst_n) begin
88
    if(rst_n == 1'b0)       linear <= `STARTUP_PREFETCH_LINEAR;
89
    else if(pr_reset)       linear <= cs_base + prefetch_eip;
90
    else if(prefetched_do)  linear <= linear + { 27'd0, length };
91
end
92
 
93
always @(posedge clk or negedge rst_n) begin
94
    if(rst_n == 1'b0)                       limit_signaled <= `FALSE;
95
    else if(pr_reset)                       limit_signaled <= `FALSE;
96
    else if(prefetchfifo_signal_limit_do)   limit_signaled <= `TRUE;
97
end
98
 
99
//------------------------------------------------------------------------------
100
 
101
// synthesis translate_off
102
wire _unused_ok = &{ 1'b0, cs_cache[54:52], cs_cache[47:40], 1'b0 };
103
// synthesis translate_on
104
 
105
//------------------------------------------------------------------------------
106
 
107
endmodule

powered by: WebSVN 2.1.0

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