S6.7.1 Place the Sections

MediumImplement22 minIcarus Verilog · serverReview the topic

Play the linker: place four sections in a small ROM and a small RAM, and find the numbers that start-up code needs.

Hardware context: Start-up code in Boot ROM on a small processor model, checked against the real ap_rv32. Bare-metal firmware start-up

A small chip has a ROM of 256 bytes at address 0 and a RAM of 256 bytes at 0x8000_0000. The linker script places .text, .rodata, .data and .bss in that order. The stack starts at the top of RAM and may use 64 bytes.

This worksheet uses named constants. The first three entries show how to record your decisions.

Signals in the Timeline

SignalWidthRole
question8input of each check
Full specification
Section.text.rodata.data.bss
Size, in bytes96161220
First values stored in ROMyesyesyesno

With execute in place, .text and .rodata run in ROM, and .data and .bss run in RAM. With copy to RAM, all four run in RAM, in the same order, and ROM holds the stored copies. Enter ROM addresses as plain numbers. Enter RAM addresses as bytes from the first address of RAM. All answers are decimal.

EntryYour decision
RODATA_STARTAddress of .rodata, with execute in place.
DATA_LOADLoad address of .data.
ROM_USEDBytes of ROM in use.
BSS_STARTWhere .bss starts, in bytes from the first address of RAM, with execute in place.
BSS_ENDWhere .bss ends, in bytes from the first address of RAM.
COPY_WORDSWords that start-up code copies, with execute in place.
CLEAR_WORDSWords that start-up code clears.
STACK_BOTTOMLowest address the stack may reach, in bytes from the first address of RAM.
FREE_BYTESBytes between the end of .bss and the bottom of the stack, with execute in place.
COPY_ALL_WORDSWords that start-up code copies with copy to RAM.
COPY_RAM_USEDBytes of RAM in use with copy to RAM, the stack included.
COPY_FREEBytes between the end of .bss and the bottom of the stack, with copy to RAM.
BSS_START_AFTERWhere would .bss start, in bytes from the first address of RAM, if .data held N words in place of 3? Use execute in place.

Examples

Example 1

RODATA START
Input
Address of .rodata, with execute in place.
Output
matches = 1

.text takes addresses 0 to 95, so .rodata starts at 96.

Example 2

DATA LOAD
Input
Load address of .data.
Output
matches = 1

The stored copy of .data follows .rodata: 96 + 16.

Example 3

ROM USED
Input
Bytes of ROM in use.
Output
matches = 1

96 + 16 + 12. Nothing is stored for .bss.

Constraints and Contract

  • Keep the parameter and named constants. Use the numeric codes and units on this page.
  • For BSS_START_AFTER, enter a constant expression using N. Only this entry changes with the parameter. The supported integer range is 0 through 29, inclusive.

Hints

Hint 1

Add the sizes of the stored sections in order. Each sum is the address of the next one.

Hint 2

Do the same for the sections that run in RAM.

Hint 3

Take its size from the top of RAM, and compare its bottom with the end of the sections.

What the grader checks: Each check compares the full eight-bit answer. Parameter trials change one condition and keep the other decisions fixed.

13 checks on Icarus Verilog · server. Run the examples first, then check the full regression. Full checks use the server judge. Downloads contain your source only; samples require the simulation service. A passing result establishes the tested cases, not a proof for all possible inputs.

See all 2 problems on this path

Report a problem with this page

Your code SystemVerilogSaved locally
Ln 1, Col 1Tab indents · Ctrl/⌘ + Enter runs samples
Not run yet

RODATA START

Input
Address of .rodata, with execute in place.
Expected output
matches = 1

.text takes addresses 0 to 95, so .rodata starts at 96.

Run samples executes all 3 public checks. Check all tests runs 13 checks on the server.

Icarus Verilog · server