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

Subversion Repositories s80186

[/] [s80186/] [trunk/] [rtl/] [CSIPSync.sv] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 jamieiles
// Copyright Jamie Iles, 2017
2
//
3
// This file is part of s80x86.
4
//
5
// s80x86 is free software: you can redistribute it and/or modify
6
// it under the terms of the GNU General Public License as published by
7
// the Free Software Foundation, either version 3 of the License, or
8
// (at your option) any later version.
9
//
10
// s80x86 is distributed in the hope that it will be useful,
11
// but WITHOUT ANY WARRANTY; without even the implied warranty of
12
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
// GNU General Public License for more details.
14
//
15
// You should have received a copy of the GNU General Public License
16
// along with s80x86.  If not, see .
17
 
18
// Synchronize CS and IP updates so that they can be deployed to the
19
// prefetcher atomically.  For something like a far jump, the microcode would
20
// first update the IP and then update CS.  If this happens during the
21
// microcode execution then potentially the prefetcher can start prefetching
22
// from an invalid address - CS remains the same but IP changes and we fetch
23
// from invalid/unmapped memory.
24
//
25
// This simple module just defers the output until propagation is ready, in
26
// this case, on completion of the microinstruction when CS:IP can be
27
// delivered to the prefetcher in a single cycle.
28
module CSIPSync(input logic clk,
29
                input logic reset,
30
                input logic cs_update,
31
                input logic ip_update,
32
                input logic [15:0] ip_in,
33
                input logic [15:0] new_ip,
34
                input logic propagate,
35
                output logic [15:0] ip_out,
36
                output logic update_out);
37
 
38
reg [15:0] ip;
39
reg ip_updated;
40
reg cs_updated;
41
 
42
assign ip_out = ip_updated ? ip : ip_update ? new_ip : ip_in;
43
assign update_out = propagate &
44
    (ip_updated | cs_updated | cs_update | ip_update);
45
 
46
always @(posedge clk or posedge reset) begin
47
    if (reset) begin
48
        ip_updated <= 1'b0;
49
        cs_updated <= 1'b0;
50
    end else begin
51
        if (propagate) begin
52
            ip_updated <= 1'b0;
53
            cs_updated <= 1'b0;
54
        end
55
 
56
        if (ip_update && !ip_updated && !propagate) begin
57
            ip <= new_ip;
58
            ip_updated <= 1'b1;
59
        end
60
 
61
        if (cs_update && !propagate)
62
            cs_updated <= 1'b1;
63
    end
64
end
65
 
66
endmodule

powered by: WebSVN 2.1.0

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