mirror of
https://github.com/holub/mame
synced 2025-06-04 03:46:29 +03:00
netlist: Fix performance issues and VC2019. [Couriersud]
For reasons unknown to me compile optimizations do not behave for template code. If the implementation is in separate compile units, the code compiles and performs.
This commit is contained in:
parent
5a43cc6432
commit
6141fa4a9c
@ -116,6 +116,9 @@ project "netlist"
|
||||
MAME_DIR .. "src/lib/netlist/solver/nld_ms_w.h",
|
||||
MAME_DIR .. "src/lib/netlist/solver/nld_ms_direct_lu.h",
|
||||
MAME_DIR .. "src/lib/netlist/solver/vector_base.h",
|
||||
MAME_DIR .. "src/lib/netlist/devices/net_lib.cpp",
|
||||
MAME_DIR .. "src/lib/netlist/devices/net_lib.h",
|
||||
MAME_DIR .. "src/lib/netlist/devices/nld_9316_base.hxx",
|
||||
MAME_DIR .. "src/lib/netlist/devices/nld_2102A.cpp",
|
||||
MAME_DIR .. "src/lib/netlist/devices/nld_2102A.h",
|
||||
MAME_DIR .. "src/lib/netlist/devices/nld_tms4800.cpp",
|
||||
@ -162,6 +165,8 @@ project "netlist"
|
||||
MAME_DIR .. "src/lib/netlist/devices/nld_74125.h",
|
||||
MAME_DIR .. "src/lib/netlist/devices/nld_74153.cpp",
|
||||
MAME_DIR .. "src/lib/netlist/devices/nld_74153.h",
|
||||
MAME_DIR .. "src/lib/netlist/devices/nld_74161.cpp",
|
||||
MAME_DIR .. "src/lib/netlist/devices/nld_74163.cpp",
|
||||
MAME_DIR .. "src/lib/netlist/devices/nld_74164.cpp",
|
||||
MAME_DIR .. "src/lib/netlist/devices/nld_74164.h",
|
||||
MAME_DIR .. "src/lib/netlist/devices/nld_74165.cpp",
|
||||
@ -190,6 +195,7 @@ project "netlist"
|
||||
MAME_DIR .. "src/lib/netlist/devices/nld_82S16.h",
|
||||
MAME_DIR .. "src/lib/netlist/devices/nld_82S115.cpp",
|
||||
MAME_DIR .. "src/lib/netlist/devices/nld_82S115.h",
|
||||
MAME_DIR .. "src/lib/netlist/devices/nld_9310.cpp",
|
||||
MAME_DIR .. "src/lib/netlist/devices/nld_9316.cpp",
|
||||
MAME_DIR .. "src/lib/netlist/devices/nld_9316.h",
|
||||
MAME_DIR .. "src/lib/netlist/devices/nld_9322.cpp",
|
||||
@ -212,8 +218,6 @@ project "netlist"
|
||||
MAME_DIR .. "src/lib/netlist/devices/nld_schmitt.h",
|
||||
MAME_DIR .. "src/lib/netlist/devices/nld_legacy.cpp",
|
||||
MAME_DIR .. "src/lib/netlist/devices/nld_legacy.h",
|
||||
MAME_DIR .. "src/lib/netlist/devices/net_lib.cpp",
|
||||
MAME_DIR .. "src/lib/netlist/devices/net_lib.h",
|
||||
MAME_DIR .. "src/lib/netlist/devices/nld_log.cpp",
|
||||
MAME_DIR .. "src/lib/netlist/devices/nld_log.h",
|
||||
MAME_DIR .. "src/lib/netlist/devices/nld_roms.cpp",
|
||||
|
@ -164,6 +164,8 @@ NLOBJS := \
|
||||
$(NLOBJ)/devices/nld_74123.o \
|
||||
$(NLOBJ)/devices/nld_74125.o \
|
||||
$(NLOBJ)/devices/nld_74153.o \
|
||||
$(NLOBJ)/devices/nld_74161.o \
|
||||
$(NLOBJ)/devices/nld_74163.o \
|
||||
$(NLOBJ)/devices/nld_74164.o \
|
||||
$(NLOBJ)/devices/nld_74165.o \
|
||||
$(NLOBJ)/devices/nld_74166.o \
|
||||
@ -178,6 +180,7 @@ NLOBJS := \
|
||||
$(NLOBJ)/devices/nld_74ls629.o \
|
||||
$(NLOBJ)/devices/nld_82S16.o \
|
||||
$(NLOBJ)/devices/nld_82S115.o \
|
||||
$(NLOBJ)/devices/nld_9310.o \
|
||||
$(NLOBJ)/devices/nld_9316.o \
|
||||
$(NLOBJ)/devices/nld_9322.o \
|
||||
$(NLOBJ)/devices/nld_am2847.o \
|
||||
|
@ -115,12 +115,15 @@
|
||||
<ClCompile Include="..\analog\nlid_twoterm.cpp" />
|
||||
<ClCompile Include="..\devices\net_lib.cpp" />
|
||||
<ClCompile Include="..\devices\nld_2102A.cpp" />
|
||||
<ClCompile Include="..\devices\nld_2716.cpp" />
|
||||
<ClCompile Include="..\devices\nld_4006.cpp" />
|
||||
<ClCompile Include="..\devices\nld_74125.cpp" />
|
||||
<ClCompile Include="..\devices\nld_74163.cpp" />
|
||||
<ClCompile Include="..\devices\nld_74377.cpp" />
|
||||
<ClCompile Include="..\devices\nld_74393.cpp" />
|
||||
<ClCompile Include="..\devices\nld_7442.cpp" />
|
||||
<ClCompile Include="..\devices\nld_7492.cpp" />
|
||||
<ClCompile Include="..\devices\nld_7497.cpp" />
|
||||
<ClCompile Include="..\devices\nld_roms.cpp" />
|
||||
<ClCompile Include="..\devices\nld_schmitt.cpp" />
|
||||
<ClCompile Include="..\devices\nld_tms4800.cpp" />
|
||||
<ClCompile Include="..\devices\nld_4013.cpp" />
|
||||
@ -151,8 +154,6 @@
|
||||
<ClCompile Include="..\devices\nld_7493.cpp" />
|
||||
<ClCompile Include="..\devices\nld_74ls629.cpp" />
|
||||
<ClCompile Include="..\devices\nld_82S115.cpp" />
|
||||
<ClCompile Include="..\devices\nld_82S123.cpp" />
|
||||
<ClCompile Include="..\devices\nld_82S126.cpp" />
|
||||
<ClCompile Include="..\devices\nld_82S16.cpp" />
|
||||
<ClCompile Include="..\devices\nld_9310.cpp" />
|
||||
<ClCompile Include="..\devices\nld_9316.cpp" />
|
||||
@ -174,6 +175,7 @@
|
||||
<ClCompile Include="..\macro\nlm_cd4xxx.cpp" />
|
||||
<ClCompile Include="..\macro\nlm_opamp.cpp" />
|
||||
<ClCompile Include="..\macro\nlm_other.cpp" />
|
||||
<ClCompile Include="..\macro\nlm_roms.cpp" />
|
||||
<ClCompile Include="..\macro\nlm_ttl74xx.cpp" />
|
||||
<ClCompile Include="..\nl_base.cpp" />
|
||||
<ClCompile Include="..\nl_factory.cpp" />
|
||||
|
@ -162,9 +162,6 @@
|
||||
<ClCompile Include="..\devices\nld_7485.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\devices\nld_2716.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\devices\nld_tms4800.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
@ -219,18 +216,12 @@
|
||||
<ClCompile Include="..\devices\nld_7474.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\devices\nld_82S126.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\devices\nlid_truthtable.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\devices\nld_tristate.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\devices\nld_82S123.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\devices\nld_legacy.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
@ -270,6 +261,21 @@
|
||||
<ClCompile Include="..\devices\nld_74393.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\devices\nld_74163.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\devices\nld_roms.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\devices\nld_74125.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\devices\nld_74377.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\macro\nlm_roms.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\nl_errstr.h">
|
||||
@ -476,9 +482,6 @@
|
||||
<ClInclude Include="..\devices\nlid_cmos.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\devices\nld_4013.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\devices\nld_4020.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
|
@ -135,7 +135,7 @@
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalIncludeDirectories>$(SolutionDir)..\..\</AdditionalIncludeDirectories>
|
||||
<AdditionalIncludeDirectories>$(SolutionDir)..\..\;$(SolutionDir)..\</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
|
31
src/lib/netlist/devices/nld_74161.cpp
Normal file
31
src/lib/netlist/devices/nld_74161.cpp
Normal file
@ -0,0 +1,31 @@
|
||||
// license:GPL-2.0+
|
||||
// copyright-holders:Couriersud
|
||||
/*
|
||||
* nld_74161.cpp
|
||||
*
|
||||
*/
|
||||
|
||||
#include "nl_base.h"
|
||||
#include "nl_factory.h"
|
||||
|
||||
#include "nld_9316_base.hxx"
|
||||
|
||||
// FIXME: All detail can be found in nld_9316_base.hxx
|
||||
// At least gcc-7.x needs the implementations of the base device
|
||||
// in different compilation units. If created in the same file
|
||||
// performance degrades horrible.
|
||||
|
||||
// FIXME: this file could be created programmatically
|
||||
|
||||
namespace netlist
|
||||
{
|
||||
namespace devices
|
||||
{
|
||||
|
||||
NETLIB_DEVICE_IMPL(74161, "TTL_74161", "+CLK,+ENP,+ENT,+CLRQ,+LOADQ,+A,+B,+C,+D,@VCC,@GND")
|
||||
NETLIB_DEVICE_IMPL(74161_dip, "TTL_74161_DIP", "")
|
||||
// FIXME: This happens on copy/paste
|
||||
NETLIB_DEVICE_IMPL(74161_fixme, "TTL_74161_FIXME", "+A,+B,+C,+D,+CLRQ,+LOADQ,+CLK,+ENP,+ENT,@VCC,@GND")
|
||||
|
||||
} //namespace devices
|
||||
} // namespace netlist
|
29
src/lib/netlist/devices/nld_74163.cpp
Normal file
29
src/lib/netlist/devices/nld_74163.cpp
Normal file
@ -0,0 +1,29 @@
|
||||
// license:GPL-2.0+
|
||||
// copyright-holders:Couriersud
|
||||
/*
|
||||
* nld_74163.cpp
|
||||
*
|
||||
*/
|
||||
|
||||
#include "nl_base.h"
|
||||
#include "nl_factory.h"
|
||||
|
||||
#include "nld_9316_base.hxx"
|
||||
|
||||
// FIXME: All detail can be found in nld_9316_base.hxx
|
||||
// At least gcc-7.x needs the implementations of the base device
|
||||
// in different compilation units. If created in the same file
|
||||
// performance degrades horrible.
|
||||
|
||||
// FIXME: this file could be created programmatically
|
||||
|
||||
namespace netlist
|
||||
{
|
||||
namespace devices
|
||||
{
|
||||
|
||||
NETLIB_DEVICE_IMPL(74163, "TTL_74163", "+CLK,+ENP,+ENT,+CLRQ,+LOADQ,+A,+B,+C,+D,@VCC,@GND")
|
||||
NETLIB_DEVICE_IMPL(74163_dip, "TTL_74163_DIP", "")
|
||||
|
||||
} //namespace devices
|
||||
} // namespace netlist
|
29
src/lib/netlist/devices/nld_9310.cpp
Normal file
29
src/lib/netlist/devices/nld_9310.cpp
Normal file
@ -0,0 +1,29 @@
|
||||
// license:GPL-2.0+
|
||||
// copyright-holders:Couriersud
|
||||
/*
|
||||
* nld_9310.cpp
|
||||
*
|
||||
*/
|
||||
|
||||
#include "nl_base.h"
|
||||
#include "nl_factory.h"
|
||||
|
||||
#include "nld_9316_base.hxx"
|
||||
|
||||
// FIXME: All detail can be found in nld_9316_base.hxx
|
||||
// At least gcc-7.x needs the implementations of the base device
|
||||
// in different compilation units. If created in the same file
|
||||
// performance degrades horrible.
|
||||
|
||||
// FIXME: this file could be created programmatically
|
||||
|
||||
namespace netlist
|
||||
{
|
||||
namespace devices
|
||||
{
|
||||
|
||||
NETLIB_DEVICE_IMPL(9310, "TTL_9310", "+CLK,+ENP,+ENT,+CLRQ,+LOADQ,+A,+B,+C,+D,@VCC,@GND")
|
||||
NETLIB_DEVICE_IMPL(9310_dip, "TTL_9310_DIP", "")
|
||||
|
||||
} //namespace devices
|
||||
} // namespace netlist
|
@ -4,214 +4,26 @@
|
||||
* nld_9316.cpp
|
||||
*
|
||||
*/
|
||||
|
||||
#include "nl_base.h"
|
||||
#include "nl_factory.h"
|
||||
|
||||
#include "nld_9316_base.hxx"
|
||||
|
||||
// FIXME: All detail can be found in nld_9316_base.hxx
|
||||
// At least gcc-7.x needs the implementations of the base device
|
||||
// in different compilation units. If created in the same file
|
||||
// performance degrades horrible.
|
||||
|
||||
// FIXME: this file could be created programmatically
|
||||
|
||||
namespace netlist
|
||||
{
|
||||
namespace devices
|
||||
{
|
||||
|
||||
// FIXME: Family needs to be set to LS for 74193. This needs some more
|
||||
// thought generally.
|
||||
|
||||
template <unsigned N>
|
||||
static constexpr unsigned rollover(unsigned v) { return v <= N ? v : 0; }
|
||||
|
||||
#if 0
|
||||
template <>
|
||||
constexpr unsigned rollover<7>(unsigned v) { return v & 7; }
|
||||
#endif
|
||||
|
||||
template <>
|
||||
constexpr unsigned rollover<15>(unsigned v) { return v & 15; }
|
||||
|
||||
|
||||
template <typename D>
|
||||
NETLIB_OBJECT(9316_base)
|
||||
{
|
||||
NETLIB_CONSTRUCTOR(9316_base)
|
||||
, m_CLK(*this, "CLK", NETLIB_DELEGATE(9316_base, clk))
|
||||
, m_ENT(*this, "ENT")
|
||||
, m_RC(*this, "RC")
|
||||
, m_LOADQ(*this, "LOADQ")
|
||||
, m_ENP(*this, "ENP")
|
||||
, m_CLRQ(*this, "CLRQ")
|
||||
, m_ABCD(*this, {"A", "B", "C", "D"}, NETLIB_DELEGATE(9316_base, abcd))
|
||||
, m_Q(*this, { "QA", "QB", "QC", "QD" })
|
||||
, m_cnt(*this, "m_cnt", 0)
|
||||
, m_abcd(*this, "m_abcd", 0)
|
||||
, m_loadq(*this, "m_loadq", 0)
|
||||
, m_ent(*this, "m_ent", 0)
|
||||
, m_power_pins(*this)
|
||||
{
|
||||
}
|
||||
|
||||
private:
|
||||
NETLIB_RESETI()
|
||||
{
|
||||
m_CLK.set_state(logic_t::STATE_INP_LH);
|
||||
m_cnt = 0;
|
||||
m_abcd = 0;
|
||||
}
|
||||
|
||||
NETLIB_UPDATEI()
|
||||
{
|
||||
const auto CLRQ(m_CLRQ());
|
||||
m_ent = m_ENT();
|
||||
m_loadq = m_LOADQ();
|
||||
|
||||
if (((m_loadq ^ 1) || (m_ent && m_ENP())) && (!D::ASYNC::value() || CLRQ))
|
||||
{
|
||||
m_CLK.activate_lh();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_CLK.inactivate();
|
||||
if (D::ASYNC::value() && !CLRQ && (m_cnt>0))
|
||||
{
|
||||
m_cnt = 0;
|
||||
m_Q.push(m_cnt, D::tCLR::value(0));
|
||||
}
|
||||
}
|
||||
m_RC.push(m_ent && (m_cnt == D::MAXCNT::value()), D::tRC::value(0));
|
||||
}
|
||||
|
||||
NETLIB_HANDLERI(clk)
|
||||
{
|
||||
if (!D::ASYNC::value() && !m_CLRQ())
|
||||
{
|
||||
m_cnt = 0;
|
||||
m_Q.push(m_cnt, D::tCLR::value(0));
|
||||
}
|
||||
else
|
||||
{
|
||||
//const auto cnt = (m_loadq ? (m_cnt + 1) & D::MAXCNT::value : m_abcd);
|
||||
const auto cnt = (m_loadq ? rollover<D::MAXCNT::value()>(m_cnt + 1) : m_abcd);
|
||||
m_RC.push(m_ent && (cnt == D::MAXCNT::value()), D::tRC::value(0));
|
||||
m_Q.push(cnt, D::tLDCNT::value(0));
|
||||
m_cnt = static_cast<unsigned>(cnt);
|
||||
}
|
||||
}
|
||||
|
||||
NETLIB_HANDLERI(abcd)
|
||||
{
|
||||
m_abcd = static_cast<unsigned>(m_ABCD());
|
||||
}
|
||||
|
||||
logic_input_t m_CLK;
|
||||
logic_input_t m_ENT;
|
||||
|
||||
logic_output_t m_RC;
|
||||
|
||||
logic_input_t m_LOADQ;
|
||||
|
||||
logic_input_t m_ENP;
|
||||
logic_input_t m_CLRQ;
|
||||
|
||||
object_array_t<logic_input_t, 4> m_ABCD;
|
||||
object_array_t<logic_output_t, 4> m_Q;
|
||||
|
||||
/* counter state */
|
||||
state_var<unsigned> m_cnt;
|
||||
/* cached pins */
|
||||
state_var<unsigned> m_abcd;
|
||||
state_var_sig m_loadq;
|
||||
state_var_sig m_ent;
|
||||
nld_power_pins m_power_pins;
|
||||
|
||||
};
|
||||
|
||||
template <typename D>
|
||||
NETLIB_OBJECT(9316_dip_base)
|
||||
{
|
||||
NETLIB_CONSTRUCTOR(9316_dip_base)
|
||||
, A(*this, "A")
|
||||
{
|
||||
this->register_subalias("1", "A.CLRQ");
|
||||
this->register_subalias("2", "A.CLK");
|
||||
this->register_subalias("3", "A.A");
|
||||
this->register_subalias("4", "A.B");
|
||||
this->register_subalias("5", "A.C");
|
||||
this->register_subalias("6", "A.D");
|
||||
this->register_subalias("7", "A.ENP");
|
||||
this->register_subalias("8", "A.GND");
|
||||
|
||||
this->register_subalias("9", "A.LOADQ");
|
||||
this->register_subalias("10", "A.ENT");
|
||||
this->register_subalias("11", "A.QD");
|
||||
this->register_subalias("12", "A.QC");
|
||||
this->register_subalias("13", "A.QB");
|
||||
this->register_subalias("14", "A.QA");
|
||||
this->register_subalias("15", "A.RC");
|
||||
this->register_subalias("16", "A.VCC");
|
||||
}
|
||||
private:
|
||||
NETLIB_SUB(9316_base)<D> A;
|
||||
};
|
||||
|
||||
struct desc_9316 : public desc_base
|
||||
{
|
||||
using ASYNC = fdesc_const_t<bool, true>;
|
||||
using MAXCNT = fdesc_const_t<unsigned, 15>;
|
||||
using tRC = time_ns<27>;
|
||||
using tCLR = time_ns<36>;
|
||||
using tLDCNT = time_ns<20>;
|
||||
};
|
||||
|
||||
struct desc_9310 : public desc_base
|
||||
{
|
||||
using ASYNC = fdesc_const_t<bool, true>;
|
||||
using MAXCNT = fdesc_const_t<unsigned, 10>;
|
||||
using tRC = time_ns<27>;
|
||||
using tCLR = time_ns<36>;
|
||||
using tLDCNT = time_ns<20>;
|
||||
};
|
||||
|
||||
struct desc_74161 : public desc_base
|
||||
{
|
||||
using ASYNC = fdesc_const_t<bool, true>;
|
||||
using MAXCNT = fdesc_const_t<unsigned, 15>;
|
||||
using tRC = time_ns<28>;
|
||||
using tCLR = time_ns<37>;
|
||||
using tLDCNT = time_ns<21>;
|
||||
};
|
||||
|
||||
struct desc_74163 : public desc_base
|
||||
{
|
||||
using ASYNC = fdesc_const_t<bool, false>;
|
||||
using MAXCNT = fdesc_const_t<unsigned, 15>;
|
||||
using tRC = time_ns<28>;
|
||||
using tCLR = time_ns<37>;
|
||||
using tLDCNT = time_ns<21>;
|
||||
};
|
||||
|
||||
using NETLIB_NAME(9310) = NETLIB_NAME(9316_base)<desc_9310>;
|
||||
using NETLIB_NAME(9316) = NETLIB_NAME(9316_base)<desc_9316>;
|
||||
using NETLIB_NAME(74161) = NETLIB_NAME(9316_base)<desc_74161>;
|
||||
using NETLIB_NAME(74161_fixme) = NETLIB_NAME(9316_base)<desc_74161>;
|
||||
using NETLIB_NAME(74163) = NETLIB_NAME(9316_base)<desc_74163>;
|
||||
|
||||
using NETLIB_NAME(9310_dip) = NETLIB_NAME(9316_dip_base)<desc_9310>;
|
||||
using NETLIB_NAME(9316_dip) = NETLIB_NAME(9316_dip_base)<desc_9316>;
|
||||
using NETLIB_NAME(74161_dip) = NETLIB_NAME(9316_dip_base)<desc_74161>;
|
||||
using NETLIB_NAME(74163_dip) = NETLIB_NAME(9316_dip_base)<desc_74163>;
|
||||
|
||||
NETLIB_DEVICE_IMPL(9310, "TTL_9310", "+CLK,+ENP,+ENT,+CLRQ,+LOADQ,+A,+B,+C,+D,@VCC,@GND")
|
||||
NETLIB_DEVICE_IMPL(9310_dip, "TTL_9310_DIP", "")
|
||||
|
||||
NETLIB_DEVICE_IMPL(9316, "TTL_9316", "+CLK,+ENP,+ENT,+CLRQ,+LOADQ,+A,+B,+C,+D,@VCC,@GND")
|
||||
NETLIB_DEVICE_IMPL(9316_dip, "TTL_9316_DIP", "")
|
||||
|
||||
#if 1
|
||||
NETLIB_DEVICE_IMPL(74161, "TTL_74161", "+CLK,+ENP,+ENT,+CLRQ,+LOADQ,+A,+B,+C,+D,@VCC,@GND")
|
||||
NETLIB_DEVICE_IMPL(74161_dip, "TTL_74161_DIP", "")
|
||||
|
||||
// FIXME: This happens on copy/paste
|
||||
NETLIB_DEVICE_IMPL(74161_fixme, "TTL_74161_FIXME", "+A,+B,+C,+D,+CLRQ,+LOADQ,+CLK,+ENP,+ENT,@VCC,@GND")
|
||||
NETLIB_DEVICE_IMPL(74163, "TTL_74163", "+CLK,+ENP,+ENT,+CLRQ,+LOADQ,+A,+B,+C,+D,@VCC,@GND")
|
||||
NETLIB_DEVICE_IMPL(74163_dip, "TTL_74163_DIP", "")
|
||||
#endif
|
||||
NETLIB_DEVICE_IMPL(9316, "TTL_9316", "+CLK,+ENP,+ENT,+CLRQ,+LOADQ,+A,+B,+C,+D,@VCC,@GND")
|
||||
NETLIB_DEVICE_IMPL(9316_dip, "TTL_9316_DIP", "")
|
||||
|
||||
} //namespace devices
|
||||
} // namespace netlist
|
||||
|
193
src/lib/netlist/devices/nld_9316_base.hxx
Normal file
193
src/lib/netlist/devices/nld_9316_base.hxx
Normal file
@ -0,0 +1,193 @@
|
||||
// license:GPL-2.0+
|
||||
// copyright-holders:Couriersud
|
||||
/*
|
||||
* nld_9316_base.hxx
|
||||
*
|
||||
*/
|
||||
|
||||
#include "nl_base.h"
|
||||
#include "nl_factory.h"
|
||||
|
||||
namespace netlist
|
||||
{
|
||||
namespace devices
|
||||
{
|
||||
|
||||
template <unsigned N>
|
||||
static constexpr unsigned rollover(unsigned v) { return v <= N ? v : 0; }
|
||||
|
||||
template <>
|
||||
constexpr unsigned rollover<15>(unsigned v) { return v & 15; }
|
||||
|
||||
template <typename D>
|
||||
NETLIB_OBJECT(9316_base)
|
||||
{
|
||||
NETLIB_CONSTRUCTOR(9316_base)
|
||||
, m_CLK(*this, "CLK", NETLIB_DELEGATE(9316_base, clk))
|
||||
, m_ENT(*this, "ENT")
|
||||
, m_RC(*this, "RC")
|
||||
, m_LOADQ(*this, "LOADQ")
|
||||
, m_ENP(*this, "ENP")
|
||||
, m_CLRQ(*this, "CLRQ")
|
||||
, m_ABCD(*this, {"A", "B", "C", "D"}, NETLIB_DELEGATE(9316_base, abcd))
|
||||
, m_Q(*this, { "QA", "QB", "QC", "QD" })
|
||||
, m_cnt(*this, "m_cnt", 0)
|
||||
, m_abcd(*this, "m_abcd", 0)
|
||||
, m_loadq(*this, "m_loadq", 0)
|
||||
, m_ent(*this, "m_ent", 0)
|
||||
, m_power_pins(*this)
|
||||
{
|
||||
}
|
||||
|
||||
private:
|
||||
NETLIB_RESETI()
|
||||
{
|
||||
m_CLK.set_state(logic_t::STATE_INP_LH);
|
||||
m_cnt = 0;
|
||||
m_abcd = 0;
|
||||
}
|
||||
|
||||
NETLIB_UPDATEI()
|
||||
{
|
||||
const auto CLRQ(m_CLRQ());
|
||||
m_ent = m_ENT();
|
||||
m_loadq = m_LOADQ();
|
||||
|
||||
if (((m_loadq ^ 1) || (m_ent && m_ENP())) && (!D::ASYNC::value || CLRQ))
|
||||
{
|
||||
m_CLK.activate_lh();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_CLK.inactivate();
|
||||
if (D::ASYNC::value && !CLRQ && (m_cnt>0))
|
||||
{
|
||||
m_cnt = 0;
|
||||
m_Q.push(m_cnt, D::tCLR::value(0));
|
||||
}
|
||||
}
|
||||
m_RC.push(m_ent && (m_cnt == D::MAXCNT::value), D::tRC::value(0));
|
||||
}
|
||||
|
||||
NETLIB_HANDLERI(clk)
|
||||
{
|
||||
if (!D::ASYNC::value && !m_CLRQ())
|
||||
{
|
||||
m_cnt = 0;
|
||||
m_Q.push(m_cnt, D::tCLR::value(0));
|
||||
}
|
||||
else
|
||||
{
|
||||
//const auto cnt = (m_loadq ? (m_cnt + 1) & D::MAXCNT::value : m_abcd);
|
||||
const auto cnt = (m_loadq ? rollover<D::MAXCNT::value>(m_cnt + 1) : m_abcd);
|
||||
m_RC.push(m_ent && (cnt == D::MAXCNT::value), D::tRC::value(0));
|
||||
m_Q.push(cnt, D::tLDCNT::value(0));
|
||||
m_cnt = static_cast<unsigned>(cnt);
|
||||
}
|
||||
}
|
||||
|
||||
NETLIB_HANDLERI(abcd)
|
||||
{
|
||||
m_abcd = static_cast<unsigned>(m_ABCD());
|
||||
}
|
||||
|
||||
logic_input_t m_CLK;
|
||||
logic_input_t m_ENT;
|
||||
|
||||
logic_output_t m_RC;
|
||||
|
||||
logic_input_t m_LOADQ;
|
||||
|
||||
logic_input_t m_ENP;
|
||||
logic_input_t m_CLRQ;
|
||||
|
||||
object_array_t<logic_input_t, 4> m_ABCD;
|
||||
object_array_t<logic_output_t, 4> m_Q;
|
||||
|
||||
/* counter state */
|
||||
state_var<unsigned> m_cnt;
|
||||
/* cached pins */
|
||||
state_var<unsigned> m_abcd;
|
||||
state_var_sig m_loadq;
|
||||
state_var_sig m_ent;
|
||||
nld_power_pins m_power_pins;
|
||||
|
||||
};
|
||||
|
||||
template <typename D>
|
||||
NETLIB_OBJECT(9316_dip_base)
|
||||
{
|
||||
NETLIB_CONSTRUCTOR(9316_dip_base)
|
||||
, A(*this, "A")
|
||||
{
|
||||
this->register_subalias("1", "A.CLRQ");
|
||||
this->register_subalias("2", "A.CLK");
|
||||
this->register_subalias("3", "A.A");
|
||||
this->register_subalias("4", "A.B");
|
||||
this->register_subalias("5", "A.C");
|
||||
this->register_subalias("6", "A.D");
|
||||
this->register_subalias("7", "A.ENP");
|
||||
this->register_subalias("8", "A.GND");
|
||||
|
||||
this->register_subalias("9", "A.LOADQ");
|
||||
this->register_subalias("10", "A.ENT");
|
||||
this->register_subalias("11", "A.QD");
|
||||
this->register_subalias("12", "A.QC");
|
||||
this->register_subalias("13", "A.QB");
|
||||
this->register_subalias("14", "A.QA");
|
||||
this->register_subalias("15", "A.RC");
|
||||
this->register_subalias("16", "A.VCC");
|
||||
}
|
||||
private:
|
||||
NETLIB_SUB(9316_base)<D> A;
|
||||
};
|
||||
|
||||
struct desc_9316 : public desc_base
|
||||
{
|
||||
using ASYNC = desc_const_t<bool, true>;
|
||||
using MAXCNT = desc_const_t<unsigned, 15>;
|
||||
using tRC = time_ns<27>;
|
||||
using tCLR = time_ns<36>;
|
||||
using tLDCNT = time_ns<20>;
|
||||
};
|
||||
|
||||
struct desc_9310 : public desc_base
|
||||
{
|
||||
using ASYNC = desc_const_t<bool, true>;
|
||||
using MAXCNT = desc_const_t<unsigned, 10>;
|
||||
using tRC = time_ns<27>;
|
||||
using tCLR = time_ns<36>;
|
||||
using tLDCNT = time_ns<20>;
|
||||
};
|
||||
|
||||
struct desc_74161 : public desc_base
|
||||
{
|
||||
using ASYNC = desc_const_t<bool, true>;
|
||||
using MAXCNT = desc_const_t<unsigned, 15>;
|
||||
using tRC = time_ns<27>;
|
||||
using tCLR = time_ns<36>;
|
||||
using tLDCNT = time_ns<20>;
|
||||
};
|
||||
|
||||
struct desc_74163 : public desc_base
|
||||
{
|
||||
using ASYNC = desc_const_t<bool, false>;
|
||||
using MAXCNT = desc_const_t<unsigned, 15>;
|
||||
using tRC = time_ns<27>;
|
||||
using tCLR = time_ns<36>;
|
||||
using tLDCNT = time_ns<20>;
|
||||
};
|
||||
|
||||
using NETLIB_NAME(9310) = NETLIB_NAME(9316_base)<desc_9310>;
|
||||
using NETLIB_NAME(9316) = NETLIB_NAME(9316_base)<desc_9316>;
|
||||
using NETLIB_NAME(74161) = NETLIB_NAME(9316_base)<desc_74161>;
|
||||
using NETLIB_NAME(74161_fixme) = NETLIB_NAME(9316_base)<desc_74161>;
|
||||
using NETLIB_NAME(74163) = NETLIB_NAME(9316_base)<desc_74163>;
|
||||
|
||||
using NETLIB_NAME(9310_dip) = NETLIB_NAME(9316_dip_base)<desc_9310>;
|
||||
using NETLIB_NAME(9316_dip) = NETLIB_NAME(9316_dip_base)<desc_9316>;
|
||||
using NETLIB_NAME(74161_dip) = NETLIB_NAME(9316_dip_base)<desc_74161>;
|
||||
using NETLIB_NAME(74163_dip) = NETLIB_NAME(9316_dip_base)<desc_74163>;
|
||||
|
||||
} //namespace devices
|
||||
} // namespace netlist
|
@ -206,20 +206,6 @@ namespace netlist
|
||||
}
|
||||
};
|
||||
|
||||
template<typename T, T V>
|
||||
struct fintegral_constant
|
||||
{
|
||||
static constexpr const T value() noexcept { return V; }
|
||||
typedef T value_type;
|
||||
typedef fintegral_constant<T, V> type;
|
||||
};
|
||||
|
||||
template <std::size_t V>
|
||||
using fdesc_const = fintegral_constant<std::size_t, V>;
|
||||
|
||||
template <typename T, T V>
|
||||
using fdesc_const_t = fintegral_constant<T, V>;
|
||||
|
||||
/// \brief: used define a constant in device description struct
|
||||
///
|
||||
/// See the 74125 implementation
|
||||
|
Loading…
Reference in New Issue
Block a user