Skip to content

Commit

Permalink
Merge pull request #55 from PandABlocks/no-min-time
Browse files Browse the repository at this point in the history
Remove support for .MIN value on time fields
  • Loading branch information
tomtrafford authored Apr 11, 2024
2 parents 6422090 + 730fddb commit ee4c352
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 55 deletions.
8 changes: 2 additions & 6 deletions docs/config.rst
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ Field
``param`` field-subtype [ ``=`` value ]
``read`` field-subtype
``write`` field-subtype
``time`` [ ``>`` min_value ]
``time``
``bit_out``
``pos_out`` [ scale [ offset [ units ]]]
``ext_out`` ( ``timestamp`` | ``samples`` | ``bits`` group )
Expand All @@ -96,14 +96,10 @@ Field
actions on a block. The `field-subtype` must be specified, and the `action`
subtype is useful for ``write`` fields which take no data.

``time`` [ ``>`` min_value ]
``time``
Time fields behave like ``param`` fields, but need special treatment because
the underlying value is 64-bits and so two registers need to be written.

If desired a minimum valid value can be specified as `min_value`. This will
prevent the writing of values less than this value and can be read as the
``.MIN`` attribute.

``bit_out``
This identifies an output bit.

Expand Down
5 changes: 0 additions & 5 deletions docs/fields.rst
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,6 @@ Field type Description
This attribute can be read or written to report or set the delay in FPGA
ticks.

``MIN``
This reports the minimum valid value for this field in the currently
selected units.

The ``UNITS`` attribute determines how numbers read or written to the field
are interpreted. For example::

Expand Down Expand Up @@ -466,7 +462,6 @@ scalar RAW Underlying integer value R W
lut RAW Computed Lookup Table 32-bit value R
time UNITS Units and scaling selection for time R W C
\ RAW Raw time in FPGA clock cycles R W
\ MIN Minimum valid setting (for type only) R
bit_out CAPTURE_WORD Capturable word containing this bit R
\ OFFSET Offset of this bit in captured word R
bit_mux DELAY Bit input delay in FPGA ticks R W C
Expand Down
4 changes: 2 additions & 2 deletions python/sim_config/registers
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ DIV 9
COUNT 4

PULSE 10
DELAY 3 2 >3
WIDTH 5 4 >3
DELAY 3 2
WIDTH 5 4
INP 0 11
ENABLE 1 12
OUT 30 31 32 33
Expand Down
57 changes: 15 additions & 42 deletions server/time.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,6 @@ struct time_class_state {
unsigned int count; // Number of instances of this block
pthread_mutex_t mutex; // Interlock for block access

/* If min_value is set then the range of values [1..min_value] will be
* forbidden. This is used to assist the hardware. */
uint64_t min_value; // Minimum valid value less 1

struct time_field {
unsigned int time_scale; // Scaling factor selection (enum ix)
uint64_t value; // Current value
Expand Down Expand Up @@ -104,11 +100,7 @@ static error__t time_parse_register(
return
check_parse_register(field, line, &state->low_register) ?:
parse_whitespace(line) ?:
check_parse_register(field, line, &state->high_register) ?:
IF(**line != '\0',
parse_whitespace(line) ?:
parse_char(line, '>') ?:
parse_uint64(line, &state->min_value));
check_parse_register(field, line, &state->high_register);
}


Expand Down Expand Up @@ -142,23 +134,20 @@ static error__t write_time_value(
void *class_data, unsigned int number, uint64_t value)
{
struct time_class_state *state = class_data;
error__t error =
TEST_OK_(value == 0 || value > state->min_value, "Value too small");
if (!error)
WITH_MUTEX(state->mutex)
{
hw_write_register(
state->block_base, number, state->low_register,
(uint32_t) value);
hw_write_register(
state->block_base, number, state->high_register,
(uint32_t) (value >> 32));

struct time_field *field = &state->values[number];
field->value = value;
field->update_index = get_change_index();
}
return error;
WITH_MUTEX(state->mutex)
{
hw_write_register(
state->block_base, number, state->low_register,
(uint32_t) value);
hw_write_register(
state->block_base, number, state->high_register,
(uint32_t) (value >> 32));

struct time_field *field = &state->values[number];
field->value = value;
field->update_index = get_change_index();
}
return ERROR_OK;
}


Expand Down Expand Up @@ -283,19 +272,6 @@ static error__t time_class_units_put(
}


static error__t time_min_format(
void *owner, void *class_data, unsigned int number,
char result[], size_t length)
{
struct time_class_state *state = class_data;
struct time_field *field = &state->values[number];
return format_double(
result, length,
(double) (state->min_value + 1) /
time_conversion[field->time_scale] / hw_read_nominal_clock());
}


/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* Time. */

Expand Down Expand Up @@ -407,9 +383,6 @@ const struct class_methods time_class_methods = {
.put = time_class_units_put,
.get_enumeration = time_units_get_enumeration,
},
{ "MIN", "Minimum programmable time",
.format = time_min_format,
},
),
};

Expand Down

0 comments on commit ee4c352

Please sign in to comment.