Keep track of longest shortfall.
This adds six cycles to the TX and RX shortfall paths.
This commit is contained in:
@ -30,6 +30,7 @@ struct m0_state {
|
|||||||
uint32_t m0_count;
|
uint32_t m0_count;
|
||||||
uint32_t m4_count;
|
uint32_t m4_count;
|
||||||
uint32_t num_shortfalls;
|
uint32_t num_shortfalls;
|
||||||
|
uint32_t longest_shortfall;
|
||||||
};
|
};
|
||||||
|
|
||||||
enum m0_mode {
|
enum m0_mode {
|
||||||
|
@ -67,9 +67,9 @@ shadow registers.
|
|||||||
There are four key code paths, with the following worst-case timings:
|
There are four key code paths, with the following worst-case timings:
|
||||||
|
|
||||||
RX, normal: 147 cycles
|
RX, normal: 147 cycles
|
||||||
RX, overrun: 65 cycles
|
RX, overrun: 71 cycles
|
||||||
TX, normal: 133 cycles
|
TX, normal: 133 cycles
|
||||||
TX, underrun: 129 cycles
|
TX, underrun: 135 cycles
|
||||||
|
|
||||||
Design
|
Design
|
||||||
======
|
======
|
||||||
@ -112,6 +112,7 @@ registers and fixed memory addresses.
|
|||||||
.equ M0_COUNT, 0x04
|
.equ M0_COUNT, 0x04
|
||||||
.equ M4_COUNT, 0x08
|
.equ M4_COUNT, 0x08
|
||||||
.equ NUM_SHORTFALLS, 0x0C
|
.equ NUM_SHORTFALLS, 0x0C
|
||||||
|
.equ LONGEST_SHORTFALL, 0x10
|
||||||
|
|
||||||
// Operating modes.
|
// Operating modes.
|
||||||
.equ MODE_IDLE, 0
|
.equ MODE_IDLE, 0
|
||||||
@ -172,6 +173,7 @@ main:
|
|||||||
str zero, [state, #M0_COUNT] // state.m0_count = zero // 2
|
str zero, [state, #M0_COUNT] // state.m0_count = zero // 2
|
||||||
str zero, [state, #M4_COUNT] // state.m4_count = zero // 2
|
str zero, [state, #M4_COUNT] // state.m4_count = zero // 2
|
||||||
str zero, [state, #NUM_SHORTFALLS] // state.num_shortfalls = zero // 2
|
str zero, [state, #NUM_SHORTFALLS] // state.num_shortfalls = zero // 2
|
||||||
|
str zero, [state, #LONGEST_SHORTFALL] // state.longest_shortfall = zero // 2
|
||||||
|
|
||||||
idle:
|
idle:
|
||||||
// Wait for RX or TX mode to be set.
|
// Wait for RX or TX mode to be set.
|
||||||
@ -185,6 +187,7 @@ idle:
|
|||||||
str zero, [state, #M0_COUNT] // state.m0_count = zero // 2
|
str zero, [state, #M0_COUNT] // state.m0_count = zero // 2
|
||||||
str zero, [state, #M4_COUNT] // state.m4_count = zero // 2
|
str zero, [state, #M4_COUNT] // state.m4_count = zero // 2
|
||||||
str zero, [state, #NUM_SHORTFALLS] // state.num_shortfalls = zero // 2
|
str zero, [state, #NUM_SHORTFALLS] // state.num_shortfalls = zero // 2
|
||||||
|
str zero, [state, #LONGEST_SHORTFALL] // state.longest_shortfall = zero // 2
|
||||||
mov shortfall_length, zero // shortfall_length = zero // 1
|
mov shortfall_length, zero // shortfall_length = zero // 1
|
||||||
|
|
||||||
loop:
|
loop:
|
||||||
@ -299,6 +302,13 @@ extend_shortfall:
|
|||||||
add length, #32 // length += 32 // 1
|
add length, #32 // length += 32 // 1
|
||||||
mov shortfall_length, length // shortfall_length = length // 1
|
mov shortfall_length, length // shortfall_length = length // 1
|
||||||
|
|
||||||
|
// Is this now the longest shortfall?
|
||||||
|
longest .req r1
|
||||||
|
ldr longest, [state, #LONGEST_SHORTFALL] // longest = state.longest_shortfall // 2
|
||||||
|
cmp length, longest // if length <= longest: // 1
|
||||||
|
blt loop // goto loop // 1 thru, 3 taken
|
||||||
|
str length, [state, #LONGEST_SHORTFALL] // state.longest_shortfall = length // 2
|
||||||
|
|
||||||
// Return to main loop.
|
// Return to main loop.
|
||||||
b loop // goto loop // 3
|
b loop // goto loop // 3
|
||||||
|
|
||||||
|
@ -389,6 +389,7 @@ static void print_state(hackrf_m0_state *state) {
|
|||||||
printf("M0 count: %u bytes\n", state->m0_count);
|
printf("M0 count: %u bytes\n", state->m0_count);
|
||||||
printf("M4 count: %u bytes\n", state->m4_count);
|
printf("M4 count: %u bytes\n", state->m4_count);
|
||||||
printf("Number of shortfalls: %u\n", state->num_shortfalls);
|
printf("Number of shortfalls: %u\n", state->num_shortfalls);
|
||||||
|
printf("Longest shortfall: %u bytes\n", state->longest_shortfall);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void usage() {
|
static void usage() {
|
||||||
|
@ -1159,11 +1159,12 @@ int main(int argc, char** argv) {
|
|||||||
if (result != HACKRF_SUCCESS)
|
if (result != HACKRF_SUCCESS)
|
||||||
fprintf(stderr, "\nhackrf_get_m0_state() failed: %s (%d)\n", hackrf_error_name(result), result);
|
fprintf(stderr, "\nhackrf_get_m0_state() failed: %s (%d)\n", hackrf_error_name(result), result);
|
||||||
else
|
else
|
||||||
fprintf(stderr, ", %d bytes %s in buffer, %u %s\n",
|
fprintf(stderr, ", %d bytes %s in buffer, %u %s, longest %u bytes\n",
|
||||||
tx ? state.m4_count - state.m0_count : state.m0_count - state.m4_count,
|
tx ? state.m4_count - state.m0_count : state.m0_count - state.m4_count,
|
||||||
tx ? "filled" : "free",
|
tx ? "filled" : "free",
|
||||||
state.num_shortfalls,
|
state.num_shortfalls,
|
||||||
tx ? "underruns" : "overruns");
|
tx ? "underruns" : "overruns",
|
||||||
|
state.longest_shortfall);
|
||||||
} else {
|
} else {
|
||||||
fprintf(stderr, "\n");
|
fprintf(stderr, "\n");
|
||||||
}
|
}
|
||||||
@ -1219,11 +1220,12 @@ int main(int argc, char** argv) {
|
|||||||
"Transfer statistics:\n"
|
"Transfer statistics:\n"
|
||||||
"%lu bytes transferred by M0\n"
|
"%lu bytes transferred by M0\n"
|
||||||
"%lu bytes transferred by M4\n"
|
"%lu bytes transferred by M4\n"
|
||||||
"%u %s\n",
|
"%u %s, longest %u bytes\n",
|
||||||
stats.m0_total,
|
stats.m0_total,
|
||||||
stats.m4_total,
|
stats.m4_total,
|
||||||
state.num_shortfalls,
|
state.num_shortfalls,
|
||||||
(transmit || signalsource) ? "underruns" : "overruns");
|
(transmit || signalsource) ? "underruns" : "overruns",
|
||||||
|
state.longest_shortfall);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -165,6 +165,8 @@ typedef struct {
|
|||||||
uint32_t m4_count;
|
uint32_t m4_count;
|
||||||
/** Number of shortfalls. */
|
/** Number of shortfalls. */
|
||||||
uint32_t num_shortfalls;
|
uint32_t num_shortfalls;
|
||||||
|
/** Longest shortfall. */
|
||||||
|
uint32_t longest_shortfall;
|
||||||
} hackrf_m0_state;
|
} hackrf_m0_state;
|
||||||
|
|
||||||
struct hackrf_device_list {
|
struct hackrf_device_list {
|
||||||
|
Reference in New Issue
Block a user