summaryrefslogtreecommitdiffstatshomepage
path: root/src/emu/cpu/dsp16/dsp16.h
blob: b87f775a8e73720a3a3ddd711aa98a1ed2b20cb8 (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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
/***************************************************************************

    dsp16.h

    WE|AT&T DSP16 series emulator.

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

#pragma once

#ifndef __DSP16_H__
#define __DSP16_H__


//**************************************************************************
//  TYPE DEFINITIONS
//**************************************************************************

// ======================> dsp16_device

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

	// public interfaces

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

	// device_execute_interface overrides
	virtual UINT32 execute_min_cycles() const;
	virtual UINT32 execute_max_cycles() const;
	virtual UINT32 execute_input_lines() const;
	virtual void execute_run();
	virtual void execute_set_input(int inputnum, int state);

	// device_memory_interface overrides
	virtual const address_space_config *memory_space_config(address_spacenum spacenum = AS_0) const;

	// device_state_interface overrides
	virtual void state_string_export(const device_state_entry &entry, astring &string);

	// device_disasm_interface overrides
	virtual UINT32 disasm_min_opcode_bytes() const;
	virtual UINT32 disasm_max_opcode_bytes() const;
	virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram, UINT32 options);

	// address spaces
	const address_space_config m_program_config;
	const address_space_config m_data_config;

	// CPU registers
	// ROM Address Arithmetic Unit (XAAU)
	UINT16 m_i;		// 12 bits
	UINT16 m_pc;
	UINT16 m_pt;
	UINT16 m_pr;
	UINT16 m_pi;
	// RAM Address Arithmetic Unit (YAAU)
	UINT16 m_j;
	UINT16 m_k;
	UINT16 m_rb;
	UINT16 m_re;
	UINT16 m_r0;
	UINT16 m_r1;
	UINT16 m_r2;
	UINT16 m_r3;
	// Data Arithmetic Unit (DAU)
	UINT16 m_x;
	UINT32 m_y;
	UINT32 m_p;
	UINT64 m_a0;	// 36 bits
	UINT64 m_a1;	// 36 bits
	UINT8 m_auc;	// 6 bits
	UINT16 m_psw;
	UINT8 m_c0;
	UINT8 m_c1;
	UINT8 m_c2;
	// Serial and parallel interfaces
	UINT16 m_sioc;
	UINT16 m_srta;
	UINT16 m_sdx;
	UINT16 m_pioc;
	UINT16 m_pdx0;	// pdx0 & pdx1 refer to the same physical register (page 6-1)
	UINT16 m_pdx1;	//   but we keep them seperate for logic's sake.

	// internal stuff
	UINT16 m_ppc;

	// This core handles the cache as more of a loop than 15 seperate memory elements.
	// It's a bit of a hack, but it's easier this way.
	UINT16 m_cacheStart;
	UINT16 m_cacheEnd;
	UINT16 m_cacheRedoNextPC;
	UINT16 m_cacheIterations;
	static const UINT16 CACHE_INVALID = 0xffff;

	// memory access
	inline UINT32 data_read(const UINT16& addr);
	inline void data_write(const UINT16& addr, const UINT16& data);
	inline UINT32 opcode_read(const UINT8 pcOffset=0);

	// address spaces
	address_space* m_program;
	address_space* m_data;
	direct_read_data* m_direct;

	// other internal states
	int m_icount;

	// operations
	void execute_one(const UINT16& op, UINT8& cycles, UINT8& pcAdvance);

	// table decoders
	void* registerFromRImmediateField(const UINT8& R);
	void* registerFromRTable(const UINT8& R);
	void* registerFromYFieldUpper(const UINT8& Y);

	// execution
	void executeF1Field(const UINT8& F1, const UINT8& D, const UINT8& S);
	void executeYFieldPost(const UINT8& Y);
	void executeZFieldPartOne(const UINT8& Z, UINT16* rN);
	void executeZFieldPartTwo(const UINT8& Z, UINT16* rN);

	// helpers
	void* addressYL();
	void writeRegister(void* reg, const UINT16& value);
	bool conditionTest(const UINT8& CON);
};


// device type definition
extern const device_type DSP16;


/***************************************************************************
    REGISTER ENUMERATION
***************************************************************************/

enum
{
	DSP16_I,		// ROM Address Arithmetic Unit (XAAU)
	DSP16_PC,
	DSP16_PT,
	DSP16_PR,
	DSP16_PI,
	DSP16_J,		// RAM Address Arithmetic Unit (YAAU)
	DSP16_K,
	DSP16_RB,
	DSP16_RE,
	DSP16_R0,
	DSP16_R1,
	DSP16_R2,
	DSP16_R3,
	DSP16_X,		// Data Arithmetic Unit (DAU)
	DSP16_Y,
	DSP16_P,
	DSP16_A0,
	DSP16_A1,
	DSP16_AUC,
	DSP16_PSW,
	DSP16_C0,
	DSP16_C1,
	DSP16_C2,
	DSP16_SIOC,
	DSP16_SRTA,
	DSP16_SDX,
	DSP16_PIOC,
    DSP16_PDX0,
    DSP16_PDX1
};


#endif /* __DSP16_H__ */