From Microcontroller to Application Processor: What Changes at Scale

A phone chip has the same eight kinds of block as ap_soc. Each one has grown into a subsystem, and behind each growth stands one number that no longer fitted.

You Will Be Able To

  • Say what each of the eight kinds of block becomes on a large chip.
  • Work out, from one camera frame, the numbers that force the memory, the bus and the address to grow.
  • Explain why connections grow faster than blocks, and what a subsystem costs.
Lesson
S10.1
Time
25 min
Runs on
Your browser
Check
5 questions

A small camera works on your bench. It raises one pin when a picture is ready, and ap_soc reads that pin.

Now the same idea must go into a phone, with a full picture thirty times a second. Nobody invents a new kind of block for that: every block you already know has to grow.

Before You Start

You need From Board to Chip: What an SoC Is, and Why: the eight kinds of block, and a microcontroller beside an application processor.

You need The Memory Map: regions, sizes and address bits.

You need Many Managers: Arbitration and the Bus Matrix: managers, subordinates and the bus matrix.

You need The Interrupt Controller: A PLIC: the source ID, and the value 0 for "no interrupt".

Five questions this page answers
Question
1Which kinds of block does a large chip have that ap_soc lacks?
2Why can one camera frame not stay in the memory of ap_soc?
3Why does a chip with 4 GiB of memory need more than 32 address bits?
4Why do the connections grow faster than the blocks?
5A frame grows to 3840 by 2160 pixels, and the memory to 8 GiB. What does the lab print last?

The Idea: The Same Eight Boxes, Each Outgrown

A large chip is not a different kind of machine. It has a processor, memory, a bus, peripherals, clocks and reset, power control, debug and pads. Those are the eight kinds of block you met on ap_soc.

What changes is the load. A phone shows video, holds large programs and talks to fast devices. Each of those jobs can be written as a number. One is the bytes in a picture. Another is the bytes that arrive in one second.

Follow one such number, and it soon passes what a block of ap_soc can do. The memory is too small for one picture. The bus matrix has too many pairs to connect. The address has too few bits.

A block that is outgrown does not simply get larger. It becomes a subsystem: several blocks that do one job together, usually built by one team. The memory becomes a controller on the chip and a memory chip outside it. The bus matrix becomes a network.

So read a large chip with one question for each box. Which number grew, and what did the box turn into? This page asks that question eight times, and the rest of the module answers it in depth.

New Words

New words on this page
WordMeaning
SubsystemSeveral blocks that do one job together, with a clear boundary around them.
ap_phoneThe large chip of this module. It is an exercise: nobody has built it, and every number of it was chosen for these lessons.
Pixel of a pictureOne dot of a picture, pixel for short. On this page a pixel takes 2 bytes.
Video frameOne whole picture from a camera. This page says frame for short.
GiB1024 times 1024 times 1024 bytes. That is 2 to the power 30.
DRAMA kind of RAM that packs many bits into little area. It comes as a chip of its own, outside the package.
Cluster of coresA group of processor cores that work side by side and share a cache. This module says core cluster.
RouterA small block that takes a message in and passes it on to a neighbour.
Network on chipRouters joined by short links, in place of one large bus matrix.
Compute engineA block that does one kind of heavy sum, such as picture work, faster than a core can.

One Picture: One Frame on a Large Chip

One Frame on a Large ChipStep through the picture. Each step follows one camera frame a little further, and each stop is a block that had to grow.
  • Pads
  • Bus
  • Memory
  • Processor
  • Peripheral
  • Clock / reset
  • Debug
One Frame on a Large ChipStep through the picture. Each step follows one camera frame a little further, and each stop is a block that had to grow. component Camera port fast pins: 124 millionbytes arrive eachsecond component Network 9 routers in place ofone bus matrix component Memorycontroller decides when eachread and write goesout component DRAM a memory chip outsidethe package: 4 GiB component Core cluster 8 cores in place of 1 component Compute engines blocks that dopicture sums fasterthan a core component Clocks and power 6 PLLs and 12 powerdomains, in place of 1and 2 component Debug and trace 8 harts to halt andto watch framewritememory pinsrequestrequest
  1. component Camera portfast pins: 124 million bytes arrive each second
    • frame → Network
  2. component Memory controllerdecides when each read and write goes out
    • memory pins → DRAM
  3. component DRAMa memory chip outside the package: 4 GiB
  4. component Network9 routers in place of one bus matrix
    • write → Memory controller
  5. component Core cluster8 cores in place of 1
    • request → Network
  6. component Compute enginesblocks that do picture sums faster than a core
    • request → Network
  7. component Clocks and power6 PLLs and 12 power domains, in place of 1 and 2
  8. component Debug and trace8 harts to halt and to watch
  1. A frame arrives

    A camera sends one frame after another. On ap_soc a pin said that a frame was ready. Here the bytes themselves come in.

  2. Memory leaves the chip

    One frame is larger than all the memory of ap_soc. So the memory becomes a DRAM outside the package, with a controller on the chip.

  3. The bus becomes a network

    Many blocks now want that memory. One bus matrix would need a path for every pair, so routers with short links take its place.

  4. One core becomes a cluster

    A frame must be worked on before the next one comes. Eight cores share the work, and engines take the heaviest sums.

  5. The quiet blocks grow too

    More blocks need more clocks, more power domains and more to watch. Nothing here is a new kind of block.

Read the diagram as text
  • Camera port: fast pins: 124 million bytes arrive each second
  • Network: 9 routers in place of one bus matrix
  • Memory controller: decides when each read and write goes out
  • DRAM: a memory chip outside the package: 4 GiB
  • Core cluster: 8 cores in place of 1
  • Compute engines: blocks that do picture sums faster than a core
  • Clocks and power: 6 PLLs and 12 power domains, in place of 1 and 2
  • Debug and trace: 8 harts to halt and to watch
  • Camera port → Network: frame
  • Network → Memory controller: write
  • Memory controller → DRAM: memory pins
  • Core cluster → Network: request
  • Compute engines → Network: request

The exercise chip ap_phone, drawn by kind of block. Its numbers are chosen for this module and describe no real chip.

The Smallest Example, Worked by Hand

No simulator yet. Put a small camera on ap_soc. Its picture is 320 pixels wide and 240 high, and 15 frames arrive each second. Then ask four questions, each with one sum.

Four sums for ap_soc and a small camera
QuestionSumResultVerdict
How large is one frame?320 × 240 × 2153,600 bytesThe SRAM holds 65,536 bytes. The frame does not fit.
How many bytes arrive each second?153,600 × 152,304,000 bytesAbout 35 times the whole SRAM, every second.
How many pairs must the bus connect?3 managers × 5 subordinates15 pairsFew enough for one bus matrix.
How many bits does a source ID need?16 sources and the value 0: 17 values5 bits4 bits give only 16 values.
How many address bits does the memory use?65,536 is 2 to the power 1616 of 32 bits16 bits are left for everything else.

The managers are the processor, the debug module and the DMA. The subordinates on the fast bus are the boot ROM, ap_clint, ap_plic, the bridge and the SRAM.

Read the first verdict again. Even this small camera breaks the memory of ap_soc. The chip can still see that a frame is ready. It cannot keep the frame.

The other sums pass with room to spare. That is what makes a microcontroller simple: every number fits inside its block.

The Rules

  1. Rule 1: The eight kinds of block stay.

    A large chip adds no ninth kind. Each kind becomes one subsystem, or several.

  2. Rule 2: A block grows when a number outgrows it.

    Name the number before you draw the new block: bytes, bytes each second, pairs or sources.

  3. Rule 3: Pairs grow as a product.

    M managers and S subordinates give M times S pairs. Double both, and the pairs become four times as many.

  4. Rule 4: An identifier needs enough bits for every value.

    Count the values, with any that are kept aside. Then take the smallest power of two that reaches the count.

  5. Rule 5: Memory uses address bits.

    A memory of 2 to the power n bytes uses n address bits. The map needs more bits than that, for everything else.

  6. Rule 6: A subsystem has a boundary, and a boundary needs an agreement.

    Write down who owns each number that crosses it. Count a shared block once.

Sources for These Rules

A microcontroller beside the SoC of a small computer board: Harris and Harris, Digital Design and Computer Architecture, ARM edition, section 9.3.

DRAM needs one transistor for each bit and is denser and cheaper than SRAM: Patterson and Hennessy, Computer Organization and Design, ARM edition, section 5.2.

Rules 3 to 5 are arithmetic. The values of ap_soc come from its memory map, version 1.0, and from its interrupt controller.

Every value of ap_phone is chosen for this module. It describes no real chip.

Rule 6 is engineering practice, and has no single source.

Now Run It

The lab at the end of this page is a sheet of sums. It repeats the hand example for ap_soc, and then asks the same questions of ap_phone. That chip has 8 cores, 4 GiB of DRAM, 24 managers, 40 subordinates and 240 interrupt sources. Its camera sends 1920 by 1080 pixels, 30 times a second.

Printed by the lab on Icarus: the four rows for ap_phone. Every value of ap_phone is an exercise value.
ap_phone frame_bytes=4147200 memory_bytes=4294967296 fits=1 bytes_per_s=124416000
ap_phone managers=24 subordinates=40 pairs=960
ap_phone sources=240 id_bits=8
ap_phone memory_bits=32 address_bits=40 bits_left=8

Rule 2 at work, in the first row. One frame is 4,147,200 bytes, more than 63 times the whole SRAM of ap_soc. In 4 GiB it fits, so the row says fits=1.

The same row gives the load: 124,416,000 bytes each second, from the camera alone. The lesson on the memory subsystem starts from that number.

Rule 3, in the second row. The blocks on the bus grew from 8 to 64, a factor of 8. The pairs grew from 15 to 960, a factor of 64.

Rule 4, in the third row. 240 sources and the value 0 make 241 values, and 8 bits give 256.

Rule 5, in the last row. The memory alone uses 32 address bits. Set ADDRESS_BITS to 32 and that row ends with bits_left=0: nothing is left for a single device. So ap_phone has an address of 40 bits.

This lab is a sheet of sums, not a circuit. No lab in this track builds ap_phone. Each lesson that follows builds one small piece of it.

What Each Box Becomes

The eight kinds of block, on the small chip and on the large one
Kind of blockOn ap_socOn ap_phoneThe number that grew
ProcessorOne hartA core cluster of 8 cores, with cachesWork to finish before the next frame
Memory4 KiB of ROM and 64 KiB of SRAM4 GiB of DRAM, behind a controllerBytes in a frame, and bytes each second
BusOne bus matrix and a bridgeA network on chip of 9 routersPairs: 15 against 960
PeripheralsSeven slow devices behind the bridgeFast ports and compute enginesBytes each second for one device
Clocks and resetTwo oscillators and one PLL6 PLLsClock rates that differ from block to block
Power2 power domains12 power domainsParts that must sleep while others run
DebugOne hart behind one TAP8 harts, and trace from eachHarts to halt together
PadsA pin mux and slow pinsFast lanes for memory, camera and displayBits each second on one pin

Every value in the third column is an exercise value.

Each row is a lesson of this module, or several. The processor row continues in The Cache Hierarchy of a Core Cluster. The bus row continues in The Network-on-Chip, and the memory row in The Memory Subsystem.

Peripherals and pads continue in High-Speed I/O Subsystems and Heterogeneous Compute. The last three rows are clocks, power and debug. Clocks: Clocking at Scale. Power: Power Domains at Scale and Power at Scale. Debug: Debug at Scale and Trace at Scale.

Why It Is Built This Way

ChoiceThe alternativeIts cost
Memory as a DRAM outside the package4 GiB of SRAM on the chipSRAM needs several transistors for each bit. The memory would be far larger than the rest of the chip.
A network of routersOne bus matrix with 960 pairsEvery pair is a path with long wires, and every new block adds a row or a column of them.
Subsystems with boundariesOne flat list of hundreds of blocksNo single team can hold it. But every boundary is a place where two teams can disagree.

The last row is the price of scale. A subsystem lets one team finish its part alone. The chip works only if the parts agree where they meet.

The Trap: Two Teams, One Number

The camera team numbers its interrupt sources from 0. The team of the interrupt controller keeps 0 for "no interrupt". Both blocks pass their own tests.

On the first joint run, the first frame wakes nobody. Its source has the one number that is never delivered. No block is wrong. The agreement of rule 6 was never written down.

The second trap is the block that is counted three times. Three camera units each list the shared hub in their own inventory. The sum says three hubs, and the chip has one.

The third trap is on your bench. Reading the pin proved that a frame was ready. It never proved that a frame was stored, and on ap_soc no frame could be.

At Scale

ap_soc~12 blocks
Phone-class SoChundreds of blocks

This section looks ahead, past the edge of one chip and past one team.

  1. More than one piece of silicon

    A package can hold several pieces of silicon, called chiplets, side by side or stacked. Then a boundary between subsystems can also be a boundary between two of them.

  2. One description, many outputs

    With hundreds of blocks nobody wires the top level by hand. Tools write the connections from one description that every team shares.

  3. Who may reach what

    More managers mean more routes to every asset. A large chip filters the accesses of its devices, and keeps part of itself for trusted code only.

The first two continue in How Hundreds of IP Blocks Are Integrated and I/O Memory Management and Virtualisation. The third continues there too, in The Secure World and in The Multi-Stage Secure Boot Chain.

The Drawing for the First Worksheet
Read the Frame Subsystem DrawingInspect the units and follow the request arrows. Read data returns along the request path.
  • Pads
  • Peripheral
  • Bus
  • Memory
  • Processor
Read the Frame Subsystem DrawingInspect the units and follow the request arrows. Read data returns along the request path. component Sensor pads Camera samples enterhere. component Capture DMA Writes one completedframe and raises anevent. component System fabric Routes requests tothe memorysubsystem. component DRAM port Owns the framebuffer. component Event router Routes capturecompletion to theassigned core. component Core cluster Runs the handler thatconsumes thenotification. component Display engine Reads a buffer andemits scanned pixels. component Panel pads Drive the scannedpixels off chip. samplesbuffer writememory requestdoneservicebuffer readpixels
    • samples → Capture DMA
    • buffer write → System fabric
    • done → Event router
    • memory request → DRAM port
    • service → Core cluster
    • buffer read → System fabric
    • pixels → Panel pads
  1. Sensor pads

    Camera samples enter here.

  2. Capture DMA

    Writes one completed frame and raises an event.

  3. System fabric

    Routes requests to the memory subsystem.

  4. DRAM port

    Owns the frame buffer.

  5. Event router

    Routes capture completion to the assigned core.

  6. Core cluster

    Runs the handler that consumes the notification.

  7. Display engine

    Reads a buffer and emits scanned pixels.

  8. Panel pads

    Drive the scanned pixels off chip.

Read the diagram as text
  • Sensor pads: Camera samples enter here.
  • Capture DMA: Writes one completed frame and raises an event.
  • System fabric: Routes requests to the memory subsystem.
  • DRAM port: Owns the frame buffer.
  • Event router: Routes capture completion to the assigned core.
  • Core cluster: Runs the handler that consumes the notification.
  • Display engine: Reads a buffer and emits scanned pixels.
  • Panel pads: Drive the scanned pixels off chip.
  • Sensor pads → Capture DMA: samples
  • Capture DMA → System fabric: buffer write
  • System fabric → DRAM port: memory request
  • Capture DMA → Event router: done
  • Event router → Core cluster: service
  • Display engine → System fabric: buffer read
  • Display engine → Panel pads: pixels

Phone exercise topology. Only the displayed connections are in scope.

Try It

Run the sheet. The first four rows are the hand example. Check each against your own sums.

Set ADDRESS_BITS to 32. Which row changes, and what does it say about the memory map?

Set FRAME_W to 640 and FRAME_H to 480. By what factor does frame_bytes of ap_phone fall?

Names Printed by the Lab
NameMeaning
frame_bytesThe size of one frame: width times height times 2 bytes for each pixel.
memory_bytesThe largest memory of the chip: the SRAM of ap_soc, the DRAM of ap_phone.
fits1 when one frame fits in that memory, 0 when it does not.
bytes_per_sThe bytes that the camera sends in one second.
pairsManagers times subordinates: the paths that one bus matrix would need.
id_bitsThe bits of a source ID. One value more than the sources, because 0 means "none".
memory_bitsThe address bits that the memory uses by itself.
bits_leftThe address bits that remain to tell the memory from everything else.
RUNIcarus Verilog · in your browser
Edit the code, then run it
Expected: ap_soc frame_bytes=153600 memory_bytes=65536 fits=0 bytes_per_s=2304000 ap_soc managers=3 subordinates=5 pairs=15 ap_soc sources=16 id_bits=5 ap_soc memory_bits=16 address_bits=32 bits_left=16 ap_phone frame_bytes=4147200 memory_bytes=4294967296 fits=1 bytes_per_s=124416000 ap_phone managers=24 subordinates=40 pairs=960 ap_phone sources=240 id_bits=8 ap_phone memory_bits=32 address_bits=40 bits_left=8

Check Yourself

Predict the outputIn this run the frame is 3840 by 2160 pixels and the memory is 8 GiB. What is the last line? Its form is: ap_phone memory_bits=.. address_bits=40 bits_left=..
module tb;
  // The camera frame and the memory of the large chip. Change these and run again.
  localparam int FRAME_W = 3840;
  localparam int FRAME_H = 2160;
  localparam int MEMORY_GIB = 8;      // external memory, in GiB (1 GiB = 1024 * 1024 * 1024 bytes)
  localparam int ADDRESS_BITS = 40;   // width of an address on the large chip

  // One chip, four sums. Each sum is one reason why a block must grow.
  task automatic chip(input string name, input int width, height, pixel_bytes, frames_per_s,
                      input longint memory_bytes,
                      input int managers, subordinates, sources, address_bits);
    longint frame_bytes, per_second;
    int memory_bits;
    frame_bytes = width * height * pixel_bytes;
    per_second = frame_bytes * frames_per_s;
    memory_bits = $clog2(memory_bytes);
    $display("%s frame_bytes=%0d memory_bytes=%0d fits=%0d bytes_per_s=%0d",
             name, frame_bytes, memory_bytes, frame_bytes <= memory_bytes, per_second);
    $display("%s managers=%0d subordinates=%0d pairs=%0d",
             name, managers, subordinates, managers * subordinates);
    // One more value than there are sources: ID 0 means "no interrupt".
    $display("%s sources=%0d id_bits=%0d", name, sources, $clog2(sources + 1));
    $display("%s memory_bits=%0d address_bits=%0d bits_left=%0d",
             name, memory_bits, address_bits, address_bits - memory_bits);
  endtask

  initial begin
    // ap_soc with a small camera: 320 by 240 pixels, 2 bytes each, 15 frames a second, 64 KiB of SRAM.
    chip("ap_soc", 320, 240, 2, 15, 64 * 1024, 3, 5, 16, 32);
    // ap_phone, the exercise chip of this module: 30 frames a second.
    chip("ap_phone", FRAME_W, FRAME_H, 2, 30, longint'(MEMORY_GIB) * 1024 * 1024 * 1024, 24, 40, 240, ADDRESS_BITS);
  end
endmodule
ConceptWhich kind of block does a large chip have that ap_soc lacks?
ConceptOne frame is 153,600 bytes, and the SRAM of ap_soc holds 65,536 bytes. What follows?
ConceptA chip has 4 GiB of memory and a 32-bit address. How many address bits are left for everything else?
ConceptThe managers double, and so do the subordinates. What happens to the pairs?

Common Mistakes

Wrong Look for a new kind of block on a large chip.

There is none. The eight kinds stay.

Fix Ask what each kind became, and which number forced it.

Wrong Count a shared block once for each of its users.

All users reach the same instance.

Fix Count what is copied, then add each shared block once.

Wrong Read a ready bit as a stored frame.

The bit reports one pin.

Fix Follow the bytes of the frame to the memory that holds them.

Remember

  • A large chip has the same eight kinds of block. Each became a subsystem.
  • A block grows when a number outgrows it: bytes, bytes each second, pairs, sources or address bits.
  • Pairs grow as a product, so connections grow faster than blocks.
  • Every boundary between subsystems needs a written agreement.

Practice

Report a problem with this page