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

Subversion Repositories s80186

[/] [s80186/] [trunk/] [tests/] [jtag/] [JTAGCPU.h] - 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
#pragma once
19
 
20
#include <cassert>
21
#include <string>
22
 
23
#include "CPU.h"
24
#include "RegisterFile.h"
25
 
26
class JTAGCPU : public CPU
27
{
28
public:
29
    JTAGCPU(const std::string &test_name);
30
    ~JTAGCPU();
31
    void reset();
32
    void write_reg(GPR regnum, uint16_t val);
33
    uint16_t read_reg(GPR regnum) const;
34
    size_t step();
35
    void write_flags(uint16_t val);
36
    uint16_t read_flags() const;
37
    bool has_trapped();
38
    uint32_t idcode();
39
 
40
    uint16_t debug_run_proc(unsigned addr, bool block = true);
41
    void debug_seize();
42
    void debug_step();
43
    bool debug_is_stopped() const;
44
 
45
    bool instruction_had_side_effects() const
46
    {
47
        return false;
48
    }
49
 
50
    void clear_side_effects()
51
    {
52
    }
53
 
54
    void write_mem8(uint16_t segment, uint16_t addr, uint8_t val);
55
    void write_mem16(uint16_t segment, uint16_t addr, uint16_t val);
56
    void write_mem32(uint16_t segment, uint16_t addr, uint32_t val);
57
    uint8_t read_mem8(uint16_t segment, uint16_t addr);
58
    uint16_t read_mem16(uint16_t segment, uint16_t addr);
59
    uint32_t read_mem32(uint16_t segment, uint16_t addr);
60
    void write_vector8(uint16_t segment,
61
                       uint16_t addr,
62
                       const std::vector<uint8_t> &v);
63
    void write_vector16(uint16_t segment,
64
                        uint16_t addr,
65
                        const std::vector<uint16_t> &v);
66
    void write_io8(uint32_t addr, uint8_t val);
67
    void write_io16(uint32_t addr, uint16_t val);
68
    uint8_t read_io8(uint32_t addr);
69
    uint16_t read_io16(uint32_t addr);
70
 
71
    virtual bool has_instruction_length() const
72
    {
73
        return false;
74
    }
75
 
76
    void add_ioport(IOPorts *p)
77
    {
78
        (void)p;
79
        // No emulated IO for hardware, those tests don't run.
80
    }
81
 
82
    virtual void raise_nmi()
83
    {
84
        write_io8(0xfff6, 0x00);
85
        write_io8(0xfff6, 0x80);
86
    }
87
 
88
    virtual void raise_irq(int irq_num)
89
    {
90
        assert(irq_num >= 0 && irq_num < 7);
91
        write_io8(0xfff6, 1 << irq_num);
92
        write_io8(0xfff6, 0);
93
    }
94
 
95
    unsigned long cycle_count() const
96
    {
97
        return num_cycles;
98
    }
99
 
100
private:
101
    uint16_t read_ip();
102
    uint16_t read_sr(GPR regnum);
103
    uint16_t read_gpr(GPR regnum);
104
    void write_ip(uint16_t v);
105
    void write_sr(GPR regnum, uint16_t v);
106
    void write_gpr(GPR regnum, uint16_t v);
107
    void debug_write_data(uint16_t v);
108
    uint16_t debug_read_data();
109
    void write_mar(uint16_t v);
110
    void write_mdr(uint16_t v);
111
    void write_scr(uint16_t v);
112
    uint16_t read_scr();
113
    std::string test_name;
114
    unsigned long num_cycles;
115
};

powered by: WebSVN 2.1.0

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