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.

This commit is contained in:
Brian Taylor 2023-10-10 15:41:06 -07:00 committed by Holger Vogt
parent 307ba1985b
commit df28fabc42
3 changed files with 43 additions and 20 deletions

View File

@ -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,

View File

@ -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;
if (process->N_din > 0) {
memcpy(packet.din, din, process->N_din); 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)); 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)); din = (uint8_t *)malloc(local_process->N_din * sizeof(uint8_t));
memset(din, 0, local_process->N_din); 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); if (din) free(din);
free(dout); if (dout) free(dout);
} }
else { else {
for (i=0; i<PORT_SIZE(out); i++) { for (i=0; i<PORT_SIZE(out); i++) {

View File

@ -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 Parameter_Name: clk_delay reset_delay
Description: "delay from CLK" Description: "delay from CLK" "delay from reset"
Data_Type: real Data_Type: real real
Default_Value: 1.0e-9 Default_Value: 1.0e-9 1.0e-9
Limits: - Limits: - -
Vector: no Vector: no no
Vector_Bounds: - Vector_Bounds: - -
Null_Allowed: yes 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