1 // license:BSD-3-Clause
2 // copyright-holders:Olivier Galibert
3 #include "emu.h"
4 #include "h8s2357.h"
5
6 DEFINE_DEVICE_TYPE(H8S2357, h8s2357_device, "h8s2357", "Hitachi H8S/2357")
7 DEFINE_DEVICE_TYPE(H8S2352, h8s2352_device, "h8s2352", "Hitachi H8S/2352")
8 DEFINE_DEVICE_TYPE(H8S2398, h8s2398_device, "h8s2398", "Hitachi H8S/2398")
9 DEFINE_DEVICE_TYPE(H8S2394, h8s2394_device, "h8s2394", "Hitachi H8S/2394")
10 DEFINE_DEVICE_TYPE(H8S2392, h8s2392_device, "h8s2392", "Hitachi H8S/2392")
11 DEFINE_DEVICE_TYPE(H8S2390, h8s2390_device, "h8s2390", "Hitachi H8S/2390")
12
h8s2357_device(const machine_config & mconfig,device_type type,const char * tag,device_t * owner,uint32_t clock,uint32_t start)13 h8s2357_device::h8s2357_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock, uint32_t start) :
14 h8s2000_device(mconfig, type, tag, owner, clock, address_map_constructor(FUNC(h8s2357_device::map), this)),
15 intc(*this, "intc"),
16 adc(*this, "adc"),
17 port1(*this, "port1"),
18 port2(*this, "port2"),
19 port3(*this, "port3"),
20 port4(*this, "port4"),
21 port5(*this, "port5"),
22 port6(*this, "port6"),
23 porta(*this, "porta"),
24 portb(*this, "portb"),
25 portc(*this, "portc"),
26 portd(*this, "portd"),
27 porte(*this, "porte"),
28 portf(*this, "portf"),
29 portg(*this, "portg"),
30 timer8_0(*this, "timer8_0"),
31 timer8_1(*this, "timer8_1"),
32 timer16(*this, "timer16"),
33 timer16_0(*this, "timer16:0"),
34 timer16_1(*this, "timer16:1"),
35 timer16_2(*this, "timer16:2"),
36 timer16_3(*this, "timer16:3"),
37 timer16_4(*this, "timer16:4"),
38 timer16_5(*this, "timer16:5"),
39 sci0(*this, "sci0"),
40 sci1(*this, "sci1"),
41 sci2(*this, "sci2"),
42 watchdog(*this, "watchdog"),
43 ram_start(start),
44 syscr(0)
45 {
46 }
47
h8s2357_device(const machine_config & mconfig,const char * tag,device_t * owner,uint32_t clock)48 h8s2357_device::h8s2357_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
49 h8s2357_device(mconfig, H8S2357, tag, owner, clock, 0xffdc00)
50 {
51 }
52
h8s2352_device(const machine_config & mconfig,const char * tag,device_t * owner,uint32_t clock)53 h8s2352_device::h8s2352_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
54 h8s2357_device(mconfig, H8S2352, tag, owner, clock, 0xffdc00)
55 {
56 }
57
h8s2398_device(const machine_config & mconfig,const char * tag,device_t * owner,uint32_t clock)58 h8s2398_device::h8s2398_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
59 h8s2357_device(mconfig, H8S2398, tag, owner, clock, 0xffdc00)
60 {
61 }
62
h8s2394_device(const machine_config & mconfig,const char * tag,device_t * owner,uint32_t clock)63 h8s2394_device::h8s2394_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
64 h8s2357_device(mconfig, H8S2394, tag, owner, clock, 0xff7c00)
65 {
66 }
67
h8s2392_device(const machine_config & mconfig,const char * tag,device_t * owner,uint32_t clock)68 h8s2392_device::h8s2392_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
69 h8s2357_device(mconfig, H8S2392, tag, owner, clock, 0xffdc00)
70 {
71 }
72
h8s2390_device(const machine_config & mconfig,const char * tag,device_t * owner,uint32_t clock)73 h8s2390_device::h8s2390_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
74 h8s2357_device(mconfig, H8S2390, tag, owner, clock, 0xffec00)
75 {
76 }
77
map(address_map & map)78 void h8s2357_device::map(address_map &map)
79 {
80 map(ram_start, 0xfffbff).ram();
81 map(0xfffe80, 0xfffe80).rw("timer16:3", FUNC(h8_timer16_channel_device::tcr_r), FUNC(h8_timer16_channel_device::tcr_w));
82 map(0xfffe81, 0xfffe81).rw("timer16:3", FUNC(h8_timer16_channel_device::tmdr_r), FUNC(h8_timer16_channel_device::tmdr_w));
83 map(0xfffe82, 0xfffe83).rw("timer16:3", FUNC(h8_timer16_channel_device::tior_r), FUNC(h8_timer16_channel_device::tior_w));
84 map(0xfffe84, 0xfffe84).rw("timer16:3", FUNC(h8_timer16_channel_device::tier_r), FUNC(h8_timer16_channel_device::tier_w));
85 map(0xfffe85, 0xfffe85).rw("timer16:3", FUNC(h8_timer16_channel_device::tsr_r), FUNC(h8_timer16_channel_device::tsr_w));
86 map(0xfffe86, 0xfffe87).rw("timer16:3", FUNC(h8_timer16_channel_device::tcnt_r), FUNC(h8_timer16_channel_device::tcnt_w));
87 map(0xfffe88, 0xfffe8f).rw("timer16:3", FUNC(h8_timer16_channel_device::tgr_r), FUNC(h8_timer16_channel_device::tgr_w));
88 map(0xfffe90, 0xfffe90).rw("timer16:4", FUNC(h8_timer16_channel_device::tcr_r), FUNC(h8_timer16_channel_device::tcr_w));
89 map(0xfffe91, 0xfffe91).rw("timer16:4", FUNC(h8_timer16_channel_device::tmdr_r), FUNC(h8_timer16_channel_device::tmdr_w));
90 map(0xfffe92, 0xfffe92).rw("timer16:4", FUNC(h8_timer16_channel_device::tior_r), FUNC(h8_timer16_channel_device::tior_w));
91 map(0xfffe94, 0xfffe94).rw("timer16:4", FUNC(h8_timer16_channel_device::tier_r), FUNC(h8_timer16_channel_device::tier_w));
92 map(0xfffe95, 0xfffe95).rw("timer16:4", FUNC(h8_timer16_channel_device::tsr_r), FUNC(h8_timer16_channel_device::tsr_w));
93 map(0xfffe96, 0xfffe97).rw("timer16:4", FUNC(h8_timer16_channel_device::tcnt_r), FUNC(h8_timer16_channel_device::tcnt_w));
94 map(0xfffe98, 0xfffe9b).rw("timer16:4", FUNC(h8_timer16_channel_device::tgr_r), FUNC(h8_timer16_channel_device::tgr_w));
95 map(0xfffea0, 0xfffea0).rw("timer16:5", FUNC(h8_timer16_channel_device::tcr_r), FUNC(h8_timer16_channel_device::tcr_w));
96 map(0xfffea1, 0xfffea1).rw("timer16:5", FUNC(h8_timer16_channel_device::tmdr_r), FUNC(h8_timer16_channel_device::tmdr_w));
97 map(0xfffea2, 0xfffea2).rw("timer16:5", FUNC(h8_timer16_channel_device::tior_r), FUNC(h8_timer16_channel_device::tior_w));
98 map(0xfffea4, 0xfffea4).rw("timer16:5", FUNC(h8_timer16_channel_device::tier_r), FUNC(h8_timer16_channel_device::tier_w));
99 map(0xfffea5, 0xfffea5).rw("timer16:5", FUNC(h8_timer16_channel_device::tsr_r), FUNC(h8_timer16_channel_device::tsr_w));
100 map(0xfffea6, 0xfffea7).rw("timer16:5", FUNC(h8_timer16_channel_device::tcnt_r), FUNC(h8_timer16_channel_device::tcnt_w));
101 map(0xfffea8, 0xfffeab).rw("timer16:5", FUNC(h8_timer16_channel_device::tgr_r), FUNC(h8_timer16_channel_device::tgr_w));
102 map(0xfffeb0, 0xfffeb0).w("port1", FUNC(h8_port_device::ddr_w));
103 map(0xfffeb1, 0xfffeb1).w("port2", FUNC(h8_port_device::ddr_w));
104 map(0xfffeb2, 0xfffeb2).w("port3", FUNC(h8_port_device::ddr_w));
105 map(0xfffeb4, 0xfffeb4).w("port5", FUNC(h8_port_device::ddr_w));
106 map(0xfffeb5, 0xfffeb5).w("port6", FUNC(h8_port_device::ddr_w));
107 map(0xfffeb9, 0xfffeb9).w("porta", FUNC(h8_port_device::ddr_w));
108 map(0xfffeba, 0xfffeba).w("portb", FUNC(h8_port_device::ddr_w));
109 map(0xfffebb, 0xfffebb).w("portc", FUNC(h8_port_device::ddr_w));
110 map(0xfffebc, 0xfffebc).w("portd", FUNC(h8_port_device::ddr_w));
111 map(0xfffebd, 0xfffebd).w("porte", FUNC(h8_port_device::ddr_w));
112 map(0xfffebe, 0xfffebe).w("portf", FUNC(h8_port_device::ddr_w));
113 map(0xfffebf, 0xfffebf).w("portg", FUNC(h8_port_device::ddr_w));
114 map(0xfffec4, 0xfffecd).rw("intc", FUNC(h8s_intc_device::ipr_r), FUNC(h8s_intc_device::ipr_w));
115 map(0xfffece, 0xfffece).rw("intc", FUNC(h8s_intc_device::iprk_r), FUNC(h8s_intc_device::iprk_w));
116 map(0xffff2c, 0xffff2c).rw("intc", FUNC(h8s_intc_device::iscrh_r), FUNC(h8s_intc_device::iscrh_w));
117 map(0xffff2d, 0xffff2d).rw("intc", FUNC(h8s_intc_device::iscrl_r), FUNC(h8s_intc_device::iscrl_w));
118 map(0xffff2e, 0xffff2e).rw("intc", FUNC(h8s_intc_device::ier_r), FUNC(h8s_intc_device::ier_w));
119 map(0xffff2f, 0xffff2f).rw("intc", FUNC(h8s_intc_device::isr_r), FUNC(h8s_intc_device::isr_w));
120 map(0xffff39, 0xffff39).rw(FUNC(h8s2357_device::syscr_r), FUNC(h8s2357_device::syscr_w));
121 map(0xffff50, 0xffff50).r("port1", FUNC(h8_port_device::port_r));
122 map(0xffff51, 0xffff51).r("port2", FUNC(h8_port_device::port_r));
123 map(0xffff52, 0xffff52).r("port3", FUNC(h8_port_device::port_r));
124 map(0xffff53, 0xffff53).r("port4", FUNC(h8_port_device::port_r));
125 map(0xffff54, 0xffff54).r("port5", FUNC(h8_port_device::port_r));
126 map(0xffff55, 0xffff55).r("port6", FUNC(h8_port_device::port_r));
127 map(0xffff59, 0xffff59).r("porta", FUNC(h8_port_device::port_r));
128 map(0xffff5a, 0xffff5a).r("portb", FUNC(h8_port_device::port_r));
129 map(0xffff5b, 0xffff5b).r("portc", FUNC(h8_port_device::port_r));
130 map(0xffff5c, 0xffff5c).r("portd", FUNC(h8_port_device::port_r));
131 map(0xffff5d, 0xffff5d).r("porte", FUNC(h8_port_device::port_r));
132 map(0xffff5e, 0xffff5e).r("portf", FUNC(h8_port_device::port_r));
133 map(0xffff5f, 0xffff5f).r("portg", FUNC(h8_port_device::port_r));
134 map(0xffff60, 0xffff60).rw("port1", FUNC(h8_port_device::dr_r), FUNC(h8_port_device::dr_w));
135 map(0xffff61, 0xffff61).rw("port2", FUNC(h8_port_device::dr_r), FUNC(h8_port_device::dr_w));
136 map(0xffff62, 0xffff62).rw("port3", FUNC(h8_port_device::dr_r), FUNC(h8_port_device::dr_w));
137 map(0xffff64, 0xffff64).rw("port5", FUNC(h8_port_device::dr_r), FUNC(h8_port_device::dr_w));
138 map(0xffff65, 0xffff65).rw("port6", FUNC(h8_port_device::dr_r), FUNC(h8_port_device::dr_w));
139 map(0xffff69, 0xffff69).rw("porta", FUNC(h8_port_device::dr_r), FUNC(h8_port_device::dr_w));
140 map(0xffff6a, 0xffff6a).rw("portb", FUNC(h8_port_device::dr_r), FUNC(h8_port_device::dr_w));
141 map(0xffff6b, 0xffff6b).rw("portc", FUNC(h8_port_device::dr_r), FUNC(h8_port_device::dr_w));
142 map(0xffff6c, 0xffff6c).rw("portd", FUNC(h8_port_device::dr_r), FUNC(h8_port_device::dr_w));
143 map(0xffff6d, 0xffff6d).rw("porte", FUNC(h8_port_device::dr_r), FUNC(h8_port_device::dr_w));
144 map(0xffff6e, 0xffff6e).rw("portf", FUNC(h8_port_device::dr_r), FUNC(h8_port_device::dr_w));
145 map(0xffff6f, 0xffff6f).rw("portg", FUNC(h8_port_device::dr_r), FUNC(h8_port_device::dr_w));
146 map(0xffff70, 0xffff70).rw("porta", FUNC(h8_port_device::pcr_r), FUNC(h8_port_device::pcr_w));
147 map(0xffff71, 0xffff71).rw("portb", FUNC(h8_port_device::pcr_r), FUNC(h8_port_device::pcr_w));
148 map(0xffff72, 0xffff72).rw("portc", FUNC(h8_port_device::pcr_r), FUNC(h8_port_device::pcr_w));
149 map(0xffff73, 0xffff73).rw("portd", FUNC(h8_port_device::pcr_r), FUNC(h8_port_device::pcr_w));
150 map(0xffff74, 0xffff74).rw("porte", FUNC(h8_port_device::pcr_r), FUNC(h8_port_device::pcr_w));
151 map(0xffff76, 0xffff76).rw("port3", FUNC(h8_port_device::odr_r), FUNC(h8_port_device::odr_w));
152 map(0xffff77, 0xffff77).rw("porta", FUNC(h8_port_device::odr_r), FUNC(h8_port_device::odr_w));
153 map(0xffff78, 0xffff78).rw("sci0", FUNC(h8_sci_device::smr_r), FUNC(h8_sci_device::smr_w));
154 map(0xffff79, 0xffff79).rw("sci0", FUNC(h8_sci_device::brr_r), FUNC(h8_sci_device::brr_w));
155 map(0xffff7a, 0xffff7a).rw("sci0", FUNC(h8_sci_device::scr_r), FUNC(h8_sci_device::scr_w));
156 map(0xffff7b, 0xffff7b).rw("sci0", FUNC(h8_sci_device::tdr_r), FUNC(h8_sci_device::tdr_w));
157 map(0xffff7c, 0xffff7c).rw("sci0", FUNC(h8_sci_device::ssr_r), FUNC(h8_sci_device::ssr_w));
158 map(0xffff7d, 0xffff7d).r("sci0", FUNC(h8_sci_device::rdr_r));
159 map(0xffff7e, 0xffff7e).rw("sci0", FUNC(h8_sci_device::scmr_r), FUNC(h8_sci_device::scmr_w));
160 map(0xffff80, 0xffff80).rw("sci1", FUNC(h8_sci_device::smr_r), FUNC(h8_sci_device::smr_w));
161 map(0xffff81, 0xffff81).rw("sci1", FUNC(h8_sci_device::brr_r), FUNC(h8_sci_device::brr_w));
162 map(0xffff82, 0xffff82).rw("sci1", FUNC(h8_sci_device::scr_r), FUNC(h8_sci_device::scr_w));
163 map(0xffff83, 0xffff83).rw("sci1", FUNC(h8_sci_device::tdr_r), FUNC(h8_sci_device::tdr_w));
164 map(0xffff84, 0xffff84).rw("sci1", FUNC(h8_sci_device::ssr_r), FUNC(h8_sci_device::ssr_w));
165 map(0xffff85, 0xffff85).r("sci1", FUNC(h8_sci_device::rdr_r));
166 map(0xffff86, 0xffff86).rw("sci1", FUNC(h8_sci_device::scmr_r), FUNC(h8_sci_device::scmr_w));
167 map(0xffff88, 0xffff88).rw("sci2", FUNC(h8_sci_device::smr_r), FUNC(h8_sci_device::smr_w));
168 map(0xffff89, 0xffff89).rw("sci2", FUNC(h8_sci_device::brr_r), FUNC(h8_sci_device::brr_w));
169 map(0xffff8a, 0xffff8a).rw("sci2", FUNC(h8_sci_device::scr_r), FUNC(h8_sci_device::scr_w));
170 map(0xffff8b, 0xffff8b).rw("sci2", FUNC(h8_sci_device::tdr_r), FUNC(h8_sci_device::tdr_w));
171 map(0xffff8c, 0xffff8c).rw("sci2", FUNC(h8_sci_device::ssr_r), FUNC(h8_sci_device::ssr_w));
172 map(0xffff8d, 0xffff8d).r("sci2", FUNC(h8_sci_device::rdr_r));
173 map(0xffff8e, 0xffff8e).rw("sci2", FUNC(h8_sci_device::scmr_r), FUNC(h8_sci_device::scmr_w));
174 map(0xffff90, 0xffff97).r("adc", FUNC(h8_adc_device::addr8_r));
175 map(0xffff98, 0xffff98).rw("adc", FUNC(h8_adc_device::adcsr_r), FUNC(h8_adc_device::adcsr_w));
176 map(0xffff99, 0xffff99).rw("adc", FUNC(h8_adc_device::adcr_r), FUNC(h8_adc_device::adcr_w));
177 map(0xffffb0, 0xffffb0).rw("timer8_0", FUNC(h8_timer8_channel_device::tcr_r), FUNC(h8_timer8_channel_device::tcr_w));
178 map(0xffffb1, 0xffffb1).rw("timer8_1", FUNC(h8_timer8_channel_device::tcr_r), FUNC(h8_timer8_channel_device::tcr_w));
179 map(0xffffb2, 0xffffb2).rw("timer8_0", FUNC(h8_timer8_channel_device::tcsr_r), FUNC(h8_timer8_channel_device::tcsr_w));
180 map(0xffffb3, 0xffffb3).rw("timer8_1", FUNC(h8_timer8_channel_device::tcsr_r), FUNC(h8_timer8_channel_device::tcsr_w));
181 map(0xffffb4, 0xffffb7).rw("timer8_0", FUNC(h8_timer8_channel_device::tcor_r), FUNC(h8_timer8_channel_device::tcor_w)).umask16(0xff00);
182 map(0xffffb4, 0xffffb7).rw("timer8_1", FUNC(h8_timer8_channel_device::tcor_r), FUNC(h8_timer8_channel_device::tcor_w)).umask16(0x00ff);
183 map(0xffffb8, 0xffffb8).rw("timer8_0", FUNC(h8_timer8_channel_device::tcnt_r), FUNC(h8_timer8_channel_device::tcnt_w));
184 map(0xffffb9, 0xffffb9).rw("timer8_1", FUNC(h8_timer8_channel_device::tcnt_r), FUNC(h8_timer8_channel_device::tcnt_w));
185 map(0xffffbc, 0xffffbd).rw("watchdog", FUNC(h8_watchdog_device::wd_r), FUNC(h8_watchdog_device::wd_w));
186 map(0xffffbe, 0xffffbf).rw("watchdog", FUNC(h8_watchdog_device::rst_r), FUNC(h8_watchdog_device::rst_w));
187 map(0xffffc0, 0xffffc0).rw("timer16", FUNC(h8_timer16_device::tstr_r), FUNC(h8_timer16_device::tstr_w));
188 map(0xffffc1, 0xffffc1).rw("timer16", FUNC(h8_timer16_device::tsyr_r), FUNC(h8_timer16_device::tsyr_w));
189 map(0xffffd0, 0xffffd0).rw("timer16:0", FUNC(h8_timer16_channel_device::tcr_r), FUNC(h8_timer16_channel_device::tcr_w));
190 map(0xffffd1, 0xffffd1).rw("timer16:0", FUNC(h8_timer16_channel_device::tmdr_r), FUNC(h8_timer16_channel_device::tmdr_w));
191 map(0xffffd2, 0xffffd3).rw("timer16:0", FUNC(h8_timer16_channel_device::tior_r), FUNC(h8_timer16_channel_device::tior_w));
192 map(0xffffd4, 0xffffd4).rw("timer16:0", FUNC(h8_timer16_channel_device::tier_r), FUNC(h8_timer16_channel_device::tier_w));
193 map(0xffffd5, 0xffffd5).rw("timer16:0", FUNC(h8_timer16_channel_device::tsr_r), FUNC(h8_timer16_channel_device::tsr_w));
194 map(0xffffd6, 0xffffd7).rw("timer16:0", FUNC(h8_timer16_channel_device::tcnt_r), FUNC(h8_timer16_channel_device::tcnt_w));
195 map(0xffffd8, 0xffffdf).rw("timer16:0", FUNC(h8_timer16_channel_device::tgr_r), FUNC(h8_timer16_channel_device::tgr_w));
196 map(0xffffe0, 0xffffe0).rw("timer16:1", FUNC(h8_timer16_channel_device::tcr_r), FUNC(h8_timer16_channel_device::tcr_w));
197 map(0xffffe1, 0xffffe1).rw("timer16:1", FUNC(h8_timer16_channel_device::tmdr_r), FUNC(h8_timer16_channel_device::tmdr_w));
198 map(0xffffe2, 0xffffe2).rw("timer16:1", FUNC(h8_timer16_channel_device::tior_r), FUNC(h8_timer16_channel_device::tior_w));
199 map(0xffffe4, 0xffffe4).rw("timer16:1", FUNC(h8_timer16_channel_device::tier_r), FUNC(h8_timer16_channel_device::tier_w));
200 map(0xffffe5, 0xffffe5).rw("timer16:1", FUNC(h8_timer16_channel_device::tsr_r), FUNC(h8_timer16_channel_device::tsr_w));
201 map(0xffffe6, 0xffffe7).rw("timer16:1", FUNC(h8_timer16_channel_device::tcnt_r), FUNC(h8_timer16_channel_device::tcnt_w));
202 map(0xffffe8, 0xffffeb).rw("timer16:1", FUNC(h8_timer16_channel_device::tgr_r), FUNC(h8_timer16_channel_device::tgr_w));
203 map(0xfffff0, 0xfffff0).rw("timer16:2", FUNC(h8_timer16_channel_device::tcr_r), FUNC(h8_timer16_channel_device::tcr_w));
204 map(0xfffff1, 0xfffff1).rw("timer16:2", FUNC(h8_timer16_channel_device::tmdr_r), FUNC(h8_timer16_channel_device::tmdr_w));
205 map(0xfffff2, 0xfffff2).rw("timer16:2", FUNC(h8_timer16_channel_device::tior_r), FUNC(h8_timer16_channel_device::tior_w));
206 map(0xfffff4, 0xfffff4).rw("timer16:2", FUNC(h8_timer16_channel_device::tier_r), FUNC(h8_timer16_channel_device::tier_w));
207 map(0xfffff5, 0xfffff5).rw("timer16:2", FUNC(h8_timer16_channel_device::tsr_r), FUNC(h8_timer16_channel_device::tsr_w));
208 map(0xfffff6, 0xfffff7).rw("timer16:2", FUNC(h8_timer16_channel_device::tcnt_r), FUNC(h8_timer16_channel_device::tcnt_w));
209 map(0xfffff8, 0xfffffb).rw("timer16:2", FUNC(h8_timer16_channel_device::tgr_r), FUNC(h8_timer16_channel_device::tgr_w));
210 }
211
device_add_mconfig(machine_config & config)212 void h8s2357_device::device_add_mconfig(machine_config &config)
213 {
214 H8S_INTC(config, "intc");
215 H8_ADC_2357(config, "adc", "intc", 28);
216 H8_PORT(config, "port1", h8_device::PORT_1, 0x00, 0x00);
217 H8_PORT(config, "port2", h8_device::PORT_2, 0x00, 0x00);
218 H8_PORT(config, "port3", h8_device::PORT_3, 0xc0, 0xc0);
219 H8_PORT(config, "port4", h8_device::PORT_4, 0x00, 0x00);
220 H8_PORT(config, "port5", h8_device::PORT_5, 0xf0, 0xf0);
221 H8_PORT(config, "port6", h8_device::PORT_6, 0x00, 0x00);
222 H8_PORT(config, "porta", h8_device::PORT_A, 0x00, 0x00);
223 H8_PORT(config, "portb", h8_device::PORT_B, 0x00, 0x00);
224 H8_PORT(config, "portc", h8_device::PORT_C, 0x00, 0x00);
225 H8_PORT(config, "portd", h8_device::PORT_D, 0x00, 0x00);
226 H8_PORT(config, "porte", h8_device::PORT_E, 0x00, 0x00);
227 H8_PORT(config, "portf", h8_device::PORT_F, 0x00, 0x00);
228 H8_PORT(config, "portg", h8_device::PORT_G, 0xe0, 0xe0);
229 H8H_TIMER8_CHANNEL(config, "timer8_0", "intc", 64, 65, 66, "timer8_1", h8_timer8_channel_device::CHAIN_OVERFLOW, true, false);
230 H8H_TIMER8_CHANNEL(config, "timer8_1", "intc", 68, 69, 70, "timer8_0", h8_timer8_channel_device::CHAIN_A, false, false);
231 H8_TIMER16(config, "timer16", 6, 0x00);
232 H8S_TIMER16_CHANNEL(config, "timer16:0", 4, 0x60, "intc", 32,
233 h8_timer16_channel_device::DIV_1,
234 h8_timer16_channel_device::DIV_4,
235 h8_timer16_channel_device::DIV_16,
236 h8_timer16_channel_device::DIV_64,
237 h8_timer16_channel_device::INPUT_A,
238 h8_timer16_channel_device::INPUT_B,
239 h8_timer16_channel_device::INPUT_C,
240 h8_timer16_channel_device::INPUT_D);
241 H8S_TIMER16_CHANNEL(config, "timer16:1", 2, 0x4c, "intc", 40,
242 h8_timer16_channel_device::DIV_1,
243 h8_timer16_channel_device::DIV_4,
244 h8_timer16_channel_device::DIV_16,
245 h8_timer16_channel_device::DIV_64,
246 h8_timer16_channel_device::INPUT_A,
247 h8_timer16_channel_device::INPUT_B,
248 h8_timer16_channel_device::DIV_256,
249 h8_timer16_channel_device::CHAIN).set_chain("timer16:2");
250 H8S_TIMER16_CHANNEL(config, "timer16:2", 2, 0x4c, "intc", 44,
251 h8_timer16_channel_device::DIV_1,
252 h8_timer16_channel_device::DIV_4,
253 h8_timer16_channel_device::DIV_16,
254 h8_timer16_channel_device::DIV_64,
255 h8_timer16_channel_device::INPUT_A,
256 h8_timer16_channel_device::INPUT_B,
257 h8_timer16_channel_device::INPUT_C,
258 h8_timer16_channel_device::DIV_1024);
259 H8S_TIMER16_CHANNEL(config, "timer16:3", 4, 0x60, "intc", 48,
260 h8_timer16_channel_device::DIV_1,
261 h8_timer16_channel_device::DIV_4,
262 h8_timer16_channel_device::DIV_16,
263 h8_timer16_channel_device::DIV_64,
264 h8_timer16_channel_device::INPUT_A,
265 h8_timer16_channel_device::DIV_1024,
266 h8_timer16_channel_device::DIV_256,
267 h8_timer16_channel_device::DIV_4096);
268 H8S_TIMER16_CHANNEL(config, "timer16:4", 2, 0x4c, "intc", 56,
269 h8_timer16_channel_device::DIV_1,
270 h8_timer16_channel_device::DIV_4,
271 h8_timer16_channel_device::DIV_16,
272 h8_timer16_channel_device::DIV_64,
273 h8_timer16_channel_device::INPUT_A,
274 h8_timer16_channel_device::INPUT_C,
275 h8_timer16_channel_device::DIV_1024,
276 h8_timer16_channel_device::CHAIN).set_chain("timer16:5");
277 H8S_TIMER16_CHANNEL(config, "timer16:5", 2, 0x4c, "intc", 60,
278 h8_timer16_channel_device::DIV_1,
279 h8_timer16_channel_device::DIV_4,
280 h8_timer16_channel_device::DIV_16,
281 h8_timer16_channel_device::DIV_64,
282 h8_timer16_channel_device::INPUT_A,
283 h8_timer16_channel_device::INPUT_C,
284 h8_timer16_channel_device::DIV_256,
285 h8_timer16_channel_device::INPUT_D);
286 H8_SCI(config, "sci0", "intc", 80, 81, 82, 83);
287 H8_SCI(config, "sci1", "intc", 84, 85, 86, 87);
288 H8_SCI(config, "sci2", "intc", 88, 89, 90, 91);
289 H8_WATCHDOG(config, "watchdog", "intc", 25, h8_watchdog_device::S);
290 }
291
execute_set_input(int inputnum,int state)292 void h8s2357_device::execute_set_input(int inputnum, int state)
293 {
294 intc->set_input(inputnum, state);
295 }
296
exr_in_stack() const297 bool h8s2357_device::exr_in_stack() const
298 {
299 return syscr & 0x20;
300 }
301
trace_setup()302 int h8s2357_device::trace_setup()
303 {
304 CCR |= F_I;
305 EXR &= ~EXR_T;
306 return 5;
307 }
308
trapa_setup()309 int h8s2357_device::trapa_setup()
310 {
311 CCR |= F_I;
312 if(syscr & 0x20)
313 EXR &= ~EXR_T;
314 return 8;
315 }
316
irq_setup()317 void h8s2357_device::irq_setup()
318 {
319 switch(syscr & 0x30) {
320 case 0x00:
321 CCR |= F_I;
322 break;
323 case 0x20:
324 EXR = EXR & (EXR_NC);
325 if(taken_irq_level == 8)
326 EXR |= 7;
327 else
328 EXR |= taken_irq_level;
329 break;
330 }
331 }
332
update_irq_filter()333 void h8s2357_device::update_irq_filter()
334 {
335 switch(syscr & 0x20) {
336 case 0x00:
337 if(CCR & F_I)
338 intc->set_filter(2, -1);
339 else
340 intc->set_filter(0, -1);
341 break;
342 case 0x20:
343 intc->set_filter(0, EXR & 7);
344 break;
345 }
346 }
347
interrupt_taken()348 void h8s2357_device::interrupt_taken()
349 {
350 standard_irq_callback(intc->interrupt_taken(taken_irq_vector));
351 }
352
internal_update(uint64_t current_time)353 void h8s2357_device::internal_update(uint64_t current_time)
354 {
355 uint64_t event_time = 0;
356
357 add_event(event_time, adc->internal_update(current_time));
358 add_event(event_time, sci0->internal_update(current_time));
359 add_event(event_time, sci1->internal_update(current_time));
360 add_event(event_time, sci2->internal_update(current_time));
361 add_event(event_time, timer8_0->internal_update(current_time));
362 add_event(event_time, timer8_1->internal_update(current_time));
363 add_event(event_time, timer16_0->internal_update(current_time));
364 add_event(event_time, timer16_1->internal_update(current_time));
365 add_event(event_time, timer16_2->internal_update(current_time));
366 add_event(event_time, timer16_3->internal_update(current_time));
367 add_event(event_time, timer16_4->internal_update(current_time));
368 add_event(event_time, timer16_5->internal_update(current_time));
369 add_event(event_time, watchdog->internal_update(current_time));
370
371 recompute_bcount(event_time);
372 }
373
device_start()374 void h8s2357_device::device_start()
375 {
376 h8s2000_device::device_start();
377 }
378
device_reset()379 void h8s2357_device::device_reset()
380 {
381 h8s2000_device::device_reset();
382 syscr = 0x01;
383 }
384
syscr_r()385 uint8_t h8s2357_device::syscr_r()
386 {
387 return syscr;
388 }
389
syscr_w(uint8_t data)390 void h8s2357_device::syscr_w(uint8_t data)
391 {
392 syscr = data;
393 update_irq_filter();
394 logerror("syscr = %02x\n", data);
395 }
396