Previous 199869 Revisions Next

r20096 Sunday 6th January, 2013 at 06:30:11 UTC by Andrew Gardner
dsp16: Additional work (nw).

I'll do a full writeup when the whatsnew.txt comes out.
[src/emu/cpu/dsp16]dsp16.c dsp16.h dsp16dis.c dsp16ops.c

trunk/src/emu/cpu/dsp16/dsp16.h
r20095r20096
1313
1414
1515//**************************************************************************
16//  INTERFACE CONFIGURATION MACROS
17//**************************************************************************
18
19//#define MCFG_DSP16_CONFIG(_config)
20//  dsp16_device::static_set_config(*device, _config);
21
22
23
24//**************************************************************************
2516//  TYPE DEFINITIONS
2617//**************************************************************************
2718
r20095r20096
9586    // internal stuff
9687   UINT16 m_ppc;
9788
89   // This core handles the cache as more of a loop than 15 seperate memory elements.
90   // It's a bit of a hack, but it's easier this way.
91   UINT16 m_cacheStart;
92   UINT16 m_cacheEnd;
93   UINT16 m_cacheRedoNextPC;
94   UINT16 m_cacheIterations;
95   static const UINT16 CACHE_INVALID = 0xffff;
96
9897   // memory access
9998   inline UINT32 program_read(UINT32 addr);
10099   inline void program_write(UINT32 addr, UINT32 data);
r20095r20096
108107    int m_icount;
109108
110109   // operations
111   void execute_one(const UINT16& op, UINT8& cycles, UINT8& pcAdvance);
110   void execute_one(const UINT16& op, UINT8& cycles, INT16& pcAdvance);
112111
112   // table decoders
113   void* registerFromRImmediateField(const UINT8& R);
113114   void* registerFromRTable(const UINT8& R);
114115
115116   // helpers
116117   void* addressYL();
117   //void writeYxRegister(const UINT16& value);
118118   void writeRegister(void* reg, const UINT16& value);
119119};
120120
trunk/src/emu/cpu/dsp16/dsp16dis.c
r20095r20096
523523            // R = N
524524            const UINT8 R = (op & 0x03f0) >> 4;
525525            astring rString = disasmRField(R);
526            sprintf(buffer, "%s = 0x%x", rString.cstr(), op2);
526         sprintf(buffer, "%s = 0x%04x", rString.cstr(), op2);
527527            opSize = 2;
528528            break;
529529        }
trunk/src/emu/cpu/dsp16/dsp16.c
r20095r20096
1010#include "debugger.h"
1111#include "dsp16.h"
1212
13//
14// TODO:
15//  * Store the cache in 15 unique memory locations as it is on-chip.
16//  * Modify cycle counts when running from within the cache
17//
1318
1419//**************************************************************************
1520//  DEVICE INTERFACE
r20095r20096
5257     m_sioc(0),
5358     m_pioc(0),
5459     m_ppc(0),
60     m_cacheStart(CACHE_INVALID),
61     m_cacheEnd(CACHE_INVALID),
62     m_cacheRedoNextPC(CACHE_INVALID),
63     m_cacheIterations(0),
5564     m_program(NULL),
5665     m_direct(NULL),
5766     m_icount(0)
r20095r20096
6978{
7079   // register state with the debugger
7180   state_add(STATE_GENPC,    "GENPC",     m_pc).noshow();
81   //state_add(STATE_GENPCBASE, "GENPCBASE", m_ppc).noshow();
7282   state_add(STATE_GENFLAGS, "GENFLAGS",  m_psw).callimport().callexport().formatstr("%10s").noshow();
7383   state_add(DSP16_PC,       "PC",        m_pc);
7484   state_add(DSP16_I,        "I",         m_i);
r20095r20096
96106   state_add(DSP16_SIOC,     "SIOC",      m_sioc).formatstr("%16s");
97107   state_add(DSP16_PIOC,     "PIOC",      m_pioc); //.formatstr("%16s");
98108
109   // register our state for saving
99110   save_item(NAME(m_i));
100111   save_item(NAME(m_pc));
101112   save_item(NAME(m_pt));
r20095r20096
121132   save_item(NAME(m_c2));
122133   save_item(NAME(m_sioc));
123134   save_item(NAME(m_pioc));
135   save_item(NAME(m_ppc));
136   save_item(NAME(m_cacheStart));
137   save_item(NAME(m_cacheEnd));
138   save_item(NAME(m_cacheRedoNextPC));
139   save_item(NAME(m_cacheIterations));
124140
125141   // get our address spaces
126142   m_program = &space(AS_PROGRAM);
r20095r20096
145161   m_re = 0x0000;
146162   // AUC is not affected by reset
147163   m_ppc = m_pc;
164
165   // Hacky cache emulation.
166   m_cacheStart = CACHE_INVALID;
167   m_cacheEnd = CACHE_INVALID;
168   m_cacheRedoNextPC = CACHE_INVALID;
169   m_cacheIterations = 0;
148170}
149171
150172
r20095r20096
170192   switch (entry.index())
171193   {
172194      case STATE_GENFLAGS:
173      string.printf("(multiple below)");
195      string.printf("(below)");
174196         break;
175197
176198      // Placeholder for a better view later (TODO)
r20095r20096
290312
291313      // instruction fetch & execute
292314      UINT8 cycles;
293      UINT8 pcAdvance;
315      INT16 pcAdvance;
294316      const UINT16 op = opcode_read();
317      printf("%d ", m_cacheIterations);
295318      execute_one(op, cycles, pcAdvance);
319      printf("%d\n", m_cacheIterations);
296320
297      // step forward
321      // step
298322      m_pc += pcAdvance;
299323      m_icount -= cycles;
300324
trunk/src/emu/cpu/dsp16/dsp16ops.c
r20095r20096
1010
1111void dsp16_device::writeRegister(void* reg, const UINT16 &value)
1212{
13   // Make sure you're not attempting to write somewhere this function doesn't support.
14   if (reg == &m_p || reg == &m_a0 || reg == &m_a1)
15   {
16      logerror("dsp16::writeRegister called on invalid register at PC 0x%04x.\n", m_pc);
17      return;
18   }
19
1320   if (reg == &m_auc || reg == &m_c0 || reg == &m_c1 || reg == &m_c2)
1421   {
15      *(UINT8*)reg = value & 0x00ff;   // 8 bit registers
22      // 8 bit registers
23      *(UINT8*)reg = value & 0x00ff;
1624   }
1725   else if (reg == &m_i)
1826   {
19      m_i = value & 0x0fff;   // 12 bit register
27      // 12 bit register
28      m_i = value & 0x0fff;
2029   }
2130   else if (reg == &m_y)
2231   {
23      //writeYxRegister(value);   // TODO - check a flag to see if clearing yl is necessary
24      m_y = (value << 16) | (m_y & 0x0000ffff);   // Temporary
32      // Y register [[TODO - check a flag to see if clearing yl is necessary]]
33      m_y = (value << 16) | (m_y & 0x0000ffff);
2534   }
2635   else if (reg == addressYL())
2736   {
28      m_y = value | (m_y & 0xffff0000);         // Temporary
37      // Yl register
38      m_y = value | (m_y & 0xffff0000);
2939   }
3040   else
3141   {
32      *(UINT16*)reg = value;   // The rest
42      // Everything else
43      *(UINT16*)reg = value;
3344   }
3445}
3546
3647
48void* dsp16_device::registerFromRImmediateField(const UINT8& R)
49{
50   switch (R)
51   {
52      case 0x00: return (void*)&m_j;
53      case 0x01: return (void*)&m_k;
54      case 0x02: return (void*)&m_rb;
55      case 0x03: return (void*)&m_re;
56      case 0x04: return (void*)&m_r0;
57      case 0x05: return (void*)&m_r1;
58      case 0x06: return (void*)&m_r2;
59      case 0x07: return (void*)&m_r3;
60
61      default: return NULL;
62   }
63   return NULL;
64}
65
66
3767void* dsp16_device::registerFromRTable(const UINT8 &R)
3868{
3969   switch (R)
r20095r20096
73103}
74104
75105
76void dsp16_device::execute_one(const UINT16& op, UINT8& cycles, UINT8& pcAdvance)
106void dsp16_device::execute_one(const UINT16& op, UINT8& cycles, INT16& pcAdvance)
77107{
78108   cycles = 1;
79109   pcAdvance = 1;
r20095r20096
286316         const UINT16 iVal = opcode_read(1);
287317         void* reg = registerFromRTable(R);
288318         writeRegister(reg, iVal);
289
290319         cycles = 2;
291320         pcAdvance = 2;
292321         break;
r20095r20096
296325      case 0x02: case 0x03:
297326      {
298327         // R = M
299         //const UINT8 M = (op & 0x00ff);
300         //const UINT8 R = (op & 0x0e00) >> 9;
328         const INT8 M = (op & 0x00ff);
329         const UINT8 R = (op & 0x0e00) >> 9;
330         void* reg = registerFromRImmediateField(R);
331         writeRegister(reg, (INT16)M);   // Sign extend 8 bit int
332         cycles = 1;
301333         break;
302334      }
303335
r20095r20096
305337      case 0x0e:
306338      {
307339         // do|redo K
308         //const UINT8 K = (op & 0x007f);
309         //const UINT8 NI = (op & 0x0780) >> 7;
340         const UINT8 K = (op & 0x007f);
341         const UINT8 NI = (op & 0x0780) >> 7;
342         if (NI != 0)
343         {
344            // Do
345            m_cacheStart = m_pc + 1;
346            m_cacheEnd = m_pc + NI + 1;
347            m_cacheIterations = K+1;
348            cycles = 1;
349         }
350         else
351         {
352            // Redo
353            m_cacheIterations = K+1;
354            m_cacheRedoNextPC = m_pc + 1;
355            pcAdvance = m_cacheStart - m_pc;
356            cycles = 2;
357         }
310358         break;
311359      }
312360
r20095r20096
322370         break;
323371      }
324372   }
373
374   // Handle end-of-cache conditions for do|redos
375   if (m_cacheIterations == 0 && m_cacheRedoNextPC != CACHE_INVALID)
376   {
377      // You've reached the end of a cache loop after a redo opcode.
378      pcAdvance = m_cacheRedoNextPC - m_pc;
379      m_cacheRedoNextPC = CACHE_INVALID;
380   }
381   if (m_cacheIterations > 0 && (m_pc+pcAdvance == m_cacheEnd))
382   {
383      // A regular iteration on a cached loop.
384      m_cacheIterations--;
385      pcAdvance = m_cacheStart - m_pc;
386   }
325387}

Previous 199869 Revisions Next


© 1997-2024 The MAME Team