Worked System: A Sensor Hub

A phone counts steps all day while its large processor sleeps. A small chip beside it, the sensor hub, does the work. This page designs one on the review board, column by column.

You Will Be Able To

  • Turn four sensor streams into bytes a second, a batch size and an interrupt count.
  • Size the batch storage two ways, and say why a ring needs half the SRAM of a double buffer.
  • Choose the slowest clock that meets the load, and show why it forces DMA on the host link.
Lesson
S11.10
Time
30 min
Runs on
Your browser
Check
5 questions

Every 62.5 ms, one reading of how the phone turns goes missing. The reading of how it moves comes over the same wires, at the same rate, and never does.

Nothing is broken. Which number did nobody write down?

Before You Start

You need Design Reviews: "Design This SoC": the eight columns of the board.

You need Serial Peripherals: SPI, I2C and Their Pins and DMA.

You need the watermark of Serial Peripherals: The UART: a request raised when a queue holds a set number of items.

Five questions this page answers
Question
1How do four sensors become one rate in bytes a second?
2Why does a ring need about half the SRAM of a double buffer?
3Why does the second sensor on a shared bus need a deeper FIFO?
4Why does the slowest good clock force DMA on the host link?
5The sensor bus runs twice as fast. What does the lab print last?

The Idea: A Small Chip That Stays Awake

A large processor uses a lot of power just by being awake. A sensor hub is a small chip that stays awake in its place. It collects sensor readings and stores them.

Every few seconds it hands a whole batch to the large processor, the host processor, or host for short. The host wakes, takes the batch and sleeps again.

The first idea is a table of streams. Each sensor gives a sample of a few bytes, many times a second. Add a tag to each record, and the table gives bytes a second.

The second idea is where the data waits. It waits first in a FIFO inside each sensor, then in a batch in the SRAM of the hub. Both must be sized.

The third idea is that the clock comes last. It should be as slow as the work allows, to save power. A slow clock then rules some jobs out for the core, and those jobs need hardware.

New Words

New words on this page
WordMeaning
Sensor hubA small, always-on chip that collects sensor readings so that a larger processor can sleep.
Host processorThe processor that the hub serves, called the host for short. Here it is the application processor of a phone.
Accelerometer, gyroscope, magnetometerSensors of motion, of turning and of the magnetic field. Each gives three values, of 2 bytes each.
Pressure sensorA sensor of air pressure, used for height. It gives one value of 3 bytes here.
Record tagTwo bytes stored with each sample: which sensor, and the time since the last record.
BatchThe records stored between two visits of the host. The host takes a whole batch at once.
Sensor FIFOA small queue of samples inside a sensor. It can raise a request when it reaches a watermark.
Double bufferTwo batch spaces. The hub fills one while the host reads the other, then they swap.
Ring bufferOne space that the hub writes round and round. The reader follows behind, and the writer must never pass it.
Host SPI targetThe SPI port of the hub that faces the host. It answers the host and uses the clock the host drives.

One Picture: The Board, Filled for a Hub

The Board of the Sensor HubStep through the board. The entries are those of this page; every number comes from the sizing sheet below.
  • File
  • Processor
  • Memory
  • Clock / reset
  • Control / FSM
  • Power
  • Debug
  • Report
The Board of the Sensor HubStep through the board. The entries are those of this page; every number comes from the sizing sheet below. component Requirements four sensors, 925samples a second;7325 B/s with tags;a batch every 2 s component Block diagram core, SPI and I2C tothe sensors, a SPItarget and DMA tothe host, timer,SRAM component Memory map ap_soc map; I2C at1000_8000, hostSPI at 1000_9000;SRAM of 32 KiB component Clocks and resets RC oscillator 25 MHz÷ 16 = 1.5625 MHz;one reset, plus a lineto the host component Interrupts 157 requests asecond withwatermarks, not 925;eight source numbers component Power modes run 24 percent, sleepthe rest; SRAMstays powered; about398 µW component Debug JTAG from reset; alost-sample counterfor each sensor; alate-read flag component Risks load 24 of 25percent; gyroscopeFIFO 26 of 32; theI2C bus can hang what to buildwhat to placewhat to timewhat to countwhen to wakewhat to seewhat is thinchange and run again
  1. component Requirementsfour sensors, 925 samples a second; 7325 B/s with tags; a batch every 2 s
    • what to build → Block diagram
  2. component Block diagramcore, SPI and I2C to the sensors, a SPI target and DMA to the host, timer, SRAM
    • what to place → Memory map
  3. component Memory mapap_soc map; I2C at 1000_8000, host SPI at 1000_9000; SRAM of 32 KiB
    • what to time → Clocks and resets
  4. component Clocks and resetsRC oscillator 25 MHz ÷ 16 = 1.5625 MHz; one reset, plus a line to the host
    • what to count → Interrupts
  5. component Interrupts157 requests a second with watermarks, not 925; eight source numbers
    • when to wake → Power modes
  6. component Power modesrun 24 percent, sleep the rest; SRAM stays powered; about 398 µW
    • what to see → Debug
  7. component DebugJTAG from reset; a lost-sample counter for each sensor; a late-read flag
    • what is thin → Risks
  8. component Risksload 24 of 25 percent; gyroscope FIFO 26 of 32; the I2C bus can hang
    • change and run again → Requirements
  1. 1. Requirements

    Four streams, each with a size and a rate. A 2-byte tag goes with every record. The host takes a batch every 2 seconds.

  2. 2. Block diagram

    One block for each job: two sensor buses and a timer for the tags. The host link moves the batch without the core.

  3. 3. Memory map

    The two new controllers take the first pages of the expansion reserve. The ring of 14,758 bytes needs 32 KiB of SRAM.

  4. 4. Clocks and resets

    The slowest clock that keeps the load under 25 percent. The host sees the reset of the hub, so it knows a batch was lost.

  5. 5. Interrupts

    The accelerometer and gyroscope ask once for every 25 samples. The other two ask for each sample.

  6. 6. Power modes

    The core sleeps between requests. Deep sleep would lose the ring, so it is used only when no batch is kept.

  7. 7. Debug

    A missing sample must leave a mark. Counters show which sensor lost data and whether the host came late.

  8. 8. Risks

    Each thin number is listed with a test. A faster clock, a lower watermark or a bus-recovery routine would retire one.

Read the diagram as text
  • Requirements: four sensors, 925 samples a second; 7325 B/s with tags; a batch every 2 s
  • Block diagram: core, SPI and I2C to the sensors, a SPI target and DMA to the host, timer, SRAM
  • Memory map: ap_soc map; I2C at 1000_8000, host SPI at 1000_9000; SRAM of 32 KiB
  • Clocks and resets: RC oscillator 25 MHz ÷ 16 = 1.5625 MHz; one reset, plus a line to the host
  • Interrupts: 157 requests a second with watermarks, not 925; eight source numbers
  • Power modes: run 24 percent, sleep the rest; SRAM stays powered; about 398 µW
  • Debug: JTAG from reset; a lost-sample counter for each sensor; a late-read flag
  • Risks: load 24 of 25 percent; gyroscope FIFO 26 of 32; the I2C bus can hang
  • Requirements → Block diagram: what to build
  • Block diagram → Memory map: what to place
  • Memory map → Clocks and resets: what to time
  • Clocks and resets → Interrupts: what to count
  • Interrupts → Power modes: when to wake
  • Power modes → Debug: what to see
  • Debug → Risks: what is thin
  • Risks → Requirements: change and run again

The eight columns of S11.4, filled for the hub. The next two pages fill the same board for very different products.

The Smallest Example, Worked by Hand

No simulator yet. Start with column 1, the streams. Every record is the sample plus a tag of 2 bytes.

Four streams, by hand
SensorBusSampleRateRecord × rate
AccelerometerSPI6 bytes400 a second8 × 400 = 3200 B/s
GyroscopeSPI6 bytes400 a second8 × 400 = 3200 B/s
MagnetometerI2C6 bytes100 a second8 × 100 = 800 B/s
Pressure sensorI2C3 bytes25 a second5 × 25 = 125 B/s
All four925 samples7325 B/s

The host comes every 2 seconds, so a batch holds 14,650 bytes. Now size the storage two ways.

Where the batch waits, by hand
PlanSumBytes
Double buffer2 × 14,65029,300
Ring buffer: one batch14,65014,650
... plus what arrives during the read14,650 × 8 bits ÷ 8 Mb/s = 14,650 µs; 7325 B/s × 14,650 µs = 107.3108
Ring buffer in all14,650 + 10814,758

Last, the interrupts of column 5. One request for every sample is 925 a second. With a watermark of 25 on the two motion sensors, each asks 400 ÷ 25 = 16 times. The total is 16 + 16 + 100 + 25 = 157.

The Rules

  1. Rule 1: Count the record, not the sample.

    The tag travels with every sample. Leave it out and every later column is short.

  2. Rule 2: A watermark trades requests for depth.

    Fewer requests mean more samples waiting in the sensor. The FIFO must hold the watermark plus what arrives before it is read.

  3. Rule 3: On a shared bus, the second reader waits.

    Size each FIFO for the wait behind the readers served before it, not only for its own read.

  4. Rule 4: A ring holds one batch plus the read.

    The writer keeps going while the host reads. Only what arrives during the read needs extra room.

  5. Rule 5: Choose the slowest clock that meets the load, then check every byte-rate job.

    A job that needs a few cycles for each byte is moved to hardware, here to DMA.

  6. Rule 6: Data that must survive a sleep stays powered.

    The ring lives in SRAM, so the hub may sleep but not lose the SRAM supply while a batch is kept.

Sources for These Rules

A DMA moves data without the core: DMA. A request raised at a watermark: Serial Peripherals: The UART.

Every sensor size, rate, watermark and cycle count is an exercise value, not a part's data sheet. The I2C cost of 9 bits a byte, plus 3 for start and stop, is a budget rule of this page. It is not checked against the I2C specification.

Sensor hubs beside phone processors, batching, and the ring against the double buffer are common practice. No book in our library describes them.

Now Run It: The Sizing Sheet

The lab at the end of this page is the sizing sheet of the hub. It works out every number on the board. Its last row comes from a run of the two sensor FIFOs.

Printed by the lab on Icarus: the sizing sheet of the sensor hub.
records   rate=7325 B/s  batch=14650 B  samples=925/s
links     sensor_spi=8%  i2c=2%  host_read=14650 us
clock     work=379420 cycles/s  need=1517680 Hz  core=1562500 Hz (divide by 16)  load=24%
irq       one_per_sample=925/s  with_watermark=157/s
buffer    double=29300 B  ring=14758 B  (arrive during a read: 108 B)
memory    ring: need=17830 sram=32768 spare=45%   double: need=32372 sram=32768 spare=1%
power     awake=24%  average=398 uW
host      core_cycles_per_byte=1  dma_needed=1
fifo      read_per_sample=112 us  max_fill: accelerometer=25 gyroscope=26

Rule 1, in the first row: 7325 bytes a second and a batch of 14,650, as in the hand table.

The links row. The motion sensors use 8 percent of their SPI bus, and the I2C sensors 2 percent. The host needs 14,650 µs to read a batch.

Rule 5, in the clock row. The work is 379,420 cycles a second. Under a 25 percent cap, the core needs 1,517,680 Hz. The RC oscillator divided by 16 gives 1,562,500 Hz, just enough.

Rule 5 again, in the host row. At that clock the core has one cycle for each byte of the host link. No program moves a byte in one cycle. The batch goes by DMA.

Rule 4, in the buffer and memory rows. The ring fits 32 KiB with 45 percent spare. The double buffer fits too, with 1 percent spare. That is a risk, not a plan.

Rules 2 and 3, in the last row. Each sample takes 112 µs on the sensor bus, so 25 samples take 2800 µs. The gyroscope waits behind the accelerometer.

A gyroscope sample arrives every 2500 µs. One arrives during the wait, so its FIFO reaches 26. A FIFO of 25 places would drop that sample, once every 62.5 ms.

This lab leaves things out. Its sensors are counters, its buses are delays, and its power numbers are exercise values. No sensor or SPI controller is modelled.

The Rest of the Board

Columns 3 to 8 need decisions as well as numbers. Here they are, column by column.

Column 3: the memory map
BlockBaseSizeWhy there
Boot ROM, CLINT, PLIC, UART0 to DMAas in ap_socas in ap_socOld firmware and tools keep working.
I2C controller1000_80004 KiBThe first page of the expansion reserve.
Host SPI target1000_90004 KiBThe next page; the DMA writes each batch into it.
SRAM8000_000032 KiBThe ring and stack need 17,830 bytes. 16 KiB is too small.
Columns 4 and 5: clocks, resets and interrupts
EntryChoiceReason
Core clockRC oscillator ÷ 16The slowest that meets the load. The bus and peripherals share it.
Resetone reset domain; a reset line out to the hostAfter a reset the host must know that the batch is gone.
Sources 1 to 6as in ap_soc; GPIO carries the four data-ready pinsEach sensor pin raises a GPIO request.
Source 7I2C controllerA transfer is done, or the bus is stuck.
Source 8Host SPI targetThe host has started or ended a read.
Columns 6, 7 and 8: power, debug and risks
EntryChoiceReason
Power modesrun; sleep with every supply on; deep sleep only with no batch keptDeep sleep would cut the SRAM and lose the ring.
DebugJTAG from reset; a lost-sample counter for each sensor; a late-read flagA missing sample must leave a mark the host can read.
Risk: load24 percent against a cap of 25Measure the real handlers. Divide by 8 if they are slower.
Risk: FIFOgyroscope 26 of 32 placesRetest whenever the watermark or the bus speed changes.
Risk: I2Ca sensor can hold the data wire lowA routine that clocks the bus free, and a counter of its use.

Why It Is Built This Way

ChoiceThe alternativeWhat it buys, and what it costs
A ring bufferA double bufferHalf the SRAM. The cost is two pointers and a rule that the writer never passes the reader.
Watermarks on the motion sensorsA request for every sample157 requests a second in place of 925, so the core sleeps longer. The FIFOs must be deeper.
DMA to the hostThe core copies the batchThe only way at 1.5625 MHz. The cost is a DMA channel and a source number.
A slow clockA fast clock, then a long sleepLess power while running. A fast clock might save energy if sleep is very cheap. This lab does not measure that.

The Trap: A FIFO Sized to Its Own Read

This is the hook. The gyroscope FIFO was given 25 places, the watermark. That is enough for its own read. It is not enough for the wait behind the accelerometer.

So one gyroscope sample was dropped every 62.5 ms. The lost-sample counter of column 7 showed it, and rule 3 explains it.

The second trap is the double buffer. It fits 32 KiB, so it passed review. With 1 percent spare, the first larger stack broke it.

The third trap is the slow clock. It met the load, so the host link was left to the core. The core had one cycle for each byte.

At Scale

This page4 sensors, 1 host
A phone huba dozen sensors, wake words

This section looks ahead, to the hubs inside phones and watches.

  1. The hub thinks

    Real hubs run step counting, orientation and gesture detection. They wake the host only for an event, not on a timer.

  2. More streams, same sums

    Each new sensor is one more row of the stream table. The columns to its right are run again.

  3. A product of its own

    The hub gets its own firmware, updated by the host. Its boot and its debug lock follow Secure Boot.

Try It

Run the lab. Find the rows that give a clock, a buffer depth, an interrupt count and a memory size.

Set BATCH_MS to 1000. Which rows change? Which memory plan now fits 16 KiB?

Set WATERMARK to 30. Watch both the interrupt count and the gyroscope fill. A sensor FIFO of 32 places is the limit.

Names Printed by the Lab
NameMeaning
rate, batch, samplesBytes stored each second with their tags; bytes in one batch; samples taken each second.
sensor_spi, i2cThe share of each sensor bus that the readings use.
host_readThe time to send one batch to the host over its SPI link.
work, need, core, loadCore cycles each second; the clock that would use exactly 25 percent; the clock chosen; the share it uses.
one_per_sample, with_watermarkInterrupt requests each second, without and with sensor watermarks.
double, ringThe batch storage as two whole batches, or as one batch plus what arrives during a read.
need, sram, spareStorage plus 2048 bytes of stack and 1024 of driver data; the power of two that holds it; the share left.
awake, averageThe share of time the core runs, and the average power at 1500 µW running and 50 µW asleep.
core_cycles_per_byte, dma_neededCore cycles for each byte of the host link; 1 when that is fewer than 20.
read_per_sample, max_fillThe time to read one sample over the sensor SPI bus, and the most samples each FIFO held during the run.
RUNIcarus Verilog · in your browser
Edit the code, then run it
Expected: records rate=7325 B/s batch=14650 B samples=925/s links sensor_spi=8% i2c=2% host_read=14650 us clock work=379420 cycles/s need=1517680 Hz core=1562500 Hz (divide by 16) load=24% irq one_per_sample=925/s with_watermark=157/s buffer double=29300 B ring=14758 B (arrive during a read: 108 B) memory ring: need=17830 sram=32768 spare=45% double: need=32372 sram=32768 spare=1% power awake=24% average=398 uW host core_cycles_per_byte=1 dma_needed=1 fifo read_per_sample=112 us max_fill: accelerometer=25 gyroscope=26

Check Yourself

Predict the outputIn this run the sensor SPI bus runs at 1 MHz in place of 500 kHz. What is the last line? Its form is: fifo read_per_sample=.. us max_fill: accelerometer=.. gyroscope=..
// The sizing sheet of a sensor hub. Test code: arithmetic, and one small run of two sensor FIFOs.
// Every number is an exercise value. Change a requirement and run the sheet again.
module tb;
  // ---- Requirements -------------------------------------------------------------------------------------
  parameter int ACC_B = 6, ACC_HZ = 400, GYR_B = 6, GYR_HZ = 400;   // on the sensor SPI bus
  parameter int MAG_B = 6, MAG_HZ = 100, PRS_B = 3, PRS_HZ = 25;    // on the I2C bus
  parameter int TAG_B = 2, BATCH_MS = 2000;       // a tag on each stored record; the host reads a batch this often
  parameter int HOST_SPI_HZ = 8000000, SENSOR_SPI_HZ = 1000000, I2C_HZ = 400000;
  // ---- Choices of this design ---------------------------------------------------------------------------
  parameter int WATERMARK = 25;                  // accelerometer and gyroscope interrupt every WATERMARK samples
  parameter int WORK_CYCLES = 400, IRQ_CYCLES = 60, LOAD_CAP_PCT = 25;   // core work per sample and per interrupt
  localparam int ROOT_HZ = 25000000;              // the RC oscillator; the core clock is ROOT_HZ / 1, 2, 4, 8 or 16
  localparam int STACK = 2048, DRIVER = 1024;     // bytes
  localparam int RUN_UW = 1500, SLEEP_UW = 50;    // power while running and while asleep, in microwatts

  function automatic int ceil_div(input longint a, input longint b); return (a + b - 1) / b; endfunction
  function automatic int pow2_at_least(input int n); int s = 1; while (s < n) s = s * 2; return s; endfunction

  initial begin
    int rate, batch, samples, spi_bits, i2c_bits, read_us, arrivals, ring, dbl, plain, marked, work, need, div, core, load;
    int mem_ring, mem_dbl, sram_ring, sram_dbl, avg_uw, cycles_per_byte;
    // 1. Records: every sample is stored with its tag.
    rate = (ACC_B + TAG_B) * ACC_HZ + (GYR_B + TAG_B) * GYR_HZ + (MAG_B + TAG_B) * MAG_HZ + (PRS_B + TAG_B) * PRS_HZ;
    batch = longint'(rate) * BATCH_MS / 1000;
    samples = ACC_HZ + GYR_HZ + MAG_HZ + PRS_HZ;
    $display("records   rate=%0d B/s  batch=%0d B  samples=%0d/s", rate, batch, samples);
    // 2. Links. SPI: one command byte, then the data. I2C: address, register, address again, data: 9 bits a byte, 3 for start and stop.
    spi_bits = 8 * ((1 + ACC_B) * ACC_HZ + (1 + GYR_B) * GYR_HZ);
    i2c_bits = (3 + 9 * (3 + MAG_B)) * MAG_HZ + (3 + 9 * (3 + PRS_B)) * PRS_HZ;
    read_us = ceil_div(longint'(batch) * 8 * 1000000, HOST_SPI_HZ);
    $display("links     sensor_spi=%0d%%  i2c=%0d%%  host_read=%0d us", spi_bits * 100 / SENSOR_SPI_HZ, i2c_bits * 100 / I2C_HZ, read_us);
    // 3. Clock: the slowest core clock that keeps the load under its cap.
    plain = samples;                                                       // one interrupt for every sample
    marked = ACC_HZ / WATERMARK + GYR_HZ / WATERMARK + MAG_HZ + PRS_HZ;   // FIFOs with a watermark
    work = samples * WORK_CYCLES + marked * IRQ_CYCLES;
    need = ceil_div(longint'(work) * 100, LOAD_CAP_PCT);
    div = 16; while (div > 1 && ROOT_HZ / div < need) div = div / 2;
    core = ROOT_HZ / div;
    load = longint'(work) * 100 / core;
    $display("clock     work=%0d cycles/s  need=%0d Hz  core=%0d Hz (divide by %0d)  load=%0d%%", work, need, core, div, load);
    // 4. Interrupts.
    $display("irq       one_per_sample=%0d/s  with_watermark=%0d/s", plain, marked);
    // 5. Buffers: two whole batches, or one batch and what arrives while the host reads it.
    arrivals = ceil_div(longint'(rate) * read_us, 1000000);
    dbl = 2 * batch;
    ring = batch + arrivals;
    $display("buffer    double=%0d B  ring=%0d B  (arrive during a read: %0d B)", dbl, ring, arrivals);
    // 6. Memory: the SRAM is a power of two.
    mem_ring = ring + STACK + DRIVER; mem_dbl = dbl + STACK + DRIVER;
    sram_ring = pow2_at_least(mem_ring); sram_dbl = pow2_at_least(mem_dbl);
    $display("memory    ring: need=%0d sram=%0d spare=%0d%%   double: need=%0d sram=%0d spare=%0d%%", mem_ring, sram_ring,
      (sram_ring - mem_ring) * 100 / sram_ring, mem_dbl, sram_dbl, (sram_dbl - mem_dbl) * 100 / sram_dbl);
    // 7. Power: running for the load share of each second, asleep for the rest.
    avg_uw = (load * RUN_UW + (100 - load) * SLEEP_UW) / 100;
    $display("power     awake=%0d%%  average=%0d uW", load, avg_uw);
    // 8. The host link: core cycles for each byte if the core moved the batch itself.
    cycles_per_byte = longint'(core) * 8 / HOST_SPI_HZ;
    $display("host      core_cycles_per_byte=%0d  dma_needed=%0d", cycles_per_byte, cycles_per_byte < 20);
  end

  // ---- A run: the accelerometer and gyroscope FIFOs, read over one shared SPI bus --------------------------
  // Samples arrive together on both sensors. When a FIFO reaches WATERMARK, it asks to be read out. The bus
  // reads one sample at a time, (1 + B) bytes, and serves the accelerometer first. Steps of 1 us, for 130 ms.
  initial begin
    int acc = 0, gyr = 0, acc_max = 0, gyr_max = 0, busy = 0, who = 0, acc_ask = 0, gyr_ask = 0;
    int acc_us, gyr_us, period_acc, period_gyr;
    #1;
    acc_us = ceil_div(8 * (1 + ACC_B) * 1000000, SENSOR_SPI_HZ);
    gyr_us = ceil_div(8 * (1 + GYR_B) * 1000000, SENSOR_SPI_HZ);
    period_acc = 1000000 / ACC_HZ; period_gyr = 1000000 / GYR_HZ;
    for (int t = 0; t < 130000; t++) begin
      if (t % period_acc == 0) acc++;
      if (t % period_gyr == 0) gyr++;
      if (acc >= WATERMARK) acc_ask = 1;
      if (gyr >= WATERMARK) gyr_ask = 1;
      if (acc > acc_max) acc_max = acc;
      if (gyr > gyr_max) gyr_max = gyr;
      if (busy == 0) begin                              // the bus is free: start the next sample
        if (who == 1) begin acc--; if (acc == 0) acc_ask = 0; end
        if (who == 2) begin gyr--; if (gyr == 0) gyr_ask = 0; end
        who = 0;
        if (acc_ask && acc > 0) begin who = 1; busy = acc_us; end
        else if (gyr_ask && gyr > 0) begin who = 2; busy = gyr_us; end
      end
      if (busy > 0) busy--;
    end
    $display("fifo      read_per_sample=%0d us  max_fill: accelerometer=%0d gyroscope=%0d", acc_us, acc_max, gyr_max);
  end
endmodule
ConceptHow do four sensors become one rate in bytes a second?
ConceptWhy does a ring buffer need about half the SRAM of a double buffer?
ConceptWhy did the gyroscope FIFO reach 26 with a watermark of 25?
ConceptWhy does the clock of 1.5625 MHz force DMA on the host link?

Common Mistakes

Wrong Count only the sample bytes.

The tag goes with every record.

Fix Add the tag before summing the streams.

Wrong Give each sensor FIFO as many places as its watermark.

A reader on a shared bus may wait behind another.

Fix Add the samples that arrive during the longest wait.

Wrong Leave a byte-rate job to the core after choosing a slow clock.

At 1.5625 MHz the core has one cycle for each host byte.

Fix Check every byte-rate job against the clock, and give it DMA.

Remember

  • Streams times records give bytes a second; the host interval gives the batch.
  • A ring holds one batch plus what arrives during the read: about half a double buffer.
  • A watermark cuts requests, and the FIFO must hold the watermark plus the longest wait.
  • The slowest good clock is chosen last, and byte-rate jobs then go to hardware.

Practice

Report a problem with this page