From 17a8faf1bbbfce7659c2c8b59831475a43fbd535 Mon Sep 17 00:00:00 2001 From: h_vogt Date: Sat, 27 Aug 2016 23:07:02 +0200 Subject: [PATCH] add xspice digital model d_lut (digital n-input look-up table gate) provided by Tim Edwards --- src/xspice/icm/digital/d_lut/cfunc.mod | 263 ++++++++++++++++++++++++ src/xspice/icm/digital/d_lut/ifspec.ifs | 77 +++++++ src/xspice/icm/digital/modpath.lst | 1 + visualc/xspice/digital.vcxproj | 4 + 4 files changed, 345 insertions(+) create mode 100644 src/xspice/icm/digital/d_lut/cfunc.mod create mode 100644 src/xspice/icm/digital/d_lut/ifspec.ifs diff --git a/src/xspice/icm/digital/d_lut/cfunc.mod b/src/xspice/icm/digital/d_lut/cfunc.mod new file mode 100644 index 000000000..8c38e3ff3 --- /dev/null +++ b/src/xspice/icm/digital/d_lut/cfunc.mod @@ -0,0 +1,263 @@ +/*.......1.........2.........3.........4.........5.........6.........7.........8 +================================================================================ + +FILE d_lut/cfunc.mod + +Copyright 2016 +efabless inc., San Jose, CA +All Rights Reserved + +AUTHORS + + 25 Aug 2016 Tim Edwards + + +SUMMARY + + This file contains the functional description of the d_lut + code model. + + +INTERFACES + + FILE ROUTINE CALLED + + CMevt.c void *cm_event_alloc() + void *cm_event_get_ptr() + + + +REFERENCED FILES + + Inputs from and outputs to ARGS structure. + + +NON-STANDARD FEATURES + + NONE + +===============================================================================*/ + +/*=== INCLUDE FILES ====================*/ + +#include +#include +#include +#include + + + +/*=== CONSTANTS ========================*/ + + + + +/*=== MACROS ===========================*/ + + + + +/*=== LOCAL VARIABLES & TYPEDEFS =======*/ + + + + +/*=== FUNCTION PROTOTYPE DEFINITIONS ===*/ + + + + + +/*============================================================================== + +FUNCTION cm_d_lut() + +AUTHORS + + 25 Aug 2016 Tim Edwards + +SUMMARY + + This function implements the d_lut code model. + +INTERFACES + + FILE ROUTINE CALLED + + CMevt.c void *cm_event_alloc() + void *cm_event_get_ptr() + +RETURNED VALUE + + Returns inputs and outputs via ARGS structure. + +GLOBAL VARIABLES + + NONE + +NON-STANDARD FEATURES + + NONE + +==============================================================================*/ + +/*=== CM_D_LUT ROUTINE ===*/ + +/************************************************ +* The following is the model for the * +* digital n-input LUT gate * +* * +* Created 8/25/16 Tim Edwards * +************************************************/ + + +void cm_d_lut(ARGS) + +{ + int i, /* generic loop counter index */ + j, /* lookup index bit value */ + idx, /* lookup index */ + size, /* number of input & output ports */ + tablelen; /* length of table (2^size) */ + + char *table_string; + + Digital_State_t *out, /* temporary output for buffers */ + *out_old, /* previous output for buffers */ + input, /* temp storage for input bits */ + *lookup_table; /* lookup table */ + + /** Retrieve size value and compute table length... **/ + size = PORT_SIZE(in); + tablelen = 1 << size; + + /*** Setup required state variables ***/ + + if (INIT) { /* initial pass */ + + /* allocate storage for the lookup table */ + STATIC_VAR (locdata) = calloc(tablelen, sizeof(Digital_State_t)); + lookup_table = STATIC_VAR (locdata); + + /* allocate storage for the outputs */ + cm_event_alloc(0, sizeof(Digital_State_t)); + cm_event_alloc(1, size * sizeof(Digital_State_t)); + + /* set loading for inputs */ + for (i=0; i..\..\src\xspice\%(RelativeDir);%(AdditionalIncludeDirectories) + + ..\..\src\xspice\%(RelativeDir);%(AdditionalIncludeDirectories) @@ -328,6 +330,8 @@ + +