diff options
author | Couriersud <couriersud@users.noreply.github.com> | 2007-12-30 01:35:45 +0000 |
---|---|---|
committer | Couriersud <couriersud@users.noreply.github.com> | 2007-12-30 01:35:45 +0000 |
commit | e15832fcb488fe1d5f63ac1c6819aa186bf3570f (patch) | |
tree | 2aae3ad66f3e1bf007858f908f62bdcc3ad46315 /src/emu | |
parent | 83d4e33df8cbebce467d73546a9b8648a0485f89 (diff) |
Added discrete 74LS624(56789) implementation
- DISCRETE_74LS624 is a VCO needed for dkongjr
- Supports Logic, Energy and Count outputs
Diffstat (limited to 'src/emu')
-rw-r--r-- | src/emu/sound/disc_dev.c | 93 | ||||
-rw-r--r-- | src/emu/sound/discrete.c | 2 | ||||
-rw-r--r-- | src/emu/sound/discrete.h | 54 |
3 files changed, 146 insertions, 3 deletions
diff --git a/src/emu/sound/disc_dev.c b/src/emu/sound/disc_dev.c index dd7351f0182..f86b7da66c0 100644 --- a/src/emu/sound/disc_dev.c +++ b/src/emu/sound/disc_dev.c @@ -100,6 +100,12 @@ struct dsd_566_context double triOffset; // used to shift a triangle to AC }; +struct dsd_ls624_context +{ + int state; + double remain; // remaining time from last step + int outtype; +}; /* Test to see if basic 555 options are valid. */ @@ -1370,3 +1376,90 @@ void dsd_566_reset(node_description *node) /* Step the output */ dsd_566_step(node); } + +/************************************************************************ + * + * DSD_LS624 - Usage of node_description values + * + * input[0] - Enable input value + * input[1] - Modulation Voltage + * input[2] - Range Voltage + * input[3] - C value + * input[4] - Output type + * + * Dec 2007, Couriersud + ************************************************************************/ +#define DSD_LS624__ENABLE (*(node->input[0])) +#define DSD_LS624__VMOD (*(node->input[1])) +#define DSD_LS624__VRNG (*(node->input[2])) +#define DSD_LS624__C (*(node->input[3])) +#define DSD_LS624__OUTTYPE (*(node->input[4])) + +/* + * These formulas are derived from diagrams in the datasheet! + * They are not based on any law. The function is not + * described anywhere. + */ + +#define LS624_F1(x) (0.19 + 20.0/90.0*(x)) +#define LS624_T(_C, _R, _F) (-600.0 * (_C) * log(1.0-LS624_F1(_R)*0.12/LS624_F1(_F))) + +void dsd_ls624_step(node_description *node) +{ + struct dsd_ls624_context *context = node->context; + + if (DSD_LS624__ENABLE) + { + double dt; // change in time + double sample_t; + double t; + int lst, cntf=0, cntr=0; + + sample_t = discrete_current_context->sample_time; // Change in time + dt = LS624_T(DSD_LS624__C, DSD_LS624__VRNG, DSD_LS624__VMOD); + dt = 16 * dt; + t = context->remain; + lst = context->state; + while (t + dt < sample_t) + { + context->state = (1-context->state); + if (context->state) + cntr++; + else + cntf++; + t += dt; + } + context->remain = t - sample_t; + + switch (context->outtype) + { + case DISC_LS624_OUT_ENERGY: + node->output = ((double) lst) * (1.0+context->remain/sample_t) - ((double) context->state) * context->remain/sample_t; + break; + case DISC_LS624_OUT_LOGIC: + node->output = context->state; + break; + case DISC_LS624_OUT_COUNT_F: + node->output = cntf; + break; + case DISC_LS624_OUT_COUNT_R: + node->output = cntr; + break; + } + + } + else + node->output = 0; +} + +void dsd_ls624_reset(node_description *node) +{ + struct dsd_ls624_context *context = node->context; + + context->remain = 0; + context->state = 0; + context->outtype = DSD_LS624__OUTTYPE; + + /* Step the output */ + dsd_ls624_step(node); +} diff --git a/src/emu/sound/discrete.c b/src/emu/sound/discrete.c index bc6d43f979f..823208f8a70 100644 --- a/src/emu/sound/discrete.c +++ b/src/emu/sound/discrete.c @@ -259,7 +259,7 @@ static const discrete_module module_list[] = { DSD_555_CC ,"DSD_555_CC" ,sizeof(struct dsd_555_cc_context) ,dsd_555_cc_reset ,dsd_555_cc_step }, { DSD_555_VCO1 ,"DSD_555_VCO1" ,sizeof(struct dsd_555_vco1_context) ,dsd_555_vco1_reset ,dsd_555_vco1_step }, { DSD_566 ,"DSD_566" ,sizeof(struct dsd_566_context) ,dsd_566_reset ,dsd_566_step }, - + { DSD_LS624 ,"DSD_LS624" ,sizeof(struct dsd_ls624_context) ,dsd_ls624_reset ,dsd_ls624_step }, /* must be the last one */ { DSS_NULL ,"DSS_NULL" ,0 ,NULL ,NULL } }; diff --git a/src/emu/sound/discrete.h b/src/emu/sound/discrete.h index 96661a2a04f..753d8e5fd29 100644 --- a/src/emu/sound/discrete.h +++ b/src/emu/sound/discrete.h @@ -2911,9 +2911,9 @@ * * 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, - * vMod node or static value, * address of discrete_566_desc structure) * * discrete_566_desc = {options, vPlus, vNeg} @@ -2929,6 +2929,50 @@ * *********************************************************************** * + * DISCRETE_74LS624 - VCO. + * + * Simplified 74LS624 - calculated frequencies should match datasheet + * for C > 1nF. Output is Logic (1/0) + * + * The datasheet gives no formulae. The implementation therefore is + * a rough model of the diagrams given. + * + * For a LS628, use VRng = 3.2 + * + * V+ + * | + * .---------. + * vRng >------------|Rng V+ | + * | | + * vMod >------------|Freq Z |---------> Netlist Node + * | | + * .---|CX1 | + * | | | + * --- | | + * C --- | | + * | | | + * '---|CX2 | + * '---------' + * | + * GND + * + * Declaration syntax + * + * DISCRETE_74LS624(name of node, + * enable node or static value, + * vMod node or static value, + * vRng node or static value, + * C node or static value in Farads, + * Type of output static value) + * + * Type of Output + * DISC_LS624_OUT_ENERGY Energy - use for audio output + * DISC_LS624_OUT_LOGIC Logic ( 0 or 1) + * DISC_LS624_OUT_COUNT_F Number of Falling edges + * DISC_LS624_OUT_COUNT_R Number of Rising edges + * + *********************************************************************** + * * DISCRETE_CUSTOMx - Link to custom code * where x = 1 to 5 * @@ -3208,6 +3252,11 @@ enum #define DISC_566_OUT_MASK 0x30 /* Bits that define output type. * Used only internally in module. */ +/* LS624 output flags */ +#define DISC_LS624_OUT_ENERGY 0x01 +#define DISC_LS624_OUT_LOGIC 0x02 +#define DISC_LS624_OUT_COUNT_F 0x03 +#define DISC_LS624_OUT_COUNT_R 0x04 /* Oneshot types */ #define DISC_ONESHOT_FEDGE 0x00 @@ -3739,6 +3788,7 @@ enum DSD_555_CC, /* Constant Current 555 circuit (VCO)*/ DSD_555_VCO1, /* Op-Amp linear ramp based 555 VCO */ DSD_566, /* NE566 Emulation */ + DSD_LS624, /* 74LS624 Emulation */ /* Custom */ DST_CUSTOM, /* whatever you want */ @@ -3902,7 +3952,7 @@ enum #define DISCRETE_555_VCO1(NODE,RESET,VIN,OPTIONS) { NODE, DSD_555_VCO1 , 3, { RESET,VIN,NODE_NC }, { RESET,VIN,-1 }, OPTIONS, "555 VCO1 - Op-Amp type" }, #define DISCRETE_555_VCO1_CV(NODE,RESET,VIN,CTRLV,OPTIONS) { NODE, DSD_555_VCO1 , 3, { RESET,VIN,CTRLV }, { RESET,VIN,CTRLV }, OPTIONS, "555 VCO1 with CV - Op-Amp type" }, #define DISCRETE_566(NODE,ENAB,VMOD,R,C,OPTIONS) { NODE, DSD_566 , 4, { ENAB,VMOD,R,C }, { ENAB,VMOD,R,C }, OPTIONS, "566" }, - +#define DISCRETE_74LS624(NODE,ENAB,VMOD,VRNG,C,OUTTYPE) { NODE, DSD_LS624 , 5, { ENAB,VMOD,VRNG,C,NODE_NC }, { ENAB,VMOD,VRNG,C, OUTTYPE }, NULL, "74LS624" }, #define DISCRETE_CSVLOG1(NODE1) { NODE_SPECIAL, DSO_CSVLOG , 1, { NODE1 }, { NODE1 }, NULL, "CSV Log 1 Node" }, #define DISCRETE_CSVLOG2(NODE1,NODE2) { NODE_SPECIAL, DSO_CSVLOG , 2, { NODE1,NODE2 }, { NODE1,NODE2 }, NULL, "CSV Log 2 Nodes" }, #define DISCRETE_CSVLOG3(NODE1,NODE2,NODE3) { NODE_SPECIAL, DSO_CSVLOG , 3, { NODE1,NODE2,NODE3 }, { NODE1,NODE2,NODE3 }, NULL, "CSV Log 3 Nodes" }, |