Previous 199869 Revisions Next

r33376 Friday 14th November, 2014 at 22:25:53 UTC by hap
made pla_device more generic
[src/emu/bus/plus4]c1551.h
[src/emu/machine]pla.c pla.h
[src/mess/includes]c128.h c64.h cbm2.h pet.h plus4.h

trunk/src/emu/bus/plus4/c1551.h
r241887r241888
8484   required_device<tpi6525_device> m_tpi0;
8585   required_device<tpi6525_device> m_tpi1;
8686   required_device<c64h156_device> m_ga;
87   required_device<pls100_device> m_pla;
87   required_device<pla_device> m_pla;
8888   required_device<floppy_image_device> m_floppy;
8989   required_device<plus4_expansion_slot_device> m_exp;
9090   required_ioport m_jp1;
trunk/src/emu/machine/pla.c
r241887r241888
22// copyright-holders:Curt Coder
33/**********************************************************************
44
5    PLS100 16x48x8 Programmable Logic Array emulation
5    PLA (Programmable Logic Array) emulation
66
77    Copyright MESS Team.
88    Visit http://mamedev.org for licensing and usage restrictions.
r241887r241888
1010**********************************************************************/
1111
1212#include "pla.h"
13#include "jedparse.h"
14#include "plaparse.h"
1315
1416
17const device_type PLA = &device_creator<pla_device>;
1518
16//**************************************************************************
17//  DEVICE TYPE DEFINITIONS
18//**************************************************************************
19
20const device_type PLS100 = &device_creator<pls100_device>;
21const device_type MOS8721 = &device_creator<mos8721_device>;
22
23
24
25//**************************************************************************
26//  LIVE DEVICE
27//**************************************************************************
28
2919//-------------------------------------------------
3020//  pla_device - constructor
3121//-------------------------------------------------
3222
33pla_device::pla_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, int inputs, int outputs, int terms, UINT32 input_mask, const char *shortname, const char *source) :
34   device_t(mconfig, type, name, tag, owner, clock, shortname, source),
35   m_inputs(inputs),
36   m_outputs(outputs),
37   m_terms(terms),
38   m_input_mask(((UINT64)input_mask << 32) | input_mask)
23pla_device::pla_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
24   : device_t(mconfig, PLA, "PLA", tag, owner, clock, "pla", __FILE__),
25      m_format(PLA_FMT_JEDBIN),
26      m_inputs(0),
27      m_outputs(0),
28      m_terms(0),
29      m_input_mask(0)
3930{
4031}
4132
42pls100_device::pls100_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
43   pla_device(mconfig, PLS100, "PLS100", tag, owner, clock, 16, 8, 48, 0xffff, "pls100", __FILE__),
44   m_output(*this, "output")
45{
46}
4733
48mos8721_device::mos8721_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
49   pla_device(mconfig, MOS8721, "MOS8721", tag, owner, clock, 27, 18, 379, 0x7ffffff, "mos8721", __FILE__) // TODO actual number of terms is unknown
50{
51}
52
53
5434//-------------------------------------------------
5535//  device_start - device-specific startup
5636//-------------------------------------------------
5737
5838void pla_device::device_start()
5939{
60   assert(machine().root_device().memregion(tag()) != NULL);
40   assert(*region() != NULL);
41   assert(m_terms < MAX_TERMS);
42   assert(m_inputs <= 32 && m_outputs <= 32);
6143
44   if (m_input_mask == 0)
45      m_input_mask = ((UINT64)1 << m_inputs) - 1;
46   m_input_mask = ((UINT64)m_input_mask << 32) | m_input_mask;
47
6248   // parse fusemap
6349   parse_fusemap();
6450
65   // clear cache
66   for (int i = 0; i < CACHE_SIZE; i++)
67   {
68      m_cache[i] = 0;
69   }
51   // initialize cache
52   m_cache2_ptr = 0;
53   for (int i = 0; i < CACHE2_SIZE; i++)
54      m_cache2[i] = 0;
7055
71   m_cache_ptr = 0;
56   m_cache_size = 0;
57   int csize = 1 << ((m_inputs > MAX_CACHE_BITS) ? MAX_CACHE_BITS : m_inputs);
58   m_cache.resize(csize);
59   for (int i = 0; i < csize; i++)
60      m_cache[i] = read(i);
61   
62   m_cache_size = csize;
7263}
7364
74void pls100_device::device_start()
75{
76   pla_device::device_start();
7765
78   m_output.allocate(0x10000);
79
80   for (UINT32 input = 0; input < 0x10000; input++)
81   {
82      m_output[input] = pla_device::read(input);
83   }
84}
85
86
8766//-------------------------------------------------
8867//  parse_fusemap -
8968//-------------------------------------------------
9069
9170void pla_device::parse_fusemap()
9271{
93   memory_region *region = machine().root_device().memregion(tag());
9472   jed_data jed;
95
96   jedbin_parse(region->base(), region->bytes(), &jed);
97
73   int result = JEDERR_NONE;
74   
75   // read pla file
76   switch (m_format)
77   {
78      case PLA_FMT_JEDBIN:
79         result = jedbin_parse(region()->base(), region()->bytes(), &jed);
80         break;
81     
82      case PLA_FMT_BERKELEY:
83         result = pla_parse(region()->base(), region()->bytes(), &jed);
84         break;
85   }
86   
87   if (result != JEDERR_NONE)
88      fatalerror("%s PLA parse error %d\n", tag(), result);
89   
90   // parse it
9891   UINT32 fusenum = 0;
9992
10093   for (int p = 0; p < m_terms; p++)
r241887r241888
143136UINT32 pla_device::read(UINT32 input)
144137{
145138   // try the cache first
146   for (int i = 0; i < CACHE_SIZE; ++i)
139   if (input < m_cache_size)
140      return m_cache[input];
141   
142   for (int i = 0; i < CACHE2_SIZE; ++i)
147143   {
148      UINT64 cache_entry = m_cache[i];
144      UINT64 cache2_entry = m_cache2[i];
149145
150      if ((UINT32)cache_entry == input)
146      if ((UINT32)cache2_entry == input)
151147      {
152         // cache hit
153         return cache_entry >> 32;
148         // cache2 hit
149         return cache2_entry >> 32;
154150      }
155151   }
156152
r241887r241888
170166
171167   s ^= m_xor;
172168
173   // store output in cache
174   m_cache[m_cache_ptr] = s | input;
175   ++m_cache_ptr &= (CACHE_SIZE - 1);
169   // store output in cache2
170   m_cache2[m_cache2_ptr] = s | input;
171   ++m_cache2_ptr &= (CACHE2_SIZE - 1);
176172
177173   return s >> 32;
178174}
179
180
181//-------------------------------------------------
182//  read -
183//-------------------------------------------------
184
185UINT32 pls100_device::read(UINT32 input)
186{
187   return m_output[input];
188}
trunk/src/emu/machine/pla.h
r241887r241888
22// copyright-holders:Curt Coder
33/**********************************************************************
44
5    PLS100 16x48x8 Programmable Logic Array emulation
5    PLA (Programmable Logic Array) emulation
66
77    Copyright MESS Team.
88    Visit http://mamedev.org for licensing and usage restrictions.
99
10**********************************************************************
11                            _____   _____
12                    FE   1 |*    \_/     | 28  Vcc
13                    I7   2 |             | 27  I8
14                    I6   3 |             | 26  I9
15                    I5   4 |             | 25  I10
16                    I4   5 |             | 24  I11
17                    I3   6 |    82S100   | 23  I12
18                    I2   7 |    82S101   | 22  I13
19                    I1   8 |    PLS100   | 21  I14
20                    I0   9 |    PLS101   | 20  I15
21                    F7  10 |             | 19  _CE
22                    F6  11 |             | 18  F0
23                    F5  12 |             | 17  F1
24                    F4  13 |             | 16  F2
25                   GND  14 |_____________| 15  F3
26
2710**********************************************************************/
2811
2912#pragma once
r241887r241888
3215#define __PLA__
3316
3417#include "emu.h"
35#include "jedparse.h"
3618
3719
3820
r241887r241888
4123//**************************************************************************
4224
4325#define MAX_TERMS       512
44#define CACHE_SIZE      8
26#define MAX_CACHE_BITS  16
27#define CACHE2_SIZE     8
4528
29enum
30{
31   PLA_FMT_JEDBIN = 0,
32   PLA_FMT_BERKELEY
33};
4634
4735
36
4837///*************************************************************************
4938//  INTERFACE CONFIGURATION MACROS
5039///*************************************************************************
5140
41#define MCFG_PLA_ADD(_tag, _inputs, _outputs, _terms) \
42   MCFG_DEVICE_ADD(_tag, PLA, 0) \
43   pla_device::set_num_inputs(*device, _inputs); \
44   pla_device::set_num_outputs(*device, _outputs); \
45   pla_device::set_num_terms(*device, _terms);
46
47#define MCFG_PLA_INPUTMASK(_mask) \
48   pla_device::set_inputmask(*device, _mask);
49
50#define MCFG_PLA_FILEFORMAT(_format) \
51   pla_device::set_format(*device, _format);
52
53
54// macros for known (and used) devices
55
56// 82S100, 82S101, PLS100, PLS101
57// 16x48x8 PLA, 28-pin
5258#define MCFG_PLS100_ADD(_tag) \
53   MCFG_DEVICE_ADD(_tag, PLS100, 0)
59   MCFG_PLA_ADD(_tag, 16, 8, 48)
5460
61// MOS 8721 PLA
62// TODO: actual number of terms is unknown
5563#define MCFG_MOS8721_ADD(_tag) \
56   MCFG_DEVICE_ADD(_tag, MOS8721, 0)
64   MCFG_PLA_ADD(_tag, 27, 18, 379)
5765
5866
67
5968///*************************************************************************
6069//  TYPE DEFINITIONS
6170///*************************************************************************
6271
6372// ======================> pla_device
6473
65class pla_device : public device_t
74class pla_device : public device_t
6675{
6776public:
6877   // construction/destruction
69   pla_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, int inputs, int outputs, int terms, UINT32 output_mask, const char *shortname, const char *source);
78   pla_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
7079
71   virtual UINT32 read(UINT32 input);
80   // static configuration helpers
81   static void set_num_inputs(device_t &device, UINT32 i) { downcast<pla_device &>(device).m_inputs = i; }
82   static void set_num_outputs(device_t &device, UINT32 o) { downcast<pla_device &>(device).m_outputs = o; }
83   static void set_num_terms(device_t &device, UINT32 t) { downcast<pla_device &>(device).m_terms = t; }
84   static void set_inputmask(device_t &device, UINT32 mask) { downcast<pla_device &>(device).m_input_mask = mask; } // UINT32!
85   static void set_format(device_t &device, int format) { downcast<pla_device &>(device).m_format = format; }
7286
87   UINT32 read(UINT32 input);
88
7389protected:
7490   // device-level overrides
7591   virtual void device_start();
7692
93private:
7794   void parse_fusemap();
7895
79   int m_inputs;
80   int m_outputs;
81   int m_terms;
96   int m_format;
97   
98   UINT32 m_inputs;
99   UINT32 m_outputs;
100   UINT32 m_terms;
82101   UINT64 m_input_mask;
83102   UINT64 m_xor;
84103
104   int m_cache_size;
105   dynamic_array<UINT32> m_cache;
106   UINT64 m_cache2[CACHE2_SIZE];
107   UINT8 m_cache2_ptr;
108
85109   struct term
86110   {
87111      UINT64 m_and;
88112      UINT64 m_or;
89   };
90
91   term m_term[MAX_TERMS];
92
93   UINT64 m_cache[CACHE_SIZE];
94   UINT8 m_cache_ptr;
113   } m_term[MAX_TERMS];
95114};
96115
97116
98// ======================> pls100_device
99
100class pls100_device : public pla_device
101{
102public:
103   pls100_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
104
105   // device-level overrides
106   virtual void device_start();
107
108   virtual UINT32 read(UINT32 input);
109
110private:
111   optional_shared_ptr<UINT8> m_output;
112};
113
114
115// ======================> mos8721_device
116
117class mos8721_device : public pla_device
118{
119public:
120   mos8721_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
121};
122
123
124117// device type definition
125extern const device_type PLS100;
126extern const device_type MOS8721;
118extern const device_type PLA;
127119
128120
129
130121#endif
trunk/src/mess/includes/c128.h
r241887r241888
105105   required_device<cpu_device> m_maincpu;
106106   required_device<m8502_device> m_subcpu;
107107   required_device<mos8722_device> m_mmu;
108   required_device<mos8721_device> m_pla;
108   required_device<pla_device> m_pla;
109109   required_device<mos8563_device> m_vdc;
110110   required_device<mos6566_device> m_vic;
111111   required_device<mos6581_device> m_sid;
trunk/src/mess/includes/c64.h
r241887r241888
7878   UINT8 *m_charom;
7979
8080   required_device<m6510_device> m_maincpu;
81   required_device<pls100_device> m_pla;
81   required_device<pla_device> m_pla;
8282   required_device<mos6566_device> m_vic;
8383   required_device<mos6581_device> m_sid;
8484   required_device<mos6526_device> m_cia1;
trunk/src/mess/includes/cbm2.h
r241887r241888
113113   { }
114114
115115   required_device<cpu_device> m_maincpu;
116   required_device<pls100_device> m_pla1;
116   required_device<pla_device> m_pla1;
117117   optional_device<mc6845_device> m_crtc;
118118   optional_device<palette_device> m_palette;
119119   required_device<mos6581_device> m_sid;
r241887r241888
274274         m_vic_irq(CLEAR_LINE)
275275   { }
276276
277   required_device<pls100_device> m_pla2;
277   required_device<pla_device> m_pla2;
278278   required_device<mos6566_device> m_vic;
279279   optional_shared_ptr<UINT8> m_color_ram;
280280
trunk/src/mess/includes/pet.h
r241887r241888
259259   required_memory_region m_editor_rom;
260260   required_memory_region m_ue5_rom;
261261   required_memory_region m_ue6_rom;
262   required_device<pls100_device> m_pla1;
263   required_device<pls100_device> m_pla2;
262   required_device<pla_device> m_pla1;
263   required_device<pla_device> m_pla2;
264264
265265   DECLARE_MACHINE_START( cbm8296 );
266266   DECLARE_MACHINE_RESET( cbm8296 );
trunk/src/mess/includes/plus4.h
r241887r241888
3131#define SCREEN_TAG          "screen"
3232#define CONTROL1_TAG        "joy1"
3333#define CONTROL2_TAG        "joy2"
34#define PET_USER_PORT_TAG     "user"
34#define PET_USER_PORT_TAG   "user"
3535
3636class plus4_state : public driver_device
3737{
r241887r241888
7171   { }
7272
7373   required_device<m7501_device> m_maincpu;
74   required_device<pls100_device> m_pla;
74   required_device<pla_device> m_pla;
7575   required_device<mos7360_device> m_ted;
7676   optional_device<mos6551_device> m_acia;
7777   optional_device<mos6529_device> m_spi_user;


Previous 199869 Revisions Next


© 1997-2024 The MAME Team