Netlist: Roms now specify an identifier in the netlist.

The identifier is used to load data from a source_t implementation. This
allos a consistent approach in netlists independent of netlist
implementation. Both sources code and parameter code needed quite some
rewrite to support this. [Couriersud]
This commit is contained in:
couriersud 2016-12-27 02:43:14 +01:00
parent 15e101afc8
commit f43e45a5cf
13 changed files with 283 additions and 131 deletions

View File

@ -15,6 +15,7 @@
#include "netlist/nl_factory.h" #include "netlist/nl_factory.h"
#include "netlist/nl_parser.h" #include "netlist/nl_parser.h"
#include "netlist/devices/net_lib.h" #include "netlist/devices/net_lib.h"
#include "plib/palloc.h"
#include "debugger.h" #include "debugger.h"
//#define LOG_DEV_CALLS(x) printf x //#define LOG_DEV_CALLS(x) printf x
@ -225,35 +226,33 @@ void netlist_mame_logic_input_t::device_start()
netlist_mame_rom_t::netlist_mame_rom_t(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) netlist_mame_rom_t::netlist_mame_rom_t(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
: device_t(mconfig, NETLIST_ROM_REGION, "Netlist ROM Region", tag, owner, clock, "netlist_rom_region", __FILE__) : device_t(mconfig, NETLIST_ROM_REGION, "Netlist ROM Region", tag, owner, clock, "netlist_rom_region", __FILE__)
, netlist_mame_sub_interface(*owner) , netlist_mame_sub_interface(*owner)
, m_param(nullptr) , m_name("")
, m_param_name("") , m_region_tag(nullptr)
, m_data_tag(nullptr) , m_offset(0)
, m_data(nullptr) , m_size(0)
{ {
} }
void netlist_mame_rom_t::static_set_params(device_t &device, const char *param_name, const char* data_tag) void netlist_mame_rom_t::static_set_params(device_t &device, const char *name, const char* region_tag, std::size_t offset, std::size_t size)
{ {
netlist_mame_rom_t &netlist = downcast<netlist_mame_rom_t&>(device); netlist_mame_rom_t &r = downcast<netlist_mame_rom_t&>(device);
LOG_DEV_CALLS(("static_set_params %s\n", device.tag())); LOG_DEV_CALLS(("static_set_params %s\n", device.tag()));
netlist.m_param_name = param_name; r.m_name = name;
netlist.m_data_tag = data_tag; r.m_region_tag = region_tag;
r.m_offset = offset;
r.m_size = size;
}
void netlist_mame_rom_t::custom_netlist_additions(netlist::setup_t &setup)
{
if (memregion(m_region_tag) == nullptr)
fatalerror("device %s region %s not found\n", basetag(), m_region_tag);
setup.register_source(plib::make_unique_base<netlist::source_t, netlist_data_memregion_t>(setup,
m_name, memregion(m_region_tag)->base() + m_offset, m_size));
} }
void netlist_mame_rom_t::device_start() void netlist_mame_rom_t::device_start()
{ {
LOG_DEV_CALLS(("start %s\n", tag()));
netlist::param_t *p = downcast<netlist_mame_device_t *>(this->owner())->setup().find_param(m_param_name);
m_param = dynamic_cast<netlist::param_ptr_t *>(p);
if (m_param == nullptr)
{
fatalerror("device %s wrong parameter type for %s\n", basetag(), m_param_name.cstr());
}
if (memregion(m_data_tag) != nullptr)
m_data = memregion(m_data_tag)->base();
m_param->setTo(m_data);
} }
// ---------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------
@ -449,6 +448,17 @@ void netlist_mame_device_t::device_start()
nl_register_devices(); nl_register_devices();
/* let sub-devices add sources and do stuff prior to parsing */
for (device_t &d : subdevices())
{
netlist_mame_sub_interface *sdev = dynamic_cast<netlist_mame_sub_interface *>(&d);
if( sdev != nullptr )
{
LOG_DEV_CALLS(("Preparse subdevice %s/%s\n", d.name(), d.shortname()));
sdev->pre_parse_action(*m_setup);
}
}
m_setup_func(*m_setup); m_setup_func(*m_setup);
/* let sub-devices tweak the netlist */ /* let sub-devices tweak the netlist */
@ -783,9 +793,17 @@ void netlist_mame_sound_device_t::sound_stream_update(sound_stream &stream, stre
// memregion source support // memregion source support
// ---------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------
bool netlist_source_memregion_t::parse(netlist::setup_t &setup, const pstring &name) std::unique_ptr<plib::pistream> netlist_source_memregion_t::stream(const pstring &name)
{ {
memory_region *mem = downcast<netlist_mame_t &>(setup.netlist()).machine().root_device().memregion(m_name.cstr()); memory_region *mem = downcast<netlist_mame_t &>(setup().netlist()).machine().root_device().memregion(m_name.cstr());
plib::pimemstream istrm(mem->base(),mem->bytes() ); return plib::make_unique_base<plib::pistream, plib::pimemstream>(mem->base(), mem->bytes());
return setup.parse_stream(istrm, name);
} }
std::unique_ptr<plib::pistream> netlist_data_memregion_t::stream(const pstring &name)
{
if (name == m_name)
return plib::make_unique_base<plib::pistream, plib::pimemstream>(m_ptr, m_size);
else
return std::unique_ptr<plib::pistream>(nullptr);
}

View File

@ -49,9 +49,9 @@
MCFG_DEVICE_ADD(_basetag ":" _tag, NETLIST_INT_INPUT, 0) \ MCFG_DEVICE_ADD(_basetag ":" _tag, NETLIST_INT_INPUT, 0) \
netlist_mame_int_input_t::static_set_params(*device, _name, _mask, _shift); netlist_mame_int_input_t::static_set_params(*device, _name, _mask, _shift);
#define MCFG_NETLIST_ROM_REGION(_basetag, _tag, _name, _region) \ #define MCFG_NETLIST_ROM_REGION(_basetag, _tag, _region, _name, _offset, _size) \
MCFG_DEVICE_ADD(_basetag ":" _tag, NETLIST_ROM_REGION, 0) \ MCFG_DEVICE_ADD(_basetag ":" _tag, NETLIST_ROM_REGION, 0) \
netlist_mame_rom_t::static_set_params(*device, _name ".m_ROM", ":" _region); netlist_mame_rom_t::static_set_params(*device, _name, ":" _region, _offset, _size);
#define MCFG_NETLIST_RAM_POINTER(_basetag, _tag, _name) \ #define MCFG_NETLIST_RAM_POINTER(_basetag, _tag, _name) \
MCFG_DEVICE_ADD(_basetag ":" _tag, NETLIST_RAM_POINTER, 0) \ MCFG_DEVICE_ADD(_basetag ":" _tag, NETLIST_RAM_POINTER, 0) \
@ -76,7 +76,7 @@
#define MEMREGION_SOURCE(_name) \ #define MEMREGION_SOURCE(_name) \
setup.register_source(plib::make_unique_base<netlist::source_t, netlist_source_memregion_t>(_name)); setup.register_source(plib::make_unique_base<netlist::source_t, netlist_source_memregion_t>(setup, _name));
#define NETDEV_ANALOG_CALLBACK_MEMBER(_name) \ #define NETDEV_ANALOG_CALLBACK_MEMBER(_name) \
void _name(const double data, const attotime &time) void _name(const double data, const attotime &time)
@ -92,16 +92,35 @@
class netlist_source_memregion_t : public netlist::source_t class netlist_source_memregion_t : public netlist::source_t
{ {
public: public:
netlist_source_memregion_t(pstring name) netlist_source_memregion_t(netlist::setup_t &setup, pstring name)
: netlist::source_t(), m_name(name) : netlist::source_t(setup), m_name(name)
{ {
} }
bool parse(netlist::setup_t &setup, const pstring &name) override; virtual std::unique_ptr<plib::pistream> stream(const pstring &name) override;
private: private:
pstring m_name; pstring m_name;
}; };
class netlist_data_memregion_t : public netlist::source_t
{
public:
netlist_data_memregion_t(netlist::setup_t &setup,
pstring name, uint8_t *ptr, std::size_t size)
: netlist::source_t(setup, netlist::source_t::DATA)
, m_name(name)
, m_ptr(ptr)
, m_size(size)
{
}
virtual std::unique_ptr<plib::pistream> stream(const pstring &name) override;
private:
pstring m_name;
uint8_t *m_ptr;
std::size_t m_size;
};
class netlist_mame_device_t; class netlist_mame_device_t;
class netlist_mame_t : public netlist::netlist_t class netlist_mame_t : public netlist::netlist_t
@ -325,6 +344,7 @@ public:
virtual ~netlist_mame_sub_interface() { } virtual ~netlist_mame_sub_interface() { }
virtual void custom_netlist_additions(netlist::setup_t &setup) { } virtual void custom_netlist_additions(netlist::setup_t &setup) { }
virtual void pre_parse_action(netlist::setup_t &setup) { }
inline netlist_mame_device_t &nl_owner() const { return *m_owner; } inline netlist_mame_device_t &nl_owner() const { return *m_owner; }
@ -557,21 +577,18 @@ public:
netlist_mame_rom_t(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); netlist_mame_rom_t(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
virtual ~netlist_mame_rom_t() { } virtual ~netlist_mame_rom_t() { }
static void static_set_params(device_t &device, const char *param_name, const char* region_tag); static void static_set_params(device_t &device, const char *name, const char* region_tag, std::size_t offset, std::size_t size);
protected: protected:
// device-level overrides // device-level overrides
virtual void device_start() override; virtual void device_start() override;
virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) override virtual void custom_netlist_additions(netlist::setup_t &setup) override;
{
m_param->setTo(m_data);
}
private: private:
netlist::param_ptr_t *m_param; pstring m_name;
pstring m_param_name; const char* m_region_tag;
const char* m_data_tag; std::size_t m_offset;
uint8_t* m_data; std::size_t m_size;
}; };
// ---------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------

View File

@ -19,7 +19,7 @@ namespace netlist
, m_EPQ(*this, "EPQ") , m_EPQ(*this, "EPQ")
, m_D(*this, {{ "D0", "D1", "D2", "D3", "D4", "D5", "D6", "D7" }}) , m_D(*this, {{ "D0", "D1", "D2", "D3", "D4", "D5", "D6", "D7" }})
, m_last_EPQ(*this, "m_last_EPQ", 1) , m_last_EPQ(*this, "m_last_EPQ", 1)
, m_ROM(*this, "m_ROM", nullptr) , m_ROM(*this, "ROM")
{ {
} }
@ -33,7 +33,7 @@ namespace netlist
state_var<unsigned> m_last_EPQ; state_var<unsigned> m_last_EPQ;
param_ptr_t m_ROM; // 16 Kbits, used as 2 Kbit x 8 param_rom_t<uint8_t, 11, 8> m_ROM; // 16 Kbits, used as 2 Kbit x 8
}; };
NETLIB_OBJECT_DERIVED(2716_dip, 2716) NETLIB_OBJECT_DERIVED(2716_dip, 2716)
@ -78,10 +78,7 @@ namespace netlist
for (std::size_t i=0; i<11; i++) for (std::size_t i=0; i<11; i++)
a |= (m_A[i]() << i); a |= (m_A[i]() << i);
if (m_ROM() != nullptr) d = m_ROM[a];
{
d = ((std::uint_fast8_t*)(m_ROM()))[a];
}
if (m_last_EPQ) if (m_last_EPQ)
delay = NLTIME_FROM_NS(120); delay = NLTIME_FROM_NS(120);

View File

@ -18,7 +18,7 @@ namespace netlist
, m_CE1Q(*this, "CE1Q") , m_CE1Q(*this, "CE1Q")
, m_CE2Q(*this, "CE2Q") , m_CE2Q(*this, "CE2Q")
, m_O(*this, {{"O1", "O2", "O3", "O4" }}) , m_O(*this, {{"O1", "O2", "O3", "O4" }})
, m_ROM(*this, "m_ROM", nullptr) , m_ROM(*this, "ROM")
{ {
} }
@ -30,7 +30,7 @@ namespace netlist
logic_input_t m_CE2Q; logic_input_t m_CE2Q;
object_array_t<logic_output_t, 4> m_O; object_array_t<logic_output_t, 4> m_O;
param_ptr_t m_ROM; // 1024 bits, 32x32, used as 256x4 param_rom_t<uint8_t, 8, 4> m_ROM; // 1024 bits, 32x32, used as 256x4
}; };
NETLIB_OBJECT_DERIVED(82S126_dip, 82S126) NETLIB_OBJECT_DERIVED(82S126_dip, 82S126)
@ -68,8 +68,7 @@ namespace netlist
for (std::size_t i=0; i<8; i++) for (std::size_t i=0; i<8; i++)
a |= (m_A[i]() << i); a |= (m_A[i]() << i);
if (m_ROM() != nullptr) o = m_ROM[a];
o = ((std::uint_fast8_t*)(m_ROM()))[a];
delay = NLTIME_FROM_NS(50); delay = NLTIME_FROM_NS(50);
} }

View File

@ -464,27 +464,7 @@ void netlist_t::print_stats() const
} }
} }
// ----------------------------------------------------------------------------------------
// Parameters ...
// ----------------------------------------------------------------------------------------
template <typename C, param_t::param_type_t T>
param_template_t<C, T>::param_template_t(device_t &device, const pstring name, const C val)
: param_t(T, device, device.name() + "." + name)
, m_param(val)
{
/* pstrings not yet supported, these need special logic */
if (T != param_t::STRING && T != param_t::MODEL)
netlist().save(*this, m_param, "m_param");
device.setup().register_and_set_param(device.name() + "." + name, *this);
}
template class param_template_t<double, param_t::DOUBLE>;
template class param_template_t<int, param_t::INTEGER>;
template class param_template_t<bool, param_t::LOGIC>;
template class param_template_t<std::uint_fast8_t*, param_t::POINTER>;
template class param_template_t<pstring, param_t::STRING>;
template class param_template_t<pstring, param_t::MODEL>;
// ---------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------
// core_device_t // core_device_t
@ -905,15 +885,45 @@ logic_input_t::logic_input_t(core_device_t &dev, const pstring &aname)
} }
// ---------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------
// param_t & friends // Parameters ...
// ---------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------
param_t::param_t(const param_type_t atype, device_t &device, const pstring &name) param_t::param_t(const param_type_t atype, device_t &device, const pstring &name)
: device_object_t(device, name, PARAM) : device_object_t(device, device.name() + "." + name, PARAM)
, m_param_type(atype) , m_param_type(atype)
{ {
} }
void param_t::register_and_set()
{
dynamic_cast<device_t &>(device()).setup().register_and_set_param(this->name(), *this);
}
void param_t::changed_and_update()
{
changed();
device().update_param();
if (device().needs_update_after_param_change())
device().update_dev();
}
template <typename C, param_t::param_type_t T>
param_template_t<C, T>::param_template_t(device_t &device, const pstring name, const C val)
: param_t(T, device, name)
, m_param(val)
{
/* pstrings not yet supported, these need special logic */
if (T != param_t::STRING && T != param_t::MODEL)
netlist().save(*this, m_param, "m_param");
}
template class param_template_t<double, param_t::DOUBLE>;
template class param_template_t<int, param_t::INTEGER>;
template class param_template_t<bool, param_t::LOGIC>;
template class param_template_t<std::uint_fast8_t*, param_t::POINTER>;
template class param_template_t<pstring, param_t::STRING>;
//template class param_template_t<pstring, param_t::MODEL>;
const pstring param_model_t::model_type() const pstring param_model_t::model_type()
{ {
if (m_map.size() == 0) if (m_map.size() == 0)
@ -936,6 +946,12 @@ nl_double param_model_t::model_value(const pstring &entity)
return netlist().setup().model_value(m_map, entity); return netlist().setup().model_value(m_map, entity);
} }
std::unique_ptr<plib::pistream> param_data_t::stream()
{
return device().netlist().setup().get_data_stream(Value());
}
namespace devices namespace devices
{ {

View File

@ -21,6 +21,7 @@
#include "plib/pdynlib.h" #include "plib/pdynlib.h"
#include "plib/pstate.h" #include "plib/pstate.h"
#include "plib/pfmtlog.h" #include "plib/pfmtlog.h"
#include "plib/pstream.h"
// ---------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------
// Type definitions // Type definitions
@ -842,6 +843,11 @@ namespace netlist
param_type_t param_type() const { return m_param_type; } param_type_t param_type() const { return m_param_type; }
protected:
virtual void changed() { }
void changed_and_update();
void register_and_set();
private: private:
const param_type_t m_param_type; const param_type_t m_param_type;
}; };
@ -849,41 +855,70 @@ namespace netlist
template <typename C, param_t::param_type_t T> template <typename C, param_t::param_type_t T>
class param_template_t : public param_t class param_template_t : public param_t
{ {
P_PREVENT_COPYING(param_template_t)
public: public:
param_template_t(device_t &device, const pstring name, const C val); param_template_t(device_t &device, const pstring name, const C val);
const C operator()() const { return Value(); } const C operator()() const { return Value(); }
void setTo(const C &param); void setTo(const C &param)
void initial(const C &val) { m_param = val; } {
if (m_param != param)
{
m_param = param;
changed_and_update();
}
}
void initial(const C &val) { m_param = val; changed(); }
protected: protected:
C Value() const { return m_param; } C Value() const { return m_param; }
virtual void changed() { }
C m_param; C m_param;
private: private:
}; };
using param_double_t = param_template_t<nl_double, param_t::DOUBLE>; template <typename C, param_t::param_type_t T>
using param_int_t = param_template_t<int, param_t::INTEGER>; class param_template_final_t final : public param_template_t<C, T>
using param_str_t = param_template_t<pstring, param_t::STRING>; {
public:
param_template_final_t(device_t &device, const pstring name, const C val)
: param_template_t<C,T>(device, name, val)
{
this->register_and_set();
}
};
using param_logic_t = param_template_t<bool, param_t::LOGIC>; using param_double_t = param_template_final_t<nl_double, param_t::DOUBLE>;
using param_ptr_t = param_template_t<std::uint_fast8_t*, param_t::POINTER>; using param_int_t = param_template_final_t<int, param_t::INTEGER>;
class param_model_t : public param_str_t using param_logic_t = param_template_final_t<bool, param_t::LOGIC>;
using param_ptr_t = param_template_final_t<std::uint_fast8_t*, param_t::POINTER>;
using param_str_base_t = param_template_t<pstring, param_t::STRING>;
class param_str_t final : public param_str_base_t
{
public:
param_str_t(device_t &device, const pstring name, const pstring val)
: param_str_base_t(device, name, val)
{
register_and_set();
}
};
class param_model_t final : public param_str_base_t
{ {
public: public:
param_model_t(device_t &device, const pstring name, const pstring val) param_model_t(device_t &device, const pstring name, const pstring val)
: param_str_t(device, name, val) { } : param_str_base_t(device, name, val)
{
register_and_set();
}
/* these should be cached! */ /* these should be cached! */
nl_double model_value(const pstring &entity); nl_double model_value(const pstring &entity);
const pstring model_value_str(const pstring &entity); const pstring model_value_str(const pstring &entity);
const pstring model_type(); const pstring model_type();
protected: protected:
void changed() override virtual void changed() override
{ {
m_map.clear(); m_map.clear();
} }
@ -891,6 +926,45 @@ namespace netlist
model_map_t m_map; model_map_t m_map;
}; };
class param_data_t : public param_str_base_t
{
public:
typedef uint8_t type;
param_data_t(device_t &device, const pstring name)
: param_str_base_t(device, name, "") { }
std::unique_ptr<plib::pistream> stream();
protected:
virtual void changed() override { }
private:
};
template <typename ST, std::size_t AW, std::size_t DW>
class param_rom_t final: public param_data_t
{
public:
param_rom_t(device_t &device, const pstring name)
: param_data_t(device, name)
{
register_and_set();
}
const ST & operator[] (std::size_t n) { return m_data[n]; }
protected:
virtual void changed() override
{
stream()->read(&m_data[0],1<<AW);
}
private:
ST m_data[1 << AW];
};
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// core_device_t // core_device_t
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
@ -1211,19 +1285,6 @@ namespace netlist
// inline implementations // inline implementations
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
template <class C, param_t::param_type_t T>
inline void param_template_t<C, T>::setTo(const C &param)
{
if (m_param != param)
{
m_param = param;
changed();
device().update_param();
if (device().needs_update_after_param_change())
device().update_dev();
}
}
inline bool detail::core_terminal_t::is_logic() const noexcept inline bool detail::core_terminal_t::is_logic() const noexcept
{ {
return dynamic_cast<const logic_t *>(this) != nullptr; return dynamic_cast<const logic_t *>(this) != nullptr;

View File

@ -221,13 +221,12 @@ void setup_t::register_and_set_param(pstring name, param_t &param)
static_cast<param_ptr_t &>(param).initial(nullptr); static_cast<param_ptr_t &>(param).initial(nullptr);
break; break;
case param_t::STRING: case param_t::STRING:
case param_t::MODEL:
{ {
static_cast<param_str_t &>(param).initial(val); static_cast<param_str_t &>(param).initial(val);
} }
break; break;
//default: default:
// log().fatal("Parameter is not supported {1} : {2}\n", name, val); log().fatal("Parameter is not supported {1} : {2}\n", name, val);
} }
} }
if (!m_params.insert({param.name(), param_ref_t(param.name(), param.device(), param)}).second) if (!m_params.insert({param.name(), param_ref_t(param.name(), param.device(), param)}).second)
@ -975,12 +974,28 @@ void setup_t::include(const pstring &netlist_name)
{ {
for (auto &source : m_sources) for (auto &source : m_sources)
{ {
if (source->parse(*this, netlist_name)) if (source->parse(netlist_name))
return; return;
} }
log().fatal("unable to find {1} in source collection", netlist_name); log().fatal("unable to find {1} in source collection", netlist_name);
} }
std::unique_ptr<plib::pistream> setup_t::get_data_stream(const pstring name)
{
for (auto &source : m_sources)
{
if (source->type() == source_t::DATA)
{
auto strm = source->stream(name);
if (strm)
return strm;
}
}
log().fatal("unable to find data named {1} in source collection", name);
return std::unique_ptr<plib::pistream>(nullptr);
}
bool setup_t::parse_stream(plib::pistream &istrm, const pstring &name) bool setup_t::parse_stream(plib::pistream &istrm, const pstring &name)
{ {
plib::pomemstream ostrm; plib::pomemstream ostrm;
@ -1002,22 +1017,27 @@ void setup_t::register_define(pstring defstr)
// base sources // base sources
// ---------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------
bool source_string_t::parse(setup_t &setup, const pstring &name) bool source_t::parse(const pstring &name)
{ {
plib::pimemstream istrm(m_str.cstr(), m_str.len()); if (m_type != SOURCE)
return setup.parse_stream(istrm, name); return false;
else
return m_setup.parse_stream(*stream(name), name);
} }
bool source_mem_t::parse(setup_t &setup, const pstring &name) std::unique_ptr<plib::pistream> source_string_t::stream(const pstring &name)
{ {
plib::pimemstream istrm(m_str.cstr(), m_str.len()); return plib::make_unique_base<plib::pistream, plib::pimemstream>(m_str.cstr(), m_str.len());
return setup.parse_stream(istrm, name);
} }
bool source_file_t::parse(setup_t &setup, const pstring &name) std::unique_ptr<plib::pistream> source_mem_t::stream(const pstring &name)
{ {
plib::pifilestream istrm(m_filename); return plib::make_unique_base<plib::pistream, plib::pimemstream>(m_str.cstr(), m_str.len());
return setup.parse_stream(istrm, name); }
std::unique_ptr<plib::pistream> source_file_t::stream(const pstring &name)
{
return plib::make_unique_base<plib::pistream, plib::pifilestream>(m_filename);
} }
} }

View File

@ -67,7 +67,7 @@ void NETLIST_NAME(name)(netlist::setup_t &setup) \
#define NETLIST_END() } #define NETLIST_END() }
#define LOCAL_SOURCE(name) \ #define LOCAL_SOURCE(name) \
setup.register_source(plib::make_unique_base<netlist::source_t, netlist::source_proc_t>(# name, &NETLIST_NAME(name))); setup.register_source(plib::make_unique_base<netlist::source_t, netlist::source_proc_t>(setup, # name, &NETLIST_NAME(name)));
#define LOCAL_LIB_ENTRY(name) \ #define LOCAL_LIB_ENTRY(name) \
LOCAL_SOURCE(name) \ LOCAL_SOURCE(name) \
@ -149,16 +149,28 @@ namespace netlist
class source_t class source_t
{ {
public: public:
enum type_t
{
SOURCE,
DATA
};
using list_t = std::vector<std::unique_ptr<source_t>>; using list_t = std::vector<std::unique_ptr<source_t>>;
source_t() source_t(setup_t &setup, const type_t type = SOURCE)
: m_setup(setup), m_type(type)
{} {}
virtual ~source_t() { } virtual ~source_t() { }
virtual bool parse(setup_t &setup, const pstring &name) = 0; virtual bool parse(const pstring &name);
virtual std::unique_ptr<plib::pistream> stream(const pstring &name) = 0;
setup_t &setup() { return m_setup; }
type_t type() const { return m_type; }
private: private:
setup_t &m_setup;
const type_t m_type;
}; };
// ---------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------
@ -223,6 +235,7 @@ namespace netlist
/* parse a source */ /* parse a source */
void include(const pstring &netlist_name); void include(const pstring &netlist_name);
std::unique_ptr<plib::pistream> get_data_stream(const pstring name);
bool parse_stream(plib::pistream &istrm, const pstring &name); bool parse_stream(plib::pistream &istrm, const pstring &name);
@ -307,12 +320,12 @@ namespace netlist
{ {
public: public:
source_string_t(const pstring &source) source_string_t(setup_t &setup, const pstring &source)
: source_t(), m_str(source) : source_t(setup), m_str(source)
{ {
} }
bool parse(setup_t &setup, const pstring &name) override; virtual std::unique_ptr<plib::pistream> stream(const pstring &name) override;
private: private:
pstring m_str; pstring m_str;
@ -322,12 +335,12 @@ namespace netlist
{ {
public: public:
source_file_t(const pstring &filename) source_file_t(setup_t &setup, const pstring &filename)
: source_t(), m_filename(filename) : source_t(setup), m_filename(filename)
{ {
} }
bool parse(setup_t &setup, const pstring &name) override; virtual std::unique_ptr<plib::pistream> stream(const pstring &name) override;
private: private:
pstring m_filename; pstring m_filename;
@ -336,12 +349,12 @@ namespace netlist
class source_mem_t : public source_t class source_mem_t : public source_t
{ {
public: public:
source_mem_t(const char *mem) source_mem_t(setup_t &setup, const char *mem)
: source_t(), m_str(mem) : source_t(setup), m_str(mem)
{ {
} }
bool parse(setup_t &setup, const pstring &name) override; virtual std::unique_ptr<plib::pistream> stream(const pstring &name) override;
private: private:
pstring m_str; pstring m_str;
@ -350,23 +363,29 @@ namespace netlist
class source_proc_t : public source_t class source_proc_t : public source_t
{ {
public: public:
source_proc_t(pstring name, void (*setup_func)(setup_t &)) source_proc_t(setup_t &setup, pstring name, void (*setup_func)(setup_t &))
: source_t(), : source_t(setup),
m_setup_func(setup_func), m_setup_func(setup_func),
m_setup_func_name(name) m_setup_func_name(name)
{ {
} }
bool parse(setup_t &setup, const pstring &name) override virtual bool parse(const pstring &name) override
{ {
if (name == m_setup_func_name) if (name == m_setup_func_name)
{ {
m_setup_func(setup); m_setup_func(setup());
return true; return true;
} }
else else
return false; return false;
} }
virtual std::unique_ptr<plib::pistream> stream(const pstring &name) override
{
std::unique_ptr<plib::pistream> p(nullptr);
return p;
}
private: private:
void (*m_setup_func)(setup_t &); void (*m_setup_func)(setup_t &);
pstring m_setup_func_name; pstring m_setup_func_name;

View File

@ -117,7 +117,7 @@ public:
m_setup->register_define(d); m_setup->register_define(d);
m_setup->register_source(plib::make_unique_base<netlist::source_t, m_setup->register_source(plib::make_unique_base<netlist::source_t,
netlist::source_file_t>(filename)); netlist::source_file_t>(*m_setup, filename));
m_setup->include(name); m_setup->include(name);
log_setup(logs); log_setup(logs);
@ -316,7 +316,7 @@ static void listdevices(tool_options_t &opts)
netlist::factory_list_t &list = nt.setup().factory(); netlist::factory_list_t &list = nt.setup().factory();
nt.setup().register_source(plib::make_unique_base<netlist::source_t, nt.setup().register_source(plib::make_unique_base<netlist::source_t,
netlist::source_proc_t>("dummy", &netlist_dummy)); netlist::source_proc_t>(nt.setup(), "dummy", &netlist_dummy));
nt.setup().include("dummy"); nt.setup().include("dummy");

View File

@ -331,8 +331,8 @@ static MACHINE_CONFIG_START( stuntcyc, stuntcyc_state )
MCFG_DEVICE_ADD("maincpu", NETLIST_CPU, STUNTCYC_NL_CLOCK) MCFG_DEVICE_ADD("maincpu", NETLIST_CPU, STUNTCYC_NL_CLOCK)
MCFG_NETLIST_SETUP(stuntcyc) MCFG_NETLIST_SETUP(stuntcyc)
MCFG_NETLIST_ROM_REGION("maincpu", "hf1", "hf1", "hf1") MCFG_NETLIST_ROM_REGION("maincpu", "hf1", "hf1", "004275.f1", 0x0000, 0x0200)
MCFG_NETLIST_ROM_REGION("maincpu", "d7", "d7", "d7") MCFG_NETLIST_ROM_REGION("maincpu", "d7", "d7", "004811.d7", 0x0000, 0x0020)
//MCFG_NETLIST_ANALOG_OUTPUT("maincpu", "vid0", "VIDEO_OUT", fixedfreq_device, update_vid, "fixfreq") //MCFG_NETLIST_ANALOG_OUTPUT("maincpu", "vid0", "VIDEO_OUT", fixedfreq_device, update_vid, "fixfreq")
MCFG_NETLIST_LOGIC_OUTPUT("maincpu", "probe_bit0", "probe_bit0", stuntcyc_state, probe_bit0_cb, "") MCFG_NETLIST_LOGIC_OUTPUT("maincpu", "probe_bit0", "probe_bit0", stuntcyc_state, probe_bit0_cb, "")

View File

@ -712,8 +712,8 @@ static MACHINE_CONFIG_START( hazl1500, hazl1500_state )
MCFG_DEVICE_ADD(NETLIST_TAG, NETLIST_CPU, VIDEOBRD_CLOCK) MCFG_DEVICE_ADD(NETLIST_TAG, NETLIST_CPU, VIDEOBRD_CLOCK)
MCFG_NETLIST_SETUP(hazelvid) MCFG_NETLIST_SETUP(hazelvid)
MCFG_NETLIST_ROM_REGION(NETLIST_TAG, VIDEO_PROM_TAG, VIDEO_PROM_TAG, VIDEO_PROM_TAG) MCFG_NETLIST_ROM_REGION(NETLIST_TAG, VIDEO_PROM_TAG, VIDEO_PROM_TAG, "u90_702128_82s129.bin", 0x0000, 0x0100)
MCFG_NETLIST_ROM_REGION(NETLIST_TAG, CHAR_EPROM_TAG, CHAR_EPROM_TAG, CHAR_EPROM_TAG) MCFG_NETLIST_ROM_REGION(NETLIST_TAG, CHAR_EPROM_TAG, CHAR_EPROM_TAG, "u83_chr.bin", 0x0000, 0x0800)
// First 1K // First 1K
MCFG_NETLIST_RAM_POINTER(NETLIST_TAG, "u22", "u22") MCFG_NETLIST_RAM_POINTER(NETLIST_TAG, "u22", "u22")

View File

@ -49,6 +49,7 @@ NETLIST_START(hazelvid)
/* signal lookup PROM */ /* signal lookup PROM */
PROM_82S126(u71, low, low, u70.QA, u70.QB, u70.QC, u70.QD, u69.QA, u69.QB, u69.QC, low) PROM_82S126(u71, low, low, u70.QA, u70.QB, u70.QC, u70.QD, u69.QA, u69.QB, u69.QC, low)
PARAM(u71.ROM, "u90_702128_82s129.bin")
/* signal decoding */ /* signal decoding */
TTL_9334(u72, high, u81.Q1Q, u71.O4, u71.O1, u71.O2, u71.O3) TTL_9334(u72, high, u81.Q1Q, u71.O4, u71.O1, u71.O2, u71.O3)
@ -215,6 +216,7 @@ NETLIST_START(hazelvid)
ALIAS(fgbit_q, u56.Q3Q) ALIAS(fgbit_q, u56.Q3Q)
EPROM_2716(u78, low, low, lc20, lc21, lc22, lc23, u66.Q1, u66.Q2, u66.Q3, u66.Q4, u66.Q5, u66.Q6, u56.Q1) EPROM_2716(u78, low, low, lc20, lc21, lc22, lc23, u66.Q1, u66.Q2, u66.Q3, u66.Q4, u66.Q5, u66.Q6, u56.Q1)
PARAM(u78.ROM, "u83_chr.bin")
TTL_74166(u77, video_clk, low, ndot, low, u78.D0, u78.D1, u78.D2, u78.D3, u78.D4, u78.D5, u78.D6, low, clr_vid_sr) TTL_74166(u77, video_clk, low, ndot, low, u78.D0, u78.D1, u78.D2, u78.D3, u78.D4, u78.D5, u78.D6, low, clr_vid_sr)
ALIAS(raw_dot, u77.QH) ALIAS(raw_dot, u77.QH)

View File

@ -119,6 +119,7 @@ NETLIST_START(stuntcyc)
TTL_9322(J1, HSYNC, V4, P, V3, 4V, V1, 1V, V2, 2V, GROUND) TTL_9322(J1, HSYNC, V4, P, V3, 4V, V1, 1V, V2, 2V, GROUND)
PROM_82S115(hf1, GROUND, P, J1.Y3, J1.Y4, J1.Y2, J1.Y1, H2_2.Q, H2_1.Q, R2, R3, R4, P) PROM_82S115(hf1, GROUND, P, J1.Y3, J1.Y4, J1.Y2, J1.Y1, H2_2.Q, H2_1.Q, R2, R3, R4, P)
PARAM(hf1.ROM, "004275.f1")
CLOCK(PROBECLK, 7129200) CLOCK(PROBECLK, 7129200)
ALIAS(probe_bit0, WHITE_VIDEO) ALIAS(probe_bit0, WHITE_VIDEO)
@ -447,6 +448,8 @@ NETLIST_START(stuntcyc)
ALIAS(SCORE_2, K6_1.Q) ALIAS(SCORE_2, K6_1.Q)
PROM_82S123(d7, GROUND, S1, S2, S3, S4, S5) PROM_82S123(d7, GROUND, S1, S2, S3, S4, S5)
PARAM(d7.ROM, "004811.d7")
ALIAS(MAX_SCORE_Q, d7.O6) ALIAS(MAX_SCORE_Q, d7.O6)
TTL_7410_NAND(D6_1, 256H_Q, 128H, 128H) TTL_7410_NAND(D6_1, 256H_Q, 128H, 128H)