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

Subversion Repositories s80186

[/] [s80186/] [trunk/] [rtl/] [Flags.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
module Flags(input logic clk,
19
             input logic reset,
20
             // verilator lint_off UNUSED
21
             input logic [15:0] flags_in,
22
             // verilator lint_on UNUSED
23
             input logic [8:0] update_flags,
24
             output logic [15:0] flags_out);
25
 
26
reg C, P, A, Z, S, T, I, D, O;
27
 
28
assign flags_out = {4'b1111, O, D, I, T, S, Z, 1'b0, A, 1'b0, P, 1'b1, C};
29
 
30
always_ff @(posedge clk or posedge reset) begin
31
    if (reset) begin
32
        C <= 1'b0;
33
        P <= 1'b0;
34
        A <= 1'b0;
35
        Z <= 1'b0;
36
        S <= 1'b0;
37
        T <= 1'b0;
38
        I <= 1'b0;
39
        D <= 1'b0;
40
        O <= 1'b0;
41
    end else begin
42
        C <= update_flags[UpdateFlags_CF] ? flags_in[CF_IDX] : C;
43
        P <= update_flags[UpdateFlags_PF] ? flags_in[PF_IDX] : P;
44
        A <= update_flags[UpdateFlags_AF] ? flags_in[AF_IDX] : A;
45
        Z <= update_flags[UpdateFlags_ZF] ? flags_in[ZF_IDX] : Z;
46
        S <= update_flags[UpdateFlags_SF] ? flags_in[SF_IDX] : S;
47
        T <= update_flags[UpdateFlags_TF] ? flags_in[TF_IDX] : T;
48
        I <= update_flags[UpdateFlags_IF] ? flags_in[IF_IDX] : I;
49
        D <= update_flags[UpdateFlags_DF] ? flags_in[DF_IDX] : D;
50
        O <= update_flags[UpdateFlags_OF] ? flags_in[OF_IDX] : O;
51
    end
52
end
53
 
54
endmodule

powered by: WebSVN 2.1.0

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