Reading an SoC Specification

A chip is described by documents long before it exists. Learn their parts, and how to pull one answer out of five tables. Learn what to do when a table is silent or wrong.

You Will Be Able To

  • Name the parts of a data sheet and of an architecture document.
  • Answer a question about one device by crossing the tables of the document.
  • Find what a document leaves out, and where the RTL disagrees with it.
Lesson
S1.6
Time
26 min
Runs on
Your browser
Check
5 questions

The document says the timer is at 0x1000_2000. The RTL answers at 0x1000_3000. Both passed their reviews. Software written from the document will talk to the wrong device.

Before You Start

You need the memory map from S0.2, and reset and interrupts from S0.8. You need the architecture document and its owner from S1.4.

Five questions this page answers
Question
1Which two documents describe a chip, and who reads each?
2Which five tables does an architecture document always have?
3How do you collect everything about one device?
4What do you do when a table says nothing about a device?
5How do you find where the RTL disagrees with the document?

The Idea: The Document Is the Chip, Until There Is a Chip

For most of the flow of S1.4 there is no chip. There is a document. Designers write RTL from it. Verification engineers write tests from it. Firmware engineers write code from it.

So reading that document well is a working skill, and it is the first one a new engineer needs. The skill has three parts.

Know where things are. Join facts that live in different tables. And notice what is absent or contradicted, because that is where the bugs of S1.4 begin.

New Words

New words on this page
WordMeaning
Data sheetThe document for the user of a chip. It says what the chip does, and what each pin needs.
Pin listThe table of every pin: its name, its direction and the device behind it.
ReservedKept for later use. Software must not use a reserved address or bit.
Reset sourceOne of the things that can reset the chip, such as its reset pin. A power-on reset is the one that acts when power arrives.
Reset cause registerA register that records which reset source acted last.
OscillatorA circuit that makes a clock.
PLLPhase-locked loop: a circuit that makes a faster clock from a slower one.
Open pointA place where a document is silent, unclear or contradicted. It is written down and sent to the owner.
DebuggerA tool outside the chip that can stop the processor and look inside. S1.1 met its block.

Two short names belong to UART0: TX stands for transmit, and RX stands for receive.

The architecture document of S1.4 is the second document of a chip. The data sheet faces outward, to the customer. The architecture document faces inward, to the team.

One Picture: Five Tables, Joined by a Name

The two documents
Data sheetArchitecture document
Readerthe engineer who puts the chip on a boardthe team that builds the chip
Main partssummary and block diagram, pin list, how to operate it, voltages and timingblock diagram, memory map, clock table, reset table, interrupt table, pin list
Writtenbefore the chip is made, for the customerfirst of all, at the architecture stage
One Device, Five TablesStep around the tables. The name UART0 is the key that joins them.
  • Peripheral
  • Memory
  • Processor
  • Clock / reset
  • Power
  • Pads
One Device, Five TablesStep around the tables. The name UART0 is the key that joins them. component UART0 one name, used thesame way in everytable component Memory map where its registersare component Interrupt table which source numberit raises component Clock table which clock drives it component Reset table which resets clear it component Pin list which pins it owns 0x1000_0000source 150 MHzfour of five sourcesUART TX, UART RX
  1. component Memory mapwhere its registers are
    • 0x1000_0000 → UART0
  2. component UART0one name, used the same way in every table
  3. component Interrupt tablewhich source number it raises
    • source 1 → UART0
  4. component Clock tablewhich clock drives it
    • 50 MHz → UART0
  5. component Reset tablewhich resets clear it
    • four of five sources → UART0
  6. component Pin listwhich pins it owns
    • UART TX, UART RX → UART0
  1. Memory map

    Software reaches UART0 at 0x1000_0000. The region is 0x1000 bytes long.

  2. Interrupt table

    UART0 raises interrupt source 1.

  3. Clock table

    UART0 is a device of table 1, so the peripheral clock of 50 MHz drives it.

  4. Reset table

    Every source except the debugger resets the devices. A debugger reset leaves UART0 as it was.

  5. Pin list

    UART0 owns two pins: one out and one in.

Read the diagram as text
  • UART0: one name, used the same way in every table
  • Memory map: where its registers are
  • Interrupt table: which source number it raises
  • Clock table: which clock drives it
  • Reset table: which resets clear it
  • Pin list: which pins it owns
  • Memory map → UART0: 0x1000_0000
  • Interrupt table → UART0: source 1
  • Clock table → UART0: 50 MHz
  • Reset table → UART0: four of five sources
  • Pin list → UART0: UART TX, UART RX

Every edge is one row of the excerpt below.

The Smallest Example, Worked by Hand: Everything About UART0

Here is an excerpt of the ap_soc architecture document. We wrote it for this page, with the real values of ap_soc version 1.0.

Excerpt, table 1: memory map of the devices
DeviceFirst addressSizePurpose
UART00x1000_00000x0000_1000Serial console.
GPIO0x1000_10000x0000_100016 general-purpose pins.
Timer and PWM0x1000_20000x0000_1000Timer and pulse-width modulation.
Watchdog0x1000_30000x0000_1000Watchdog reset control.
ap_sysctl0x1000_40000x0000_1000Chip ID, reset cause, clock control, pin mux and straps.
SPI0x1000_50000x0000_1000SPI controller.
DMA0x1000_60000x0000_1000DMA control registers; transfers use its AHB manager port.

From the ap_soc architecture document, version 1.0. Addresses 0x1000_8000 to 0x1000_FFFF are reserved.

Excerpt, table 2: interrupt sources
SourceDevice
1UART0
2GPIO
3Timer and PWM
4SPI
5DMA
6Watchdog, shortly before it resets the chip
7 to 16spare, no device
Excerpt, table 3: clocks
ClockRateUsed by
RC oscillator25 MHzthe chip, from power-on until it switches to the PLL
Crystal oscillator50 MHzthe PLL, as its reference
PLL output100 MHzthe processor and the bus
Peripheral clock50 MHz, the PLL output divided by twothe devices of table 1
Excerpt, table 4: reset sources
SourceBit of the reset cause registerWhat it resets
Power-on0everything
Reset pin1processor, bus and devices
Watchdog2processor, bus and devices
Software3processor, bus and devices
Debugger4the processor only

The reset cause register is in ap_sysctl, at offset 4. It reads 01 after a power-on reset.

Excerpt, table 5: pins
PinDirectionDevice
CLKincrystal oscillator
RSTinreset pin
JTAGin and outdebug
UART TXoutUART0
UART RXinUART0
GPIO pins, 16 of themin and outGPIO

A firmware engineer must print one letter and be told when it has gone. That needs four facts, and each lives in a different table.

One task, four lookups
NeededTableAnswer
Where to write the letter1, memory mapthe UART0 region, from 0x1000_0000
Which interrupt says "sent"2, interrupt sourcessource 1
Which pin to watch on the board5, pinsUART TX
How fast UART0 is clocked3, clocks50 MHz, the peripheral clock

Now look for silence. Take each device of table 1 and find it in tables 2 and 5.

Devices against tables
DeviceIn table 2, interruptsIn table 5, pins
UART0source 1UART TX, UART RX
GPIOsource 2GPIO pins, 16 of them
Timer and PWMsource 3no row
Watchdogsource 6no row
ap_sysctlno rowno row
SPIsource 4no row
DMAsource 5no row

Built from the excerpt. "No row" may be correct, or it may be an omission. The excerpt does not say which.

Two blanks are worth a question. ap_sysctl has no interrupt: is that meant? And SPI talks to chips outside, yet it has no pins. Its pins may be shared through the pin mux of S1.1, and the excerpt is silent.

The Rules

  1. Rule 1: Find the five tables first.

    They are the memory map, the clocks, the resets, the interrupts and the pins. Almost every question starts in one of them.

  2. Rule 2: Join tables by the name of the device.

    A full answer about one device takes a row from several tables. The name must be spelled the same in each.

  3. Rule 3: A blank is an open point.

    If a table has no row for a device, the document must say why. Do not guess. Ask the owner of the document.

  4. Rule 4: Reserved means "do not touch".

    A reserved address or bit may gain a meaning in a later version. Software that used it will then break.

  5. Rule 5: When the document and the RTL disagree, one of them has a bug.

    Do not decide alone which one. Report the difference to both owners.

Sources for These Rules

The parts of a data sheet: Weste and Harris, CMOS VLSI Design, 4th edition, section 14.6.

The five tables and the five rules are common practice. They are not taken from a library source.

Every value of the excerpt is a value of ap_soc version 1.0, the chip of this course. No vendor document was copied.

Now Run It: The Document Against the RTL

The lab at the end of this page holds a small top level. It decodes three devices, wires three interrupts and gives one reset value. The test code walks seven rows of the excerpt and checks each against the RTL.

Recorded from the lab on Icarus.
map: UART0 at 0x1000_0000: agrees
map: GPIO at 0x1000_1000: agrees
map: Timer and PWM at 0x1000_2000: DIFFERS
interrupts: UART0 is source 1: agrees
interrupts: GPIO is source 2: DIFFERS
interrupts: Timer and PWM is source 3: agrees
resets: cause reads 01 after power-on: DIFFERS
rows that differ: 3 of 7

Three rows differ. Rule 5 at work: each one is a bug in the RTL or in the document. The lab alone cannot say which.

The three open points
RowThe document saysThe RTL doesWho would be hurt
Map, Timer and PWMfirst address 0x1000_2000it answers at 0x1000_3000, the place of the Watchdogsoftware: every timer access reaches nothing
Interrupts, GPIOsource 2it raises source 4, the number of SPIfirmware: the SPI handler runs for a GPIO event
Resets, cause register01 after power-onit reads 00firmware: it cannot tell why the chip started

None of these would stop the RTL from compiling. None would show in a synthesis report. Only a check that reads the document finds them.

The lab leaves things out. Seven rows are checked by hand-written calls. A real team builds such checks from the document itself, so that no row is skipped.

Why It Is Built This Way

Design choiceThe alternativeWhat the choice buys, and costs
One table for each kind of factOne chapter for each deviceClashes show at a glance: two devices at one address sit in adjacent rows. A device is spread over five tables.
Reserved ranges written downUnused space left unmentionedLater versions can grow without breaking software. The RTL must refuse access to them.
The document is the referenceThe RTL is the referenceFirmware and tests can start before the RTL exists. The document must be kept up to date.

The Trap: Reading the RTL in Place of the Document

An engineer needs the timer address. The document is long, and the RTL is open on the screen. The decoder says 0x1000_3000, and the engineer uses that.

The code works on today's RTL. Next month the RTL bug is repaired, and the code breaks. The engineer copied a bug into software.

The cure is rule 5, used in both directions. Take the fact from the document. If the RTL differs, do not pick a side. Report the open point.

At Scale

This page5 tables, about 30 rows
A phone chipthousands of rows

This section looks ahead. The excerpt has five small tables. The document of a phone chip has thousands of rows.

  1. Tables as data

    The tables are kept as files that tools can read. The decoder, the firmware addresses and the tests are all built from them.

  2. Checks built from the document

    A tool turns each row into a check like the calls of the lab. A new row brings its check with it.

  3. Versions

    Every hand-off names the version of the document it was built from. A change to a table is reviewed like a change to RTL.

  4. Later in this course

    Each table gets its own module: the map in S4, clocks and resets in S5, interrupts in S6, pins in S7.

Try It

Run the lab. Find each of the three differences in the RTL of small_top.

Repair the RTL so that all seven rows agree. Change no line of the test code.

Add an eighth row for a reserved address: no select may rise at 0x1000_8000.

RUNIcarus Verilog · in your browser
Edit the code, then run it
Expected: map: UART0 at 0x1000_0000: agrees map: GPIO at 0x1000_1000: agrees map: Timer and PWM at 0x1000_2000: DIFFERS interrupts: UART0 is source 1: agrees interrupts: GPIO is source 2: DIFFERS interrupts: Timer and PWM is source 3: agrees resets: cause reads 01 after power-on: DIFFERS rows that differ: 3 of 7

Check Yourself

Predict the outputTwo of the three differences have been repaired in the RTL. What is the last line the lab prints?
// A small top level, and test code that walks the tables of its document, row by row.
// ---- The RTL: three device selects, the interrupt wiring and one status value ----
module small_top (
  input  logic [31:0] addr,
  input  logic        uart_irq, gpio_irq, timer_irq,
  output logic        sel_uart, sel_gpio, sel_timer,
  output logic [6:1]  irq_source,      // one wire for each interrupt source number
  output logic [7:0]  reset_cause      // the value software reads after a power-on reset
);
  wire devices = (addr[31:16] == 16'h1000);
  assign sel_uart  = devices && (addr[15:12] == 4'h0);
  assign sel_gpio  = devices && (addr[15:12] == 4'h1);
  assign sel_timer = devices && (addr[15:12] == 4'h2);

  always @* begin
    irq_source = 0;
    irq_source[1] = uart_irq;
    irq_source[4] = gpio_irq;
    irq_source[3] = timer_irq;
  end

  assign reset_cause = 8'h01;
endmodule

// ---- Test code: each call below is one row of the document ----
module tb;
  logic [31:0] addr = 0;
  logic uart_irq = 0, gpio_irq = 0, timer_irq = 0;
  wire  sel_uart, sel_gpio, sel_timer;
  wire [6:1] irq_source;
  wire [7:0] reset_cause;
  small_top dut (.*);                   // .* joins every port to the signal of the same name

  int differ = 0;
  task row(input string text, input logic ok);
    if (ok) $display("%s: agrees", text);
    else begin
      $display("%s: DIFFERS", text);
      differ++;
    end
  endtask

  initial begin
    // The memory map table: one address inside each region.
    addr = 32'h1000_0000; #1 row("map: UART0 at 0x1000_0000", sel_uart);
    addr = 32'h1000_1004; #1 row("map: GPIO at 0x1000_1000", sel_gpio);
    addr = 32'h1000_2000; #1 row("map: Timer and PWM at 0x1000_2000", sel_timer);
    // The interrupt table: raise one request at a time and look at its source number.
    uart_irq = 1;  #1 row("interrupts: UART0 is source 1", irq_source == 6'b000001); uart_irq = 0;
    gpio_irq = 1;  #1 row("interrupts: GPIO is source 2", irq_source == 6'b000010); gpio_irq = 0;
    timer_irq = 1; #1 row("interrupts: Timer and PWM is source 3", irq_source == 6'b000100); timer_irq = 0;
    // The reset table: bit 0 of the reset cause is set after a power-on reset.
    #1 row("resets: cause reads 01 after power-on", reset_cause == 8'h01);
    $display("rows that differ: %0d of 7", differ);
    $finish;                      // $finish ends the simulation
  end
endmodule
ConceptWho is the main reader of a data sheet?
ConceptAccording to the excerpt, which interrupt source does the device at 0x1000_5000 raise?
ConceptThe pin list has no row for SPI. What is the right next step?
ConceptThe document and the RTL disagree about an address. Which one is wrong?

Common Mistakes

Wrong Take an address from the RTL because it is quicker to find.

The RTL may hold a bug that the document does not.

Fix Take it from the document, and report any difference.

Wrong Read a missing row as "none".

A blank can be a decision or an omission.

Fix Ask the owner, and have the answer written into the document.

Wrong Use a reserved address for a quick test.

A later version may give it a meaning.

Fix Leave every reserved address and bit alone.

Remember

  • A data sheet faces the customer; an architecture document faces the team.
  • Five tables hold most facts: map, clocks, resets, interrupts and pins.
  • Join the tables by the name of the device.
  • A blank, and a reserved range, are facts to respect and to question.
  • A difference between the document and the RTL is an open point for both owners.

Practice

Report a problem with this page