Fixed two minor issues in bx_param_num_c class.

- reset() must call set() to ensure the set handler is called if present.
- don't set value if parameter is disabled.
This commit is contained in:
Volker Ruppert 2021-03-28 06:31:03 +00:00
parent dc9c93f0c5
commit 0ccf537103
2 changed files with 3 additions and 1 deletions

View File

@ -231,6 +231,8 @@ Bit64s bx_param_num_c::get64()
void bx_param_num_c::set(Bit64s newval) void bx_param_num_c::set(Bit64s newval)
{ {
if (!enabled) return;
if (handler) { if (handler) {
// the handler can override the new value and/or perform some side effect // the handler can override the new value and/or perform some side effect
val.number = (*handler)(this, 1, newval); val.number = (*handler)(this, 1, newval);

View File

@ -211,7 +211,7 @@ public:
const char *description, const char *description,
Bit64s min, Bit64s max, Bit64s initial_val, Bit64s min, Bit64s max, Bit64s initial_val,
bool is_shadow = 0); bool is_shadow = 0);
virtual void reset() { val.number = initial_val; } virtual void reset() { set(initial_val); }
void set_handler(param_event_handler handler); void set_handler(param_event_handler handler);
void set_sr_handlers(void *devptr, param_save_handler save, param_restore_handler restore); void set_sr_handlers(void *devptr, param_save_handler save, param_restore_handler restore);
void set_enable_handler(param_enable_handler handler) { enable_handler = handler; } void set_enable_handler(param_enable_handler handler) { enable_handler = handler; }