ext/bridge.c in origen_sim-0.20.6 vs ext/bridge.c in origen_sim-0.20.7

- old
+ new

@@ -27,10 +27,11 @@ int compare_wave; // Index of the compare wave to be used for this pin int drive_wave_pos; // Position of the pin in the drive_wave's active pin array int compare_wave_pos; // Position of the pin in the compare_wave's active pin array int index; // The pin's index in the pins array int previous_state; // Used to keep track of whether the pin was previously driving or comparing + int drive_data; // Used to hold the new drive data for this pin until needed by the drive wave bool capture_en; // Used to indicated when compare data should be captured instead of compared bool present; // Set to true if the pin is present in the testbench } Pin; typedef struct Event { @@ -106,10 +107,11 @@ (*pin).index = index; (*pin).drive_wave = atoi(drive_wave_ix); (*pin).compare_wave = atoi(compare_wave_ix); (*pin).previous_state = 0; (*pin).capture_en = false; + (*pin).drive_data = 0; char * driver = (char *) malloc(strlen(name) + 16); strcpy(driver, ORIGEN_SIM_TESTBENCH_CAT("pins.")); strcat(driver, name); @@ -324,13 +326,19 @@ static void drive_pin(char * index, char * val) { Pin *pin = &pins[atoi(index)]; s_vpi_value v = {vpiIntVal, {0}}; if ((*pin).present) { + // Store the pin drive data to be applied at the data edge + (*pin).drive_data = (val[0] - '0'); + // Apply the data value to the pin's driver - v.value.integer = (val[0] - '0'); - vpi_put_value((*pin).data, &v, NULL, vpiNoDelay); + if (is_drive_whole_cycle(pin)) { + v.value.integer = (*pin).drive_data; + vpi_put_value((*pin).data, &v, NULL, vpiNoDelay); + } + // Make sure not comparing v.value.integer = 0; vpi_put_value((*pin).compare, &v, NULL, vpiNoDelay); // Register it as actively driving with it's wave @@ -429,10 +437,11 @@ /// Callback handler to implement the events registered by register_wave_event PLI_INT32 apply_wave_event_cb(p_cb_data data) { s_vpi_value v = {vpiIntVal, {0}}; s_vpi_value v2 = {vpiIntVal, {0}}; + s_vpi_value v3 = {vpiIntVal, {0}}; int * wave_ix = (int*)(&(data->user_data[0])); int * event_ix = (int*)(&(data->user_data[sizeof(int)])); int * compare = (int*)(&(data->user_data[sizeof(int) * 2])); @@ -484,9 +493,14 @@ on = 1; break; case 'D' : d = 0; on = 1; + // Apply the data value to the pin's driver + for (int i = 0; i < (*wave).active_pin_count; i++) { + v3.value.integer = (*(*wave).active_pins[i]).drive_data; + vpi_put_value((*(*wave).active_pins[i]).data, &v3, NULL, vpiNoDelay); + } break; case 'X' : d = 0; on = 0; break;