Skip to content

Commit

Permalink
Add simbus vector binary reset mechanism.
Browse files Browse the repository at this point in the history
Signed-off-by: Rule Timothy (VM/EMT3) <[email protected]>
  • Loading branch information
timrulebosch committed Aug 8, 2024
1 parent ba4730a commit 85f6c4b
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 0 deletions.
27 changes: 27 additions & 0 deletions dse/modelc/adapter/adapter_loopb.c
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,7 @@ static int adapter_loopb_model_ready(AdapterModel* am)
&sc->vector.buffer_size[*sc_index], sv->bin, sv->bin_size);
log_simbus(" SignalValue: %u = <binary> (len=%u) [name=%s]",
sv->uid, sv->bin_size, sv->name);
/* Indicate the binary object was consumed. */
sv->bin_size = 0;
} else if (sv->val != sv->final_val) {
sc->vector.scalar[*sc_index] = sv->final_val;
Expand Down Expand Up @@ -378,3 +379,29 @@ SimbusVectorIndex simbus_vector_lookup(
}
return index;
}


static int _binary_reset(void* map_item, void* data)
{
UNUSED(data);

SimbusChannel* sc = map_item;
if (sc) {
for (uint32_t i = 0; i < sc->vector.count; i++) {
sc->vector.length[i] = 0;
}
}
return 0;
}

void simbus_vector_binary_reset(SimulationSpec* sim)
{
assert(sim);
Controller* controller = controller_object_ref();
assert(controller);
assert(controller->adapter);
if (controller->adapter->vtable == NULL) return;

AdapterLoopbVTable* v = (AdapterLoopbVTable*)controller->adapter->vtable;
hashmap_iterator(&v->channels, _binary_reset, false, NULL);
}
1 change: 1 addition & 0 deletions dse/modelc/adapter/simbus/simbus.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ DLL_PUBLIC void simbus_adapter_run(Adapter* adapter);
/* adapter_loopb.c (in parent directory) */
DLL_PUBLIC SimbusVectorIndex simbus_vector_lookup(
SimulationSpec* sim, const char* vname, const char* sname);
DLL_PUBLIC void simbus_vector_binary_reset(SimulationSpec* sim);


#endif // DSE_MODELC_ADAPTER_SIMBUS_SIMBUS_H_
1 change: 1 addition & 0 deletions dse/modelc/runtime.h
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ typedef struct {
double step_size;
double end_time;
double step_time_correction;
bool binary_signals_reset;
} runtime;
} RuntimeModelDesc;

Expand Down

0 comments on commit 85f6c4b

Please sign in to comment.