1 // license:BSD-3-Clause
2 // copyright-holders:ElSemi
3 #ifndef MAME_CPU_SE3208_SE3208_H
4 #define MAME_CPU_SE3208_SE3208_H
5 
6 #pragma once
7 
8 enum
9 {
10 	SE3208_PC=1, SE3208_SR, SE3208_ER, SE3208_SP,SE3208_PPC,
11 	SE3208_R0, SE3208_R1, SE3208_R2, SE3208_R3, SE3208_R4, SE3208_R5, SE3208_R6, SE3208_R7
12 };
13 
14 #define SE3208_INT  0
15 
16 
17 class se3208_device :  public cpu_device
18 {
19 public:
20 	// construction/destruction
21 	se3208_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
22 
23 	// callback configuration
machinex_cb()24 	auto machinex_cb() { return m_machinex_cb.bind(); }
iackx_cb()25 	auto iackx_cb() { return m_iackx_cb.bind(); }
26 
27 protected:
28 	// device-level overrides
29 	virtual void device_resolve_objects() override;
30 	virtual void device_start() override;
31 	virtual void device_reset() override;
32 
33 	// device_execute_interface overrides
execute_min_cycles()34 	virtual uint32_t execute_min_cycles() const noexcept override { return 1; }
execute_max_cycles()35 	virtual uint32_t execute_max_cycles() const noexcept override { return 1; }
execute_input_lines()36 	virtual uint32_t execute_input_lines() const noexcept override { return 1; }
execute_input_edge_triggered(int inputnum)37 	virtual bool execute_input_edge_triggered(int inputnum) const noexcept override { return inputnum == INPUT_LINE_NMI; }
38 	virtual void execute_run() override;
39 	virtual void execute_set_input(int inputnum, int state) override;
40 
41 	// device_memory_interface overrides
42 	virtual space_config_vector memory_space_config() const override;
43 
44 	// device_state_interface overrides
45 	virtual void state_string_export(const device_state_entry &entry, std::string &str) const override;
46 
47 	// device_disasm_interface overrides
48 	virtual std::unique_ptr<util::disasm_interface> create_disassembler() override;
49 
50 private:
51 	address_space_config m_program_config;
52 
53 	devcb_write8 m_machinex_cb;
54 	devcb_read8 m_iackx_cb;
55 
56 	//GPR
57 	uint32_t m_R[8];
58 	//SPR
59 	uint32_t m_PC;
60 	uint32_t m_SR;
61 	uint32_t m_SP;
62 	uint32_t m_ER;
63 	uint32_t m_PPC;
64 
65 	memory_access<32, 2, 0, ENDIANNESS_LITTLE>::cache m_cache;
66 	memory_access<32, 2, 0, ENDIANNESS_LITTLE>::specific m_program;
67 	uint8_t m_IRQ;
68 	uint8_t m_NMI;
69 
70 	int m_icount;
71 
72 	inline uint8_t SE3208_Read8(uint32_t addr);
73 	inline uint16_t SE3208_Read16(uint32_t addr);
74 	inline uint32_t SE3208_Read32(uint32_t addr);
75 	inline void SE3208_Write8(uint32_t addr,uint8_t val);
76 	inline void SE3208_Write16(uint32_t addr,uint16_t val);
77 	inline void SE3208_Write32(uint32_t addr,uint32_t val);
78 	inline uint32_t AddWithFlags(uint32_t a,uint32_t b);
79 	inline uint32_t SubWithFlags(uint32_t a,uint32_t b);
80 	inline uint32_t AdcWithFlags(uint32_t a,uint32_t b);
81 	inline uint32_t SbcWithFlags(uint32_t a,uint32_t b);
82 	inline uint32_t MulWithFlags(uint32_t a,uint32_t b);
83 	inline uint32_t NegWithFlags(uint32_t a);
84 	inline uint32_t AsrWithFlags(uint32_t Val, uint8_t By);
85 	inline uint32_t LsrWithFlags(uint32_t Val, uint8_t By);
86 	inline uint32_t AslWithFlags(uint32_t Val, uint8_t By);
87 	inline void PushVal(uint32_t Val);
88 	inline uint32_t PopVal();
89 
90 	typedef void (se3208_device::*OP)(uint16_t Opcode);
91 	OP OpTable[0x10000];
92 
93 	void INVALIDOP(uint16_t Opcode);
94 	void LDB(uint16_t Opcode);
95 	void STB(uint16_t Opcode);
96 	void LDS(uint16_t Opcode);
97 	void STS(uint16_t Opcode);
98 	void LD(uint16_t Opcode);
99 	void ST(uint16_t Opcode);
100 	void LDBU(uint16_t Opcode);
101 	void LDSU(uint16_t Opcode);
102 	void LERI(uint16_t Opcode);
103 	void LDSP(uint16_t Opcode);
104 	void STSP(uint16_t Opcode);
105 	void PUSH(uint16_t Opcode);
106 	void POP(uint16_t Opcode);
107 	void LEATOSP(uint16_t Opcode);
108 	void LEAFROMSP(uint16_t Opcode);
109 	void LEASPTOSP(uint16_t Opcode);
110 	void MOV(uint16_t Opcode);
111 	void LDI(uint16_t Opcode);
112 	void LDBSP(uint16_t Opcode);
113 	void STBSP(uint16_t Opcode);
114 	void LDSSP(uint16_t Opcode);
115 	void STSSP(uint16_t Opcode);
116 	void LDBUSP(uint16_t Opcode);
117 	void LDSUSP(uint16_t Opcode);
118 	void ADDI(uint16_t Opcode);
119 	void SUBI(uint16_t Opcode);
120 	void ADCI(uint16_t Opcode);
121 	void SBCI(uint16_t Opcode);
122 	void ANDI(uint16_t Opcode);
123 	void ORI(uint16_t Opcode);
124 	void XORI(uint16_t Opcode);
125 	void CMPI(uint16_t Opcode);
126 	void TSTI(uint16_t Opcode);
127 	void ADD(uint16_t Opcode);
128 	void SUB(uint16_t Opcode);
129 	void ADC(uint16_t Opcode);
130 	void SBC(uint16_t Opcode);
131 	void AND(uint16_t Opcode);
132 	void OR(uint16_t Opcode);
133 	void XOR(uint16_t Opcode);
134 	void CMP(uint16_t Opcode);
135 	void TST(uint16_t Opcode);
136 	void MULS(uint16_t Opcode);
137 	void NEG(uint16_t Opcode);
138 	void CALL(uint16_t Opcode);
139 	void JV(uint16_t Opcode);
140 	void JNV(uint16_t Opcode);
141 	void JC(uint16_t Opcode);
142 	void JNC(uint16_t Opcode);
143 	void JP(uint16_t Opcode);
144 	void JM(uint16_t Opcode);
145 	void JNZ(uint16_t Opcode);
146 	void JZ(uint16_t Opcode);
147 	void JGE(uint16_t Opcode);
148 	void JLE(uint16_t Opcode);
149 	void JHI(uint16_t Opcode);
150 	void JLS(uint16_t Opcode);
151 	void JGT(uint16_t Opcode);
152 	void JLT(uint16_t Opcode);
153 	void JMP(uint16_t Opcode);
154 	void JR(uint16_t Opcode);
155 	void CALLR(uint16_t Opcode);
156 	void ASR(uint16_t Opcode);
157 	void LSR(uint16_t Opcode);
158 	void ASL(uint16_t Opcode);
159 	void EXTB(uint16_t Opcode);
160 	void EXTS(uint16_t Opcode);
161 	void SET(uint16_t Opcode);
162 	void CLR(uint16_t Opcode);
163 	void SWI(uint16_t Opcode);
164 	void HALT(uint16_t Opcode);
165 	void MVTC(uint16_t Opcode);
166 	void MVFC(uint16_t Opcode);
167 
168 	void BuildTable(void);
169 	OP DecodeOp(uint16_t Opcode);
170 	void SE3208_NMI();
171 	void SE3208_Interrupt();
172 
173 };
174 
175 
176 DECLARE_DEVICE_TYPE(SE3208, se3208_device)
177 
178 #endif // MAME_CPU_SE3208_SE3208_H
179