Previous 199869 Revisions Next

r26196 Saturday 16th November, 2013 at 14:27:26 UTC by Phil Bennett
TMS57002 fixes and improvements: [Phil Bennett]
- Moved CA/ID post-increment outside of execution.
  Fixes case where dual instructions post-increment, also reduces number of generated instructions.
- Fixed data ordering of external memory accesses.
- Don't generate redundant instructions for undefined rounding modes; remap them in decode.
- Set XOA to 0 on reset.
- Use [READ|WRITE]LINE_MEMBER for I/O lines.
- Added PC0 line.
- Added registers to debugger state.
[src/emu/cpu/tms57002]tms57002.c tms57002.h tms57kdec.c tmsmake.py
[src/mame/drivers]konamigx.c

trunk/src/emu/cpu/tms57002/tms57002.h
r26195r26196
1919   DECLARE_READ8_MEMBER(data_r);
2020   DECLARE_WRITE8_MEMBER(data_w);
2121
22   DECLARE_WRITE8_MEMBER(pload_w);
23   DECLARE_WRITE8_MEMBER(cload_w);
24   DECLARE_READ8_MEMBER(empty_r);
25   DECLARE_READ8_MEMBER(dready_r);
22   DECLARE_WRITE_LINE_MEMBER(pload_w);
23   DECLARE_WRITE_LINE_MEMBER(cload_w);
24   DECLARE_READ_LINE_MEMBER(empty_r);
25   DECLARE_READ_LINE_MEMBER(dready_r);
26   DECLARE_READ_LINE_MEMBER(pc0_r);
27   DECLARE_WRITE_LINE_MEMBER(sync_w);
2628
27   void sync();
28
2929protected:
3030   virtual void device_start();
3131   virtual void device_reset();
r26195r26196
8989
9090   enum { IBS = 8192, HBS = 4096 };
9191
92   enum { INC_CA = 1, INC_ID = 2 };
93
9294   struct icd {
9395      unsigned short op;
9496      short next;
r26195r26196
110112
111113   struct cstate {
112114      int branch;
115      int inc;
113116      short hnode;
114117      short ipc;
115118   };
r26195r26196
125128   UINT32 st0, st1, sti;
126129   UINT32 aacc, xoa, xba, xwr, xrd, creg;
127130
128   UINT8 pc, ca, id, ba0, ba1, rptc, rptc_next, sa;
131   UINT8 pc, hpc, ca, id, ba0, ba1, rptc, rptc_next, sa;
129132
130133   UINT32 xm_adr;
131134
r26195r26196
145148   void decode_cat3(UINT32 opcode, unsigned short *op, cstate *cs);
146149   void decode_cat2_post(UINT32 opcode, unsigned short *op, cstate *cs);
147150
148   inline int xmode(UINT32 opcode, char type);
151   inline int xmode(UINT32 opcode, char type, cstate *cs);
149152   inline int sfao(UINT32 st1);
150153   inline int dbp(UINT32 st1);
151154   inline int crm(UINT32 st1);
r26195r26196
185188};
186189
187190enum {
188   TMS57002_PC=1
191   TMS57002_PC=1,
192   TMS57002_AACC,
193   TMS57002_BA0,
194   TMS57002_BA1,
195   TMS57002_CREG,
196   TMS57002_CA,
197   TMS57002_DREG,
198   TMS57002_ID,
199   TMS57002_MACC,
200   TMS57002_HIDX,
201   TMS57002_HOST0,
202   TMS57002_HOST1,
203   TMS57002_HOST2,
204   TMS57002_HOST3,
205   TMS57002_RPTC,
206   TMS57002_SA,
207   TMS57002_ST0,
208   TMS57002_ST1,
209   TMS57002_TREG,
210   TMS57002_XBA,
211   TMS57002_XOA,
212   TMS57002_XRD,
213   TMS57002_XWR,
189214};
190215
191216extern const device_type TMS57002;
trunk/src/emu/cpu/tms57002/tms57kdec.c
r26195r26196
1212#include "debugger.h"
1313#include "tms57002.h"
1414
15inline int tms57002_device::xmode(UINT32 opcode, char type)
15inline int tms57002_device::xmode(UINT32 opcode, char type, cstate *cs)
1616{
1717   if(((opcode & 0x400) && (type == 'c')) || (!(opcode & 0x400) && (type == 'd'))) {
1818      if(opcode & 0x100)
1919         return 0;
2020      else if(opcode & 0x80)
21         return 2;
22      else
23         return 1;
24   } else if(opcode & 0x200)
25      return 2;
21         cs->inc |= type == 'c' ? INC_CA : INC_ID;
2622
23      return 1;
24   }
25   else if(opcode & 0x200)
26      cs->inc |= type == 'c' ? INC_CA : INC_ID;
27
2728   return 1;
2829}
2930
r26195r26196
3940
4041inline int tms57002_device::crm(UINT32 st1)
4142{
42   return (st1 & ST1_CRM) >> ST1_CRM_SHIFT;
43   int crm = (st1 & ST1_CRM) >> ST1_CRM_SHIFT;
44   return crm <= 2 ? crm : 0;
4345}
4446
4547inline int tms57002_device::sfai(UINT32 st1)
r26195r26196
5456
5557inline int tms57002_device::rnd(UINT32 st1)
5658{
57   return (st1 & ST1_RND) >> ST1_RND_SHIFT;
59   int rnd = (st1 & ST1_RND) >> ST1_RND_SHIFT;
60   return rnd <= 4 ? rnd : 0;
5861}
5962
6063inline int tms57002_device::movm(UINT32 st1)
trunk/src/emu/cpu/tms57002/tmsmake.py
r26195r26196
2020}
2121
2222def expand_c(v):
23    fmt =  ["%s", "(%s & 0xffff0000)", "(%s << 16)", "%s"][v["crm"]]
24    param = ["cmem[i->param]", "cmem[ca]", "cmem[ca++]"][v["cmode"]]
23    fmt =  ["%s", "(%s & 0xffff0000)", "(%s << 16)"][v["crm"]]
24    param = ["cmem[i->param]", "cmem[ca]"][v["cmode"]]
2525    return fmt %  param
2626
2727def expand_d(v):
28    index = ["(i->param + ", "(id + ", "((id++) + "][v["dmode"]]
28    index = ["(i->param + ", "(id + "][v["dmode"]]
2929    mask =  ["ba0) & 0xff] << 8)", "ba1) & 0x1f] << 8)"][v["dbp"]]
3030    return "(dmem%d[" % v["dbp"] + index + mask
3131
3232def expand_d24(v):
33    index = ["(i->param + ", "(id + ", "((id++) + "][v["dmode"]]
33    index = ["(i->param + ", "(id + "][v["dmode"]]
3434    mask =  ["ba0) & 0xff]", "ba1) & 0x1f]"][v["dbp"]]
3535    return "dmem%d[" % v["dbp"] + index + mask
3636
r26195r26196
4040    c = ["", "s"][v["movm"]]
4141    return "check_macc_overflow_%d%s()" % (v["sfmo"], c)
4242
43EXPAND_WC = ["cmem[i->param] =", "cmem[ca] =", "cmem[ca++] ="]
43EXPAND_WC = ["cmem[i->param] =", "cmem[ca] ="]
4444
4545
4646ROUNDING = [ 0, 1 << (48-32-1), 1 << (48-24-1), 1 << (48-30-1),
47             1 << (48-16-1), 0, 0, 0]
47             1 << (48-16-1)]
4848
4949A = (1 << 64) - 1
5050RMASK= [A,
r26195r26196
5252        A - (1 << (48-24)) + 1,
5353        A - (1 << (48-30)) + 1,
5454        A - (1 << (48-16)) + 1,
55        A,
56        A,
57        A,
5855        ]
5956
6057def expand_mo(v):
r26195r26196
6461
6562
6663def expand_wd1(v):
67    index = ["(i->param + ", "(id + ", "((id++) + "][v["dmode"]]
64    index = ["(i->param + ", "(id + "][v["dmode"]]
6865    mask =  ["ba0) & 0xff] =", "ba1) & 0x1f] ="][v["dbp"]]
6966    return "dmem%d[" % v["dbp"] + index + mask
7067
r26195r26196
111108}
112109
113110VARIANTS = {
114    "cmode": (3, "xmode(opcode, 'c')" ),
115    "dmode": (3, "xmode(opcode, 'd')" ),
111    "cmode": (2, "xmode(opcode, 'c', cs)" ),
112    "dmode": (2, "xmode(opcode, 'd', cs)" ),
116113    "sfai":  (2, "sfai(st1)"),
117    "crm":   (4, "crm(st1)"),
114    "crm":   (3, "crm(st1)"),
118115    "dbp":   (2, "dbp(st1)"),
119116    "sfao":  (2, "sfao(st1)"),
120117    "sfmo":  (4, "sfmo(st1)"),
121    "rnd":   (8, "rnd(st1)"),
118    "rnd":   (5, "rnd(st1)"),
122119    "movm":  (2, "movm(st1)"),
123120    "sfma":  (4, "sfma(st1)"),
124121    # dummy
r26195r26196
364361
365362def EmitCdec(f, ins_list):
366363    ins_list.sort(cmp=ins_cmp_dasm)
367    no = 1
364    no = 4
368365    last_cat = ""
369366    for i in ins_list:
370367        if not i._run: continue
r26195r26196
383380        no += i._variants
384381        print >>f
385382
386    no = 1
383    no = 4
387384    for i in ins_list:
388385        if not i._run: continue
389386        cat = i._cat.upper()
r26195r26196
409406def EmitCintrp(f, ins_list):
410407    ins_list.sort(cmp=ins_cmp_dasm)
411408    print >>f, "#ifdef CINTRP"
412    no = 1
409    no = 4
413410    for i in ins_list:
414411        no = i.EmitCintrp(f, "", no)
415412    print >>f, "#endif"
trunk/src/emu/cpu/tms57002/tms57002.c
r26195r26196
2828}
2929
3030
31WRITE8_MEMBER(tms57002_device::pload_w)
31WRITE_LINE_MEMBER(tms57002_device::pload_w)
3232{
3333   UINT8 olds = sti;
34   if(data)
34   if(state)
3535      sti &= ~IN_PLOAD;
3636   else
3737      sti |= IN_PLOAD;
38   if(olds ^ sti)
39      hidx = 0;
38   if(olds ^ sti) {
39      if (sti & IN_PLOAD) {
40         hidx = 0;
41         hpc = 0;
42      }
43   }
4044}
4145
42WRITE8_MEMBER(tms57002_device::cload_w)
46WRITE_LINE_MEMBER(tms57002_device::cload_w)
4347{
4448   UINT8 olds = sti;
45   if(data)
49   if(state)
4650      sti &= ~IN_CLOAD;
4751   else
4852      sti |= IN_CLOAD;
49   if(olds ^ sti)
50      hidx = 0;
53   if(olds ^ sti) {
54      if (sti & IN_CLOAD) {
55         hidx = 0;
56         ca = 0;
57      }
58   }
5159}
5260
5361void tms57002_device::device_reset()
r26195r26196
6573   st1 &= ~(ST1_AOV | ST1_SFAI | ST1_SFAO | ST1_MOVM | ST1_MOV |
6674         ST1_SFMA | ST1_SFMO | ST1_RND | ST1_CRM | ST1_DBP);
6775
68   xba = 0; // Not sure but makes sense
69
76   xba = 0;
77   xoa = 0;
7078   cache_flush();
7179}
7280
r26195r26196
93101            sti = (sti & ~SU_MASK) | SU_PRG;
94102            break;
95103         case SU_PRG:
96            program->write_dword((pc++) << 2, val);
104            program->write_dword(pc++ << 2, val);
97105            break;
98106         }
99107      }
r26195r26196
141149   return res;
142150}
143151
144READ8_MEMBER(tms57002_device::empty_r)
152READ_LINE_MEMBER(tms57002_device::empty_r)
145153{
146154   return 1;
147155}
148156
149READ8_MEMBER(tms57002_device::dready_r)
157READ_LINE_MEMBER(tms57002_device::dready_r)
150158{
151159   return sti & S_HOST ? 0 : 1;
152160}
153161
154void tms57002_device::sync()
162READ_LINE_MEMBER(tms57002_device::pc0_r)
155163{
164   return pc == 0 ? 0 : 1;
165}
166
167WRITE_LINE_MEMBER(tms57002_device::sync_w)
168{
156169   if(sti & (IN_PLOAD | IN_CLOAD))
157170      return;
158171
r26195r26196
197210   int done;
198211   if(st0 & ST0_WORD) {
199212      if(st0 & ST0_SEL) {
200         int off = (adr & 3) << 3;
213         int off = 16 - ((adr & 3) << 3);
201214         xrd = (xrd & ~(0xff << off)) | (v << off);
202         done = off == 16;
215         done = off == 0;
203216      } else {
204         int off = (adr & 7) << 2;
217         int off = 20 - ((adr & 7) << 2);
205218         xrd = (xrd & ~(0xf << off)) | ((v & 0xf) << off);
206         done = off == 20;
219         done = off == 0;
207220      }
208221   } else {
209222      if(st0 & ST0_SEL) {
210         int off = (adr & 1) << 3;
223         int off = 16 - ((adr & 1) << 3);
211224         xrd = (xrd & ~(0xff << off)) | (v << off);
212225         done = off == 8;
213226         if(done)
214            xrd &= 0x00ffff;
227            xrd &= 0xffff00;
215228      } else {
216         int off = (adr & 3) << 2;
229         int off = 20 - ((adr & 3) << 2);
217230         xrd = (xrd & ~(0xf << off)) | ((v & 0xf) << off);
218         done = off == 12;
231         done = off == 8;
219232         if(done)
220            xrd &= 0x00ffff;
233            xrd &= 0xffff00;
221234      }
222235   }
223236   if(done) {
r26195r26196
234247   int done;
235248   if(st0 & ST0_WORD) {
236249      if(st0 & ST0_SEL) {
237         int off = (adr & 3) << 3;
250         int off = 16 - ((adr & 3) << 3);
238251         v = xwr >> off;
239         done = off == 16;
252         done = off == 0;
240253      } else {
241         int off = (adr & 7) << 2;
254         int off = 20 - ((adr & 7) << 2);
242255         v = (xwr >> off) & 0xf;
243         done = off == 20;
256         done = off == 0;
244257      }
245258   } else {
246259      if(st0 & ST0_SEL) {
247         int off = (adr & 1) << 3;
260         int off = 16 - ((adr & 1) << 3);
248261         v = xwr >> off;
249262         done = off == 8;
250263      } else {
251         int off = (adr & 3) << 2;
264         int off = 20 - ((adr & 3) << 2);
252265         v = (xwr >> off) & 0xf;
253         done = off == 12;
266         done = off == 8;
254267      }
255268   }
256269   data->write_byte(adr, v);
r26195r26196
669682   for(;;) {
670683      short ipc;
671684      UINT32 opcode = program->read_dword(adr << 2);
685     
686      cs.inc = 0;
672687
673688      if((opcode & 0xfc0000) == 0xfc0000)
674689         decode_one(opcode, &cs, &tms57002_device::decode_cat3);
r26195r26196
677692         decode_one(opcode, &cs, &tms57002_device::decode_cat1);
678693         decode_one(opcode, &cs, &tms57002_device::decode_cat2_post);
679694      }
680      add_one(&cs, 0, 0);
695      add_one(&cs, cs.inc, 0);
681696
682697      if(cs.branch)
683698         break;
r26195r26196
725740         case 0:
726741            goto inst;
727742
743         case 1:
744            ++ca;
745            goto inst;
746         
747         case 2:
748            ++id;
749            goto inst;
750         
751         case 3:
752            ++ca, ++id;
753            goto inst;
754
728755#define CINTRP
729756#include "cpu/tms57002/tms57002.inc"
730757#undef CINTRP
r26195r26196
761788   program = &space(AS_PROGRAM);
762789   data    = &space(AS_DATA);
763790
764   state_add(STATE_GENPC,"GENPC", pc).noshow();
791   state_add(STATE_GENPC,    "GENPC",  pc).noshow();
792   state_add(TMS57002_PC,    "PC",     pc);
793   state_add(TMS57002_ST0,   "ST0",    st0);
794   state_add(TMS57002_ST1,   "ST1",    st1);
795   state_add(TMS57002_RPTC,  "RPTC",   rptc);
796   state_add(TMS57002_AACC,  "AACC",   aacc);
797   state_add(TMS57002_MACC,  "MACC",   macc).mask(U64(0xfffffffffffff));
798   state_add(TMS57002_BA0,   "BA0",    ba0);
799   state_add(TMS57002_BA1,   "BA1",    ba1);
800   state_add(TMS57002_CREG,  "CREG",   creg);
801   state_add(TMS57002_CA,    "CA",     ca);
802   state_add(TMS57002_ID,    "ID",     id);
803   state_add(TMS57002_XBA,   "XBA",    xba);
804   state_add(TMS57002_XOA,   "XOA",    xoa);
805   state_add(TMS57002_XRD,   "XRD",    xrd);
806   state_add(TMS57002_XWR,   "XWR",    xwr);
807   state_add(TMS57002_HIDX,  "HIDX",   hidx);
808   state_add(TMS57002_HOST0, "HOST0",  host[0]);
809   state_add(TMS57002_HOST1, "HOST1",  host[1]);
810   state_add(TMS57002_HOST2, "HOST2",  host[2]);
811   state_add(TMS57002_HOST3, "HOST3",  host[3]);
765812
766813   m_icountptr = &icount;
767814
trunk/src/mame/drivers/konamigx.c
r26195r26196
12501250
12511251INTERRUPT_GEN_MEMBER(konamigx_state::tms_sync)
12521252{
1253   downcast<tms57002_device *>(&device)->sync();
1253   m_dasp->sync_w(1);
12541254}
12551255
12561256READ16_MEMBER(konamigx_state::tms57002_data_word_r)
r26195r26196
12661266
12671267READ16_MEMBER(konamigx_state::tms57002_status_word_r)
12681268{
1269   return (m_dasp->dready_r(space, 0) ? 4 : 0) |
1270      (m_dasp->empty_r(space, 0) ? 1 : 0);
1269   return (m_dasp->dready_r() ? 4 : 0) |
1270      (m_dasp->pc0_r() ? 2 : 0) |
1271      (m_dasp->empty_r() ? 1 : 0);
12711272}
12721273
12731274WRITE16_MEMBER(konamigx_state::tms57002_control_word_w)
12741275{
12751276   if (ACCESSING_BITS_0_7)
12761277   {
1277      m_dasp->pload_w(space, 0, data & 4);
1278      m_dasp->cload_w(space, 0, data & 8);
1278      m_dasp->pload_w(data & 4);
1279      m_dasp->cload_w(data & 8);
12791280      m_dasp->set_input_line(INPUT_LINE_RESET, !(data & 16) ? ASSERT_LINE : CLEAR_LINE);
12801281   }
12811282}

Previous 199869 Revisions Next


© 1997-2024 The MAME Team