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

Subversion Repositories ao486

[/] [ao486/] [trunk/] [ao486_tool/] [src/] [ao486/] [test/] [layers/] [FlagsLayer.java] - 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
package ao486.test.layers;
28
 
29
import java.util.Random;
30
 
31
public class FlagsLayer extends Layer {
32
    public FlagsLayer(Random random) {
33
        this(Type.RANDOM, random);
34
    }
35
    public FlagsLayer(FlagsLayer.Type type, Random random) {
36
        this.random = random;
37
 
38
        cf = random.nextBoolean();
39
        pf = random.nextBoolean();
40
        af = random.nextBoolean();
41
        zf = random.nextBoolean();
42
        sf = random.nextBoolean();
43
        tf = false; //random.nextBoolean();
44
        iflag = random.nextBoolean();
45
        df = random.nextBoolean();
46
        of = random.nextBoolean();
47
        iopl = random.nextInt(4);
48
        nt = (type == Type.NOT_V8086_NT)?       true :
49
             (type == Type.NOT_V8086_NOT_NT)?   false :
50
                                                random.nextBoolean();
51
        rf = false;
52
        vm = (type == Type.V8086)?                                  true :
53
             (type == Type.NOT_V8086 || type == Type.NOT_V8086_NT || type == Type.NOT_V8086_NOT_NT)? false :
54
                                                                    random.nextBoolean();
55
        ac = random.nextBoolean();
56
        id = random.nextBoolean();
57
    }
58
    public enum Type {
59
        RANDOM,
60
        V8086,
61
        NOT_V8086,
62
        NOT_V8086_NT,
63
        NOT_V8086_NOT_NT
64
    }
65
 
66
    public long cflag()  { return cf? 1 : 0; }
67
    public long pflag()  { return pf? 1 : 0; }
68
    public long aflag()  { return af? 1 : 0; }
69
    public long zflag()  { return zf? 1 : 0; }
70
    public long sflag()  { return sf? 1 : 0; }
71
    public long tflag()  { return tf? 1 : 0; }
72
    public long iflag()  { return iflag? 1 : 0; }
73
    public long dflag()  { return df? 1 : 0; }
74
    public long oflag()  { return of? 1 : 0; }
75
    public long iopl()   { return iopl; }
76
    public long ntflag() { return nt? 1 : 0; }
77
    public long rflag()  { return rf? 1 : 0; }
78
    public long vmflag() { return vm? 1 : 0; }
79
    public long acflag() { return ac? 1 : 0; }
80
    public long idflag() { return id? 1 : 0; }
81
 
82
    boolean cf, pf, af, zf, sf, tf, iflag, df, of, nt, rf, vm, ac, id;
83
    int iopl;
84
}

powered by: WebSVN 2.1.0

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