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

Subversion Repositories s80186

[/] [s80186/] [trunk/] [tests/] [rtl/] [TestFlags.cpp] - 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 <http://www.gnu.org/licenses/>.
17
 
18
#include <gtest/gtest.h>
19
#include <VFlags.h>
20
 
21
#include "VerilogTestbench.h"
22
#include "MicrocodeTypes.h"
23
#include "RegisterFile.h"
24
 
25
class FlagsTestFixture : public VerilogTestbench<VFlags>, public ::testing::Test
26
{
27
public:
28
    FlagsTestFixture();
29
};
30
 
31
FlagsTestFixture::FlagsTestFixture()
32
{
33
    reset();
34
}
35
 
36
static int flag_to_update_mask(Flag f)
37
{
38
    switch (f) {
39
    case CF: return 1 << static_cast<int>(UpdateFlags_CF);
40
    case PF: return 1 << static_cast<int>(UpdateFlags_PF);
41
    case AF: return 1 << static_cast<int>(UpdateFlags_AF);
42
    case ZF: return 1 << static_cast<int>(UpdateFlags_ZF);
43
    case SF: return 1 << static_cast<int>(UpdateFlags_SF);
44
    case TF: return 1 << static_cast<int>(UpdateFlags_TF);
45
    case IF: return 1 << static_cast<int>(UpdateFlags_IF);
46
    case DF: return 1 << static_cast<int>(UpdateFlags_DF);
47
    case OF: return 1 << static_cast<int>(UpdateFlags_OF);
48
    default: abort();
49
    }
50
}
51
 
52
TEST_F(FlagsTestFixture, update_flags)
53
{
54
    ASSERT_EQ(dut.flags_out, FLAGS_STUCK_BITS);
55
 
56
    dut.flags_in = CF | PF | AF | ZF | SF | IF | DF | OF;
57
    dut.update_flags = 0;
58
    cycle();
59
 
60
    ASSERT_EQ(dut.flags_out, FLAGS_STUCK_BITS);
61
 
62
    std::vector<Flag> flags = {CF, PF, AF, ZF, SF, TF, IF, DF, OF};
63
    for (auto f : flags) {
64
        reset();
65
 
66
        dut.flags_in = f;
67
        dut.update_flags = flag_to_update_mask(f);
68
        cycle();
69
 
70
        ASSERT_EQ(dut.flags_out, f | FLAGS_STUCK_BITS);
71
    }
72
}

powered by: WebSVN 2.1.0

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