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

Subversion Repositories s80186

[/] [s80186/] [trunk/] [python/] [py8086sim/] [Cpu.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 <boost/python.hpp>
19
#include <boost/version.hpp>
20
 
21
#include "RegisterFile.h"
22
#include "RTLCPU.h"
23
#include "SoftwareCPU.h"
24
#include "JTAGCPU.h"
25
 
26
using namespace boost::python;
27
 
28
typedef RTLCPU<verilator_debug_enabled> rtlcpu;
29
 
30
template <typename T>
31
void write_vector8(T *c,
32
                   uint16_t segment,
33
                   uint16_t addr,
34
                   boost::python::list vals)
35
{
36
    std::vector<uint8_t> vec;
37
 
38
    for (auto i = 0; i < boost::python::len(vals); ++i)
39
        vec.push_back(boost::python::extract<uint8_t>(vals[i]));
40
 
41
    c->write_vector8(segment, addr, vec);
42
}
43
 
44
template <typename T>
45
void write_vector16(T *c,
46
                    uint16_t segment,
47
                    uint16_t addr,
48
                    boost::python::list vals)
49
{
50
    std::vector<uint16_t> vec;
51
 
52
    for (auto i = 0; i < boost::python::len(vals); ++i)
53
        vec.push_back(boost::python::extract<uint16_t>(vals[i]));
54
 
55
    c->write_vector16(segment, addr, vec);
56
}
57
 
58
BOOST_PYTHON_MODULE(Cpu)
59
{
60
    class_<SoftwareCPU, boost::noncopyable>("Sim", init<const std::string &>())
61
        .def("reset", &SoftwareCPU::reset)
62
        .def("write_reg", &SoftwareCPU::write_reg)
63
        .def("read_reg", &SoftwareCPU::read_reg)
64
        .def("write_mem8", &SoftwareCPU::write_mem8)
65
        .def("write_mem16", &SoftwareCPU::write_mem16)
66
        .def("write_mem32", &SoftwareCPU::write_mem32)
67
        .def("read_mem8", &SoftwareCPU::read_mem8)
68
        .def("read_mem16", &SoftwareCPU::read_mem16)
69
        .def("read_mem32", &SoftwareCPU::read_mem32)
70
        .def("write_io8", &SoftwareCPU::write_io8)
71
        .def("write_io16", &SoftwareCPU::write_io16)
72
        .def("write_vector8", &write_vector8<SoftwareCPU>)
73
        .def("write_vector16", &write_vector16<SoftwareCPU>)
74
        .def("read_io8", &SoftwareCPU::read_io8)
75
        .def("read_io16", &SoftwareCPU::read_io16)
76
        .def("read_flags", &SoftwareCPU::read_flags)
77
        .def("write_flags", &SoftwareCPU::write_flags)
78
        .def("step", &SoftwareCPU::step)
79
        .def("has_trapped", &SoftwareCPU::has_trapped);
80
    class_<rtlcpu, boost::noncopyable>("RTLCPU", init<const std::string &>())
81
        .def("reset", &rtlcpu::reset)
82
        .def("write_reg", &rtlcpu::write_reg)
83
        .def("read_reg", &rtlcpu::read_reg)
84
        .def("write_mem8", &rtlcpu::write_mem8)
85
        .def("write_mem16", &rtlcpu::write_mem16)
86
        .def("write_mem32", &rtlcpu::write_mem32)
87
        .def("read_mem8", &rtlcpu::read_mem8)
88
        .def("read_mem16", &rtlcpu::read_mem16)
89
        .def("read_mem32", &rtlcpu::read_mem32)
90
        .def("write_vector8", &write_vector8<rtlcpu>)
91
        .def("write_vector16", &write_vector16<rtlcpu>)
92
        .def("write_io8", &rtlcpu::write_io8)
93
        .def("write_io16", &rtlcpu::write_io16)
94
        .def("read_io8", &rtlcpu::read_io8)
95
        .def("read_io16", &rtlcpu::read_io16)
96
        .def("read_flags", &rtlcpu::read_flags)
97
        .def("write_flags", &rtlcpu::write_flags)
98
        .def("step", &rtlcpu::step)
99
        .def("idle", &rtlcpu::idle)
100
        .def("time_step", &rtlcpu::time_step)
101
        .def("has_trapped", &rtlcpu::has_trapped);
102
    class_<JTAGCPU, boost::noncopyable>("JTAGCPU", init<const std::string &>())
103
        .def("reset", &JTAGCPU::reset)
104
        .def("write_reg", &JTAGCPU::write_reg)
105
        .def("read_reg", &JTAGCPU::read_reg)
106
        .def("write_mem8", &JTAGCPU::write_mem8)
107
        .def("write_mem16", &JTAGCPU::write_mem16)
108
        .def("write_mem32", &JTAGCPU::write_mem32)
109
        .def("read_mem8", &JTAGCPU::read_mem8)
110
        .def("read_mem16", &JTAGCPU::read_mem16)
111
        .def("read_mem32", &JTAGCPU::read_mem32)
112
        .def("write_vector8", &write_vector8<JTAGCPU>)
113
        .def("write_vector16", &write_vector16<JTAGCPU>)
114
        .def("write_io8", &JTAGCPU::write_io8)
115
        .def("write_io16", &JTAGCPU::write_io16)
116
        .def("read_io8", &JTAGCPU::read_io8)
117
        .def("read_io16", &JTAGCPU::read_io16)
118
        .def("read_flags", &JTAGCPU::read_flags)
119
        .def("write_flags", &JTAGCPU::write_flags)
120
        .def("step", &JTAGCPU::step)
121
        .def("has_trapped", &JTAGCPU::has_trapped);
122
    enum_<GPR>("GPR")
123
        .value("AX", AX)
124
        .value("CX", CX)
125
        .value("DX", DX)
126
        .value("BX", BX)
127
        .value("SP", SP)
128
        .value("BP", BP)
129
        .value("SI", SI)
130
        .value("DI", DI)
131
        .value("IP", IP)
132
        .value("ES", ES)
133
        .value("CS", CS)
134
        .value("SS", SS)
135
        .value("DS", DS)
136
        .value("AL", AL)
137
        .value("CL", CL)
138
        .value("DL", DL)
139
        .value("BL", BL)
140
        .value("AH", AH)
141
        .value("CH", CH)
142
        .value("DH", DH)
143
        .value("BH", BH);
144
    enum_<Flag>("Flag")
145
        .value("CF", CF)
146
        .value("PF", PF)
147
        .value("AF", AF)
148
        .value("ZF", ZF)
149
        .value("SF", SF)
150
        .value("TF", TF)
151
        .value("IF", IF)
152
        .value("DF", DF)
153
        .value("OF", OF);
154
}

powered by: WebSVN 2.1.0

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