[wrap]
#pragma once
#ifndef __DISCRETE_H__
#define __DISCRETE_H__
#include "machine/rescap.h"
/***********************************************************************
*
* MAME - Discrete sound system emulation library
*
* Written by Keith Wilkins (mame@esplexo.co.uk)
*
* (c) K.Wilkins 2000
*
* Coding started in November 2000
*
* Additions/bugfix February 2003 - D.Renaud, F.Palazzolo, K.Wilkins
*
***********************************************************************
*
* For free text books on electronic theory check out:
* http://www.ibiblio.org/obp/electricCircuits/
* For a free circuit simulator:
* http://qucs.sourceforge.net/index.html
* For a free waveform editor to view DISCRETE_WAVELOG dumps:
* http://audacity.sourceforge.net/
* http://www.sonicvisualiser.org/
*
***********************************************************************
*
* Currently only one instance of a discrete sound system is supported.
* If more then one instance is required in the future, then a chip #
* will have to be added to the read/writes and the discrete inputs
* modified to match. This functionality should never be needed.
* There is no real need to run more then 1 discrete system.
*
* If a clock is specified in the machine driver setup, then this is
* used for the simulation sample rate. Otherwise it will default to
* run at the audio sample rate.
*
* Unused/Unconnected input nodes should be set to NODE_NC (No Connect)
*
* Each node can have many inputs from either constants or other
* nodes within the system.
*
* It should be remembered that the discrete sound system emulation
* does not do individual device emulation, but instead does a function
* emulation. So you will need to convert the schematic design into
* a logic block representation.
*
* There is the possibility to support multiple outputs per module.
* In this case, NODE_XXX is the default output. Alternative outputs may
* be accessed by using NODE_XXX_YY where 00<=Y<08.
*
* You may also access nodes with a macros:
*
* NODE_XXX = NODE_SUB(XXX, 0)
* NODE_XXX = NODE(XXX)
* NODE_XXX_YY = NODE_SUB(XXX, YY) with YY != 00
*
* One node point may feed a number of inputs, for example you could
* connect the output of a DISCRETE_SINEWAVE to the AMPLITUDE input
* of another DISCRETE_SINEWAVE to amplitude modulate its output and
* also connect it to the frequency input of another to frequency
* modulate its output, the combinations are endless....
*
* Consider the circuit below:
*
* .--------. .----------. .-------.
* | | | | | |
* | SQUARE | Enable| SINEWAVE | | |
* | WAVE |-+---------->| 2000Hz |---------------->| |
* | | | | | | ADDER |-->OUT
* | NODE11 | | | NODE12 | | |
* '--------' | '----------' .->| |
* | | |NODE20 |
* | .------. .---------. | '-------'
* | |Logic | | | | ^
* | | INV | Enable | SINEWVE | | |
* '->| ERT |------------->| 4000Hz |--' .-------.
* | | | | | |
* |NODE13| | NODE14 | | INPUT |
* '------' '---------' | |
* |NODE01 |
* '-------'
*
* This should give you an alternating two tone sound switching
* between the 2000Hz and 4000Hz sine waves at the frequency of the
* square wave, with the memory mapped enable signal mapped onto NODE07
* so discrete_sound_w(NODE_01,1) will enable the sound, and
* discrete_sound_w(NODE_01,0) will disable the sound.
*
* DISCRETE_SOUND_START(test_interface)
* DISCRETE_INPUT_LOGIC(NODE_01)
* DISCRETE_SQUAREWFIX(NODE_11, 1, 0.5, 1, 50, 1.0/2, 0) // Output 0:1
* DISCRETE_SINEWAVE(NODE_12, NODE_11, 2000, 10000, 0, 0)
* DISCRETE_LOGIC_INVERT(NODE_13, 1, NODE_11)
* DISCRETE_SINEWAVE(NODE_14, NODE_13, 4000, 10000, 0, 0)
* DISCRETE_ADDER2(NODE_20, NODE_01, NODE_12, NODE_14)
* DISCRETE_OUTPUT(NODE_20, 1)
* DISCRETE_SOUND_END
*
* To aid simulation speed it is preferable to use the enable/disable
* inputs to a block rather than setting the output amplitude to zero
*
* Feedback loops are allowed BUT they will always feedback one time
* step later, the loop over the netlist is only performed once per
* deltaT so feedback occurs in the next deltaT step. This is not
* the perfect solution but saves repeatedly traversing the netlist
* until all nodes have settled.
*
* The best way to work out your system is generally to use a pen and
* paper to draw a logical block diagram like the one above, it helps
* to understand the system ,map the inputs and outputs and to work
* out your node numbering scheme.
*
* Node numbers NODE_01 to NODE_299 are defined at present.
*
* It is recommended to put all Inputs at the start of the interface.
* That way they are updated first.
*
* Each sound effects final node should come after all nodes that
* create it. The final mixing of all sound effects should come
* at the end of the interface.
*
***********************************************************************
*
* x_time - ANTI-ALIASING features.
*
* Certain modules make use of x_time. This is a feature that passes
* information between modules about how long in the current sample, the
* switch in state happened. This is a decimal value of the % of the
* full sample period that it has been in the new state.
* 0 means it has been at the same state the whole sample.
*
* Example: Here is the output of a clock source with x_time on the
* output. The square wave is the real world waveform we
* want. The ^'s are the sample point. The numbers under
* the ^'s are the node output with the logic state left of
* the decimal and the x_time to the right. Under that is
* what the node's anti-aliased output energy would be.
* Note: the example is not 4x sampling so the energy
* does not provide an accurate representation of the
* original waveform. This is intentional so it fits
* in this header file.
* 1 ____ ____ ____ ____ ____ ____ ____ ____
* 0 ___ ____ ____ ____ ____ ____ ____ ____ __
* ^....^....^....^....^....^....^....^....^....^....^....^....^
* x_time 0.2 1.4 0.6 1.8 1.2 0.4 1.6 0.8 0.2 1.4 0.6
* energy 0.8 0.4 0.4 0.8 0.2 0.6 0.6 0.2 0.8 0.4 0.4
*
* Some modules will just pass the x_time onto another module.
*
* Modules that process x_time will keep track of the node's previous
* state so they can calculate the actual energy at the sample time.
*
* Example: Say we have a 555 module that outputs a clock with x_time
* that is connected to a counter. The output of the counter
* is connected to DAC_R1.
* In this case the counter module continues counting dependant
* on the integer portion of the 555 output. But it also
* passes the decimal portion as the x_time.
* The DAC_R1 then uses this info to anti-alias its output.
* Consider the following counter outputs vs DAC_R1
* calculations. The count changes from 9 to 10. It has
* been at the new state for 75% of the sample.
*
* counter binary x_time -- DAC_R1 bit energy --
* out count D3 D2 D1 D0
* 9.0 1001 0.0 1.0 0.0 0.0 1.0
* 10.75 1010 0.75 1.0 0.0 0.75 0.25
* 10.0 1010 0.0 1.0 0.0 1.0 0.0
*
* The DAC_R1 uses these energy calculations to scale the
* voltages created on each of its resistors. This
* anti-aliases the waveform no mater what the resistor
* weighting is.
*
***********************************************************************
*
* LIST OF CURRENTLY IMPLEMENTED DISCRETE BLOCKS
* ---------------------------------------------
*
* DISCRETE_SOUND_START(STRUCTURENAME)
* DISCRETE_SOUND_END
*
* DISCRETE_ADJUSTMENT(NODE,MIN,MAX,LOGLIN,PORT)
* DISCRETE_ADJUSTMENT_TAG(NODE,MIN,MAX,LOGLIN,TAG)
* DISCRETE_ADJUSTMENTX(NODE,MIN,MAX,LOGLIN,PORT,PMIN,PMAX)
* DISCRETE_CONSTANT(NODE,CONST0)
* DISCRETE_INPUT_DATA(NODE)
* DISCRETE_INPUTX_DATA(NODE,GAIN,OFFSET,INIT)
* DISCRETE_INPUT_LOGIC(NODE)
* DISCRETE_INPUTX_LOGIC(NODE,GAIN,OFFSET,INIT)
* DISCRETE_INPUT_NOT(NODE)
* DISCRETE_INPUTX_NOT(NODE,GAIN,OFFSET,INIT)
* DISCRETE_INPUT_PULSE(NODE,INIT)
* DISCRETE_INPUT_STREAM(NODE, NUM)
* DISCRETE_INPUTX_STREAM(NODE,NUM, GAIN,OFFSET)
*
* DISCRETE_COUNTER(NODE,ENAB,RESET,CLK,MAX,DIR,INIT0,CLKTYPE)
* DISCRETE_COUNTER_7492(NODE,ENAB,RESET,CLK,CLKTYPE)
* DISCRETE_LFSR_NOISE(NODE,ENAB,RESET,CLK,AMPL,FEED,BIAS,LFSRTB)
* DISCRETE_NOISE(NODE,ENAB,FREQ,AMP,BIAS)
* DISCRETE_NOTE(NODE,ENAB,CLK,DATA,MAX1,MAX2,CLKTYPE)
* DISCRETE_SAWTOOTHWAVE(NODE,ENAB,FREQ,AMP,BIAS,GRADIENT,PHASE)
* DISCRETE_SINEWAVE(NODE,ENAB,FREQ,AMP,BIAS,PHASE)
* DISCRETE_SQUAREWAVE(NODE,ENAB,FREQ,AMP,DUTY,BIAS,PHASE)
* DISCRETE_SQUAREWFIX(NODE,ENAB,FREQ,AMP,DUTY,BIAS,PHASE)
* DISCRETE_SQUAREWAVE2(NODE,ENAB,AMPL,T_OFF,T_ON,BIAS,TSHIFT)
* DISCRETE_TRIANGLEWAVE(NODE,ENAB,FREQ,AMP,BIAS,PHASE)
*
* DISCRETE_INVERTER_OSC(NODE,ENAB,MOD,RCHARGE,RP,C,R2,INFO)
* DISCRETE_OP_AMP_OSCILLATOR(NODE,ENAB,INFO)
* DISCRETE_OP_AMP_VCO1(NODE,ENAB,VMOD1,INFO)
* DISCRETE_OP_AMP_VCO2(NODE,ENAB,VMOD1,VMOD2,INFO)
* DISCRETE_SCHMITT_OSCILLATOR(NODE,ENAB,INP0,AMPL,TABLE)
*
* DISCRETE_ADDER2(NODE,ENAB,IN0,IN1)
* DISCRETE_ADDER3(NODE,ENAB,IN0,IN1,IN2)
* DISCRETE_ADDER4(NODE,ENAB,IN0,IN1,IN2,IN3)
* DISCRETE_CLAMP(NODE,ENAB,IN0,MIN,MAX,CLAMP)
* DISCRETE_DIVIDE(NODE,ENAB,IN0,IN1)
* DISCRETE_GAIN(NODE,IN0,GAIN)
* DISCRETE_INVERT(NODE,IN0)
* DISCRETE_LOOKUP_TABLE(NODE,ENAB,ADDR,SIZE,TABLE)
* DISCRETE_MULTIPLY(NODE,ENAB,IN0,IN1)
* DISCRETE_MULTADD(NODE,ENAB,INP0,INP1,INP2)
* DISCRETE_ONESHOT(NODE,TRIG,AMPL,WIDTH,TYPE)
* DISCRETE_ONESHOTR(NODE,RESET,TRIG,AMPL,WIDTH,TYPE)
* DISCRETE_ONOFF(NODE,ENAB,INP0)
* DISCRETE_RAMP(NODE,ENAB,RAMP,GRAD,MIN,MAX,CLAMP)
* DISCRETE_SAMPLHOLD(NODE,ENAB,INP0,CLOCK,CLKTYPE)
* DISCRETE_SWITCH(NODE,ENAB,SWITCH,INP0,INP1)
* DISCRETE_TRANSFORM2(NODE,INP0,INP1,FUNCT)
* DISCRETE_TRANSFORM3(NODE,INP0,INP1,INP2,FUNCT)
* DISCRETE_TRANSFORM4(NODE,INP0,INP1,INP2,INP3,FUNCT)
* DISCRETE_TRANSFORM5(NODE,INP0,INP1,INP2,INP3,INP4,FUNCT)
*
* DISCRETE_COMP_ADDER(NODE,DATA,TABLE)
* DISCRETE_DAC_R1(NODE,ENAB,DATA,VDATA,LADDER)
* DISCRETE_DIODE_MIXER2(NODE,IN0,IN1,TABLE)
* DISCRETE_DIODE_MIXER3(NODE,IN0,IN1,IN2,TABLE)
* DISCRETE_DIODE_MIXER4(NODE,IN0,IN1,IN2,IN3,TABLE)
* DISCRETE_INTEGRATE(NODE,TRG0,TRG1,INFO)
* DISCRETE_MIXER2(NODE,ENAB,IN0,IN1,INFO)
* DISCRETE_MIXER3(NODE,ENAB,IN0,IN1,IN2,INFO)
* DISCRETE_MIXER4(NODE,ENAB,IN0,IN1,IN2,IN3,INFO)
* DISCRETE_MIXER5(NODE,ENAB,IN0,IN1,IN2,IN3,IN4,INFO)
* DISCRETE_MIXER6(NODE,ENAB,IN0,IN1,IN2,IN3,IN4,IN5,INFO)
* DISCRETE_MIXER7(NODE,ENAB,IN0,IN1,IN2,IN3,IN4,IN5,IN6,INFO)
* DISCRETE_MIXER8(NODE,ENAB,IN0,IN1,IN2,IN3,IN4,IN5,IN6,IN7,INFO)
* DISCRETE_OP_AMP(NODE,ENAB,IN0,IN1,INFO)
* DISCRETE_OP_AMP_ONESHOT(NODE,TRIG,INFO)
* DISCRETE_OP_AMP_TRIG_VCA(NODE,TRG0,TRG1,TRG2,IN0,IN1,INFO)
*
* DISCRETE_LOGIC_INVERT(NODE,ENAB,INP0)
* DISCRETE_LOGIC_AND(NODE,ENAB,INP0,INP1)
* DISCRETE_LOGIC_AND3(NODE,ENAB,INP0,INP1,INP2)
* DISCRETE_LOGIC_AND4(NODE,ENAB,INP0,INP1,INP2,INP3)
* DISCRETE_LOGIC_NAND(NODE,ENAB,INP0,INP1)
* DISCRETE_LOGIC_NAND3(NODE,ENAB,INP0,INP1,INP2)
* DISCRETE_LOGIC_NAND4(NODE,ENAB,INP0,INP1,INP2,INP3)
* DISCRETE_LOGIC_OR(NODE,ENAB,INP0,INP1)
* DISCRETE_LOGIC_OR3(NODE,ENAB,INP0,INP1,INP2)
* DISCRETE_LOGIC_OR4(NODE,ENAB,INP0,INP1,INP2,INP3)
* DISCRETE_LOGIC_NOR(NODE,ENAB,INP0,INP1)
* DISCRETE_LOGIC_NOR3(NODE,ENAB,INP0,INP1,INP2)
* DISCRETE_LOGIC_NOR4(NODE,ENAB,INP0,INP1,INP2,INP3)
* DISCRETE_LOGIC_XOR(NODE,ENAB,INP0,INP1)
* DISCRETE_LOGIC_NXOR(NODE,ENAB,INP0,INP1)
* DISCRETE_LOGIC_DFLIPFLOP(NODE,ENAB,RESET,SET,CLK,INP)
* DISCRETE_LOGIC_JKFLIPFLOP(NODE,ENAB,RESET,SET,CLK,J,K)
* DISCRETE_MULTIPLEX2(NODE,ENAB,ADDR,INP0,INP1)
* DISCRETE_MULTIPLEX4(NODE,ENAB,ADDR,INP0,INP1,INP2,INP3)
* DISCRETE_MULTIPLEX8(NODE,ENAB,ADDR,INP0,INP1,INP2,INP3,INP4,INP5,INP6,INP7)
*
* DISCRETE_FILTER1(NODE,ENAB,INP0,FREQ,TYPE)
* DISCRETE_FILTER2(NODE,ENAB,INP0,FREQ,DAMP,TYPE)
*
* DISCRETE_CRFILTER(NODE,ENAB,IN0,RVAL,CVAL)
* DISCRETE_CRFILTER_VREF(NODE,ENAB,IN0,RVAL,CVAL,VREF)
* DISCRETE_OP_AMP_FILTER(NODE,ENAB,INP0,INP1,TYPE,INFO)
* DISCRETE_RCDISC(NODE,ENAB,IN0,RVAL,CVAL)
* DISCRETE_RCDISC2(NODE,SWITCH,INP0,RVAL0,INP1,RVAL1,CVAL)
* DISCRETE_RCDISC3(NODE,ENAB,INP0,RVAL0,RVAL1,CVAL)
* DISCRETE_RCDISC4(NODE,ENAB,INP0,RVAL0,RVAL1,RVAL2,CVAL,VP,TYPE)
* DISCRETE_RCDISC5(NODE,ENAB,IN0,RVAL,CVAL)
* DISCRETE_RCINTEGRATE(NODE,INP0,RVAL0,RVAL1,RVAL2,CVAL,vP,TYPE)
* DISCRETE_RCDISC_MODULATED(NODE,INP0,INP1,RVAL0,RVAL1,RVAL2,RVAL3,CVAL,VP)
* DISCRETE_RCFILTER(NODE,ENAB,IN0,RVAL,CVAL)
* DISCRETE_RCFILTER_VREF(NODE,ENAB,IN0,RVAL,CVAL,VREF)
*
* DISCRETE_555_ASTABLE(NODE,RESET,R1,R2,C,OPTIONS)
* DISCRETE_555_ASTABLE_CV(NODE,RESET,R1,R2,C,CTRLV,OPTIONS)
* DISCRETE_555_MSTABLE(NODE,RESET,TRIG,R,C,OPTIONS)
* DISCRETE_555_CC(NODE,RESET,VIN,R,C,RBIAS,RGND,RDIS,OPTIONS)
* DISCRETE_555_VCO1(NODE,RESET,VIN,OPTIONS)
* DISCRETE_555_VCO1_CV(NODE,RESET,VIN,CTRLV,OPTIONS)
* DISCRETE_566(NODE,ENAB,VMOD,R,C,OPTIONS)
*
* DISCRETE_CUSTOM1(NODE,IN0,INFO)
* DISCRETE_CUSTOM2(NODE,IN0,IN1,INFO)
* DISCRETE_CUSTOM3(NODE,IN0,IN1,IN2,INFO)
* DISCRETE_CUSTOM4(NODE,IN0,IN1,IN2,IN3,INFO)
* DISCRETE_CUSTOM5(NODE,IN0,IN1,IN2,IN3,IN4,INFO)
* DISCRETE_CUSTOM6(NODE,IN0,IN1,IN2,IN3,IN4,IN5,INFO)
* DISCRETE_CUSTOM7(NODE,IN0,IN1,IN2,IN3,IN4,IN5,IN6,INFO)
* DISCRETE_CUSTOM8(NODE,IN0,IN1,IN2,IN3,IN4,IN5,IN6,IN7,INFO)
* DISCRETE_CUSTOM9(NODE,IN0,IN1,IN2,IN3,IN4,IN5,IN6,IN7,IN8,INFO)
*
* DISCRETE_CSVLOG1(NODE1)
* DISCRETE_CSVLOG2(NODE1,NODE2)
* DISCRETE_CSVLOG3(NODE1,NODE2,NODE3)
* DISCRETE_CSVLOG4(NODE1,NODE2,NODE3,NODE4)
* DISCRETE_CSVLOG5(NODE1,NODE2,NODE3,NODE4,NODE5)
* DISCRETE_WAVELOG1(NODE1,GAIN1)
* DISCRETE_WAVELOG2(NODE1,GAIN1,NODE2,GAIN2)
* DISCRETE_OUTPUT(OPNODE,GAIN)
*
***********************************************************************
=======================================================================
* from from disc_inp.c
=======================================================================
***********************************************************************
*
* DISCRETE_ADJUSTMENT - Adjustable constant set by the UI [~] menu.
* DISCRETE_ADJUSTMENT_TAG - Same as above but referenced by a tag.
*
* Note: DISCRETE_ADJUSTMENT_TAG is prefered over DISCRETE_ADJUSTMENT.
*
* .----------.
* | |
* | ADJUST.. |--------> Netlist node
* | |
* '----------'
* Declaration syntax
*
* DISCRETE_ADJUSTMENT(name of node,
* static minimum value the node can take,
* static maximum value the node can take,
* log/linear scale 0=Linear !0=Logarithmic,
* input port number of the adjuster)
*
* DISCRETE_ADJUSTMENT_TAG(name of node,
* static minimum value the node can take,
* static maximum value the node can take,
* log/linear scale 0=Linear !0=Logarithmic,
* port tag name of the adjuster)
*
* Note: When using DISC_LOGADJ, the min/max values must be > 0.
* If they are <=0, they will be forced to 1.
* Min can be a higher value then max.
* Min/max is just how the slider is displayed.
*
* Example config line
*
* DISCRETE_ADJUSTMENT(NODE_01,0.0,5.0,DISC_LINADJ,0,5)
*
* Define an adjustment slider that takes a 0-100 input from input
* port #5, scaling between 0.0 and 5.0. Adjustment scaling is Linear.
*
* DISC_LOGADJ 1.0
* DISC_LINADJ 0.0
*
* EXAMPLES: see Hit Me, Fire Truck
*
***********************************************************************
*
* DISCRETE_CONSTANT - Single output, fixed at compile time.
* This is usefull as a placeholder for
* incomplete circuits.
*
* .----------.
* | |
* | CONSTANT |--------> Netlist node
* | |
* '----------'
* Declaration syntax
*
* DISCRETE_CONSTANT(name of node, constant value)
*
* Example config line
*
* DISCRETE_CONSTANT(NODE_01, 100)
*
* Define a node that has a constant value of 100
*
***********************************************************************
*
* DISCRETE_INPUT_DATA - accepts 8-bit data. Value at reset is 0.
* DISCRETE_INPUT_LOGIC - 0 if data=0; 1 if data=1. Value at reset is 0.
* DISCRETE_INPUT_NOT - 0 if data=1; 1 if data=0. Value at reset is 1.
*
* DISCRETE_INPUTX_xx - same as above, but will modify the value by the
* given GAIN and OFFSET. At reset the value will
* be INIT modified by GAIN and OFFSET.
*
* DISCRETE_INPUT_PULSE - Same as normal input node but the netlist
* node output returns to INIT after a single
* cycle of sound output. To allow for scenarios
* whereby the register write pulse is used as
* a reset to a system.
*
* .----------.
* -----\| |
* discrete_sound_w data | INPUT(A) |----> Netlist node
* Write -----/| |
* '----------'
*
* Declaration syntax
*
* DISCRETE_INPUT_DATA (name of node)
* DISCRETE_INPUT_LOGIC (name of node)
* DISCRETE_INPUT_NOT (name of node)
* DISCRETE_INPUTX_DATA (name of node, gain, offset, initial value)
* DISCRETE_INPUTX_LOGIC(name of node, gain, offset, initial value)
* DISCRETE_INPUTX_NOT (name of node, gain, offset, initial value)
* DISCRETE_INPUT_PULSE (name of node, default value)
*
* Can be written to with: discrete_sound_w(NODE_xx, data);
*
***********************************************************************
*
* DISCRETE_INPUT_STREAM(NODE,NUM) - Accepts stream input NUM
* DISCRETE_INPUTX_STREAM(NODE,NUM,GAIN,OFFSET) - Accepts a stream input and
* applies a gain and offset.
*
* Declaration syntax
*
* DISCRETE_INPUT_STREAM (name of node, stream number, )
* DISCRETE_INPUTX_STREAM(name of node, stream nubmer, gain, offset)
*
* Note: The discrete system is floating point based. So when routing a stream
* set it's gain to 100% and then use DISCRETE_INPUTX_STREAM to adjust
* it if needed.
*
* EXAMPLES: see
*
***********************************************************************
=======================================================================
* from from disc_wav.c
* Generic modules
=======================================================================
***********************************************************************
*
* DISCRETE_COUNTER - up/down counter.
*
* This counter counts up/down from 0 to MAX. When the enable is low, the output
* is held at it's last value. When reset is high, the reset value is loaded
* into the output. The counter can be clocked internally or externally. It also
* supports x_time used by the clock modules to pass on anti-aliasing info.
*
* Declaration syntax
*
* where: direction: DISC_COUNT_DOWN = 0 = down
* DISC_COUNT_UP = 1 = up
*
* clock type: DISC_CLK_ON_F_EDGE - toggle on falling edge.
* DISC_CLK_ON_R_EDGE - toggle on rising edge.
* DISC_CLK_BY_COUNT - toggle specified number of times.
* DISC_CLK_IS_FREQ - internally clock at this frequency.
* Clock node must be static if
* DISC_CLK_IS_FREQ is used.
* x_time options: you can also | these x_time features to the basic
* types above if needed, or use seperately with 7492.
* DISC_OUT_IS_ENERGY - This will uses the x_time to
* anti-alias the count. Might be
* usefull if not connected to other
* modules.
* DISC_OUT_HAS_XTIME - This will generate x_time if
* being used with DISC_CLK_IS_FREQ.
* It will pass x_time for the
* other clock types.
*
* DISCRETE_COUNTER(name of node,
* enable node or static value,
* reset node or static value, (reset when TRUE)
* clock node or static value,
* max count static value,
* direction node or static value,
* reset value node or static value,
* clock type static value)
*
* DISCRETE_COUNTER_7492(name of node,
* enable node or static value,
* reset node or static value,
* clock node or static value,
* clock type static value)
*
* Note: A 7492 counter outputs a special bit pattern on its /6 stage.
* A 7492 clocks on the falling edge,
* so it is not recommended to use DISC_CLK_ON_R_EDGE for a 7492.
* This module emulates the /6 stage only.
* Use another DISCRETE_COUNTER for the /2 stage.
*
* EXAMPLES: see Fire Truck, Monte Carlo, Super Bug, Polaris
*
***********************************************************************
*
* DISCRETE_LFSR_NOISE - Noise waveform generator node, generates
* psuedo random digital stream at the requested
* clock frequency.
*
* Declaration syntax
*
* DISCRETE_LFSR_NOISE(name of node,
* enable node or static value,
* reset node or static value,
* clock node or static value,
* amplitude node or static value,
* forced infeed bit to shift reg,
* bias node or static value,
* LFSR noise descriptor structure)
*
* discrete_lfsr_desc = {clock type, (see DISCRETE_COUNTER),
* bitlength, reset_value,
* feedback_bitsel0, feedback_bitsel1,
* feedback_function0, feedback_function1, feedback_function2,
* feedback_function2_mask, flags, output_bit}
*
* flags: DISC_LFSR_FLAG_OUT_INVERT - invert output
* DISC_LFSR_FLAG_RESET_TYPE_L - reset when LOW (Defalut)
* DISC_LFSR_FLAG_RESET_TYPE_H - reset when HIGH
* DISC_LFSR_FLAG_OUTPUT_F0 - output is result of F0
*
* The diagram below outlines the structure of the LFSR model.
*
* .-------.
* FEED | |
* ----->| F1 |<--------------------------------------------.
* | | |
* '-------' BS - Bit Select |
* | Fx - Programmable Function |
* | .-------. PI - Programmable Inversion |
* | | | |
* | .---- | SR>>1 |<--------. |
* | | | | | |
* V V '-------' | .---- |
* .------. +->| BS |--. .------. |
* BITMASK | | .-------------. | '----' '-| | |
* ------->| F2 |-+->| Shift Reg |--+ | F0 |--'
* | | | '-------------' | .----. .-| |
* '------' | ^ '->| BS |--' '------'
* | | '----'
* CLOCK | RESET VAL
* ----> | .----. .----.
* '----------------------| BS |--| PI |--->OUTPUT
* '----' '----'
*
* EXAMPLES: see Fire Truck, Monte Carlo, Super Bug, Polaris
*
***********************************************************************
*
* DISCRETE_NOISE - Noise waveform generator node, generates
* random noise of the chosen frequency.
*
* .------------.
* | |
* ENABLE -0------>| |
* | |
* FREQUENCY -1------>| NOISE |----> Netlist node
* | |
* AMPLITUDE -2------>| |
* | |
* BIAS -3------>| |
* | |
* '------------'
*
* Declaration syntax
*
* DISCRETE_NOISE(name of node,
* enable node or static value,
* frequency node or static value,
* amplitude node or static value)
*
* Example config line
*
* DISCRETE_NOISE(NODE_03,1,5000,NODE_01,0)
*
***********************************************************************
*
* DISCRETE_NOTE - Note generator. This takes a chosen clock, and
* clocks an up counter that is preloaded with the data
* value at every max 1 count. Every time max 1 count
* is reached, the output counts up one and rolls over
* to 0 at max 2 count.
* When the data value is the same as max count 1, the
* counter no longer counts.
*
* Declaration syntax
*
* DISCRETE_NOTE(name of node,
* enable node or static value,
* clock node or static value,
* data node or static value,
* max 1 count static value,
* max 2 count static value,
* clock type (see DISCRETE_COUNTER))
*
* EXAMPLES: see Polaris, Blockade
*
***********************************************************************
*
* DISCRETE_SAWTOOTHWAVE - Saw tooth shape waveform generator, rapid
* rise and then graduated fall
*
* .------------.
* | |
* ENABLE -0------>| |
* | |
* FREQUENCY -1------>| |
* | |
* AMPLITUDE -2------>| SAWTOOTH |----> Netlist Node
* | WAVE |
* BIAS -3------>| |
* | |
* GRADIENT -4------>| |
* | |
* PHASE -5------>| |
* | |
* '------------'
*
* Declaration syntax
*
* DISCRETE_SAWTOOTHWAVE(name of node,
* enable node or static value,
* frequency node or static value,
* amplitude node or static value,
* dc bias value for waveform,
* gradient of wave ==0 //// !=0 \\\\,
* starting phase value in degrees)
*
* Example config line
*
* DISCRETE_SAWTOOTHWAVE(NODE_03,1,5000,NODE_01,0,0,90)
*
***********************************************************************
*
* DISCRETE_SINEWAVE - Sinewave waveform generator node, has four
* input nodes FREQUENCY, AMPLITUDE, ENABLE and
* PHASE, if a node is not connected it will
* default to the initialised value in the macro
*
* .------------.
* | |
* ENABLE -0------>| |
* | |
* FREQUENCY -1------>| |
* | SINEWAVE |----> Netlist node
* AMPLITUDE -2------>| |
* | |
* BIAS -3------>| |
* | |
* PHASE -4------>| |
* | |
* '------------'
*
* Declaration syntax
*
* DISCRETE_SINEWAVE (name of node,
* enable node or static value,
* frequency node or static value,
* amplitude node or static value,
* dc bias value for waveform,
* starting phase value in degrees)
*
* Example config line
*
* DISCRETE_SINEWAVE(NODE_03,NODE_01,NODE_02,10000,5000.0,90)
*
***********************************************************************
*
* DISCRETE_SQUAREWAVE - Squarewave waveform generator node.
* DISCRETE_SQUAREWFIX Waveform is defined by frequency and duty
* cycle.
*
* .------------.
* | |
* ENABLE -0------>| |
* | |
* FREQUENCY -1------>| |
* | |
* AMPLITUDE -2------>| SQUAREWAVE |----> Netlist node
* | |
* DUTY CYCLE -3------>| |
* | |
* BIAS -4------>| |
* | |
* PHASE -5------>| |
* | |
* '------------'
*
* Declaration syntax
*
* DISCRETE_SQUAREWAVE(name of node,
* enable node or static value,
* frequency node or static value,
* amplitude node or static value,
* duty cycle node or static value,
* dc bias value for waveform,
* starting phase value in degrees)
*
* Example config line
*
* DISCRETE_SQUAREWAVE(NODE_03,NODE_01,NODE_02,100,50,0,90)
*
* NOTE: DISCRETE_SQUAREWFIX is used the same as DISCRETE_SQUAREWAVE.
* BUT... It does not stay in sync when you change the freq or
* duty values while enabled. This should be used only
* when these values are stable while the wave is enabled.
* It takes up less CPU time then DISCRETE_SQUAREWAVE and
* should be used whenever possible.
*
* EXAMPLES: see Polaris
*
***********************************************************************
*
* DISCRETE_SQUAREWAVE2 - Squarewave waveform generator node.
* Waveform is defined by it's off/on time
* periods.
*
* .------------.
* | |
* ENABLE -0------>| |
* | |
* AMPLITUDE -1------>| |
* | |
* OFF TIME -2------>| SQUAREWAVE |----> Netlist node
* | |
* ON TIME -3------>| |
* | |
* BIAS -4------>| |
* | |
* TIME SHIFT -5------>| |
* | |
* '------------'
*
* Declaration syntax
*
* DISCRETE_SQUAREWAVE2(name of node,
* enable node or static value,
* amplitude node or static value,
* off time node or static value in seconds,
* on time node or static value in seconds,
* dc bias value for waveform,
* starting phase value in seconds)
*
* Example config line
*
* DISCRETE_SQUAREWAVE2(NODE_03,NODE_01,NODE_02,0.01,0.001,0.0,0.001)
*
***********************************************************************
*
* DISCRETE_TRIANGLEW - Triagular waveform generator, generates
* equal ramp up/down at chosen frequency
*
* .------------.
* | |
* ENABLE -0------>| |
* | |
* FREQUENCY -1------>| TRIANGLE |----> Netlist node
* | WAVE |
* AMPLITUDE -2------>| |
* | |
* BIAS -3------>| |
* | |
* PHASE -4------>| |
* | |
* '------------'
*
* Declaration syntax
*
* DISCRETE_TRIANGLEWAVE(name of node,
* enable node or static value,
* frequency node or static value,
* amplitude node or static value,
* dc bias value for waveform,
* starting phase value in degrees)
*
* Example config line
*
* DISCRETE_TRIANGLEWAVE(NODE_03,1,5000,NODE_01,0.0,0.0)
*
***********************************************************************
=======================================================================
* from from disc_wav.c
* Component specific modules
=======================================================================
***********************************************************************
*
* DISCRETE_OP_AMP_OSCILLATOR - Various single power supply op-amp oscillator circuits
*
* Declaration syntax
*
* DISCRETE_OP_AMP_OSCILLATOR(name of node,
* enable node or static value,
* address of dss_op_amp_osc_context structure)
*
* discrete_op_amp_osc_info = {type, r1, r2, r3, r4, r5, r6, r7, r8, c, vP}
*
* Note: Set all unused components to 0.
*
* Types:
*
* DISC_OP_AMP_OSCILLATOR_1 | DISC_OP_AMP_IS_NORTON
* Basic Norton Op Amp Oscillator circuit.
*
* vP >-.
* | c
* Z .---||----+---------------------------> DISC_OP_AMP_OSCILLATOR_OUT_CAP
* Z r1 | |
* Z | |\ |
* | | | \ | |\
* '-----+---|- \ | r3 | \
* | >-+----ZZZZ----|- \
* |+ / | >--+-------> DISC_OP_AMP_OSCILLATOR_OUT_SQW
* .---| / .--|+ / |
* | |/ r5 | | / |
* | vP >--ZZZZ---+ |/ |
* Z | |
* Z r2 | r4 |
* Z '--ZZZZ---+
* | |
* | |
* '-----------------------------'
*
* Note: R1 - R5 can be nodes.
*
* EXAMPLES: see Polaris, Amazing Maze
*
***********************************************************************
*
* DISCRETE_OP_AMP_VCOn - Various single power supply op-amp VCO circuits
* (n = 1 or 2)
*
* Declaration syntax
*
* DISCRETE_OP_AMP_VCOn(name of node,
* enable node or static value,
* modulation voltage 1 node or static value,
* modulation voltage 2 node or static value, [optional]
* address of dss_op_amp_osc_context structure)
*
* discrete_op_amp_osc_info = {type, r1, r2, r3, r4, r5, r6, r7, r8, c, vP}
*
* Note: Set all unused components to 0.
*
* Types:
*
* DISC_OP_AMP_OSCILLATOR_VCO_1
* Basic Op Amp Voltage Controlled Oscillator circuit.
* Note that this circuit has only 1 modulation voltage.
* So it is used only with DISCRETE_OP_AMP_VCO1.
*
* c
* .------------------------+---||----+---------------------------> DISC_OP_AMP_OSCILLATOR_OUT_CAP
* | | |
* | | |\ |
* | r1 | | \ | |\
* | vMod1 >--+--ZZZZ-------+---|- \ | | \
* | | | >-+------------|- \
* | | r2 |+ / | >--+-------> DISC_OP_AMP_OSCILLATOR_OUT_SQW
* Z '--ZZZZ--+--------| / .--|+ / |
* Z r6 | |/ r4 | | / |
* Z Z vP/2 >--ZZZZ---+ |/ |
* | Z r5 | |
* .----. Z | r3 |
* | sw |<--------. | '--ZZZZ---+
* '----' | gnd |
* | | |
* gnd '----------------------------------------'
*
* Notes: The 'sw' block can be a transistor or 4066 switch. It connects
* r6 to ground when 'sw' is high.
*
* --------------------------------------------------
*
* DISC_OP_AMP_OSCILLATOR_VCO_1 | DISC_OP_AMP_IS_NORTON
* Basic Norton Op Amp Voltage Controlled Oscillator circuit.
* When disabled, c discharges and sqw out goes high.
*
* .---------------------------> DISC_OP_AMP_OSCILLATOR_OUT_CAP
* c |
* r6 .---||----+
* vP >--ZZZZ---. | | r5 |\
* | | |\ | vP >--ZZZZ-. | \
* r7 | r1 | | \ | '-|- \
* vMod1 >--ZZZZ---+--ZZZZ-------+---|- \ | r3 | >--+-------> DISC_OP_AMP_OSCILLATOR_OUT_SQW
* | | >-+----ZZZZ----+--|+ / |
* r8 | r2 .----. |+ / | | / |
* vMod2 >--ZZZZ---+--ZZZZ---| sw |--| / | |/ |
* '----' |/ | |
* ^ ^ | r4 |
* | | '--ZZZZ---+
* | | |
* Enable >---------' | |
* '--------------------------------'
*
* EXAMPLES: see Polaris
*
* --------------------------------------------------
*
* DISC_OP_AMP_OSCILLATOR_VCO_2 | DISC_OP_AMP_IS_NORTON
* Basic Norton Op Amp Voltage Controlled Oscillator circuit.
* Note that this circuit has only 1 modulation voltage.
* So it is used only with DISCRETE_OP_AMP_VCO1.
* When vMod1 goes to 0V, the oscillator is disabled.
* c fully charges and the sqw out goes low.
*
* .---------------------------> DISC_OP_AMP_OSCILLATOR_OUT_CAP
* |
* | r4
* c | .--ZZZZ--.
* .---||----+ | |
* | | r5 | |\ |
* | |\ | vP >--ZZZZ-+ | \ |
* r1 | | \ | '-|+ \ |
* vMod1 >--ZZZZ-----------------+---|- \ | r3 | >--+-------> DISC_OP_AMP_OSCILLATOR_OUT_SQW
* | >-+----ZZZZ-------|- / |
* r2 |+ / | / |
* vP >--ZZZZ-----------------+---| / |/ |
* | |/ |
* r6 .----. | |
* vP >--ZZZZ-----|-sw-|------' |
* '----' |
* ^ |
* | |
* '-----------------------------------------'
*
* EXAMPLES: see Double Play
*
* --------------------------------------------------
*
* DISC_OP_AMP_OSCILLATOR_VCO_3 | DISC_OP_AMP_IS_NORTON
* Basic Norton Op Amp Voltage Controlled Oscillator circuit.
*
*
* c
* r7 .---||----+---------------------------> DISC_OP_AMP_OSCILLATOR_OUT_CAP
* vP >--ZZZZ---. | |
* | | |\ |
* r1 | | | \ | |\
* vMod1 >--ZZZZ---+---------+---|- \ | r3 | \
* | | >-+----ZZZZ----|- \
* r6 | |+ / | >--+-------> DISC_OP_AMP_OSCILLATOR_OUT_SQW
* vMod2 >--ZZZZ---' .---| / .--|+ / |
* | |/ r5 | | / |
* | vP >--ZZZZ---+ |/ |
* Z | |
* Z r2 | r4 |
* Z '--ZZZZ---+
* | |
* | |
* '-----------------------------'
*
* EXAMPLES: see Space Encounter
*
***********************************************************************
*
* DISCRETE_SCHMITT_OSCILLATOR - Schmitt Inverter gate oscillator
*
* rFeedback
* .---ZZZ----. .--< Amplitude
* | | |
* | |\ | .------. |
* rIn | | \ | 0/1 | AND/ | .-.
* INP0 >---ZZZ--+--|S >o---+----->|NAND/ |--->|*|-----> Netlist Node
* | | / | OR/ | '-'
* | |/ .->| NOR |
* --- | '------'
* --- C |
* | ^
* gnd Enable
*
* Declaration syntax
*
* DISCRETE_SCHMITT_OSCILLATOR(name of node,
* enable node or static value,
* Input 0 node or static value,
* Amplitude node or static value,
* address of discrete_schmitt_osc_desc structure)
*
* discrete_schmitt_osc_desc = {rIn, rFeedback, c, trshRise, trshFall, vGate, options}
*
* Note: trshRise, trshFall, vGate can be replaced with one of these common types:
* DEFAULT_7414_VALUES or DEFAULT_74LS14_VALUES (the LS makes a difference)
* eg: {rIn, rFeedback, c, DEFAULT_7414_VALUES, options}
*
* Where:
* trshRise is the voltage level that triggers the gate input to go high (vGate) on rise.
* trshFall is the voltage level that triggers the gate input to go low (0V) on fall.
* vGate is the output high voltage of the gate that gets fedback through rFeedback.
*
* Input Options:
* DISC_SCHMITT_OSC_IN_IS_LOGIC (DEFAULT)
* DISC_SCHMITT_OSC_IN_IS_VOLTAGE
*
* Enable Options: (ORed with input options)
* DISC_SCHMITT_OSC_ENAB_IS_AND (DEFAULT)
* DISC_SCHMITT_OSC_ENAB_IS_NAND
* DISC_SCHMITT_OSC_ENAB_IS_OR
* DISC_SCHMITT_OSC_ENAB_IS_NOR
*
* EXAMPLES: see Fire Truck, Monte Carlo, Super Bug
*
***********************************************************************
*
* DISCRETE_INVERTER_OSC - Inverter gate oscillator circuits
*
* TYPE 1/3
* .----------------------------> Netlist Node (Type 3)
* |
* |\ | |\ |\
* | \ | | \ | \
* +--| >o--+--|-->o--+--| >o--+--------> Netlist Node (Type 1)
* | | / | / | | / |
* | |/ |/ | |/ |
* Z | |
* Z RP --- |
* Z --- C |
* | | R1 |
* '-------------------+----ZZZ--'
*
* TYPE 2
*
* |\ |\
* | \ | \
* +--| >o--+--|-->o--+-------> Netlist Node
* | | / | | / |
* | |/ | |/ |
* Z Z |
* Z RP Z R1 ---
* Z Z --- C
* | | |
* '---------+---------'
*
*
* TYPE 4 / see vicdual
*
* |\ |\
* | \ | \
* Enable >-+-----+--|>o-+--|-->o--+-------> Netlist Node
* | | / | | / |
* | |/ | |/ |
* Z Z |
* Z RP Z R1 ---
* Z Z --- C
* | D | |
* '------|>|---+---------'
* |
* Mod >-----ZZZ------'
* R2
*
* TYPE 5 / see vicdual
* Diode will cause inverted input behaviour and inverted output
*
* |\ |\
* | \ | \
* Enable >-+-----+--|>o-+--|-->o--+-------> Netlist Node
* | | / | | / |
* | |/ | |/ |
* Z Z |
* Z RP Z R1 ---
* Z Z --- C
* | D | |
* '------|<|---+---------'
* |
* Mod >-----ZZZ------'
* R2
*
* Declaration syntax
*
* DISCRETE_INVERTER_OSC( name of node,
* enable node or static value,
* modulation node or static value (0 when not used),
* R1 static value,
* RP static value
* C static value,
* R2 static value (0 when not used),
* address of discrete_inverter_osc_desc structure)
*
* discrete_inverter_osc_desc = {vB, vOutLow, vOutHigh, vInRise, vInFall, clamp, options}
*
* Where
* vB Supply Voltage
* vOutLow Low Output voltage
* vOutHigh High Output voltage
* vInRise voltage that triggers the gate input to go high (vGate) on rise
* vInFall voltage that triggers the gate input to go low (0V) on fall
* clamp internal diode clamp: [-clamp ... vb+clamp] if clamp>= 0
* options bitmaped options
*
* There is a macro DEFAULT_CD40XX_VALUES(_vB) which may be used to initialize the
* structure with .... = { 5, DEFAULT_CD40XX_VALUES(5), DISC_OSC_INVERTER_IS_TYPE1}
*
* The parameters are used to construct a input/output transfer function.
*
* Option Values
*
* DISC_OSC_INVERTER_IS_TYPE1
* DISC_OSC_INVERTER_IS_TYPE2
* DISC_OSC_INVERTER_IS_TYPE3
* DISC_OSC_INVERTER_IS_TYPE4
* DISC_OSC_INVERTER_OUT_IS_LOGIC
*
* EXAMPLES: see dkong
*
***********************************************************************
=======================================================================
* from from disc_wav.c
* Not yet implemented
=======================================================================
***********************************************************************
*
* DISCRETE_ADSR_ENV - Attack Decay Sustain Release envelope generator
*
* Note: Not yet implemented.
*
* .------------.
* | |
* ENABLE -0------>| |
* | /\__ |
* TRIGGER -1------>| / \ |----> Netlist node
* | ADSR |
* GAIN -2------>| Env |
* | |
* '------------'
*
* Declaration syntax
*
* DISCRETE_ADSR_ENV (name of node,
* enable node or static value,
* envelope gain node or static value,
* envelope descriptor struct)
*
* Example config line
*
* DISCRETE_ADSR_ENV(NODE_3,1,NODE_21,1.0,&adsrdesc)
*
***********************************************************************
=======================================================================
* from from disc_mth.c
* Generic modules
=======================================================================
***********************************************************************
*
* DISCRETE_ADDER - Node addition function, available in three
* lovely flavours, ADDER2,ADDER3,ADDER4
* that perform a summation of incoming nodes
*
* .------------.
* | |
* INPUT0 -0------>| |
* | |
* INPUT1 -1------>| | |
* | -+- |----> Netlist node
* INPUT2 -2------>| | |
* | |
* INPUT3 -3------>| |
* | |
* '------------'
*
* Declaration syntax
*
* DISCRETE_ADDERx (name of node,
* (x=2/3/4) enable node or static value,
* input0 node or static value,
* input1 node or static value,
* input2 node or static value, [optional]
* input3 node or static value) [optional]
*
* Example config line
*
* DISCRETE_ADDER2(NODE_03,1,NODE_12,-2000)
*
* Always enabled, subtracts 2000 from the output of NODE_12
*
***********************************************************************
*
* DISCRETE_CLAMP - Force a signal to stay within bounds MIN/MAX
*
* .------------.
* | |
* ENAB -0------>| |
* | |
* INP0 -1------>| |
* | |
* MIN -2------>| CLAMP |----> Netlist node
* | |
* MAX -3------>| |
* | |
* CLAMP -4------>| |
* | |
* '------------'
*
* Declaration syntax
*
* DISCRETE_CLAMP(name of node,
* enable,
* input node,
* minimum node or static value,
* maximum node or static value,
* clamp node or static value when disabled)
*
* Example config line
*
* DISCRETE_CLAMP(NODE_9,NODE_10,NODE_11,2.0,10.0,5.0)
*
* Node10 when not zero will allow clamp to operate forcing the value
* on the node output, to be within the MIN/MAX boundard. When enable
* is set to zero the node will output the clamp value
*
***********************************************************************
*
* DISCRETE_DIVIDE - Node division function
*
* .------------.
* | |
* ENAB -0------>| |
* | o |
* INPUT1 -1------>| --- |----> Netlist node
* | o |
* INPUT2 -2------>| |
* | |
* '------------'
*
* Declaration syntax
*
* DISCRETE_DIVIDE (name of node,
* enable node or static value,
* input0 node or static value,
* input1 node or static value)
*
* Example config line
*
* DISCRETE_DIVIDE(NODE_03,1.0,NODE_12,50.0)
*
* Always enabled, divides the input NODE_12 by 50.0. Note that a
* divide by zero condition will give a LARGE number output, it
* will not stall the machine or simulation. It will also attempt
* to write a divide by zero error to the Mame log if enabled.
*
***********************************************************************
*
* DISCRETE_LOGIC_INVERT - Logic invertor
* DISCRETE_LOGIC_AND - Logic AND gate (3 & 4 input also available)
* DISCRETE_LOGIC_NAND - Logic NAND gate (3 & 4 input also available)
* DISCRETE_LOGIC_OR - Logic OR gate (3 & 4 input also available)
* DISCRETE_LOGIC_NOR - Logic NOR gate (3 & 4 input also available)
* DISCRETE_LOGIC_XOR - Logic XOR gate
* DISCRETE_LOGIC_NXOR - Logic NXOR gate
*
* .------------.
* | |
* ENAB -0------>| |
* | |
* INPUT0 -0------>| |
* | LOGIC |
* [INPUT1] -1------>| FUNCTION |----> Netlist node
* | !&|^ |
* [INPUT2] -2------>| |
* | |
* [INPUT3] -3------>| |
* | |
* [] - Optional '------------'
*
* Declaration syntax
*
* DISCRETE_LOGIC_XXXn(name of node,
* (X=INV/AND/etc) enable node or static value,
* (n=Blank/2/3) input0 node or static value,
* [input1 node or static value],
* [input2 node or static value],
* [input3 node or static value])
*
* Example config lines
*
* DISCRETE_LOGIC_INVERT(NODE_03,1,NODE_12)
* DISCRETE_LOGIC_AND(NODE_03,1,NODE_12,NODE_13)
* DISCRETE_LOGIC_NOR4(NODE_03,1,NODE_12,NODE_13,NODE_14,NODE_15)
*
* Node output is always either 0.0 or 1.0 any input value !=0.0 is
* taken as a logic 1.
*
***********************************************************************
*
* DISCRETE_LOGIC_DFLIPFLOP - Standard D-type flip-flop.
* Changes on rising edge of clock.
*
* /SET -2 ------------.
* v
* .-----o------.
* | |
* DATA -4 ----->| |
* | FLIPFLOP |
* | Q|----> Netlist node
* | |
* CLOCK -3 ----->| |
* | |
* '-----o------'
* ^
* /RESET -1 ------------'
*
* Declaration syntax
*
* DISCRETE_LOGIC_DFLIPFLOP(name of node,
* enable node or static value,
* reset node or static value,
* set node or static value,
* clock node,
* data node or static value)
*
* Example config line
*
* DISCRETE_LOGIC_DFLIPFLOP(NODE_7,1,NODE_17,0,NODE_13,1)
*
* A flip-flop that clocks a logic 1 through on the rising edge of
* NODE_13. A logic 1 on NODE_17 resets the output to 0.
*
* EXAMPLES: see Hit Me, Polaris
*
***********************************************************************
*
* DISCRETE_LOGIC_JKFLIPFLOP - Standard JK-type flip-flop.
* Changes on falling edge of clock.
*
* /SET -2 ------------.
* v
* .-----o------.
* | |
* J -4 ----->| |
* | FLIPFLOP |
* CLOCK -3 ----->| Q|----> Netlist node
* | |
* K -5 ----->| |
* | |
* '-----o------'
* ^
* /RESET -1 ------------'
*
* Declaration syntax
*
* DISCRETE_LOGIC_JKFLIPFLOP(name of node,
* enable node or static value,
* reset node or static value,
* set node or static value,
* clock node,
* J node or static value,
* K node or static value)
*
* EXAMPLES: see Amazing Maze
*
***********************************************************************
*
* DISCRETE_LOOKUP_TABLE - returns the value in a table
*
* Declaration syntax
*
* DISCRETE_LOOKUP_TABLE(name of node,
* enable node or static value,
* address node,
* size of table static value,
* address of table of double values)
*
***********************************************************************
*
* DISCRETE_MULTIPLEX - 1 of 2/4/8 multiplexer
*
* .-------------.
* Input 0 >-----|>-<. |
* | \ |
* Input 1 >-----|>- \ |
* | \ |
* Input 2 >-----|>- |\ |
* | | \ |
* Input 3 >-----|>- | o-->|------> Netlist Node
* | | |
* Input 4 >-----|>- | |
* | | |
* Input 5 >-----|>- '------|----< Address
* | | (0 shown)
* Input 6 >-----|>- |
* | |
* Input 7 >-----|>- |
* '-------------'
*
* Declaration syntax
*
* DISCRETE_MULTIPLEXx(name of node,
* (x=2/4/8) enable node or static value,
* address node,
* input 0 node or static value,
* input 1 node or static value, ...)
*
***********************************************************************
*
* DISCRETE_GAIN - Node multiplication function output is equal
* DISCRETE_MULTIPLY to INPUT0 * INPUT1
* DISCRETE_MULTADD to (INPUT0 * INPUT1) + INPUT 2
*
* .------------.
* | |
* ENAB -0------>| |
* | |
* INPUT0 -1------>| \|/ |
* | -+- |----> Netlist node
* INPUT1 -2------>| /|\ |
* | |
* INPUT2 -3------>| |
* | |
* '------------'
*
* Declaration syntax
*
* DISCRETE_MULTIPLY (name of node,
* enable node or static value,
* input0 node or static value,
* input1 node or static value)
*
* DISCRETE_MULTADD (name of node,
* enable node or static value,
* input0 node or static value,
* input1 node or static value,
* input2 node or static value)
*
* DISCRETE_GAIN (name of node,
* input0 node or static value,
* static value for gain)
* Example config line
*
* DISCRETE_GAIN(NODE_03,NODE_12,112.0)
*
* Always enabled, multiplies the input NODE_12 by 112.0
*
***********************************************************************
*
* DISCRETE_ONESHOT - Monostable multivibrator, no reset
* DISCRETE_ONESHOTR - Monostable multivibrator, with reset
*
* Declaration syntax
*
* DISCRETE_ONESHOT (name of node,
* trigger node,
* amplitude node or static value,
* width (in seconds) node or static value,
* type of oneshot static value)
*
* DISCRETE_ONESHOTR (name of node,
* reset node or static value,
* trigger node,
* amplitude node or static value,
* width (in seconds) node or static value,
* type of oneshot static value)
*
* Types:
*
* DISC_ONESHOT_FEDGE 0x00 - trigger on falling edge (DEFAULT)
* DISC_ONESHOT_REDGE 0x01 - trigger on rising edge
*
* DISC_ONESHOT_NORETRIG 0x00 - non-retriggerable (DEFAULT)
* DISC_ONESHOT_RETRIG 0x02 - retriggerable
*
* DISC_OUT_ACTIVE_LOW 0x04 - output active low
* DISC_OUT_ACTIVE_HIGH 0x00 - output active high (DEFAULT)
*
* NOTE: A width of 0 seconds will output a pulse of 1 sample.
* This is useful for a guaranteed minimun pulse, regardless
* of the sample rate.
*
* EXAMPLES: see Polaris
*
***********************************************************************
*
* DISCRETE_RAMP - Ramp up/down circuit with clamps & reset
*
* .------------.
* | |
* ENAB -0------>| FREE/CLAMP |
* | |
* RAMP -1------>| FW/REV |
* | |
* GRAD -2------>| Grad/sec |
* | |----> Netlist node
* START -3------>| Start clamp|
* | |
* END -4------>| End clamp |
* | |
* CLAMP -5------>| off clamp |
* | |
* '------------'
*
* Declaration syntax
*
* DISCRETE_RAMP(name of node,
* enable,
* ramp forward/reverse node (or value),
* gradient node (or static value),
* start node or static value,
* end node or static value,
* clamp node or static value when disabled)
*
* Example config line
*
* DISCRETE_RAMP(NODE_9,NODE_10,NODE_11,10.0,-10.0,10.0,0)
*
* Node10 when not zero will allow ramp to operate, when 0 then output
* is clamped to clamp value specified. Node11 ramp when 0 change
* gradient from start to end. 1 is reverse. Output is clamped to max-
* min values. Gradient is specified in change/second.
*
***********************************************************************
*
* DISCRETE_SAMPHOLD - Sample & Hold circuit
*
* .------------.
* | |
* ENAB -0------>| |
* | |
* INP0 -1------>| SAMPLE |
* | & |----> Netlist node
* CLOCK -2------>| HOLD |
* | |
* CLKTYPE -3------>| |
* | |
* '------------'
*
* Declaration syntax
*
* DISCRETE_SAMPHOLD(name of node,
* enable,
* input node,
* clock node or static value,
* input clock type)
*
* Example config line
*
* DISCRETE_SAMPHOLD(NODE_9,1,NODE_11,NODE_12,DISC_SAMPHOLD_REDGE)
*
* Node9 will sample the input node 11 on the rising edge (REDGE) of
* the input clock signal of node 12.
*
* DISC_SAMPHOLD_REDGE - Rising edge clock
* DISC_SAMPHOLD_FEDGE - Falling edge clock
* DISC_SAMPHOLD_HLATCH - Output is latched whilst clock is high
* DISC_SAMPHOLD_LLATCH - Output is latched whilst clock is low
*
***********************************************************************
*
* DISCRETE_SWITCH - Node switch function, output node is switched
* by switch input to take one node/contst or
* other. Can be nodes or constants.
*
* SWITCH -0--------------.
* V
* .------------.
* | | |
* INPUT0 -1------}|----o |
* | .--- |----> Netlist node
* INPUT1 -2------>|----o / |
* | |
* '------------'
*
* Declaration syntax
*
* DISCRETE_SWITCH (name of node,
* enable node or static value,
* switch node or static value,
* input0 node or static value,
* input1 node or static value)
*
* Example config line
*
* DISCRETE_SWITCH(NODE_03,1,NODE_10,NODE_90,5.0)
*
* Always enabled, NODE_10 switches output to be either NODE_90 or
* constant value 5.0. Switch==0 inp0=output else inp1=output
*
***********************************************************************
*
* DISCRETE_ASWITCH - Node switch function, output node is same
* as input when CTRL is above threshold.
*
* CTRL -0--------------.
* V
* .------------.
* | | |
* INPUT0 -1------ |----- . --- |----> Netlist node
* | |
* | |
* '------------'
*
* Declaration syntax
*
* DISCRETE_ASWITCH (name of node,
* enable node or static value,
* ctrl node or static value,
* input node or static value,
* threshold satic value )
*
* Example config line
*
* DISCRETE_ASWITCH(NODE_03,1,NODE_10,NODE_90, 2.73)
*
* Always enabled, NODE_10 switches output to be either NODE_90 or
* constant value 0.0. Ctrl>2.73 output=NODE_90 else output=0
*
***********************************************************************
*
* DISCRETE_TRANSFORMn - Node arithmatic logic (postfix arithmatic)
* (n=2,3,4,5)
* .------------.
* | |
* INPUT0 -0------>| |
* | |
* INPUT1 -1------>| Postfix |
* | stack |----> Netlist node
* INPUT2 -2------>| maths |
* | |
* INPUT3 -3------>| |
* | |
* INPUT4 -4------>| |
* | |
* '------------'
*
* Declaration syntax
*
* DISCRETE_TRANSFORMn(name of node,
* input0 node or static value,
* input1 node or static value,
* input2 node or static value, [optional]
* input3 node or static value, [optional]
* input4 node or static value, [optional]
* maths string)
*
* Example config line
*
* DISCRETE_TRANSFORM4(NODE_12,NODE_22,50.0,120.0,33.33,"01*2+3/")
*
* Arithmetic uses stack based arithmetic similar to Forth, the maths
* has 5 registers 0-4 and various arithmetic operations. The math
* string is processed from left to right in the following manner:
* 0 - Push input 0 to stack
* 1 - Push input 1 to stack
* 2 - Push input 2 to stack
* 3 - Push input 3 to stack
* 4 - Push input 4 to stack
* - - Pop two values from stack, subtract and push result to stack
* + - Pop two values from stack, add and push result to stack
* / - Pop two values from stack, divide and push result to stack
* * - Pop two values from stack, multiply and push result to stack
* i - Pop one value from stack, multiply -1 and push result to stack
* ! - Pop one value from stack, logical invert, push result to stack
* = - Pop two values from stack, logical = and push result to stack
* > - Pop two values from stack, logical > and push result to stack
* < - Pop two values from stack, logical < and push result to stack
* & - Pop two values from stack, binary AND and push result to stack
* | - Pop two values from stack, binary OR and push result to stack
* ^ - Pop two values from stack, binary XOR and push result to stack
* P - Push a duplicate of the last stack value back on the stack
*
* EXAMPLES: see Polaris
*
***********************************************************************
=======================================================================
* from from disc_mth.c
* Component specific modules
=======================================================================
***********************************************************************
*
* DISCRETE_COMP_ADDER - Selecatable parallel component adder.
* The total netlist out will be the parallel sum of all
* components with their corresponding data bit = 1.
* Set cDefault to 0 if not used.
*
* common >---cDefault---.
* data&0x01 >-----c[0]-----+
* data&0x02 >-----c[1]-----+
* data&0x04 >-----c[2]-----+
* data&0x08 >-----c[3]-----+-----> netlist node
* data&0x10 >-----c[4]-----+
* data&0x20 >-----c[5]-----+
* data&0x40 >-----c[6]-----+
* data&0x80 >-----c[7]-----'
*
* Declaration syntax
*
* DISCRETE_COMP_ADDER(name of node,
* data node (static value is useless),
* address of discrete_comp_adder_table structure)
*
* discrete_comp_adder_table = {type, cDefault, length, c{}}
* note: length can be a maximum of 8
*
* Circuit Types:
* DISC_COMP_P_CAPACITOR - parallel capacitors
* DISC_COMP_P_RESISTOR - parallel resistors
*
* EXAMPLES: see Hit Me
*
***********************************************************************
*
* DISCRETE_DAC_R1 - R1 ladder DAC with cap smoothing and external bias
*
* rBias
* data&0x01 >--/\R[0]/\--+-----/\/\----< vBias
* data&0x02 >--/\R[1]/\--|
* data&0x04 >--/\R[2]/\--|
* data&0x08 >--/\R[3]/\--|
* data&0x10 >--/\R[4]/\--|
* data&0x20 >--/\R[5]/\--|
* data&0x40 >--/\R[6]/\--|
* data&0x80 >--/\R[7]/\--+-------------+-----> Netlist node
* | |
* Z ---
* Z rGnd --- cFilter
* | |
* gnd gnd
*
* NOTES: rBias and vBias are used together. If not needed they should
* be set to 0. If used, they should both have valid values.
* rGnd and cFilter should be 0 if not needed.
* A resistor value should be properly set for each resistor
* up to the ladder length. Remember 0 is a short circuit.
* The data node is bit mapped to the ladder. valid int 0-255.
* TTL logic 0 is actually 0.2V but 0V is used. The other parts
* have a tolerance that more then makes up for this.
*
* Declaration syntax
*
* DISCRETE_DAC_R1(name of node,
* enable node or static value,
* data node (static value is useless),
* vData node or static value (voltage when a bit is on ),
* address of discrete_dac_r1_ladder structure)
*
* discrete_dac_r1_ladder = {ladderLength, r{}, vBias, rBias, rGnd, cFilter}
*
* Note: Resistors in the ladder that are set to 0, will be handled like they
* are out of circuit. So the bit selecting them will have no effect
* on the DAC output voltage.
*
* x_time - this modules automatically handles any non-integer value
* on the data input as x_time.
*
* EXAMPLES: see Fire Truck, Monte Carlo, Super Bug, Polaris
*
***********************************************************************
*
* DISCRETE_DIODE_MIXER - mixes inputs through diodes
*
*
* input 0 >----|>|---.
* |
* input 1 >----|>|---+----------> Netlist Node
* |
* input 2 >----|>|---+
* |
* input 3 >----|>|---+--/\/\/\--.
* |
* gnd
*
* Declaration syntax
*
* DISCRETE_DIODE_MIXERx(name of node,
* (x = 2/3/4) input 0 node,
* input 1 node,
* ...,
* address of v_junction table)
*
* v_junction table can be set to NULL if you want all diodes to
* default to a 0.5V drop. Otherwise use a
* table of doubles to specify juntion voltages.
*
* EXAMPLES: see dkong
*
***********************************************************************
*
* DISCRETE_INTEGRATE - Various Integration circuits
*
* Declaration syntax
*
* DISCRETE_INTEGRATE(name of node,
* trigger 0 node or static value,
* trigger 1 node or static value,
* address of discrete_integrate_info)
*
* discrete_integrate_info = {type, r1, r2, r3, c, v1, vP, f0, f1, f2}
*
* Note: Set all unused components to 0.
* These are all single supply circuits going from gnd(0V) to vP(B+),
* so be sure to specify the vP power source.
*
* Types:
*
* DISC_INTEGRATE_OP_AMP_1
*
* v1 >----+-------.
* | | c
* Z Z .---||----.
* Z r1 Z r2 | |
* Z Z | |\ |
* | | | | \ |
* +--------------+--|- \ |
* | | | >--+----> Netlist Node
* / +---------|+ /
* |/ | | /
* Trig0 >--| NPN Z |/
* |\ Z r3
* > Z
* | |
* gnd gnd
*
*
* EXAMPLES: see Tank8
*
* --------------------------------------------------
*
* DISC_INTEGRATE_OP_AMP_1 | DISC_OP_AMP_IS_NORTON
*
* c
* .---||----.
* | |
* | |\ |
* r1 | | \ |
* v1 >----ZZZZ--------+--|- \ |
* | >--+----> Netlist Node
* r2 .--|+ /
* Trig0 >----ZZZZ--------' | /
* |/
*
* Note: Trig0 is voltage level, not logic.
* No functions are used so set them to 0, or DISC_OP_AMP_TRIGGER_FUNCTION_NONE.
* You can also use DISCRETE_OP_AMP with type DISC_OP_AMP_IS_NORTON to emulate this.
*
* EXAMPLES: see Double Play
*
* --------------------------------------------------
*
* DISC_INTEGRATE_OP_AMP_2 | DISC_OP_AMP_IS_NORTON
*
* c
* .---||----.
* r1a | |
* v1 >----ZZZZ---. | |\ |
* .----. | r1b Diode | | \ |
* | F0 |--+--ZZZZ----|>|--+--|- \ |
* '----' | >--+----> Netlist Node
* r2a r2b .--|+ /
* v1 >----ZZZZ---+--ZZZZ---------+ | /
* .----. | | |/
* | F1 |--' |
* '----' |
* r3a r3b Diode |
* v1 >----ZZZZ---+--ZZZZ----|>|--'
* .----. |
* | F2 |--'
* '----'
*
* Note: For an explanation of the functions and trigger inputs,
* see DISCRETE_OP_AMP_TRIG_VCA below.
*
* EXAMPLES: see Polaris
*
***********************************************************************
*
* DISCRETE_MIXER - Mixes multiple input signals.
*
* Declaration syntax
*
* DISCRETE_MIXERx(name of node,
* (x = 2 to 8) enable node or static value,
* input 0 node,
* input 1 node,
* input 2 node, (if used)
* input 3 node, (if used)
* input 4 node, (if used)
* input 5 node, (if used)
* input 6 node, (if used)
* input 7 node, (if used)
* address of discrete_mixer_info structure)
*
* discrete_mixer_desc = {type, r{}, r_node{}, c{}, rI, rF, cF, cAmp, vRef, gain}
*
* Note: Set all unused components to 0.
* If an rNode is not used it should also be set to 0.
*
* Types:
*
* DISC_MIXER_IS_RESISTOR
*
* rNode[0] r[0] c[0]
* IN0 >--zzzz-----zzzz----||---.
* |
* rNode[1] r[1] c[1] |
* IN1 >--zzzz-----zzzz----||---+--------.
* . . . . | | cAmp
* . . . . | Z<------||---------> Netlist Node
* . . . . | Z
* . rNode[7] r[7] c[7] | Z rF
* IN7 >--zzzz-----zzzz----||---+ |
* | |
* --- |
* cF --- |
* | |
* gnd gnd
*
* Note: The variable resistor is used in it's full volume position.
* MAME's built in volume is used for adjustment.
*
* EXAMPLES: see Polaris, Super Bug
*
* --------------------------------------------------
*
* DISC_MIXER_IS_OP_AMP
*
* cF
* .----||---.
* | |
* rNode[0] r[0] c[0] | rF |
* IN0 >--zzzz------zzzz----||---. +---ZZZZ--+
* | | |
* rNode[1] r[1] c[1] | rI | |\ |
* IN1 >--zzzz------zzzz----||---+--zzzz--+ | \ |
* . . . . | '--|- \ | cAmp
* . . . . | | >--+---||-----> Netlist Node
* . . . . | .--|+ /
* . rNode[7] r[7] c[7] | | | /
* IN7 >--zzzz------zzzz----||---' | |/
* |
* vRef >----------------------------------'
*
* Note: rI is not always used and should then be 0.
*
* EXAMPLES: see Fire Truck, Monte Carlo
*
***********************************************************************
*
* DISCRETE_OP_AMP - Various op-amp circuits
*
* Declaration syntax
*
* DISCRETE_OP_AMP(name of node,
* enable node or static value,
* input 0 node or static value,
* input 1 node or static value,
* address of discrete_op_amp_info structure)
*
* discrete_op_amp_info = {type, r1, r2, r3, r4, c, vN, vP}
*
* Note: Set all unused components to 0.
*
* Types:
*
* DISC_OP_AMP_IS_NORTON
*
* c
* .----||---.
* | |
* r3 | r4 | vP = B+
* vP >---ZZZZ------+---ZZZZ--+ vN = B-
* | |
* r1 | |\ | Note: r2 must always be used
* IN0 >---ZZZZ------+ | \ |
* '--|- \ |
* r2 | >--+-----> Netlist Node
* IN1 >---ZZZZ---------|+ /
* | /
* |/
*
* EXAMPLES: see Space Encounter
*
***********************************************************************
*
* DISCRETE_OP_AMP_ONESHOT - Various op-amp one shot circuits
*
* Declaration syntax
*
* DISCRETE_OP_AMP_ONESHOT(name of node,
* trigger node (voltage level),
* address of discrete_op_amp_1sht_info structure)
*
* discrete_op_amp_1sht_info = {type, r1, r2, r3, r4, r5, c1, c2, vN, vP}
*
* Types:
*
* DISC_OP_AMP_1SHT_1 | DISC_OP_AMP_IS_NORTON
*
* c1 .---|>|---.
* gnd >----||---+---+ |
* | | r4 | vP = B+
* Z '---ZZZZ--+ vN = B-
* Z r3 |
* Z |\ | Note: all components must be used
* r1 | | \ | The oneshot is cancelled when TRIG goes low
* vP >---ZZZZ--+------|- \ |
* | >--+-----> Netlist Node
* c2 r2 .--|+ / |
* TRIG >--||---ZZZZ--+ | / |
* | |/ |
* | r5 |
* '---ZZZZ--'
*
*
* EXAMPLES: see Space Encounter
*
***********************************************************************
*
* DISCRETE_OP_AMP_TRIG_VCA - Triggered Norton op amp voltage controlled amplifier.
* This means the cap is rapidly charged thru r5 when F2=1.
* Then it discharges thru r6+r7 when F2=0.
* This voltage controls the amplitude.
* While the diagram looks complex, usually only parts of it are used.
*
* Declaration syntax
*
* DISCRETE_OP_AMP_TRIG_VCA(name of node,
* trigger 0 node or static value,
* trigger 1 node or static value,
* trigger 2 node or static value,
* input 0 node or static value,
* input 1 node or static value,
* address of discrete_op_amp_tvca_info structure)
*
* discrete_op_amp_tvca_info = { r1, r2, r3, r4, r5, r6, r7, r8, r9, r10, r11, c1, c2, c3, v1, v2, v3, vP, f0, f1, f2, f3, f4, f5}
*
* Note: Set all unused components to 0.
* Set all unused functions to DISC_OP_AMP_TRIGGER_FUNCTION_NONE
* Set all unused nodes to NODE_NC.
* If function F3 is not used then set r6=0 and use only r7.
* r2 = r2a + r2b. r3 = r3a + r3b.
* vP is the op-amp B+.
*
* r2a
* IN0 >----ZZZZ-----. r1
* .----. | vP >------ZZZZ---.
* | F0 |----+ |
* '----' | r2b | r4
* r3a '---------------ZZZZ---+---ZZZZ--.
* IN1 >----ZZZZ---. | |
* .----. | r3b | |\ |
* | F1 |--+-----------------ZZZZ---+ | \ |
* '----' '--|- \ |
* .----. diode r6 r7 | >--+----> Netlist Node
* | F2 |--+--|>|--+--ZZZZ---+--ZZZZ-+-|+ /
* '----' | | | | | /
* | --- .----. | |/
* r5 | --- c1 | F3 | |
* v1 >----ZZZZ---' | '----' |
* gnd |
* |
* .----. diode r9 |
* | F4 |--+--|>|-----------+---ZZZZ-+
* '----' | c2 | |
* r8 | gnd >---||---' |
* v2 >----ZZZZ---' |
* .----. diode r11 |
* | F5 |--+--|>|-----------+---ZZZZ-'
* '----' | c3 |
* r10 | gnd >---||---'
* v3 >----ZZZZ---'
*
* Function types:
*
* Trigger 0, 1 and 2 are used for the functions F0 - F5.
* When the output of the function is 0, then the connection is held at 0V or gnd.
* When the output of the function is 1, then the function is an open circuit.
*
* DISC_OP_AMP_TRIGGER_FUNCTION_NONE - Not used, cicuit open.
* DISC_OP_AMP_TRIGGER_FUNCTION_TRG0 - Gnd when trigger 0 is 0.
* DISC_OP_AMP_TRIGGER_FUNCTION_TRG0_INV - Gnd when trigger 0 is 1.
* DISC_OP_AMP_TRIGGER_FUNCTION_TRG1 - Gnd when trigger 1 is 0.
* DISC_OP_AMP_TRIGGER_FUNCTION_TRG1_INV - Gnd when trigger 1 is 1.
* DISC_OP_AMP_TRIGGER_FUNCTION_TRG2 - Gnd when trigger 2 is 0.
* DISC_OP_AMP_TRIGGER_FUNCTION_TRG2_INV - Gnd when trigger 2 is 1.
* DISC_OP_AMP_TRIGGER_FUNCTION_TRG01_AND - Gnd when trigger 0 or 1 are 0.
* DISC_OP_AMP_TRIGGER_FUNCTION_TRG01_NAND - Gnd when trigger 0 and 1 are 1.
*
* EXAMPLES: see Polaris
*
***********************************************************************
=======================================================================
* from from disc_flt.c
* Generic modules
=======================================================================
***********************************************************************
*
* DISCRETE_FILTER1
*
* Declaration syntax
*
* DISCRETE_FILTER1(name of node,
* enable node or static value,
* input node,
* filter center frequency static value,
* filter type static value)
*
* Filter types: DISC_FILTER_LOWPASS,
* DISC_FILTER_HIGHPASS
* DISC_FILTER_BANDPASS
*
***********************************************************************
*
* DISCRETE_FILTER2
*
* Declaration syntax
*
* DISCRETE_FILTER2(name of node,
* enable node or static value,
* input node,
* filter center frequency static value,
* damp static value,
* filter type static value)
*
* Filter types: DISC_FILTER_LOWPASS,
* DISC_FILTER_HIGHPASS
* DISC_FILTER_BANDPASS
*
* Note: Damp = 1/Q
*
***********************************************************************
=======================================================================
* from from disc_flt.c
* Component specific modules
=======================================================================
***********************************************************************
*
* DISCRETE_CRFILTER - Simple single pole CR filter network (vRef = 0)
* DISCRETE_CRFILTER_VREF - Same but refrenced to vRef not 0V
*
* .------------.
* | |
* ENAB -0------}| CR FILTER |
* | |
* INPUT1 -1------}| --| |-+-- |
* | C | |----} Netlist node
* RVAL -2------}| Z |
* | Z R |
* CVAL -3------}| | |
* | vRef |
* '------------'
*
* Declaration syntax
*
* DISCRETE_CRFILTER(name of node,
* enable
* input node (or value)
* resistor value in OHMS
* capacitor value in FARADS)
*
* DISCRETE_CRFILTER_VREF(name of node,
* enable
* input node (or value)
* resistor value in OHMS
* capacitor value in FARADS,
* vRef static value)
*
* Example config line
*
* DISCRETE_CRFILTER(NODE_11,1,NODE_10,100,CAP_U(1))
*
* Defines an always enabled CR filter with a 100R & 1uF network
* the input is fed from NODE_10.
*
* This can be also thought of as a high pass filter with a 3dB cutoff
* at:
* 1
* Fcuttoff = --------------
* 2*Pi*RVAL*CVAL
*
* (3dB cutoff is where the output power has dropped by 3dB ie Half)
*
***********************************************************************
*
* DISCRETE_OP_AMP_FILTER - Various Op Amp Filters.
*
* Declaration syntax
*
* DISCRETE_OP_AMP_FILTER(name of node,
* enable node or static value,
* input 1 node or static value,
* input 2 node or static value,
* type static value,
* address of discrete_op_amp_filt_info)
*
* discrete_op_amp_filt_info = {r1, r2, r3, r4, rF, c1, c2, c3, vRef, vP, vN}
*
* Note: Set all unused components to 0.
* vP and vN are the +/- op-amp power supplies.
* vRef is 0 if Gnd.
*
* Types:
*
* DISC_OP_AMP_FILTER_IS_LOW_PASS_1
* First Order Low Pass Filter
*
* c1
* .-------||---------.
* | |
* r1 | rF |
* IN0 >--ZZZZ--. +------ZZZZ--------+
* | | |
* r2 | | |\ |
* IN1 >--ZZZZ--+------+--------+ | \ |
* | '--|- \ |
* r3 | | >--+----------> Netlist Node
* vRef >--ZZZZ--' .--|+ /
* | | /
* vRef >-----------------------' |/
*
* --------------------------------------------------
*
* DISC_OP_AMP_FILTER_IS_HIGH_PASS_1
* First Order High Pass Filter
*
* r1 rF
* IN0 >--ZZZZ--. .------ZZZZ--------.
* | | |
* r2 | c1 | |\ |
* IN1 >--ZZZZ--+--||--+--------+ | \ |
* | '--|- \ |
* r3 | | >--+----------> Netlist Node
* vRef >--ZZZZ--' .--|+ /
* | | /
* vRef >-----------------------' |/
*
* --------------------------------------------------
*
* DISC_OP_AMP_FILTER_IS_BAND_PASS_1
* First Order Band Pass Filter
*
* c1
* .-------||---------.
* | |
* r1 | rF |
* IN0 >--ZZZZ--. +------ZZZZ--------+
* | | |
* r2 | c2 | |\ |
* IN1 >--ZZZZ--+--||--+--------+ | \ |
* | '--|- \ |
* r3 | | >--+----------> Netlist Node
* vRef >--ZZZZ--' .--|+ /
* | | /
* vRef >-----------------------' |/
*
* --------------------------------------------------
*
* DISC_OP_AMP_FILTER_IS_BAND_PASS_1M
* Single Pole Multiple Feedback Band Pass Filter
*
* c1
* .--||----+---------.
* | | |
* r1 | Z |
* IN0 >--ZZZZ--. | Z rF |
* | | Z |
* r2 | | c2 | |\ |
* IN1 >--ZZZZ--+------+--||----+ | \ |
* | '--|- \ |
* r3 | | >--+----------> Netlist Node
* vRef >--ZZZZ--' .--|+ /
* | | /
* vRef >-----------------------' |/
*
* EXAMPLES: see Tank 8, Atari Baseball, Monte Carlo
*
* --------------------------------------------------
*
* DISC_OP_AMP_FILTER_IS_BAND_PASS_1M | DISC_OP_AMP_IS_NORTON
* Single Pole Multiple Feedback Band Pass Filter
*
* c1
* .--||----+---------.
* | | |
* | Z |
* | Z rF |
* | Z |
* r1 | c2 | |\ |
* IN0 >--ZZZZ--+------+--||----+ | \ |
* | '--|- \ |
* r2 | | >--+----------> Netlist Node
* vRef >--ZZZZ--' .--|+ /
* r3 | | /
* vP >-----------ZZZZ--------' |/
*
* EXAMPLES: see Space Encounter
*
* --------------------------------------------------
*
* DISC_OP_AMP_FILTER_IS_HIGH_PASS_0 | DISC_OP_AMP_IS_NORTON
* Basic Norton High Pass Filter
*
* rF
* r1 = r1a + r1b .--ZZZZ---.
* | |
* r1a c1 r1b | |\ |
* IN1 >--ZZZZ---||---ZZZZ------+ | \ |
* '--|- \ |
* | >--+----------> Netlist Node
* .--|+ /
* r4 | | /
* vRef >------------ZZZZ-------' |/
*
* EXAMPLES: see Polaris
*
* --------------------------------------------------
*
* DISC_OP_AMP_FILTER_IS_BAND_PASS_0 | DISC_OP_AMP_IS_NORTON
* Basic Norton Band Pass Filter
*
* rF
* r3 = r3a + r3b .--ZZZZ---.
* | |
* r1 r2 r3a c3 r3b | |\ |
* IN1 >---ZZZZ--+--ZZZZ--+--ZZZZ---||----ZZZZ---+ | \ |
* | | '--|- \ |
* --- --- | >--+---> Netlist Node
* --- c1 --- c2 .--|+ /
* | | | | /
* gnd gnd | |/
* r4 |
* vRef >--------------------------------ZZZZ----'
*
* EXAMPLES: see Polaris
*
***********************************************************************
*
* DISCRETE_SALLEN_KEY_FILTER - Sallen key low pass filter
*
* Declaration syntax
*
* DISCRETE_SALLEN_KEY_FILTER(name of node,
* enable node or static value,
* input node or static value,
* type static value,
* address of discrete_op_amp_filt_info)
*
* discrete_op_amp_filt_info = {r1, r2, r3, r4, rF, c1, c2, c3, vRef, vP, vN}
*
* Note: Set all unused components to 0.
*
* Types:
*
* DISC_SALLEN_KEY_LOWPASS
*
* .---------.
* | |
* | |\ |
* | | \ |
* `--|- \ |
* R1 R2 | >--+----> Netlist Node
* IN >---ZZZZ--+--ZZZZ--+------|+ / |
* | | | / |
* --- --- |/ |
* --- C1 --- C2 |
* | | |
* | gnd |
* | |
* `----------------------'
*
* EXAMPLES: see moon patrol, dkong
*
* References:
* http://www.t-linespeakers.org/tech/filters/Sallen-Key.html
* http://en.wikipedia.org/wiki/Sallen_Key_filter
***********************************************************************
*
* DISCRETE_RCDISC - Simple single pole RC discharge network
*
* .------------.
* | |
* ENAB -0------>| RC |
* | |
* INPUT1 -1------>| -ZZZZ-+-- |
* | R | |----> Netlist node
* RVAL -2------>| --- |
* | ---C |
* CVAL -3------>| | |
* | |
* '------------'
*
* Declaration syntax
*
* DISCRETE_RCFILTER(name of node,
* enable,
* input node (or value),
* resistor value in OHMS,
* capacitor value in FARADS)
*
* Example config line
*
* DISCRETE_RCDISC(NODE_11,NODE_10,10,100,CAP_U(1))
*
* When enabled by NODE_10, C discharges from 10v as indicated by RC
* of 100R & 1uF.
*
***********************************************************************
*
* DISCRETE_RCDISC2 - Switched input RC discharge network
*
* .------------.
* | |
* SWITCH -0------>| IP0 | IP1 |
* | |
* INPUT0 -1------>| -ZZZZ-. |
* | R0 | |
* RVAL0 -2------>| | |
* | | |
* INPUT1 -3------>| -ZZZZ-+-- |
* | R1 | |----> Netlist node
* RVAL1 -4------>| --- |
* | ---C |
* CVAL -5------>| | |
* | |
* '------------'
*
* Declaration syntax
*
* DISCRETE_RCDISC2(name of node,
* switch,
* input0 node (or value),
* resistor0 value in OHMS,
* input1 node (or value),
* resistor1 value in OHMS,
* capacitor value in FARADS)
*
* Example config line
*
* DISCRETE_RCDISC2(NODE_9,NODE_10,10.0,100,0.0,100,CAP_U(1))
*
* When switched by NODE_10, C charges/discharges from 10v/0v
* as dictated by R0/C & R1/C combos respectively
* of 100R & 1uF.
*
***********************************************************************
*
* DISCRETE_RCDISC3 - RC discharge network
*
* .-----------------.
* | |
* ENAB -0------>| |
* | diode R2 |
* INPUT1 -1------>| -+-|<|--ZZZZ-+- |----> Netlist node
* | | | |
* RVAL1 -2------>| '-ZZZZ-+----' |
* | R1 | |
* RVAL2 -3------>| --- |
* | ---C |
* CVAL -4------>| | |
* | gnd |
* '-----------------'
*
* Declaration syntax
*
* DISCRETE_RCDISC3(name of node,
* enable,
* input node (or value),
* R1 resistor value in OHMS,
* R2 resistor value in OHMS,
* capacitor value in FARADS)
*
* Example config line
*
* DISCRETE_RCDISC3(NODE_11,NODE_10,10,100,220,CAP_U(1))
*
* When enabled by NODE_10, C charges from 10v as indicated by RC
* of 100R & 1uF.
*
* EXAMPLES: see Tank8
*
***********************************************************************
*
* DISCRETE_RCDISC4 - RC discharge networks triggered by logic levels
*
* Declaration syntax
*
* DISCRETE_RCDISC4(name of node,
* enable,
* logic input node,
* R1 resistor static value in OHMS,
* R2 resistor static value in OHMS,
* R3 resistor static value in OHMS,
* C1 capacitor static value in FARADS,
* vP static value in VOLTS,
* circuit type static value)
*
* Type: 1
*
* vP >---.
* | .------.
* Z | |
* Z R2 | |\ |
* O.C. Z '-|-\ |
* |\ Diode R1 | | >-+---> node
* Input >---| o----|<|------ZZZZ---+--------+-------|+/
* |/ | | |/
* --- -----
* C1 --- \ / Diode
* | V
* gnd ---
* |
* Z
* Z R3
* Z
* |
* gnd
*
* EXAMPLES: see Phoenix
*
* --------------------------------------------------
*
* Type: 2
*
* 5V >---. .------.
* Z | |
* Z 1k | |\ |
* Z '-|-\ |
* | R1 C1 Diode | >-+---> node
* Input >---+--ZZZZ----||----+-----|>|----+--------|+/
* | | |/
* ----- Z
* ^ Z R2
* / \ Diode Z
* ----- |
* | gnd
* gnd
*
* EXAMPLES: see
*
* --------------------------------------------------
*
* Type: 3
*
* 5V >---. .------.
* Z | |
* Z 1k | |\ |
* Z '-|-\ |
* | R1 Diode | >-+---> node
* Input >---+--ZZZZ-----|>|------+---------+--------|+/
* | | |/
* --- C1 Z
* --- Z R2
* | Z
* gnd |
* gnd
*
*
* EXAMPLES: see
*
***********************************************************************
*
* DISCRETE_RCDISC5 - Diode in series with R//C
*
* .---------------.
* | |
* ENAB -0------>| |
* | |
* INPUT1 -1------>| -|>|--+---+- |
* | | | |----> Netlist node
* RVAL -2------>| --- Z |
* | C--- Z R |
* CVAL -3------>| | Z |
* | --+-- |
* | |gnd |
* '---------------'
*
* Declaration syntax
*
* DISCRETE_RCDISC5(name of node,
* enable,
* input node (or value),
* resistor value in OHMS,
* capacitor value in FARADS)
*
* Example config line
*
* DISCRETE_RCDISC5(NODE_11,NODE_10,10,100,CAP_U(1))
*
* When enabled by NODE_10, C discharges from 10v as indicated by RC
* of 100R & 1uF.
*
* EXAMPLES: see Spiders
*
***********************************************************************
*
* DISCRETE_RCDISC_MODULATED - RC triggered by logic and modulated
*
* vP >---.
* |
* Z
* Z R1
* O.C. Z
* |\ | R2 C1 R3
* INPUT1 >---| o---+--ZZZ---||------+----+---ZZZ------+---> node
* |/ | | /
* / \ Z |/
* Diode ----- Z R4 .---| NPN
* | Z | |\
* | | | >
* gnd gnd | |
* | gnd
* INPUT2 >----------ZZZ------------------------.
*
* Declaration syntax
*
* DISCRETE_RCDISC_MODULATED(name of node,
* INPUT1 node (or value),
* INPUT2 node (or value),
* R1 value in OHMS (static value),
* R2 value in OHMS (static value),
* R3 value in OHMS (static value),
* R4 value in OHMS (static value),
* C1 value in FARADS (static value),
* vP value in VOLTS)
*
* EXAMPLES: dkong
*
***********************************************************************
*
* DISCRETE_RCFILTER - Simple single pole RC filter network (vRef = 0)
* DISCRETE_RCFILTER_VREF - Same but refrenced to vRef not 0V
*
* .------------.
* | |
* ENAB -0------}| RC FILTER |
* | |
* INPUT1 -1------}| -ZZZZ-+-- |
* | R | |----} Netlist node
* RVAL -2------}| --- |
* | ---C |
* CVAL -3------}| | |
* | vRef |
* '------------'
*
* Declaration syntax
*
* DISCRETE_RCFILTER(name of node,
* enable
* input node (or value)
* resistor value in OHMS
* capacitor value in FARADS)
*
* DISCRETE_RCFILTER_VREF(name of node,
* enable
* input node (or value)
* resistor value in OHMS
* capacitor value in FARADS,
* vRef static value)
*
* Example config line
*
* DISCRETE_RCFILTER(NODE_11,1,NODE_10,100,CAP_U(1))
*
* Defines an always enabled RC filter with a 100R & 1uF network
* the input is fed from NODE_10.
*
* This can be also thought of as a low pass filter with a 3dB cutoff
* at:
* 1
* Fcuttoff = --------------
* 2*Pi*RVAL*CVAL
*
* (3dB cutoff is where the output power has dropped by 3dB ie Half)
*
* EXAMPLES: see Polaris
*
***********************************************************************
*
* DISCRETE_RCFILTER_SW - Multiple switchable RC filters
*
* R
* INPUT >-----------ZZZZ-+-------+----......-----> Output
* | |
* +-+ +-+
* SWITCH > Bit 0 ---->F1 | | F2 | |
* '-' ^ '-'
* Bit 1 ---------|----' |
* | |
* Bit ... --- ---
* --- C1 --- C2
* | |
* GND GND
*
*
* Declaration syntax
*
* DISCRETE_RCFILTER_SW(name of node,
* enable,
* input node (or value),
* switch node (or value),
* R in Ohms (static value),
* C1 in Farads (static value),
* C2 in Farads (static value),
* C3 in Farads (static value),
* C4 in Farads (static value))
*
* This is a typical filter circuit in circusc or scramble.
* Switches are usually CD4066 with a "open" resistance of
* typical 470 Ohms at 5V.
* This circuit supports up to 4 filters.
*
* EXAMPLES: see circusc
*
***********************************************************************
*
* DISCRETE_RCINTEGRATE - RC integration circuit/amplifier
*
*
* vP >-------------------+
* |
* Z
* Z R3
* Z
* |
* +-----------------> node (Type 3)
* /
* |/
* INPUT >---------------| NPN
* \ .--------------> node (Type 2)
* > | R1
* +--+--ZZZ-+-------> node (Type 1)
* | |
* Z ---
* Z R2 C---
* Z |
* | |
* gnd gnd
*
* Declaration syntax
*
* DISCRETE_RCINTEGRATE(name of node,
* INPUT node (or value),
* R1 value in OHMS,
* R2 value in OHMS,
* R3 value in OHMS,
* C value in FARADS,
* vP node (or value in VOLTS)
* TYPE)
*
* TYPE: RC_INTEGRATE_TYPE1, RC_INTEGRATE_TYPE2, RC_INTEGRATE_TYPE3
*
* Actually an amplifier as well. Primary reason for implementation was integration.
* The integration configuration (TYPE3, R3=0) works quite well, the amplifying
* configuration is missing a good, yet simple ( :-) ) transistor model. Around the
* defined working point the amplifier delivers results.
*
* EXAMPLES: dkong
*
*
***********************************************************************
=======================================================================
* from from disc_dev.c
* Component specific modules
=======================================================================
***********************************************************************
*
* DISCRETE_555_ASTABLE - NE555 Chip simulation (astable mode).
* DISCRETE_555_ASTABLE_CV - NE555 Chip simulation (astable mode) with CV control.
*
* v_charge v_pos
* V V
* | |
* | |
* | |
* Z |8
* _FAST_CHARGE_DIODE R1 Z .---------.
* (optional) | 7| Vcc |
* +---------> +-----|Discharge|
* | | | |
* --- Z | 555 |3
* \ / R2 Z | Out|---> Netlist Node
* V | 6| |
* --- +-----|Threshold|
* | | | |
* +---------> +-----|Trigger |
* | 2| |---< Control Voltage
* | | Reset |5
* | '---------'
* --- 4|
* C --- |
* | ^
* gnd Reset
*
* Declaration syntax
*
* DISCRETE_555_ASTABLE(name of node,
* reset node (or value),
* R1 node (or value) in ohms,
* R2 node (or value) in ohms,
* C node (or value) in farads,
* address of discrete_555_desc structure)
*
* DISCRETE_555_ASTABLE_CV(name of node,
* reset node (or value),
* R1 node (or value) in ohms,
* R2 node (or value) in ohms,
* C node (or value) in farads,
* Control Voltage node (or value),
* address of discrete_555_desc structure)
*
* discrete_555_desc =
* {
* options, - bit mapped options
* v_pos, - B+ voltage of 555
* v_charge, - voltage (or node) to charge circuit (Defaults to v_pos)
* v_out_high, - High output voltage of 555 (Defaults to v_pos - 1.2V)
* }
*
* The last 2 options of discrete_555_desc can use the following defaults:
* DEFAULT_555_CHARGE - to connect v_charge to v_pos
* DEFAULT_555_HIGH - to use the normal output voltage based on v_pos
* or combine both as:
* DEFAULT_555_VALUES
*
* eg. {DISC_555_OUT_SQW | DISC_555_OUT_DC, 12, DEFAULT_555_VALUES}
*
* Output Types: (only needed with DISC_555_OUT_SQW, DISC_555_OUT_CAP
* and DISC_555_OUT_ENERGY)
* DISC_555_OUT_DC - Output is actual DC. (DEFAULT)
* DISC_555_OUT_AC - A cheat to make the waveform AC.
*
* Waveform Types: (ORed with output types)
* DISC_555_OUT_SQW - Output is Squarewave. 0 or v_out_high. (DEFAULT)
* When the state changes from low to high (or high to low)
* during a sample, the output will high (or low) for that
* sample. This can cause alaising effects.
* DISC_555_OUT_CAP - Output is Timing Capacitor 'C' voltage.
* DISC_555_OUT_COUNT_F - If the 555 frequency is greater then half the sample
* rate, then the output may change state more then once
* during the sample. Using this flag will cause
* the output to be the number of falling edges that
* happened during the sample. This is usefull to feed
* to counter circuits. The Output Type flag is ingnored
* when this flag is used.
* DISC_555_OUT_COUNT_R - Same as DISC_555_OUT_COUNT_F but with rising edges.
* DISC_555_OUT_ENERGY - Same SQW, but will help reduce aliasing effects.
* This should be used when the 555 squarewave output is used
* as a final output and not as a clock source.
* If the state changes from low to high 1/4 of the way
* through the sample, then the output will be 75% of the
* normal high value.
* DISC_555_OUT_LOGIC_X - This will output the 0/1 level of the flip-flop with
* some eXtra info. This x_time is in decimal remainder.
* It lets you know the percent of sample time where the
* flip-flop changed state. If 0, the change did not happen
* during the sample. 1.75 means the flip-flop is 1 and
* switched over 1/4 of the way through the sample.
* 0.2 means the flip-flop is 0 and switched over 4/5 of
* the way through the sample.
* X modules can be used with counters to reduce alaising.
* DISC_555_OUT_COUNT_F_X - Same as DISC_555_OUT_COUNT_F but with x_time.
* DISC_555_OUT_COUNT_R_X - Same as DISC_555_OUT_COUNT_R but with x_time.
*
* other options - DISCRETE_555_ASTABLE only:
* DISC_555_ASTABLE_HAS_FAST_CHARGE_DIODE - diode used to bypass rDischarge
* when charging for quicker charge.
*
* EXAMPLES: see Hit Me, Canyon Bomber, Sky Diver
*
***********************************************************************
*
* DISCRETE_555_MSTABLE - NE555 Chip simulation (monostable mode)
* - Triggered on falling edge.
*
* v_charge v_pos
* V V
* | |
* | |
* | |
* Z |
* R Z .---------.
* | | Vcc |
* +-----|Discharge|
* | | |
* | | 555 |
* | | Out|---> Netlist Node
* | | |
* +-----|Threshold|
* | | |
* | | Trigger|--------< Trigger
* | | CV|---.
* | | Reset | |
* | '---------' --- not
* --- | --- needed
* C --- | |
* | ^ gnd
* gnd Reset
*
* Declaration syntax
*
* DISCRETE_555_MSTABLE(name of node,
* reset node (or value),
* Trigger node,
* R node (or value) in ohms,
* C node (or value) in farads,
* address of discrete_555_desc structure)
*
* discrete_555_desc = See DISCRETE_555_ASTABLE for description.
* Note: v_charge can not be a node for this circuit.
*
* Trigger Types
* DISC_555_TRIGGER_IS_LOGIC - Input is (0 or !0) logic (DEFAULT)
* DISC_555_TRIGGER_IS_VOLTAGE - Input is actual voltage.
* Voltage must drop below
* trigger to activate.
* DISC_555_TRIGGER_DISCHARGES_CAP - some circuits connect an external
* device (transistor) to the cap to
* discharge it when the trigger is
* enabled. Thereby allowing the one-shot
* to retrigger.
*
* Output Types: (ORed with trigger types)
* DISC_555_OUT_DC - Output is actual DC. (DEFAULT)
* DISC_555_OUT_AC - A cheat to make the waveform AC.
*
* Waveform Types: (ORed with trigger types)
* DISC_555_OUT_SQW - Output is Squarewave. 0 or v_out_high. (DEFAULT)
* DISC_555_OUT_CAP - Output is Timing Capacitor 'C' voltage.
*
* EXAMPLES: see Frogs
*
***********************************************************************
*
* DISCRETE_555_CC - Constant Current Controlled 555 Oscillator
* Which works out to a VCO when R is fixed.
*
* v_cc_source v_pos
* V V
* | .----------------------+
* | | |
* | | .---------.
* | | rDischarge | Vcc |
* Z Z .---+-----|Discharge|
* Z R Z rBias | | | |
* | | | Z | 555 |
* | | | Z | Out|---> Netlist Node
* .----. | >-' | | |
* Vin >--| CC |--+--> option +-----|Threshold|
* '----' >-----+ | |
* +-----|Trigger |
* | | |
* .------+-----' | Reset |
* | | '---------'
* --- Z |
* --- C Z rGnd |
* | | ^
* gnd gnd Reset
*
* Notes: R sets the current and should NEVER be 0 (short).
* The current follows the voltage I=Vin/R and charges C.
* rBias, rDischarge and rGnd should be 0 if not used.
* Reset is active low for the module.
*
* Note that the CC source can be connected two different ways.
* See the option flags below for more info.
*
* DISC_555_OUT_SQW mode only:
* When there is no rDischarge there is a very short discharge
* cycle (almost 0s), so the module triggers the output for 1
* sample. This does not effect the timing, just the duty cycle.
* But frequencies more the half the sample frequency will be
* limited to a max of half the sample frequency.
* This mode should be used to drive a counter for any real use.
* Just like the real thing.
*
* Declaration syntax
*
* DISCRETE_555_CC(name of node,
* reset node or static value,
* Vin node or static value,
* R node or static value,
* C node or static value,
* rBias node or static value,
* rGnd node or static value,
* rDischarge node or static value,
* address of discrete_555_cc_desc structure)
*
* discrete_555_cc_desc =
* {
* options; - bit mapped options
* v_pos; - B+ voltage of 555
* v_cc_source; - Voltage of the Constant Current source
* v_out_high; - High output voltage of 555 (Defaults to v_pos - 1.2V)
* v_cc_junction; - The voltage drop of the Constant Current source transitor
* (0 if Op Amp)
* }
*
* The last 2 options of discrete_555_desc can use the following defaults:
* DEFAULT_555_CC_SOURCE - to connect v_cc_source to v_pos
* DEFAULT_555_HIGH - to use the normal output voltage based on v_pos
* or combine both as:
* DEFAULT_555_VALUES
*
* Output Types:
* See DISCRETE_555_ASTABLE for description.
*
* Waveform Types: (ORed with output types)
* See DISCRETE_555_ASTABLE for description.
*
* Other Flags:
* DISCRETE_555_CC_TO_DISCHARGE_PIN - The CC source connects to the
* discharge pin. (Default)
* DISCRETE_555_CC_TO_CAP - The CC source connects to the
* threshold pin. This is not fully
* implemented yet. It only works properly
* when only rDischarge is defined.
*
* EXAMPLES: see Fire Truck, Monte Carlo, Super Bug
*
***********************************************************************
*
* DISCRETE_555_VCO1 - Op-Amp based 555 VCO circuit.
* DISCRETE_555_VCO1_CV - Op-Amp based 555 VCO circuit with CV control.
*
* c
* .------------------------+---||----+---------------------------> DISC_555_OUT_CAP
* | | |
* | | |\ |
* | r1 | | \ | .------------.
* | vIn1 >--+--ZZZZ-------+---|- \ | | |
* | | | >-+---+--|Threshold |
* | | r2 |+ / | | Out|------> DISC_555_OUT_xx
* Z '--ZZZZ--+--------| / '--|Trigger |
* Z r4 | |/ | |
* Z Z | Reset|------< Reset
* | Z r3 vIn2 >--|CV |
* .----. Z | |
* | En|<--------. | .---|Discharge |
* '----' | gnd | '------------'
* | | |
* gnd '-----------------------+---ZZZZ------> v_charge (ignored)
* rX
*
* Declaration syntax
*
* DISCRETE_555_VCO1(name of node,
* reset node or static value,
* Vin1 node or static value,
* address of discrete_555_vco1_desc structure)
*
* DISCRETE_555_VCO1_CV(name of node,
* reset node or static value,
* Vin1 node or static value,
* Vin2 (CV) node or static value,
* address of discrete_555_vco1_desc structure)
*
* discrete_555_vco1_desc =
* {
* options, - bit mapped options
* r1, r2, r3, r4, c,
* v_pos, - B+ voltage of 555
* v_out_high, - High output voltage of 555 (Defaults to v_pos - 1.2V)
* }
*
* The last option of discrete_555_vco1_desc can use the following default:
* DEFAULT_555_HIGH - to use the normal output voltage based on v_pos
*
* Notes: The value of resistor rX is not needed. It is just a pull-up
* for the discharge output.
* The 'En' block can be a transistor or 4066 switch. It connects
* r4 to ground when En is high.
*
***********************************************************************
*
* DISCRETE_566 - NE566 VCO simulation.
*
* v_charge v_pos
* V V
* | |
* | |
* | R .-------.
* '---/\/\--|6 8 |
* | |
* vMod >------------|5 3/4|---------> Netlist Node
* | |
* .---|7 1 |
* | '-------'
* --- |
* --- C |
* | |
* v_neg v_neg
*
* Declaration syntax
*
* DISCRETE_566(name of node,
* enable node or static value,
* vMod node or static value,
* R node or static value in ohms,
* C node or static value in Farads,
* address of discrete_566_desc structure)
*
* discrete_566_desc = {options, v_pos, v_neg, v_charge}
* Note: v_charge can be static value, a node
* or use DEFAULT_566_CHARGE to connect to v_pos
*
* Output Types:
* DISC_566_OUT_DC - Output is actual DC. (DEFAULT)
* DISC_566_OUT_AC - A cheat to make the wav