Browse Source

Restore the deleted unused params to be backword compatible. Handle the case where the d_process instance has a null in vector, so that N_din is zero. This allows the model to be just a pattern generator. Add include to cmproto.h to avoid a forward ref. to an enum type.

pre-master-46
Brian Taylor 3 years ago
committed by Holger Vogt
parent
commit
df28fabc42
  1. 1
      src/include/ngspice/cmproto.h
  2. 29
      src/xspice/icm/digital/d_process/cfunc.mod
  3. 33
      src/xspice/icm/digital/d_process/ifspec.ifs

1
src/include/ngspice/cmproto.h

@ -49,6 +49,7 @@ NON-STANDARD FEATURES
#include <stdio.h> #include <stdio.h>
#include "ngspice/cmtypes.h" #include "ngspice/cmtypes.h"
#include "ngspice/cktdefs.h" #include "ngspice/cktdefs.h"
#include "ngspice/cpextern.h"
void cm_climit_fcn(double in, double in_offset, double cntl_upper, void cm_climit_fcn(double in, double in_offset, double cntl_upper,

29
src/xspice/icm/digital/d_process/cfunc.mod

@ -80,9 +80,6 @@ MODIFICATIONS
For Windows VisualC and Mingw the pipes use binary mode, and For Windows VisualC and Mingw the pipes use binary mode, and
named pipes or fifos are not supported. named pipes or fifos are not supported.
8 October 2023 Brian Taylor
Remove reset_delay param from ifspec.ifs since the clk_delay
is used with synchronous reset.
REFERENCED FILES REFERENCED FILES
@ -191,7 +188,11 @@ static void dprocess_exchangedata(Process_t * process, double time, uint8_t din[
int wlen = 0; int wlen = 0;
packet_t packet; packet_t packet;
packet.time = time; packet.time = time;
memcpy(packet.din, din, process->N_din);
if (process->N_din > 0) {
memcpy(packet.din, din, process->N_din);
} else {
packet.din[0] = 0;
}
#if defined(_MSC_VER) || defined(__MINGW64__) #if defined(_MSC_VER) || defined(__MINGW64__)
wlen = _write(process->pipe_to_child, &packet, sizeof(double) + process->N_din); wlen = _write(process->pipe_to_child, &packet, sizeof(double) + process->N_din);
@ -338,6 +339,12 @@ void cm_d_process(ARGS)
#endif #endif
sendheader(local_process, PORT_SIZE(in), PORT_SIZE(out)); sendheader(local_process, PORT_SIZE(in), PORT_SIZE(out));
if (PORT_SIZE(in) == 0) {
if (local_process->N_din != 0) {
fprintf(stderr, "Error: in port size mismatch\n");
exit(1);
}
}
for (i=0; i<PORT_SIZE(in); i++) { for (i=0; i<PORT_SIZE(in); i++) {
LOAD(in[i]) = PARAM(input_load); LOAD(in[i]) = PARAM(input_load);
} }
@ -377,11 +384,13 @@ void cm_d_process(ARGS)
} }
if (*clk != *clk_old && ONE == *clk) { if (*clk != *clk_old && ONE == *clk) {
uint8_t *dout, *din;
uint8_t *dout = NULL, *din = NULL;
uint8_t b; uint8_t b;
dout = (uint8_t *) malloc(local_process->N_dout * sizeof(uint8_t));
din = (uint8_t *) malloc(local_process->N_din * sizeof(uint8_t));
memset(din, 0, local_process->N_din);
dout = (uint8_t *)malloc(local_process->N_dout * sizeof(uint8_t));
if (local_process->N_din > 0) {
din = (uint8_t *)malloc(local_process->N_din * sizeof(uint8_t));
memset(din, 0, local_process->N_din);
}
for (i=0; i<PORT_SIZE(in); i++) { for (i=0; i<PORT_SIZE(in); i++) {
switch(INPUT_STATE(in[i])) { switch(INPUT_STATE(in[i])) {
@ -411,8 +420,8 @@ void cm_d_process(ARGS)
OUTPUT_CHANGED(out[i]) = FALSE; OUTPUT_CHANGED(out[i]) = FALSE;
} }
} }
free(din);
free(dout);
if (din) free(din);
if (dout) free(dout);
} }
else { else {
for (i=0; i<PORT_SIZE(out); i++) { for (i=0; i<PORT_SIZE(out); i++) {

33
src/xspice/icm/digital/d_process/ifspec.ifs

@ -34,7 +34,7 @@ Default_Type: d d
Allowed_Types: [d] [d] Allowed_Types: [d] [d]
Vector: yes no Vector: yes no
Vector_Bounds: - - Vector_Bounds: - -
Null_Allowed: no no
Null_Allowed: yes no
PORT_TABLE: PORT_TABLE:
@ -47,21 +47,21 @@ Default_Type: d d
Allowed_Types: [d] [d] Allowed_Types: [d] [d]
Vector: no yes Vector: no yes
Vector_Bounds: - [1 -] Vector_Bounds: - [1 -]
Null_Allowed: yes no
Null_Allowed: yes yes
PARAMETER_TABLE: PARAMETER_TABLE:
Parameter_Name: clk_delay
Description: "delay from CLK"
Data_Type: real
Default_Value: 1.0e-9
Limits: -
Vector: no
Vector_Bounds: -
Null_Allowed: yes
Parameter_Name: clk_delay reset_delay
Description: "delay from CLK" "delay from reset"
Data_Type: real real
Default_Value: 1.0e-9 1.0e-9
Limits: - -
Vector: no no
Vector_Bounds: - -
Null_Allowed: yes yes
PARAMETER_TABLE: PARAMETER_TABLE:
@ -93,6 +93,19 @@ Null_Allowed: yes
PARAMETER_TABLE: PARAMETER_TABLE:
Parameter_Name: reset_state
Description: "default state on RESET & at DC"
Data_Type: int
Default_Value: 0
Limits: -
Vector: no
Vector_Bounds: -
Null_Allowed: no
PARAMETER_TABLE:
Parameter_Name: input_load Parameter_Name: input_load
Description: "input loading capacitance (F)" Description: "input loading capacitance (F)"
Data_Type: real Data_Type: real

Loading…
Cancel
Save