mirror of
https://github.com/holub/mame
synced 2025-10-04 16:34:53 +03:00
netlist: Improve validation code.
Adjust warning levels and fix a number of topics identified.
This commit is contained in:
parent
a1ed88900c
commit
e7652e14d6
@ -20,6 +20,7 @@
|
||||
#include "netlist/plib/palloc.h"
|
||||
|
||||
#include "debugger.h"
|
||||
#include "romload.h"
|
||||
|
||||
#include <cmath>
|
||||
#include <memory>
|
||||
@ -67,12 +68,12 @@ protected:
|
||||
case plib::plog_level::DEBUG:
|
||||
m_parent.logerror("netlist DEBUG: %s\n", ls.c_str());
|
||||
break;
|
||||
case plib::plog_level::INFO:
|
||||
m_parent.logerror("netlist INFO: %s\n", ls.c_str());
|
||||
break;
|
||||
case plib::plog_level::VERBOSE:
|
||||
m_parent.logerror("netlist VERBOSE: %s\n", ls.c_str());
|
||||
break;
|
||||
case plib::plog_level::INFO:
|
||||
m_parent.logerror("netlist INFO: %s\n", ls.c_str());
|
||||
break;
|
||||
case plib::plog_level::WARNING:
|
||||
m_parent.logerror("netlist WARNING: %s\n", ls.c_str());
|
||||
break;
|
||||
@ -104,19 +105,19 @@ protected:
|
||||
{
|
||||
case plib::plog_level::DEBUG:
|
||||
break;
|
||||
case plib::plog_level::INFO:
|
||||
break;
|
||||
case plib::plog_level::VERBOSE:
|
||||
break;
|
||||
case plib::plog_level::INFO:
|
||||
osd_printf_verbose("netlist INFO: %s\n", ls.c_str());
|
||||
break;
|
||||
case plib::plog_level::WARNING:
|
||||
osd_printf_verbose("netlist WARNING: %s\n", ls.c_str());
|
||||
osd_printf_warning("netlist WARNING: %s\n", ls.c_str());
|
||||
break;
|
||||
case plib::plog_level::ERROR:
|
||||
osd_printf_error("netlist ERROR: %s\n", ls.c_str());
|
||||
break;
|
||||
case plib::plog_level::FATAL:
|
||||
//throw emu_fatalerror(1, "netlist ERROR: %s\n", ls.c_str());
|
||||
throw emu_fatalerror("netlist ERROR: %s\n", ls.c_str());
|
||||
throw emu_fatalerror(1, "netlist ERROR: %s\n", ls.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
@ -307,10 +308,9 @@ private:
|
||||
|
||||
plib::unique_ptr<plib::pistream> netlist_source_memregion_t::stream(const pstring &name)
|
||||
{
|
||||
//memory_region *mem = static_cast<netlist_mame_device::netlist_mame_t &>(setup().setup().exec()).machine().root_device().memregion(m_name.c_str());
|
||||
if (m_dev.has_running_machine())
|
||||
{
|
||||
memory_region *mem = m_dev.machine().root_device().memregion(m_name.c_str());
|
||||
memory_region *mem = m_dev.memregion(m_name.c_str());
|
||||
return plib::make_unique<plib::pimemstream>(mem->base(), mem->bytes());
|
||||
}
|
||||
else
|
||||
@ -323,19 +323,43 @@ netlist_data_memregions_t::netlist_data_memregions_t(const device_t &dev)
|
||||
{
|
||||
}
|
||||
|
||||
static bool rom_exists(device_t &root, pstring name)
|
||||
{
|
||||
// iterate, starting with the driver's ROMs and continuing with device ROMs
|
||||
for (device_t &device : device_iterator(root))
|
||||
{
|
||||
// scan the ROM entries for this device
|
||||
for (tiny_rom_entry const *romp = device.rom_region(); romp && !ROMENTRY_ISEND(romp); ++romp)
|
||||
{
|
||||
if (ROMENTRY_ISREGION(romp)) // if this is a region, check for rom
|
||||
{
|
||||
char const *const basetag = romp->name;
|
||||
if (name == pstring(":") + basetag)
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
plib::unique_ptr<plib::pistream> netlist_data_memregions_t::stream(const pstring &name)
|
||||
{
|
||||
//memory_region *mem = static_cast<netlist_mame_device::netlist_mame_t &>(setup().setup().exec()).parent().memregion(name.c_str());
|
||||
memory_region *mem = m_dev.memregion(name.c_str());
|
||||
if (mem != nullptr)
|
||||
if (m_dev.has_running_machine())
|
||||
{
|
||||
return plib::make_unique<plib::pimemstream>(mem->base(), mem->bytes());
|
||||
memory_region *mem = m_dev.memregion(name.c_str());
|
||||
if (mem != nullptr)
|
||||
return plib::make_unique<plib::pimemstream>(mem->base(), mem->bytes());
|
||||
else
|
||||
return plib::unique_ptr<plib::pistream>(nullptr);
|
||||
}
|
||||
else
|
||||
{
|
||||
// This should be the last data provider being called - last resort
|
||||
fatalerror("data named %s not found in device rom regions\n", name.c_str());
|
||||
return plib::unique_ptr<plib::pistream>(nullptr);
|
||||
/* validation */
|
||||
if (rom_exists(m_dev.mconfig().root_device(), pstring(m_dev.tag()) + ":" + name))
|
||||
return plib::make_unique<plib::pimemstream>();
|
||||
else
|
||||
return plib::unique_ptr<plib::pistream>(nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
@ -957,7 +981,7 @@ void netlist_mame_device::common_dev_start(netlist::netlist_t *lnetlist) const
|
||||
}
|
||||
|
||||
/* add default data provider for roms - if not in validity check*/
|
||||
if (has_running_machine())
|
||||
//if (has_running_machine())
|
||||
lsetup.register_source(plib::make_unique<netlist_data_memregions_t>(*this));
|
||||
|
||||
m_setup_func(lsetup);
|
||||
@ -978,9 +1002,12 @@ void netlist_mame_device::common_dev_start(netlist::netlist_t *lnetlist) const
|
||||
}
|
||||
|
||||
|
||||
|
||||
void netlist_mame_device::device_validity_check(validity_checker &valid) const
|
||||
{
|
||||
#if 1
|
||||
|
||||
//rom_exists(mconfig().root_device());
|
||||
LOGDEVCALLS("device_validity_check %s\n", this->mconfig().gamedrv().name);
|
||||
|
||||
try
|
||||
|
@ -78,7 +78,6 @@ namespace netlist
|
||||
register_subalias("VCC", m_R1.m_P); // Pin 8
|
||||
register_subalias("OUT", m_ROUT.m_P); // Pin 3
|
||||
|
||||
connect(m_R1.m_N, m_R2.m_P);
|
||||
connect(m_R1.m_N, m_R2.m_P);
|
||||
connect(m_R2.m_N, m_R3.m_P);
|
||||
connect(m_RDIS.m_N, m_R3.m_N);
|
||||
|
@ -104,9 +104,9 @@ namespace netlist
|
||||
f = true;
|
||||
}
|
||||
}
|
||||
//FIXME: Use power terminals!
|
||||
//FIXME: Use power terminals and change info to warning or error
|
||||
if (!f)
|
||||
log().warning(MW_1_NO_POWER_TERMINALS_ON_DEVICE_1, out_proxied->device().name());
|
||||
log().info(MI_1_NO_POWER_TERMINALS_ON_DEVICE_1, out_proxied->device().name());
|
||||
else
|
||||
log().verbose("D/A Proxy: Found power terminals on device {1}", out_proxied->device().name());
|
||||
}
|
||||
|
@ -1036,11 +1036,32 @@ plib::unique_ptr<plib::pistream> param_data_t::stream()
|
||||
return dynamic_cast<const logic_t *>(this) != nullptr;
|
||||
}
|
||||
|
||||
bool detail::core_terminal_t::is_logic_input() const NL_NOEXCEPT
|
||||
{
|
||||
return dynamic_cast<const logic_input_t *>(this) != nullptr;
|
||||
}
|
||||
|
||||
bool detail::core_terminal_t::is_logic_output() const NL_NOEXCEPT
|
||||
{
|
||||
return dynamic_cast<const logic_output_t *>(this) != nullptr;
|
||||
}
|
||||
|
||||
bool detail::core_terminal_t::is_analog() const NL_NOEXCEPT
|
||||
{
|
||||
return dynamic_cast<const analog_t *>(this) != nullptr;
|
||||
}
|
||||
|
||||
bool detail::core_terminal_t::is_analog_input() const NL_NOEXCEPT
|
||||
{
|
||||
return dynamic_cast<const analog_input_t *>(this) != nullptr;
|
||||
}
|
||||
|
||||
bool detail::core_terminal_t::is_analog_output() const NL_NOEXCEPT
|
||||
{
|
||||
return dynamic_cast<const analog_output_t *>(this) != nullptr;
|
||||
}
|
||||
|
||||
|
||||
bool detail::net_t::is_logic() const NL_NOEXCEPT
|
||||
{
|
||||
return dynamic_cast<const logic_net_t *>(this) != nullptr;
|
||||
|
@ -565,7 +565,11 @@ namespace netlist
|
||||
net_t & net() noexcept { return *m_net;}
|
||||
|
||||
bool is_logic() const NL_NOEXCEPT;
|
||||
bool is_logic_input() const NL_NOEXCEPT;
|
||||
bool is_logic_output() const NL_NOEXCEPT;
|
||||
bool is_analog() const NL_NOEXCEPT;
|
||||
bool is_analog_input() const NL_NOEXCEPT;
|
||||
bool is_analog_output() const NL_NOEXCEPT;
|
||||
|
||||
bool is_state(state_e astate) const noexcept { return (m_state == astate); }
|
||||
state_e terminal_state() const noexcept { return m_state; }
|
||||
|
@ -41,7 +41,7 @@
|
||||
#define MF_1_UNKNOWN_SOLVER_TYPE "Unknown solver type: {1}"
|
||||
#define MF_1_NETGROUP_SIZE_EXCEEDED_1 "Encountered netgroup with > {1} nets"
|
||||
|
||||
#define MW_1_NO_SPECIFIC_SOLVER "No specific solver found for netlist of size {1}"
|
||||
#define MI_1_NO_SPECIFIC_SOLVER "No specific solver found for netlist of size {1}"
|
||||
|
||||
// nl_base.cpp
|
||||
|
||||
@ -82,14 +82,17 @@
|
||||
#define MF_2_MODEL_PARAMETERS_NOT_UPPERCASE_1_2 "model parameters should be uppercase:{1} {2}"
|
||||
#define MF_2_ENTITY_1_NOT_FOUND_IN_MODEL_2 "Entity {1} not found in model {2}"
|
||||
#define MF_1_UNKNOWN_NUMBER_FACTOR_IN_1 "Unknown number factor in: {1}"
|
||||
#define MF_1_NOT_FOUND_IN_SOURCE_COLLECTION "unable to find {1} in source collection"
|
||||
#define MF_1_NOT_FOUND_IN_SOURCE_COLLECTION "unable to find {1} in sources collection"
|
||||
|
||||
#define MW_3_OVERWRITING_PARAM_1_OLD_2_NEW_3 "Overwriting {1} old <{2}> new <{3}>"
|
||||
#define MW_1_CONNECTING_1_TO_ITSELF "Connecting {1} to itself. This may be right, though"
|
||||
#define MW_1_DUMMY_1_WITHOUT_CONNECTIONS "Found dummy terminal {1} without connections"
|
||||
#define MI_1_DUMMY_1_WITHOUT_CONNECTIONS "Found dummy terminal {1} without connections"
|
||||
#define MI_1_ANALOG_OUTPUT_1_WITHOUT_CONNECTIONS "Found analog output {1} without connections"
|
||||
#define MI_1_LOGIC_OUTPUT_1_WITHOUT_CONNECTIONS "Found logic output {1} without connections"
|
||||
#define MW_1_LOGIC_INPUT_1_WITHOUT_CONNECTIONS "Found logic input {1} without connections"
|
||||
#define MW_1_TERMINAL_1_WITHOUT_CONNECTIONS "Found terminal {1} without connections"
|
||||
#define MW_3_REMOVE_DEVICE_1_CONNECTED_ONLY_TO_RAILS_2_3 "Found device {1} connected only to railterminals {2}/{3}. Will be removed"
|
||||
#define MW_1_DATA_1_NOT_FOUND "unable to find data named {1} in source collection"
|
||||
#define MI_3_REMOVE_DEVICE_1_CONNECTED_ONLY_TO_RAILS_2_3 "Found device {1} connected only to railterminals {2}/{3}. Will be removed"
|
||||
#define MW_1_DATA_1_NOT_FOUND "unable to find data {1} in sources collection"
|
||||
|
||||
// nld_mm5837.cpp
|
||||
|
||||
@ -97,7 +100,7 @@
|
||||
|
||||
// nlid_proxy.cpp
|
||||
|
||||
#define MW_1_NO_POWER_TERMINALS_ON_DEVICE_1 "D/A Proxy: Found no valid combination of power terminals on device {1}"
|
||||
#define MI_1_NO_POWER_TERMINALS_ON_DEVICE_1 "D/A Proxy: Found no valid combination of power terminals on device {1}"
|
||||
|
||||
|
||||
#endif /* NL_ERRSTR_H_ */
|
||||
|
@ -768,11 +768,20 @@ void setup_t::resolve_inputs()
|
||||
{
|
||||
detail::core_terminal_t *term = i.second;
|
||||
if (!term->has_net() && dynamic_cast< devices::NETLIB_NAME(dummy_input) *>(&term->device()) != nullptr)
|
||||
log().warning(MW_1_DUMMY_1_WITHOUT_CONNECTIONS, term->name());
|
||||
log().info(MI_1_DUMMY_1_WITHOUT_CONNECTIONS, term->name());
|
||||
else if (!term->has_net())
|
||||
errstr += plib::pfmt("Found terminal {1} without a net\n")(term->name());
|
||||
else if (term->net().num_cons() == 0)
|
||||
log().warning(MW_1_TERMINAL_1_WITHOUT_CONNECTIONS, term->name());
|
||||
{
|
||||
if (term->is_logic_input())
|
||||
log().warning(MW_1_LOGIC_INPUT_1_WITHOUT_CONNECTIONS, term->name());
|
||||
else if (term->is_logic_output())
|
||||
log().info(MI_1_LOGIC_OUTPUT_1_WITHOUT_CONNECTIONS, term->name());
|
||||
else if (term->is_analog_output())
|
||||
log().info(MI_1_ANALOG_OUTPUT_1_WITHOUT_CONNECTIONS, term->name());
|
||||
else
|
||||
log().warning(MW_1_TERMINAL_1_WITHOUT_CONNECTIONS, term->name());
|
||||
}
|
||||
}
|
||||
//FIXME: error string handling
|
||||
if (errstr != "")
|
||||
@ -1075,7 +1084,7 @@ void setup_t::prepare_to_run()
|
||||
// FIXME: get device name, check for device
|
||||
}
|
||||
else
|
||||
log().info("Unknown parameter: {}", p.first);
|
||||
log().warning("Unknown parameter: {}", p.first);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1107,7 +1116,7 @@ void setup_t::prepare_to_run()
|
||||
{
|
||||
if (t->m_N.net().isRailNet() && t->m_P.net().isRailNet())
|
||||
{
|
||||
log().warning(MW_3_REMOVE_DEVICE_1_CONNECTED_ONLY_TO_RAILS_2_3,
|
||||
log().info(MI_3_REMOVE_DEVICE_1_CONNECTED_ONLY_TO_RAILS_2_3,
|
||||
t->name(), t->m_N.net().name(), t->m_P.net().name());
|
||||
t->m_N.net().remove_terminal(t->m_N);
|
||||
t->m_P.net().remove_terminal(t->m_P);
|
||||
|
@ -17,8 +17,8 @@ namespace plib {
|
||||
|
||||
P_ENUM(plog_level,
|
||||
DEBUG,
|
||||
INFO,
|
||||
VERBOSE,
|
||||
INFO,
|
||||
WARNING,
|
||||
ERROR,
|
||||
FATAL)
|
||||
|
@ -358,7 +358,7 @@ namespace devices
|
||||
#endif
|
||||
#endif
|
||||
default:
|
||||
log().warning(MW_1_NO_SPECIFIC_SOLVER, net_count);
|
||||
log().info(MI_1_NO_SPECIFIC_SOLVER, net_count);
|
||||
if (net_count <= 8)
|
||||
{
|
||||
ms = create_solver<double, -8>(net_count, sname);
|
||||
|
@ -66,7 +66,7 @@ private:
|
||||
|
||||
|
||||
static NETLIST_START(electra)
|
||||
SOLVER(Solve, 48000)
|
||||
SOLVER(Solver, 48000)
|
||||
// PARAM(Solver.FREQ, 48000)
|
||||
PARAM(Solver.ACCURACY, 1e-4) // works and is sufficient
|
||||
|
||||
|
@ -19,7 +19,7 @@ NETLIST_START(pong_fast)
|
||||
SOLVER(Solver, 48000)
|
||||
PARAM(Solver.PARALLEL, 0) // Don't do parallel solvers
|
||||
PARAM(Solver.ACCURACY, 1e-4) // works and is sufficient
|
||||
PARAM(Solver.LTE, 1e-4) // Default is not enough for paddle control if using LTE
|
||||
PARAM(Solver.DYNAMIC_LTE, 1e-4) // Default is not enough for paddle control if using LTE
|
||||
PARAM(NETLIST.USE_DEACTIVATE, 1)
|
||||
|
||||
ANALOG_INPUT(V5, 5)
|
||||
|
@ -72,7 +72,7 @@
|
||||
NETLIST_START(rebound_schematics)
|
||||
SOLVER(Solver, 48000)
|
||||
PARAM(Solver.DYNAMIC_TS, 1)
|
||||
PARAM(Solver.LTE, 1e-2)
|
||||
PARAM(Solver.DYNAMIC_LTE, 1e-3)
|
||||
PARAM(Solver.DYNAMIC_MIN_TIMESTEP, 5e-7)
|
||||
|
||||
PARAM(Solver.PARALLEL, 0) // Don't do parallel solvers
|
||||
|
Loading…
Reference in New Issue
Block a user