summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/cpu/score/score.h
blob: b8f8c1680cdb9162a30a4f5b3cc54088ea374e5b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
// license:BSD-3-Clause
// copyright-holders:Sandro Ronco
/**********************************************************************

    Sunplus Technology S+core

**********************************************************************/

#ifndef MAME_CPU_SCORE_SCORE_H
#define MAME_CPU_SCORE_SCORE_H

#pragma once


//**************************************************************************
//  DEFINITION
//**************************************************************************

enum
{
	SCORE_PC = 1,
	SCORE_CEH,
	SCORE_CEL,
	SCORE_GPR,
	SCORE_CR = SCORE_GPR + 0x20,
	SCORE_SR = SCORE_CR + 0x20
};


// ======================> score7_cpu_device

class score7_cpu_device : public cpu_device
{
public:
	// construction/destruction
	score7_cpu_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);

protected:
	// device-level overrides
	virtual void device_start() override;
	virtual void device_reset() override;

	// device_execute_interface overrides
	virtual uint32_t execute_min_cycles() const noexcept override { return 1; }
	virtual uint32_t execute_max_cycles() const noexcept override { return 1; }
	virtual uint32_t execute_input_lines() const noexcept override { return 64; }
	virtual void execute_run() override;
	virtual void execute_set_input(int inputnum, int state) override;

	// device_state_interface overrides
	virtual void state_string_export(const device_state_entry &entry, std::string &str) const override;

	// device_memory_interface overrides
	virtual space_config_vector memory_space_config() const override;

	// device_disasm_interface overrides
	virtual std::unique_ptr<util::disasm_interface> create_disassembler() override;

private:
	// helpers
	bool check_condition_branch(uint8_t bc);
	bool check_condition(uint8_t bc);
	int32_t sign_extend(uint32_t data, uint8_t len);
	uint32_t fetch();
	uint8_t read_byte(offs_t offset);
	uint16_t read_word(offs_t offset);
	uint32_t read_dword(offs_t offset);
	void write_byte(offs_t offset, uint8_t data);
	void write_word(offs_t offset, uint16_t data);
	void write_dword(offs_t offset, uint32_t data);
	void check_irq();
	void gen_exception(int cause, uint32_t param = 0);

	void unemulated_op(const char * op);

	// 32-bit opcodes
	void op_specialform();
	void op_iform1();
	void op_jump();
	void op_rixform1();
	void op_branch();
	void op_iform2();
	void op_crform();
	void op_rixform2();
	void op_addri();
	void op_andri();
	void op_orri();
	void op_lw();
	void op_lh();
	void op_lhu();
	void op_lb();
	void op_sw();
	void op_sh();
	void op_lbu();
	void op_sb();
	void op_cache();
	void op_cenew();
	void op_undef();

	// 16-bit opcodes
	void op_rform1();
	void op_rform2();
	void op_jform();
	void op_branch16();
	void op_ldiu();
	void op_iform1a();
	void op_iform1b();

	address_space_config m_program_config;
	address_space *     m_program;
	memory_access_cache<2, 0, ENDIANNESS_LITTLE> *m_cache;

	// internal state
	int                 m_icount;
	uint32_t              m_pc;
	uint32_t              m_ppc;
	uint32_t              m_op;
	uint32_t              m_gpr[0x20];
	uint32_t              m_cr[0x20];
	uint32_t              m_sr[3];
	uint32_t              m_ce[2];
	bool                m_pending_interrupt[64];

	// opcodes tables
	typedef void (score7_cpu_device::*op_handler)();
	static const op_handler s_opcode32_table[4*8];
	static const op_handler s_opcode16_table[8];
};

DECLARE_DEVICE_TYPE(SCORE7, score7_cpu_device)

#endif // MAME_CPU_SCORE_SCORE_H