1 // license:BSD-3-Clause
2 // copyright-holders:Olivier Galibert
3 #include "emu.h"
4 #include "h8s2320.h"
5
6 DEFINE_DEVICE_TYPE(H8S2320, h8s2320_device, "h8s2320", "Hitachi H8S/2320")
7 DEFINE_DEVICE_TYPE(H8S2321, h8s2321_device, "h8s2321", "Hitachi H8S/2321")
8 DEFINE_DEVICE_TYPE(H8S2322, h8s2322_device, "h8s2322", "Hitachi H8S/2322")
9 DEFINE_DEVICE_TYPE(H8S2323, h8s2323_device, "h8s2323", "Hitachi H8S/2323")
10 DEFINE_DEVICE_TYPE(H8S2324, h8s2324_device, "h8s2324", "Hitachi H8S/2324")
11 DEFINE_DEVICE_TYPE(H8S2326, h8s2326_device, "h8s2326", "Hitachi H8S/2326")
12 DEFINE_DEVICE_TYPE(H8S2327, h8s2327_device, "h8s2327", "Hitachi H8S/2327")
13 DEFINE_DEVICE_TYPE(H8S2328, h8s2328_device, "h8s2328", "Hitachi H8S/2328")
14 DEFINE_DEVICE_TYPE(H8S2329, h8s2329_device, "h8s2329", "Hitachi H8S/2329")
15
16
h8s2320_device(const machine_config & mconfig,device_type type,const char * tag,device_t * owner,uint32_t clock,uint32_t start)17 h8s2320_device::h8s2320_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock, uint32_t start) :
18 h8s2000_device(mconfig, type, tag, owner, clock, address_map_constructor(FUNC(h8s2320_device::map), this)),
19 intc(*this, "intc"),
20 adc(*this, "adc"),
21 dma(*this, "dma"),
22 dma0(*this, "dma:0"),
23 dma1(*this, "dma:1"),
24 dtc(*this, "dtc"),
25 port1(*this, "port1"),
26 port2(*this, "port2"),
27 port3(*this, "port3"),
28 port4(*this, "port4"),
29 port5(*this, "port5"),
30 port6(*this, "port6"),
31 porta(*this, "porta"),
32 portb(*this, "portb"),
33 portc(*this, "portc"),
34 portd(*this, "portd"),
35 porte(*this, "porte"),
36 portf(*this, "portf"),
37 portg(*this, "portg"),
38 timer8_0(*this, "timer8_0"),
39 timer8_1(*this, "timer8_1"),
40 timer16(*this, "timer16"),
41 timer16_0(*this, "timer16:0"),
42 timer16_1(*this, "timer16:1"),
43 timer16_2(*this, "timer16:2"),
44 timer16_3(*this, "timer16:3"),
45 timer16_4(*this, "timer16:4"),
46 timer16_5(*this, "timer16:5"),
47 sci0(*this, "sci0"),
48 sci1(*this, "sci1"),
49 sci2(*this, "sci2"),
50 watchdog(*this, "watchdog"),
51 ram_start(start),
52 syscr(0)
53 {
54 }
55
h8s2320_device(const machine_config & mconfig,const char * tag,device_t * owner,uint32_t clock)56 h8s2320_device::h8s2320_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
57 h8s2320_device(mconfig, H8S2320, tag, owner, clock, 0xffec00)
58 {
59 }
60
h8s2321_device(const machine_config & mconfig,const char * tag,device_t * owner,uint32_t clock)61 h8s2321_device::h8s2321_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
62 h8s2320_device(mconfig, H8S2321, tag, owner, clock, 0xffec00)
63 {
64 }
65
h8s2322_device(const machine_config & mconfig,const char * tag,device_t * owner,uint32_t clock)66 h8s2322_device::h8s2322_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
67 h8s2320_device(mconfig, H8S2322, tag, owner, clock, 0xffdc00)
68 {
69 }
70
h8s2323_device(const machine_config & mconfig,const char * tag,device_t * owner,uint32_t clock)71 h8s2323_device::h8s2323_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
72 h8s2320_device(mconfig, H8S2323, tag, owner, clock, 0xffdc00)
73 {
74 }
75
h8s2324_device(const machine_config & mconfig,const char * tag,device_t * owner,uint32_t clock)76 h8s2324_device::h8s2324_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
77 h8s2320_device(mconfig, H8S2324, tag, owner, clock, 0xff7c00)
78 {
79 }
80
h8s2326_device(const machine_config & mconfig,const char * tag,device_t * owner,uint32_t clock)81 h8s2326_device::h8s2326_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
82 h8s2320_device(mconfig, H8S2326, tag, owner, clock, 0xffdc00)
83 {
84 }
85
h8s2327_device(const machine_config & mconfig,const char * tag,device_t * owner,uint32_t clock)86 h8s2327_device::h8s2327_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
87 h8s2320_device(mconfig, H8S2327, tag, owner, clock, 0xffdc00)
88 {
89 }
90
h8s2328_device(const machine_config & mconfig,const char * tag,device_t * owner,uint32_t clock)91 h8s2328_device::h8s2328_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
92 h8s2320_device(mconfig, H8S2328, tag, owner, clock, 0xffdc00)
93 {
94 }
95
h8s2329_device(const machine_config & mconfig,const char * tag,device_t * owner,uint32_t clock)96 h8s2329_device::h8s2329_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
97 h8s2320_device(mconfig, H8S2329, tag, owner, clock, 0xff7c00)
98 {
99 }
100
map(address_map & map)101 void h8s2320_device::map(address_map &map)
102 {
103 map(ram_start, 0xfffbff).ram();
104
105 map(0xfffe80, 0xfffe80).rw("timer16:3", FUNC(h8_timer16_channel_device::tcr_r), FUNC(h8_timer16_channel_device::tcr_w));
106 map(0xfffe81, 0xfffe81).rw("timer16:3", FUNC(h8_timer16_channel_device::tmdr_r), FUNC(h8_timer16_channel_device::tmdr_w));
107 map(0xfffe82, 0xfffe83).rw("timer16:3", FUNC(h8_timer16_channel_device::tior_r), FUNC(h8_timer16_channel_device::tior_w));
108 map(0xfffe84, 0xfffe84).rw("timer16:3", FUNC(h8_timer16_channel_device::tier_r), FUNC(h8_timer16_channel_device::tier_w));
109 map(0xfffe85, 0xfffe85).rw("timer16:3", FUNC(h8_timer16_channel_device::tsr_r), FUNC(h8_timer16_channel_device::tsr_w));
110 map(0xfffe86, 0xfffe87).rw("timer16:3", FUNC(h8_timer16_channel_device::tcnt_r), FUNC(h8_timer16_channel_device::tcnt_w));
111 map(0xfffe88, 0xfffe8f).rw("timer16:3", FUNC(h8_timer16_channel_device::tgr_r), FUNC(h8_timer16_channel_device::tgr_w));
112 map(0xfffe90, 0xfffe90).rw("timer16:4", FUNC(h8_timer16_channel_device::tcr_r), FUNC(h8_timer16_channel_device::tcr_w));
113 map(0xfffe91, 0xfffe91).rw("timer16:4", FUNC(h8_timer16_channel_device::tmdr_r), FUNC(h8_timer16_channel_device::tmdr_w));
114 map(0xfffe92, 0xfffe92).rw("timer16:4", FUNC(h8_timer16_channel_device::tior_r), FUNC(h8_timer16_channel_device::tior_w));
115 map(0xfffe94, 0xfffe94).rw("timer16:4", FUNC(h8_timer16_channel_device::tier_r), FUNC(h8_timer16_channel_device::tier_w));
116 map(0xfffe95, 0xfffe95).rw("timer16:4", FUNC(h8_timer16_channel_device::tsr_r), FUNC(h8_timer16_channel_device::tsr_w));
117 map(0xfffe96, 0xfffe97).rw("timer16:4", FUNC(h8_timer16_channel_device::tcnt_r), FUNC(h8_timer16_channel_device::tcnt_w));
118 map(0xfffe98, 0xfffe9b).rw("timer16:4", FUNC(h8_timer16_channel_device::tgr_r), FUNC(h8_timer16_channel_device::tgr_w));
119 map(0xfffea0, 0xfffea0).rw("timer16:5", FUNC(h8_timer16_channel_device::tcr_r), FUNC(h8_timer16_channel_device::tcr_w));
120 map(0xfffea1, 0xfffea1).rw("timer16:5", FUNC(h8_timer16_channel_device::tmdr_r), FUNC(h8_timer16_channel_device::tmdr_w));
121 map(0xfffea2, 0xfffea2).rw("timer16:5", FUNC(h8_timer16_channel_device::tior_r), FUNC(h8_timer16_channel_device::tior_w));
122 map(0xfffea4, 0xfffea4).rw("timer16:5", FUNC(h8_timer16_channel_device::tier_r), FUNC(h8_timer16_channel_device::tier_w));
123 map(0xfffea5, 0xfffea5).rw("timer16:5", FUNC(h8_timer16_channel_device::tsr_r), FUNC(h8_timer16_channel_device::tsr_w));
124 map(0xfffea6, 0xfffea7).rw("timer16:5", FUNC(h8_timer16_channel_device::tcnt_r), FUNC(h8_timer16_channel_device::tcnt_w));
125 map(0xfffea8, 0xfffeab).rw("timer16:5", FUNC(h8_timer16_channel_device::tgr_r), FUNC(h8_timer16_channel_device::tgr_w));
126 map(0xfffeb0, 0xfffeb0).w("port1", FUNC(h8_port_device::ddr_w));
127 map(0xfffeb1, 0xfffeb1).w("port2", FUNC(h8_port_device::ddr_w));
128 map(0xfffeb2, 0xfffeb2).w("port3", FUNC(h8_port_device::ddr_w));
129 map(0xfffeb4, 0xfffeb4).w("port5", FUNC(h8_port_device::ddr_w));
130 map(0xfffeb5, 0xfffeb5).w("port6", FUNC(h8_port_device::ddr_w));
131 map(0xfffeb9, 0xfffeb9).w("porta", FUNC(h8_port_device::ddr_w));
132 map(0xfffeba, 0xfffeba).w("portb", FUNC(h8_port_device::ddr_w));
133 map(0xfffebb, 0xfffebb).w("portc", FUNC(h8_port_device::ddr_w));
134 map(0xfffebc, 0xfffebc).w("portd", FUNC(h8_port_device::ddr_w));
135 map(0xfffebd, 0xfffebd).w("porte", FUNC(h8_port_device::ddr_w));
136 map(0xfffebe, 0xfffebe).w("portf", FUNC(h8_port_device::ddr_w));
137 map(0xfffebf, 0xfffebf).w("portg", FUNC(h8_port_device::ddr_w));
138 map(0xfffec0, 0xfffec1).rw("intc", FUNC(h8s_intc_device::icr_r), FUNC(h8s_intc_device::icr_w));
139 map(0xfffec2, 0xfffec2).rw("intc", FUNC(h8s_intc_device::icrc_r), FUNC(h8s_intc_device::icrc_w));
140 map(0xfffec4, 0xfffecd).rw("intc", FUNC(h8s_intc_device::ipr_r), FUNC(h8s_intc_device::ipr_w));
141 map(0xfffece, 0xfffece).rw("intc", FUNC(h8s_intc_device::iprk_r), FUNC(h8s_intc_device::iprk_w));
142
143 map(0xfffee0, 0xfffee1).rw("dma:0", FUNC(h8_dma_channel_device::marah_r), FUNC(h8_dma_channel_device::marah_w));
144 map(0xfffee2, 0xfffee3).rw("dma:0", FUNC(h8_dma_channel_device::maral_r), FUNC(h8_dma_channel_device::maral_w));
145 map(0xfffee4, 0xfffee5).rw("dma:0", FUNC(h8_dma_channel_device::ioara_r), FUNC(h8_dma_channel_device::ioara_w));
146 map(0xfffee6, 0xfffee7).rw("dma:0", FUNC(h8_dma_channel_device::etcra_r), FUNC(h8_dma_channel_device::etcra_w));
147 map(0xfffee8, 0xfffee9).rw("dma:0", FUNC(h8_dma_channel_device::marbh_r), FUNC(h8_dma_channel_device::marbh_w));
148 map(0xfffeea, 0xfffeeb).rw("dma:0", FUNC(h8_dma_channel_device::marbl_r), FUNC(h8_dma_channel_device::marbl_w));
149 map(0xfffeec, 0xfffeed).rw("dma:0", FUNC(h8_dma_channel_device::ioarb_r), FUNC(h8_dma_channel_device::ioarb_w));
150 map(0xfffeee, 0xfffeef).rw("dma:0", FUNC(h8_dma_channel_device::etcrb_r), FUNC(h8_dma_channel_device::etcrb_w));
151 map(0xfffef0, 0xfffef1).rw("dma:1", FUNC(h8_dma_channel_device::marah_r), FUNC(h8_dma_channel_device::marah_w));
152 map(0xfffef2, 0xfffef3).rw("dma:1", FUNC(h8_dma_channel_device::maral_r), FUNC(h8_dma_channel_device::maral_w));
153 map(0xfffef4, 0xfffef5).rw("dma:1", FUNC(h8_dma_channel_device::ioara_r), FUNC(h8_dma_channel_device::ioara_w));
154 map(0xfffef6, 0xfffef7).rw("dma:1", FUNC(h8_dma_channel_device::etcra_r), FUNC(h8_dma_channel_device::etcra_w));
155 map(0xfffef8, 0xfffef9).rw("dma:1", FUNC(h8_dma_channel_device::marbh_r), FUNC(h8_dma_channel_device::marbh_w));
156 map(0xfffefa, 0xfffefb).rw("dma:1", FUNC(h8_dma_channel_device::marbl_r), FUNC(h8_dma_channel_device::marbl_w));
157 map(0xfffefc, 0xfffefd).rw("dma:1", FUNC(h8_dma_channel_device::ioarb_r), FUNC(h8_dma_channel_device::ioarb_w));
158 map(0xfffefe, 0xfffeff).rw("dma:1", FUNC(h8_dma_channel_device::etcrb_r), FUNC(h8_dma_channel_device::etcrb_w));
159 map(0xffff00, 0xffff00).rw("dma", FUNC(h8_dma_device::dmawer_r), FUNC(h8_dma_device::dmawer_w));
160 map(0xffff01, 0xffff01).rw("dma", FUNC(h8_dma_device::dmatcr_r), FUNC(h8_dma_device::dmatcr_w));
161 map(0xffff02, 0xffff03).rw("dma:0", FUNC(h8_dma_channel_device::dmacr_r), FUNC(h8_dma_channel_device::dmacr_w));
162 map(0xffff04, 0xffff05).rw("dma:1", FUNC(h8_dma_channel_device::dmacr_r), FUNC(h8_dma_channel_device::dmacr_w));
163 map(0xffff06, 0xffff07).rw("dma", FUNC(h8_dma_device::dmabcr_r), FUNC(h8_dma_device::dmabcr_w));
164 map(0xffff2c, 0xffff2c).rw("intc", FUNC(h8s_intc_device::iscrh_r), FUNC(h8s_intc_device::iscrh_w));
165 map(0xffff2d, 0xffff2d).rw("intc", FUNC(h8s_intc_device::iscrl_r), FUNC(h8s_intc_device::iscrl_w));
166 map(0xffff2e, 0xffff2e).rw("intc", FUNC(h8s_intc_device::ier_r), FUNC(h8s_intc_device::ier_w));
167 map(0xffff2f, 0xffff2f).rw("intc", FUNC(h8s_intc_device::isr_r), FUNC(h8s_intc_device::isr_w));
168 map(0xffff30, 0xffff35).rw("dtc", FUNC(h8_dtc_device::dtcer_r), FUNC(h8_dtc_device::dtcer_w));
169 map(0xffff37, 0xffff37).rw("dtc", FUNC(h8_dtc_device::dtvecr_r), FUNC(h8_dtc_device::dtvecr_w));
170 map(0xffff39, 0xffff39).rw(FUNC(h8s2320_device::syscr_r), FUNC(h8s2320_device::syscr_w));
171
172 map(0xffff50, 0xffff50).r("port1", FUNC(h8_port_device::port_r));
173 map(0xffff51, 0xffff51).r("port2", FUNC(h8_port_device::port_r));
174 map(0xffff52, 0xffff52).r("port3", FUNC(h8_port_device::port_r));
175 map(0xffff53, 0xffff53).r("port4", FUNC(h8_port_device::port_r));
176 map(0xffff54, 0xffff54).r("port5", FUNC(h8_port_device::port_r));
177 map(0xffff55, 0xffff55).r("port6", FUNC(h8_port_device::port_r));
178 map(0xffff59, 0xffff59).r("porta", FUNC(h8_port_device::port_r));
179 map(0xffff5a, 0xffff5a).r("portb", FUNC(h8_port_device::port_r));
180 map(0xffff5b, 0xffff5b).r("portc", FUNC(h8_port_device::port_r));
181 map(0xffff5c, 0xffff5c).r("portd", FUNC(h8_port_device::port_r));
182 map(0xffff5d, 0xffff5d).r("porte", FUNC(h8_port_device::port_r));
183 map(0xffff5e, 0xffff5e).r("portf", FUNC(h8_port_device::port_r));
184 map(0xffff5f, 0xffff5f).r("portg", FUNC(h8_port_device::port_r));
185 map(0xffff60, 0xffff60).rw("port1", FUNC(h8_port_device::dr_r), FUNC(h8_port_device::dr_w));
186 map(0xffff61, 0xffff61).rw("port2", FUNC(h8_port_device::dr_r), FUNC(h8_port_device::dr_w));
187 map(0xffff62, 0xffff62).rw("port3", FUNC(h8_port_device::dr_r), FUNC(h8_port_device::dr_w));
188 map(0xffff64, 0xffff64).rw("port5", FUNC(h8_port_device::dr_r), FUNC(h8_port_device::dr_w));
189 map(0xffff65, 0xffff65).rw("port6", FUNC(h8_port_device::dr_r), FUNC(h8_port_device::dr_w));
190 map(0xffff69, 0xffff69).rw("porta", FUNC(h8_port_device::dr_r), FUNC(h8_port_device::dr_w));
191 map(0xffff6a, 0xffff6a).rw("portb", FUNC(h8_port_device::dr_r), FUNC(h8_port_device::dr_w));
192 map(0xffff6b, 0xffff6b).rw("portc", FUNC(h8_port_device::dr_r), FUNC(h8_port_device::dr_w));
193 map(0xffff6c, 0xffff6c).rw("portd", FUNC(h8_port_device::dr_r), FUNC(h8_port_device::dr_w));
194 map(0xffff6d, 0xffff6d).rw("porte", FUNC(h8_port_device::dr_r), FUNC(h8_port_device::dr_w));
195 map(0xffff6e, 0xffff6e).rw("portf", FUNC(h8_port_device::dr_r), FUNC(h8_port_device::dr_w));
196 map(0xffff6f, 0xffff6f).rw("portg", FUNC(h8_port_device::dr_r), FUNC(h8_port_device::dr_w));
197 map(0xffff70, 0xffff70).rw("porta", FUNC(h8_port_device::pcr_r), FUNC(h8_port_device::pcr_w));
198 map(0xffff71, 0xffff71).rw("portb", FUNC(h8_port_device::pcr_r), FUNC(h8_port_device::pcr_w));
199 map(0xffff72, 0xffff72).rw("portc", FUNC(h8_port_device::pcr_r), FUNC(h8_port_device::pcr_w));
200 map(0xffff73, 0xffff73).rw("portd", FUNC(h8_port_device::pcr_r), FUNC(h8_port_device::pcr_w));
201 map(0xffff74, 0xffff74).rw("porte", FUNC(h8_port_device::pcr_r), FUNC(h8_port_device::pcr_w));
202 map(0xffff76, 0xffff76).rw("port3", FUNC(h8_port_device::odr_r), FUNC(h8_port_device::odr_w));
203 map(0xffff77, 0xffff77).rw("porta", FUNC(h8_port_device::odr_r), FUNC(h8_port_device::odr_w));
204 map(0xffff78, 0xffff78).rw("sci0", FUNC(h8_sci_device::smr_r), FUNC(h8_sci_device::smr_w));
205 map(0xffff79, 0xffff79).rw("sci0", FUNC(h8_sci_device::brr_r), FUNC(h8_sci_device::brr_w));
206 map(0xffff7a, 0xffff7a).rw("sci0", FUNC(h8_sci_device::scr_r), FUNC(h8_sci_device::scr_w));
207 map(0xffff7b, 0xffff7b).rw("sci0", FUNC(h8_sci_device::tdr_r), FUNC(h8_sci_device::tdr_w));
208 map(0xffff7c, 0xffff7c).rw("sci0", FUNC(h8_sci_device::ssr_r), FUNC(h8_sci_device::ssr_w));
209 map(0xffff7d, 0xffff7d).r("sci0", FUNC(h8_sci_device::rdr_r));
210 map(0xffff7e, 0xffff7e).rw("sci0", FUNC(h8_sci_device::scmr_r), FUNC(h8_sci_device::scmr_w));
211 map(0xffff80, 0xffff80).rw("sci1", FUNC(h8_sci_device::smr_r), FUNC(h8_sci_device::smr_w));
212 map(0xffff81, 0xffff81).rw("sci1", FUNC(h8_sci_device::brr_r), FUNC(h8_sci_device::brr_w));
213 map(0xffff82, 0xffff82).rw("sci1", FUNC(h8_sci_device::scr_r), FUNC(h8_sci_device::scr_w));
214 map(0xffff83, 0xffff83).rw("sci1", FUNC(h8_sci_device::tdr_r), FUNC(h8_sci_device::tdr_w));
215 map(0xffff84, 0xffff84).rw("sci1", FUNC(h8_sci_device::ssr_r), FUNC(h8_sci_device::ssr_w));
216 map(0xffff85, 0xffff85).r("sci1", FUNC(h8_sci_device::rdr_r));
217 map(0xffff86, 0xffff86).rw("sci1", FUNC(h8_sci_device::scmr_r), FUNC(h8_sci_device::scmr_w));
218 map(0xffff88, 0xffff88).rw("sci2", FUNC(h8_sci_device::smr_r), FUNC(h8_sci_device::smr_w));
219 map(0xffff89, 0xffff89).rw("sci2", FUNC(h8_sci_device::brr_r), FUNC(h8_sci_device::brr_w));
220 map(0xffff8a, 0xffff8a).rw("sci2", FUNC(h8_sci_device::scr_r), FUNC(h8_sci_device::scr_w));
221 map(0xffff8b, 0xffff8b).rw("sci2", FUNC(h8_sci_device::tdr_r), FUNC(h8_sci_device::tdr_w));
222 map(0xffff8c, 0xffff8c).rw("sci2", FUNC(h8_sci_device::ssr_r), FUNC(h8_sci_device::ssr_w));
223 map(0xffff8d, 0xffff8d).r("sci2", FUNC(h8_sci_device::rdr_r));
224 map(0xffff8e, 0xffff8e).rw("sci2", FUNC(h8_sci_device::scmr_r), FUNC(h8_sci_device::scmr_w));
225 map(0xffff90, 0xffff97).r("adc", FUNC(h8_adc_device::addr8_r));
226 map(0xffff98, 0xffff98).rw("adc", FUNC(h8_adc_device::adcsr_r), FUNC(h8_adc_device::adcsr_w));
227 map(0xffff99, 0xffff99).rw("adc", FUNC(h8_adc_device::adcr_r), FUNC(h8_adc_device::adcr_w));
228
229 map(0xffffb0, 0xffffb0).rw("timer8_0", FUNC(h8_timer8_channel_device::tcr_r), FUNC(h8_timer8_channel_device::tcr_w));
230 map(0xffffb1, 0xffffb1).rw("timer8_1", FUNC(h8_timer8_channel_device::tcr_r), FUNC(h8_timer8_channel_device::tcr_w));
231 map(0xffffb2, 0xffffb2).rw("timer8_0", FUNC(h8_timer8_channel_device::tcsr_r), FUNC(h8_timer8_channel_device::tcsr_w));
232 map(0xffffb3, 0xffffb3).rw("timer8_1", FUNC(h8_timer8_channel_device::tcsr_r), FUNC(h8_timer8_channel_device::tcsr_w));
233 map(0xffffb4, 0xffffb7).rw("timer8_0", FUNC(h8_timer8_channel_device::tcor_r), FUNC(h8_timer8_channel_device::tcor_w)).umask16(0xff00);
234 map(0xffffb4, 0xffffb7).rw("timer8_1", FUNC(h8_timer8_channel_device::tcor_r), FUNC(h8_timer8_channel_device::tcor_w)).umask16(0x00ff);
235 map(0xffffb8, 0xffffb8).rw("timer8_0", FUNC(h8_timer8_channel_device::tcnt_r), FUNC(h8_timer8_channel_device::tcnt_w));
236 map(0xffffb9, 0xffffb9).rw("timer8_1", FUNC(h8_timer8_channel_device::tcnt_r), FUNC(h8_timer8_channel_device::tcnt_w));
237 map(0xffffbc, 0xffffbd).rw("watchdog", FUNC(h8_watchdog_device::wd_r), FUNC(h8_watchdog_device::wd_w));
238 map(0xffffbe, 0xffffbf).rw("watchdog", FUNC(h8_watchdog_device::rst_r), FUNC(h8_watchdog_device::rst_w));
239 map(0xffffc0, 0xffffc0).rw("timer16", FUNC(h8_timer16_device::tstr_r), FUNC(h8_timer16_device::tstr_w));
240 map(0xffffc1, 0xffffc1).rw("timer16", FUNC(h8_timer16_device::tsyr_r), FUNC(h8_timer16_device::tsyr_w));
241
242 map(0xffffd0, 0xffffd0).rw("timer16:0", FUNC(h8_timer16_channel_device::tcr_r), FUNC(h8_timer16_channel_device::tcr_w));
243 map(0xffffd1, 0xffffd1).rw("timer16:0", FUNC(h8_timer16_channel_device::tmdr_r), FUNC(h8_timer16_channel_device::tmdr_w));
244 map(0xffffd2, 0xffffd3).rw("timer16:0", FUNC(h8_timer16_channel_device::tior_r), FUNC(h8_timer16_channel_device::tior_w));
245 map(0xffffd4, 0xffffd4).rw("timer16:0", FUNC(h8_timer16_channel_device::tier_r), FUNC(h8_timer16_channel_device::tier_w));
246 map(0xffffd5, 0xffffd5).rw("timer16:0", FUNC(h8_timer16_channel_device::tsr_r), FUNC(h8_timer16_channel_device::tsr_w));
247 map(0xffffd6, 0xffffd7).rw("timer16:0", FUNC(h8_timer16_channel_device::tcnt_r), FUNC(h8_timer16_channel_device::tcnt_w));
248 map(0xffffd8, 0xffffdf).rw("timer16:0", FUNC(h8_timer16_channel_device::tgr_r), FUNC(h8_timer16_channel_device::tgr_w));
249 map(0xffffe0, 0xffffe0).rw("timer16:1", FUNC(h8_timer16_channel_device::tcr_r), FUNC(h8_timer16_channel_device::tcr_w));
250 map(0xffffe1, 0xffffe1).rw("timer16:1", FUNC(h8_timer16_channel_device::tmdr_r), FUNC(h8_timer16_channel_device::tmdr_w));
251 map(0xffffe2, 0xffffe2).rw("timer16:1", FUNC(h8_timer16_channel_device::tior_r), FUNC(h8_timer16_channel_device::tior_w));
252 map(0xffffe4, 0xffffe4).rw("timer16:1", FUNC(h8_timer16_channel_device::tier_r), FUNC(h8_timer16_channel_device::tier_w));
253 map(0xffffe5, 0xffffe5).rw("timer16:1", FUNC(h8_timer16_channel_device::tsr_r), FUNC(h8_timer16_channel_device::tsr_w));
254 map(0xffffe6, 0xffffe7).rw("timer16:1", FUNC(h8_timer16_channel_device::tcnt_r), FUNC(h8_timer16_channel_device::tcnt_w));
255 map(0xffffe8, 0xffffeb).rw("timer16:1", FUNC(h8_timer16_channel_device::tgr_r), FUNC(h8_timer16_channel_device::tgr_w));
256 map(0xfffff0, 0xfffff0).rw("timer16:2", FUNC(h8_timer16_channel_device::tcr_r), FUNC(h8_timer16_channel_device::tcr_w));
257 map(0xfffff1, 0xfffff1).rw("timer16:2", FUNC(h8_timer16_channel_device::tmdr_r), FUNC(h8_timer16_channel_device::tmdr_w));
258 map(0xfffff2, 0xfffff2).rw("timer16:2", FUNC(h8_timer16_channel_device::tior_r), FUNC(h8_timer16_channel_device::tior_w));
259 map(0xfffff4, 0xfffff4).rw("timer16:2", FUNC(h8_timer16_channel_device::tier_r), FUNC(h8_timer16_channel_device::tier_w));
260 map(0xfffff5, 0xfffff5).rw("timer16:2", FUNC(h8_timer16_channel_device::tsr_r), FUNC(h8_timer16_channel_device::tsr_w));
261 map(0xfffff6, 0xfffff7).rw("timer16:2", FUNC(h8_timer16_channel_device::tcnt_r), FUNC(h8_timer16_channel_device::tcnt_w));
262 map(0xfffff8, 0xfffffb).rw("timer16:2", FUNC(h8_timer16_channel_device::tgr_r), FUNC(h8_timer16_channel_device::tgr_w));
263 }
264
265 // TODO: the 2321 doesn't have the dma subdevice
266
device_add_mconfig(machine_config & config)267 void h8s2320_device::device_add_mconfig(machine_config &config)
268 {
269 H8S_INTC(config, "intc");
270 H8_ADC_2320(config, "adc", "intc", 28);
271 H8_DMA(config, "dma");
272 H8_DMA_CHANNEL(config, "dma:0", "intc", 72, h8_dma_channel_device::NONE, 28, h8_dma_channel_device::NONE, h8_dma_channel_device::NONE, 82, 81, 86, 85, 32, 40, 44, 48, 56, 60);
273 H8_DMA_CHANNEL(config, "dma:1", "intc", 74, h8_dma_channel_device::NONE, 28, h8_dma_channel_device::DREQ_EDGE, h8_dma_channel_device::DREQ_LEVEL, 82, 81, 86, 85, 32, 40, 44, 48, 56, 60);
274 H8_DTC(config, "dtc", "intc", 24);
275 H8_PORT(config, "port1", h8_device::PORT_1, 0x00, 0x00);
276 H8_PORT(config, "port2", h8_device::PORT_2, 0x00, 0x00);
277 H8_PORT(config, "port3", h8_device::PORT_3, 0xc0, 0xc0);
278 H8_PORT(config, "port4", h8_device::PORT_4, 0x00, 0x00);
279 H8_PORT(config, "port5", h8_device::PORT_5, 0xf0, 0xf0);
280 H8_PORT(config, "port6", h8_device::PORT_6, 0x00, 0x00);
281 H8_PORT(config, "porta", h8_device::PORT_A, 0x00, 0x00);
282 H8_PORT(config, "portb", h8_device::PORT_B, 0x00, 0x00);
283 H8_PORT(config, "portc", h8_device::PORT_C, 0x00, 0x00);
284 H8_PORT(config, "portd", h8_device::PORT_D, 0x00, 0x00);
285 H8_PORT(config, "porte", h8_device::PORT_E, 0x00, 0x00);
286 H8_PORT(config, "portf", h8_device::PORT_F, 0x00, 0x00);
287 H8_PORT(config, "portg", h8_device::PORT_G, 0xe0, 0xe0);
288 H8H_TIMER8_CHANNEL(config, "timer8_0", "intc", 64, 65, 66, "timer8_1", h8_timer8_channel_device::CHAIN_OVERFLOW, true, false);
289 H8H_TIMER8_CHANNEL(config, "timer8_1", "intc", 68, 69, 70, "timer8_0", h8_timer8_channel_device::CHAIN_A, false, false);
290 H8_TIMER16(config, "timer16", 6, 0x00);
291 H8S_TIMER16_CHANNEL(config, "timer16:0", 4, 0x60, "intc", 32,
292 h8_timer16_channel_device::DIV_1,
293 h8_timer16_channel_device::DIV_4,
294 h8_timer16_channel_device::DIV_16,
295 h8_timer16_channel_device::DIV_64,
296 h8_timer16_channel_device::INPUT_A,
297 h8_timer16_channel_device::INPUT_B,
298 h8_timer16_channel_device::INPUT_C,
299 h8_timer16_channel_device::INPUT_D);
300 H8S_TIMER16_CHANNEL(config, "timer16:1", 2, 0x4c, "intc", 40,
301 h8_timer16_channel_device::DIV_1,
302 h8_timer16_channel_device::DIV_4,
303 h8_timer16_channel_device::DIV_16,
304 h8_timer16_channel_device::DIV_64,
305 h8_timer16_channel_device::INPUT_A,
306 h8_timer16_channel_device::INPUT_B,
307 h8_timer16_channel_device::DIV_256,
308 h8_timer16_channel_device::CHAIN).set_chain("timer16:2");
309 H8S_TIMER16_CHANNEL(config, "timer16:2", 2, 0x4c, "intc", 44,
310 h8_timer16_channel_device::DIV_1,
311 h8_timer16_channel_device::DIV_4,
312 h8_timer16_channel_device::DIV_16,
313 h8_timer16_channel_device::DIV_64,
314 h8_timer16_channel_device::INPUT_A,
315 h8_timer16_channel_device::INPUT_B,
316 h8_timer16_channel_device::INPUT_C,
317 h8_timer16_channel_device::DIV_1024);
318 H8S_TIMER16_CHANNEL(config, "timer16:3", 4, 0x60, "intc", 48,
319 h8_timer16_channel_device::DIV_1,
320 h8_timer16_channel_device::DIV_4,
321 h8_timer16_channel_device::DIV_16,
322 h8_timer16_channel_device::DIV_64,
323 h8_timer16_channel_device::INPUT_A,
324 h8_timer16_channel_device::DIV_1024,
325 h8_timer16_channel_device::DIV_256,
326 h8_timer16_channel_device::DIV_4096);
327 H8S_TIMER16_CHANNEL(config, "timer16:4", 2, 0x4c, "intc", 56,
328 h8_timer16_channel_device::DIV_1,
329 h8_timer16_channel_device::DIV_4,
330 h8_timer16_channel_device::DIV_16,
331 h8_timer16_channel_device::DIV_64,
332 h8_timer16_channel_device::INPUT_A,
333 h8_timer16_channel_device::INPUT_C,
334 h8_timer16_channel_device::DIV_1024,
335 h8_timer16_channel_device::CHAIN).set_chain("timer16:5");
336 H8S_TIMER16_CHANNEL(config, "timer16:5", 2, 0x4c, "intc", 60,
337 h8_timer16_channel_device::DIV_1,
338 h8_timer16_channel_device::DIV_4,
339 h8_timer16_channel_device::DIV_16,
340 h8_timer16_channel_device::DIV_64,
341 h8_timer16_channel_device::INPUT_A,
342 h8_timer16_channel_device::INPUT_C,
343 h8_timer16_channel_device::DIV_256,
344 h8_timer16_channel_device::INPUT_D);
345 H8_SCI(config, "sci0", "intc", 80, 81, 82, 83);
346 H8_SCI(config, "sci1", "intc", 84, 85, 86, 87);
347 H8_SCI(config, "sci2", "intc", 88, 89, 90, 91);
348 H8_WATCHDOG(config, "watchdog", "intc", 25, h8_watchdog_device::H);
349 }
350
execute_set_input(int inputnum,int state)351 void h8s2320_device::execute_set_input(int inputnum, int state)
352 {
353 intc->set_input(inputnum, state);
354 }
355
exr_in_stack() const356 bool h8s2320_device::exr_in_stack() const
357 {
358 return syscr & 0x20;
359 }
360
trace_setup()361 int h8s2320_device::trace_setup()
362 {
363 CCR |= F_I;
364 EXR &= ~EXR_T;
365 return 5;
366 }
367
trapa_setup()368 int h8s2320_device::trapa_setup()
369 {
370 CCR |= F_I;
371 if(syscr & 0x20)
372 EXR &= ~EXR_T;
373 return 8;
374 }
375
irq_setup()376 void h8s2320_device::irq_setup()
377 {
378 switch(syscr & 0x30) {
379 case 0x00:
380 CCR |= F_I;
381 break;
382 case 0x20:
383 EXR = EXR & (EXR_NC);
384 if(taken_irq_level == 8)
385 EXR |= 7;
386 else
387 EXR |= taken_irq_level;
388 break;
389 }
390 }
391
update_irq_filter()392 void h8s2320_device::update_irq_filter()
393 {
394 switch(syscr & 0x30) {
395 case 0x00:
396 if(CCR & F_I)
397 intc->set_filter(2, -1);
398 else
399 intc->set_filter(0, -1);
400 break;
401 case 0x20:
402 intc->set_filter(0, EXR & 7);
403 break;
404 }
405 }
406
interrupt_taken()407 void h8s2320_device::interrupt_taken()
408 {
409 standard_irq_callback(intc->interrupt_taken(taken_irq_vector));
410 }
411
internal_update(uint64_t current_time)412 void h8s2320_device::internal_update(uint64_t current_time)
413 {
414 uint64_t event_time = 0;
415
416 add_event(event_time, adc->internal_update(current_time));
417 add_event(event_time, sci0->internal_update(current_time));
418 add_event(event_time, sci1->internal_update(current_time));
419 add_event(event_time, sci2->internal_update(current_time));
420 add_event(event_time, timer8_0->internal_update(current_time));
421 add_event(event_time, timer8_1->internal_update(current_time));
422 add_event(event_time, timer16_0->internal_update(current_time));
423 add_event(event_time, timer16_1->internal_update(current_time));
424 add_event(event_time, timer16_2->internal_update(current_time));
425 add_event(event_time, timer16_3->internal_update(current_time));
426 add_event(event_time, timer16_4->internal_update(current_time));
427 add_event(event_time, timer16_5->internal_update(current_time));
428 add_event(event_time, watchdog->internal_update(current_time));
429
430 recompute_bcount(event_time);
431 }
432
device_start()433 void h8s2320_device::device_start()
434 {
435 h8s2000_device::device_start();
436 dma_device = dma;
437 dtc_device = dtc;
438 }
439
device_reset()440 void h8s2320_device::device_reset()
441 {
442 h8s2000_device::device_reset();
443 syscr = 0x01;
444 }
445
syscr_r()446 uint8_t h8s2320_device::syscr_r()
447 {
448 return syscr;
449 }
450
syscr_w(uint8_t data)451 void h8s2320_device::syscr_w(uint8_t data)
452 {
453 syscr = data;
454 mac_saturating = syscr & 0x80;
455 update_irq_filter();
456 logerror("syscr = %02x\n", data);
457 }
458