mirror of
https://github.com/holub/mame
synced 2025-07-05 09:57:47 +03:00
netlist: improve syntax of generic device descriptors. (nw)
This commit is contained in:
parent
40628bc269
commit
11af744ef3
@ -76,7 +76,7 @@ namespace netlist
|
|||||||
nld_power_pins m_power_pins;
|
nld_power_pins m_power_pins;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct desc_74125
|
struct desc_74125 : public desc_base
|
||||||
{
|
{
|
||||||
using invert_g = desc_const<1>;
|
using invert_g = desc_const<1>;
|
||||||
using ts_off_on = time_ns<11>;
|
using ts_off_on = time_ns<11>;
|
||||||
|
@ -31,17 +31,18 @@ namespace netlist
|
|||||||
NETLIB_CONSTRUCTOR(generic_prom)
|
NETLIB_CONSTRUCTOR(generic_prom)
|
||||||
, m_enabled(*this, "m_enabled", true)
|
, m_enabled(*this, "m_enabled", true)
|
||||||
, m_A(*this, 0, "A{}", NETLIB_DELEGATE(generic_prom, addr))
|
, m_A(*this, 0, "A{}", NETLIB_DELEGATE(generic_prom, addr))
|
||||||
, m_CEQ(*this, 1, D::chip_enable_mask ^ static_cast<size_t>(0xffff), pstring("CE{}"),
|
, m_CEQ(*this, 1,
|
||||||
|
D::chip_enable_mask::value ^ static_cast<size_t>(0xffff), pstring("CE{}"),
|
||||||
std::array<nldelegate, 3>{ NETLIB_DELEGATE(generic_prom, ce<0>),
|
std::array<nldelegate, 3>{ NETLIB_DELEGATE(generic_prom, ce<0>),
|
||||||
NETLIB_DELEGATE(generic_prom, ce<1>),
|
NETLIB_DELEGATE(generic_prom, ce<1>),
|
||||||
NETLIB_DELEGATE(generic_prom, ce<2>)})
|
NETLIB_DELEGATE(generic_prom, ce<2>)})
|
||||||
, m_O(*this, D::data_name_offset, "O{}")
|
, m_O(*this, D::data_name_offset::value, "O{}")
|
||||||
, m_ROM(*this, "ROM")
|
, m_ROM(*this, "ROM")
|
||||||
, m_power_pins(*this)
|
, m_power_pins(*this)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
using data_type = typename plib::least_type_for_bits<D::data_width>::type;
|
using data_type = typename plib::least_type_for_bits<D::data_width::value>::type;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
@ -49,9 +50,10 @@ namespace netlist
|
|||||||
inline NETLIB_HANDLERI(ce)
|
inline NETLIB_HANDLERI(ce)
|
||||||
{
|
{
|
||||||
using cet = typename D::chip_enable_time;
|
using cet = typename D::chip_enable_time;
|
||||||
m_enabled = (m_CEQ() == D::chip_enable_mask);
|
m_enabled = (m_CEQ() == D::chip_enable_mask::value);
|
||||||
const auto delay = m_enabled ? D::access_time::value() : cet::value(N);
|
const auto delay = m_enabled ? D::access_time::value() : cet::value(N);
|
||||||
const data_type o = m_enabled ? m_ROM[m_A()] : (1 << D::data_width) - 1; // FIXME tristate !
|
const data_type o = m_enabled ? m_ROM[m_A()] :
|
||||||
|
(1 << D::data_width::value) - 1; // FIXME tristate !
|
||||||
|
|
||||||
m_O.push(o, delay);
|
m_O.push(o, delay);
|
||||||
}
|
}
|
||||||
@ -72,27 +74,27 @@ namespace netlist
|
|||||||
}
|
}
|
||||||
|
|
||||||
state_var<bool> m_enabled;
|
state_var<bool> m_enabled;
|
||||||
object_array_t<logic_input_t, D::address_width> m_A;
|
object_array_t<logic_input_t, D::address_width::value> m_A;
|
||||||
object_array_t<logic_input_t, D::chip_enable_inputs> m_CEQ;
|
object_array_t<logic_input_t, D::chip_enable_inputs::value> m_CEQ;
|
||||||
object_array_t<typename D::output_type, D::data_width> m_O;
|
object_array_t<typename D::output_type, D::data_width::value> m_O;
|
||||||
|
|
||||||
param_rom_t<uint8_t, D::address_width, D::data_width> m_ROM;
|
param_rom_t<uint8_t, D::address_width::value, D::data_width::value> m_ROM;
|
||||||
nld_power_pins m_power_pins;
|
nld_power_pins m_power_pins;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct desc_82S126
|
struct desc_82S126 : public desc_base
|
||||||
{
|
{
|
||||||
static constexpr const size_t address_width = 8;
|
using address_width = desc_const<8>;
|
||||||
static constexpr const size_t data_width = 4;
|
using data_width = desc_const<4>;
|
||||||
static constexpr const size_t data_name_offset = 1; // O1, O2, ..
|
using data_name_offset = desc_const<1>; // O1, O2, ..
|
||||||
static constexpr const size_t chip_enable_inputs = 2;
|
using chip_enable_inputs = desc_const<2>;
|
||||||
// MATCH_MASK : all 0 ==> all bits inverted
|
// MATCH_MASK : all 0 ==> all bits inverted
|
||||||
static constexpr const size_t chip_enable_mask = 0x00;
|
using chip_enable_mask = desc_const<0x00>;
|
||||||
|
|
||||||
using chip_enable_time = times_ns2<25, 25>;
|
using chip_enable_time = times_ns2<25, 25>;
|
||||||
using access_time = time_ns<40>;
|
using access_time = time_ns<40>;
|
||||||
|
|
||||||
using output_type = logic_output_t;
|
using output_type = logic_output_t;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct desc_74S287 : public desc_82S126
|
struct desc_74S287 : public desc_82S126
|
||||||
@ -102,37 +104,37 @@ namespace netlist
|
|||||||
static constexpr const size_t data_name_offset = 0; // O0, O1, ..
|
static constexpr const size_t data_name_offset = 0; // O0, O1, ..
|
||||||
};
|
};
|
||||||
|
|
||||||
struct desc_82S123
|
struct desc_82S123 : public desc_base
|
||||||
{
|
{
|
||||||
// FIXME: tristate outputs, add 82S23 (open collector)
|
// FIXME: tristate outputs, add 82S23 (open collector)
|
||||||
static constexpr const size_t address_width = 5;
|
using address_width = desc_const<5>;
|
||||||
static constexpr const size_t data_width = 8;
|
using data_width = desc_const<8>;
|
||||||
static constexpr const size_t data_name_offset = 1; // O1, O2, ..
|
using data_name_offset = desc_const<1>; // O1, O2, ..
|
||||||
static constexpr const size_t chip_enable_inputs = 1;
|
using chip_enable_inputs = desc_const<1>;
|
||||||
// MATCH_MASK : all 0 ==> all bits inverted
|
// MATCH_MASK : all 0 ==> all bits inverted
|
||||||
static constexpr const size_t chip_enable_mask = 0x00;
|
using chip_enable_mask = desc_const<0x00>;
|
||||||
|
|
||||||
using chip_enable_time = times_ns1<35>;
|
using chip_enable_time = times_ns1<35>;
|
||||||
using access_time = time_ns<45>;
|
using access_time = time_ns<45>;
|
||||||
|
|
||||||
using output_type = logic_output_t;
|
using output_type = logic_output_t;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct desc_2716
|
struct desc_2716 : public desc_base
|
||||||
{
|
{
|
||||||
// FIXME: tristate outputs
|
// FIXME: tristate outputs
|
||||||
static constexpr const size_t address_width = 11;
|
using address_width = desc_const<11>;
|
||||||
static constexpr const size_t data_width = 8;
|
using data_width = desc_const<8>;
|
||||||
static constexpr const size_t data_name_offset = 0; // O0, O1, ..
|
using data_name_offset = desc_const<0>; // O0, O1, ..
|
||||||
|
|
||||||
static constexpr const size_t chip_enable_inputs = 2;
|
using chip_enable_inputs = desc_const<2>;
|
||||||
// MATCH_MASK : all 0 ==> all bits inverted
|
// MATCH_MASK : all 0 ==> all bits inverted
|
||||||
static constexpr const size_t chip_enable_mask = 0x00;
|
using chip_enable_mask = desc_const<0x00>;
|
||||||
|
|
||||||
using chip_enable_time = times_ns2<450, 100>; //CE, OE
|
using chip_enable_time = times_ns2<450, 100>; //CE, OE
|
||||||
using access_time = time_ns<450>;
|
using access_time = time_ns<450>;
|
||||||
|
|
||||||
using output_type = logic_output_t;
|
using output_type = logic_output_t;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -162,54 +162,57 @@ namespace netlist
|
|||||||
template <typename T> inline constexpr netlist_time NLTIME_FROM_US(T &&t) noexcept { return netlist_time::from_usec(t); }
|
template <typename T> inline constexpr netlist_time NLTIME_FROM_US(T &&t) noexcept { return netlist_time::from_usec(t); }
|
||||||
template <typename T> inline constexpr netlist_time NLTIME_FROM_MS(T &&t) noexcept { return netlist_time::from_msec(t); }
|
template <typename T> inline constexpr netlist_time NLTIME_FROM_MS(T &&t) noexcept { return netlist_time::from_msec(t); }
|
||||||
|
|
||||||
/// \brief: used to hold one static netlist_time value
|
struct desc_base
|
||||||
///
|
|
||||||
template<netlist_time::internal_type value0>
|
|
||||||
struct times_ns1
|
|
||||||
{
|
{
|
||||||
static constexpr netlist_time value(std::size_t N = 0)
|
/// \brief: used to hold one static netlist_time value
|
||||||
|
///
|
||||||
|
template<netlist_time::internal_type value0>
|
||||||
|
struct times_ns1
|
||||||
{
|
{
|
||||||
plib::unused_var(N);
|
static constexpr netlist_time value(std::size_t N = 0)
|
||||||
return NLTIME_FROM_NS(value0);
|
{
|
||||||
}
|
plib::unused_var(N);
|
||||||
};
|
return NLTIME_FROM_NS(value0);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
template <netlist_time::internal_type value0>
|
template <netlist_time::internal_type value0>
|
||||||
using time_ns = times_ns1<value0>;
|
using time_ns = times_ns1<value0>;
|
||||||
|
|
||||||
/// \brief: used to hold two static netlist_time values
|
/// \brief: used to hold two static netlist_time values
|
||||||
///
|
///
|
||||||
template<netlist_time::internal_type value0,
|
template<netlist_time::internal_type value0,
|
||||||
netlist_time::internal_type value1>
|
netlist_time::internal_type value1>
|
||||||
struct times_ns2
|
struct times_ns2
|
||||||
{
|
|
||||||
static constexpr netlist_time value(std::size_t N)
|
|
||||||
{
|
{
|
||||||
return NLTIME_FROM_NS(N == 0 ? value0 : value1);
|
static constexpr netlist_time value(std::size_t N)
|
||||||
}
|
{
|
||||||
};
|
return NLTIME_FROM_NS(N == 0 ? value0 : value1);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
/// \brief: used to hold two static netlist_time values
|
/// \brief: used to hold two static netlist_time values
|
||||||
///
|
///
|
||||||
template<netlist_time::internal_type value0,
|
template<netlist_time::internal_type value0,
|
||||||
netlist_time::internal_type value1,
|
netlist_time::internal_type value1,
|
||||||
netlist_time::internal_type value2>
|
netlist_time::internal_type value2>
|
||||||
struct times_ns3
|
struct times_ns3
|
||||||
{
|
|
||||||
static constexpr netlist_time value(std::size_t N)
|
|
||||||
{
|
{
|
||||||
return NLTIME_FROM_NS(N == 0 ? value0 :
|
static constexpr netlist_time value(std::size_t N)
|
||||||
N == 1 ? value1 :
|
{
|
||||||
value2);
|
return NLTIME_FROM_NS(N == 0 ? value0 :
|
||||||
}
|
N == 1 ? value1 :
|
||||||
};
|
value2);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
/// \brief: used define a constant in device description struct
|
/// \brief: used define a constant in device description struct
|
||||||
///
|
///
|
||||||
/// See the 74125 implementation
|
/// See the 74125 implementation
|
||||||
///
|
///
|
||||||
template <std::size_t V>
|
template <std::size_t V>
|
||||||
using desc_const = std::integral_constant<std::size_t, V>;
|
using desc_const = std::integral_constant<std::size_t, V>;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
} // namespace netlist
|
} // namespace netlist
|
||||||
|
Loading…
Reference in New Issue
Block a user