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

Subversion Repositories s80186

[/] [s80186/] [trunk/] [tests/] [simulator/] [TestModRM.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 <gmock/gmock.h>
20
 
21
#include <memory>
22
 
23
#include "Fifo.h"
24
#include "TestModRM.h"
25
#include "../common/TestModRM.cpp"
26
 
27
class SimulationModRMTestBench : public ModRMDecoderTestBench
28
{
29
public:
30
    SimulationModRMTestBench() : fifo(16)
31
    {
32
        decoder = std::make_unique<ModRMDecoder>(
33
            [&] { return this->fifo.pop(); }, &regs);
34
    }
35
    void set_width(OperandWidth width)
36
    {
37
        decoder->set_width(width);
38
    }
39
    void set_instruction(const std::vector<uint8_t> instruction)
40
    {
41
        for (auto &b : instruction)
42
            fifo.push(b);
43
    }
44
    void decode()
45
    {
46
        decoder->decode();
47
    }
48
    OperandType get_rm_type() const
49
    {
50
        return decoder->rm_type();
51
    }
52
    uint16_t get_effective_address() const
53
    {
54
        return decoder->effective_address();
55
    }
56
    GPR get_register() const
57
    {
58
        return decoder->reg();
59
    }
60
    GPR get_rm_register() const
61
    {
62
        return decoder->rm_reg();
63
    }
64
 
65
private:
66
    Fifo<uint8_t> fifo;
67
    std::unique_ptr<ModRMDecoder> decoder;
68
};
69
 
70
typedef ::testing::Types<SimulationModRMTestBench> ModRMImplTypes;
71
INSTANTIATE_TYPED_TEST_CASE_P(Simulation, ModRMTestFixture, ModRMImplTypes);

powered by: WebSVN 2.1.0

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