Skip to content

Commit

Permalink
Support energy monitor with --fifo; reduce APB wait states on MAX78002 (
Browse files Browse the repository at this point in the history
  • Loading branch information
Robert Muchsel authored Jun 16, 2022
1 parent 4f4ddc5 commit 09bcb29
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 11 deletions.
29 changes: 19 additions & 10 deletions izer/toplevel.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,10 +171,13 @@ def header(
memfile.write(' // Acknowledge interrupt to all quadrants\n')
for _, group in enumerate(groups):
addr = tc.dev.APB_BASE + tc.ctl_addr(group, tc.dev.REG_CTL)
memfile.write(f' *((volatile uint32_t *) 0x{addr:08x}) &= ')
if oneshot > 0 and not tc.dev.REQUIRE_ONESHOT_CLEAR:
memfile.write(f' *((volatile uint32_t *) 0x{addr:08x}) &= ~(1<<12);\n')
memfile.write('~(1<<12);\n')
elif any(state.streaming):
memfile.write('~((1<<12) | (1<<14) | 1);\n')
else:
memfile.write(f' *((volatile uint32_t *) 0x{addr:08x}) &= ~((1<<12) | 1);\n')
memfile.write('~((1<<12) | 1);\n')
memfile.write('\n')
if embedded_code and not state.measure_energy:
memfile.write(' CNN_COMPLETE; // Signal that processing is complete\n')
Expand Down Expand Up @@ -627,12 +630,18 @@ def main(
' for (i = 0; i < 100; i++)\n'
' cnn_load_weights(); // Load kernels\n'
' CNN_COMPLETE;\n\n'
' printf("Measuring input loading...\\n");\n'
' MXC_TMR_Delay(MXC_TMR0, 500000);\n'
' CNN_START;\n'
' for (i = 0; i < 100; i++)\n'
' load_input(); // Load data input\n'
' CNN_COMPLETE;\n\n')
' MXC_TMR_Delay(MXC_TMR0, 500000);\n')
if not fifo:
memfile.write(' printf("Measuring input loading...\\n");\n'
' CNN_START;\n'
' for (i = 0; i < 100; i++)\n'
' load_input(); // Load data input\n'
' CNN_COMPLETE;\n\n')
else:
memfile.write(' printf("Skipping input loading (using FIFO)...\\n");\n'
' CNN_START;\n'
' MXC_TMR_Delay(MXC_TMR0, 10); // Dummy delay displays as 0\n'
' CNN_COMPLETE;\n\n')
else:
memfile.write(' cnn_load_weights(); // Load kernels\n')
if state.verify_kernels:
Expand Down Expand Up @@ -687,8 +696,8 @@ def main(
else:
memfile.write(' cnn_wait();\n\n')
else:
memfile.write(' printf("Measuring input load + inference...\\n");\n'
' MXC_TMR_Delay(MXC_TMR0, 500000);\n'
memfile.write(' MXC_TMR_Delay(MXC_TMR0, 500000);\n'
' printf("Measuring input load + inference...\\n");\n'
' CNN_START; // Allow capture of processing time\n'
' for (i = 0; i < 100; i++) {\n')
if not fifo:
Expand Down
2 changes: 1 addition & 1 deletion izer/tornadocnn.py
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ class DevAI87(Dev):
AON_CTL = 1024

READY_SEL = 0
PIPELINE_READY_SEL = 3
PIPELINE_READY_SEL = 0
FIFO_READY_SEL = 0
AON_READY_SEL = 0

Expand Down

0 comments on commit 09bcb29

Please sign in to comment.