netlist: templatize 74107 and code maintenance.

* removed some dead friend declarations
* optimized template times_ns2
This commit is contained in:
couriersud 2020-08-23 15:27:26 +02:00
parent 8cde9585e6
commit 113de38237
8 changed files with 84 additions and 142 deletions

View File

@ -61,6 +61,7 @@ namespace netlist
{ {
} }
private:
NETLIB_HANDLERI(inputs) NETLIB_HANDLERI(inputs)
{ {
if (m_last_clock && !m_CLOCK()) if (m_last_clock && !m_CLOCK())
@ -93,8 +94,6 @@ namespace netlist
} }
} }
friend class NETLIB_NAME(CD4006_dip);
private:
logic_input_t m_CLOCK; logic_input_t m_CLOCK;
object_array_t<logic_input_t, 4> m_I; object_array_t<logic_input_t, 4> m_I;
object_array_t<logic_output_t, 7> m_Q; object_array_t<logic_output_t, 7> m_Q;

View File

@ -69,27 +69,21 @@ namespace netlist
namespace devices namespace devices
{ {
static constexpr const std::array<netlist_time, 2> delay_107 = { NLTIME_FROM_NS(16), NLTIME_FROM_NS(25) }; template <typename D>
static constexpr const std::array<netlist_time, 2> delay_107A = { NLTIME_FROM_NS(15), NLTIME_FROM_NS(15) }; NETLIB_OBJECT(74107_base)
NETLIB_OBJECT(74107A)
{ {
NETLIB_CONSTRUCTOR(74107A) NETLIB_CONSTRUCTOR(74107_base)
, m_clk(*this, "CLK", NETLIB_DELEGATE(clk)) , m_clk(*this, "CLK", NETLIB_DELEGATE(clk))
, m_Q(*this, "Q")
, m_QQ(*this, "QQ")
, m_J(*this, "J", NETLIB_DELEGATE(other)) , m_J(*this, "J", NETLIB_DELEGATE(other))
, m_K(*this, "K", NETLIB_DELEGATE(other)) , m_K(*this, "K", NETLIB_DELEGATE(other))
, m_clrQ(*this, "CLRQ", NETLIB_DELEGATE(other)) , m_clrQ(*this, "CLRQ", NETLIB_DELEGATE(other))
, m_Q(*this, "Q")
, m_QQ(*this, "QQ")
, m_power_pins(*this) , m_power_pins(*this)
{ {
m_delay[0] = delay_107A[0];
m_delay[1] = delay_107A[1];
} }
friend class NETLIB_NAME(74107_dip); private:
friend class NETLIB_NAME(74107);
NETLIB_RESETI() NETLIB_RESETI()
{ {
m_clk.set_state(logic_t::STATE_INP_HL); m_clk.set_state(logic_t::STATE_INP_HL);
@ -127,35 +121,35 @@ namespace netlist
newstate(((t ^ 1) & m_J()) | (t & (m_K() ^ 1))); newstate(((t ^ 1) & m_J()) | (t & (m_K() ^ 1)));
} }
private: void newstate(const netlist_sig_t state)
{
m_Q.push(state, D::delay::value(state));
m_QQ.push(state ^ 1, D::delay::value(state ^ 1));
}
logic_input_t m_clk; logic_input_t m_clk;
logic_output_t m_Q;
logic_output_t m_QQ;
std::array<netlist_time, 2> m_delay;
logic_input_t m_J; logic_input_t m_J;
logic_input_t m_K; logic_input_t m_K;
logic_input_t m_clrQ; logic_input_t m_clrQ;
logic_output_t m_Q;
logic_output_t m_QQ;
nld_power_pins m_power_pins; nld_power_pins m_power_pins;
void newstate(const netlist_sig_t state)
{
m_Q.push(state, m_delay[state]);
m_QQ.push(state ^ 1, m_delay[state ^ 1]);
}
}; };
NETLIB_OBJECT_DERIVED(74107, 74107A) struct desc_74107 : public desc_base
{ {
public: using delay = times_ns2<16, 25>;
NETLIB_CONSTRUCTOR(74107)
{
m_delay[0] = delay_107[0];
m_delay[1] = delay_107[1];
}
}; };
struct desc_74107A : public desc_base
{
using delay = times_ns2<15, 15>;
};
using NETLIB_NAME(74107) = NETLIB_NAME(74107_base)<desc_74107>;
using NETLIB_NAME(74107A) = NETLIB_NAME(74107_base)<desc_74107A>;
NETLIB_DEVICE_IMPL(74107, "TTL_74107", "+CLK,+J,+K,+CLRQ,@VCC,@GND") NETLIB_DEVICE_IMPL(74107, "TTL_74107", "+CLK,+J,+K,+CLRQ,@VCC,@GND")
NETLIB_DEVICE_IMPL(74107A, "TTL_74107A", "+CLK,+J,+K,+CLRQ,@VCC,@GND") NETLIB_DEVICE_IMPL(74107A, "TTL_74107A", "+CLK,+J,+K,+CLRQ,@VCC,@GND")

View File

@ -103,8 +103,6 @@ namespace netlist
m_ab = static_cast<unsigned>((m_AB() == 3) ? 1 : 0); m_ab = static_cast<unsigned>((m_AB() == 3) ? 1 : 0);
} }
friend class NETLIB_NAME(74164_dip);
private:
object_array_t<logic_input_t, 2> m_AB; object_array_t<logic_input_t, 2> m_AB;
logic_input_t m_CLRQ; logic_input_t m_CLRQ;
logic_input_t m_CLK; logic_input_t m_CLK;

View File

@ -50,6 +50,7 @@ namespace netlist
{ {
} }
private:
NETLIB_RESETI() NETLIB_RESETI()
{ {
m_shifter = 0; m_shifter = 0;
@ -103,8 +104,6 @@ namespace netlist
m_QH.push(qh, delay); //FIXME m_QH.push(qh, delay); //FIXME
} }
friend class NETLIB_NAME(74166_dip);
private:
object_array_t<logic_input_t, 8> m_DATA; object_array_t<logic_input_t, 8> m_DATA;
logic_input_t m_SER; logic_input_t m_SER;
logic_input_t m_CLRQ; logic_input_t m_CLRQ;

View File

@ -50,14 +50,13 @@ namespace netlist
{ {
} }
private:
NETLIB_RESETI() NETLIB_RESETI()
{ {
m_last_CLK = 0; m_last_CLK = 0;
m_last_Q = 0; m_last_Q = 0;
} }
friend class NETLIB_NAME(74194_dip);
private:
// FIXME: Timing // FIXME: Timing
NETLIB_HANDLERI(inputs) NETLIB_HANDLERI(inputs)
{ {

View File

@ -57,66 +57,6 @@
#include "nld_7493.h" #include "nld_7493.h"
#include "netlist/nl_base.h" #include "netlist/nl_base.h"
//- Identifier: TTL_7493_DIP
//- Title: 7493 Binary Counters
//- Description:
//- Each of these monolithic counters contains four master-slave
//- flip-flops and additional gating to provide a divide-by-two
//- counter and a three-stage binary counter for which the
//- count cycle length is divide-by-five for the 90A and divide-by-eight
//- for the 93A.
//-
//- All of these counters have a gated zero reset and the 90A
//- also has gated set-to-nine inputs for use in BCD nines complement
//- applications.
//-
//- To use their maximum count length (decade or four-bit binary),
//- the B input is connected to the Q A output. The input count pulses
//- are applied to input A and the outputs are as described in the
//- appropriate truth table. A symmetrical divide-by-ten count can be
//- obtained from the 90A counters by connecting the Q D output to the
//- A input and applying the input count to the B input which gives
//- a divide-by-ten square wave at output Q A.
//-
//- Pinalias: B,R01,R02,NC,VCC,NC,NC,QC,QB,GND,QD,QA,NC,A
//- Package: DIP
//- NamingConvention: Naming conventions follow National Semiconductor datasheet
//- Limitations: Internal resistor network currently fixed to 5k
//- more limitations
//- Example: ne555_astable.c,ne555_example
//- FunctionTable:
//- Counter Sequence
//-
//- | COUNT || QD | QC | QB | QA |
//- |------:||:--:|:--:|:--:|:--:|
//- | 0 || 0 | 0 | 0 | 0 |
//- | 1 || 0 | 0 | 0 | 1 |
//- | 2 || 0 | 0 | 1 | 0 |
//- | 3 || 0 | 0 | 1 | 1 |
//- | 4 || 0 | 1 | 0 | 0 |
//- | 5 || 0 | 1 | 0 | 1 |
//- | 6 || 0 | 1 | 1 | 0 |
//- | 7 || 0 | 1 | 1 | 1 |
//- | 8 || 1 | 0 | 0 | 0 |
//- | 9 || 1 | 0 | 0 | 1 |
//- | 10 || 1 | 0 | 1 | 0 |
//- | 11 || 1 | 0 | 1 | 1 |
//- | 12 || 1 | 1 | 0 | 0 |
//- | 13 || 1 | 1 | 0 | 1 |
//- | 14 || 1 | 1 | 1 | 0 |
//- | 15 || 1 | 1 | 1 | 1 |
//-
//- Note C Output QA is connected to input B
//-
//- Reset Count Function table
//-
//- | R01 | R02 | QD | QC | QB | QA |
//- |:---:|:---:|:--:|:--:|:--:|:--:|
//- | 1 | 1 | 0 | 0 | 0 | 0 |
//- | 0 | X | COUNT ||||
//- | X | 0 | COUNT ||||
//-
//-
namespace netlist namespace netlist
{ {

View File

@ -1355,28 +1355,39 @@ NETLIST_END()
NETLIST_END() NETLIST_END()
//- Identifier: TTL_7493_DIP //- Identifier: TTL_7493_DIP
//- Title: DM7493A Binary Counter //- Title: 7493 Binary Counters
//- Description: These monolithic counters contains four //- Description:
//- master-slave flip-flops and additional gating to provide //- Each of these monolithic counters contains four master-slave
//- a divide-by-two counter and a three-stage binary counter //- flip-flops and additional gating to provide a divide-by-two
//- for which the count cycle length is divide-by-eight. //- counter and a three-stage binary counter for which the
//- count cycle length is divide-by-five for the 90A and divide-by-eight
//- for the 93A.
//- //-
//- These counters have a gated zero reset. //- All of these counters have a gated zero reset and the 90A
//- also has gated set-to-nine inputs for use in BCD nines complement
//- applications.
//-
//- To use their maximum count length (decade or four-bit binary),
//- the B input is connected to the Q A output. The input count pulses
//- are applied to input A and the outputs are as described in the
//- appropriate truth table. A symmetrical divide-by-ten count can be
//- obtained from the 90A counters by connecting the Q D output to the
//- A input and applying the input count to the B input which gives
//- a divide-by-ten square wave at output Q A.
//- //-
//- To use their maximum count length (four-bit binary), the B input is connected
//- to the QA output. The input count pulses are applied to
//- input A and the outputs are as described in the appropriate
//- truth table.
//- Pinalias: B,R01,R02,NC,VCC,NC,NC,QC,QB,GND,QD,QA,NC,A //- Pinalias: B,R01,R02,NC,VCC,NC,NC,QC,QB,GND,QD,QA,NC,A
//- Package: DIP //- Package: DIP
//- NamingConvention: Naming conventions follow National Semiconductor datasheet //- NamingConvention: Naming conventions follow National Semiconductor datasheet
//- Limitations: Internal resistor network currently fixed to 5k
//- more limitations
//- Example: ne555_astable.c,ne555_example
//- FunctionTable: //- FunctionTable:
//- http://pdf.datasheetcatalog.com/datasheet/nationalsemiconductor/DS006533.PDF //- http://pdf.datasheetcatalog.com/datasheet/nationalsemiconductor/DS006533.PDF
//- //-
//- Count Sequence //- Counter Sequence
//- +-------++----+----+----+----+ //-
//- | Count || QD | QC | QB | QA | //- | COUNT || QD | QC | QB | QA |
//- +=======++====+====+====+====+ //- |------:||:--:|:--:|:--:|:--:|
//- | 0 || 0 | 0 | 0 | 0 | //- | 0 || 0 | 0 | 0 | 0 |
//- | 1 || 0 | 0 | 0 | 1 | //- | 1 || 0 | 0 | 0 | 1 |
//- | 2 || 0 | 0 | 1 | 0 | //- | 2 || 0 | 0 | 1 | 0 |
@ -1393,17 +1404,19 @@ NETLIST_END()
//- | 13 || 1 | 1 | 0 | 1 | //- | 13 || 1 | 1 | 0 | 1 |
//- | 14 || 1 | 1 | 1 | 0 | //- | 14 || 1 | 1 | 1 | 0 |
//- | 15 || 1 | 1 | 1 | 1 | //- | 15 || 1 | 1 | 1 | 1 |
//- +-------++----+----+----+----+
//- //-
//- Reset/Count Function Table //- Note C Output QA is connected to input B
//- +-----+-----++----+----+----+----+
//- | R01 | R02 || QD | QC | QB | QA |
//- +=====+=====++====+====+====+====+
//- | 1 | 1 || 0 | 0 | 0 | 0 |
//- | 0 | X || COUNT |
//- | X | 0 || COUNT |
//- +-----+-----++----+----+----+----+
//- //-
//- Reset Count Function table
//-
//- | R01 | R02 | QD | QC | QB | QA |
//- |:---:|:---:|:--:|:--:|:--:|:--:|
//- | 1 | 1 | 0 | 0 | 0 | 0 |
//- | 0 | X | COUNT ||||
//- | X | 0 | COUNT ||||
//-
//-
static NETLIST_START(TTL_7493_DIP) static NETLIST_START(TTL_7493_DIP)
TTL_7493(A) TTL_7493(A)
NC_PIN(NC) NC_PIN(NC)

View File

@ -265,7 +265,7 @@ namespace netlist
{ {
static constexpr netlist_time value(std::size_t N) static constexpr netlist_time value(std::size_t N)
{ {
return NLTIME_FROM_NS(N == 0 ? value0 : value1); return N == 0 ? NLTIME_FROM_NS(value0) : NLTIME_FROM_NS(value1);
} }
}; };
@ -278,9 +278,9 @@ namespace netlist
{ {
static constexpr netlist_time value(std::size_t N) static constexpr netlist_time value(std::size_t N)
{ {
return NLTIME_FROM_NS(N == 0 ? value0 : return N == 0 ? NLTIME_FROM_NS(value0) :
N == 1 ? value1 : N == 1 ? NLTIME_FROM_NS(value1) :
value2); NLTIME_FROM_NS(value2);
} }
}; };