P1.1.1 The SoC Address Decoder

MediumImplementIcarus · browser samples / server checksReview the topic

Write the decoder in front of seven windows. A remap bit moves an overlap, one window closes with its power domain, and every hole gets a decode error.

Hardware context: The address decoder of an SoC interconnect in front of memories and peripherals. Implement a priority decoder with a boot remap, a power-gated window and decode errors for the holes.

Lesson P1.1 decoded a small map with one hole and one overlap. A real SoC map has more traps. A boot ROM sits over SRAM until software sets a remap bit. A peripheral whose power is off must not answer at all.

Write module soc_decoder. For each address it picks the target that owns it, or raises decerr when no open window holds it. The decoder is combinational: the outputs follow the inputs with no clock.

Each case sets remap and timer_on, then shows your decoder sixteen addresses. Many sit on the first or last byte of a window, or one byte outside it.

Signals in the Timeline

SignalWidthRole
remap1input of each check
timer_on1input of each check
Full specification
The module you write (keep these ports)
module soc_decoder (
  input  logic [31:0] addr,
  input  logic        remap,      // 0 after reset: the boot ROM covers the bottom of SRAM
  input  logic        timer_on,   // 0: the timer's power domain is off
  output logic [2:0]  sel,        // the target; 7 when there is none
  output logic        decerr      // 1: no window holds addr (sel is then 7)
);
  // your decoder
endmodule
PriorityWindowAddresses (inclusive)selOpen when
1BOOT0x0000_0000 to 0x0000_7FFF2remap is 0
2SRAM0x0000_0000 to 0x0003_FFFF1always
3BOOT alias0x1000_0000 to 0x1000_7FFF2always
4UART0x4000_1000 to 0x4000_1FFF3always
5GPIO0x4000_2000 to 0x4000_2FFF4always
6TIMER0x4000_3000 to 0x4000_3FFF5timer_on is 1
7DRAM0x8000_0000 to 0xBFFF_FFFF0always

An address that falls in two open windows goes to the one with the higher priority (the smaller number). An address in no open window is a hole: decerr = 1 and sel = 7. Otherwise decerr = 0.

The result packs {decerr, sel} of each address into four bits, address 0 in bits 3 to 0. A hole reads as f.

Examples

Example 1

Before the Remap
Input
remap = 0, timer_on = 1
Addresses 0 to 15: 0x00000000, 0x00000004, 0x00007fff, 0x00008000, 0x0003fffc, 0x00040000, 0x10000000, 0x10008000, 0x10008000, 0x10008000, 0x10008000, 0x10008000, 0x10008000, 0x10008000, 0x10008000, 0x10008000
Output
decodes = 0xfffffffff2f11222

Address 0x0000_0004 is in BOOT and in SRAM. BOOT has priority while remap is 0, so it reads 2. Address 0x0000_8000 is past the boot ROM and still SRAM, so it reads 1. Address 0x1000_8000 is one byte past the alias: a hole, f.

Example 2

After the Remap
Input
remap = 1, timer_on = 1
Addresses 0 to 15: 0x00000000, 0x00007fff, 0x00008000, 0x0003ffff, 0x00040000, 0x10000004, 0x10007fff, 0x0fffffff, 0x0fffffff, 0x0fffffff, 0x0fffffff, 0x0fffffff, 0x0fffffff, 0x0fffffff, 0x0fffffff, 0x0fffffff
Output
decodes = 0xfffffffff22f1111

With remap at 1, everything from 0x0000_0000 to 0x0003_FFFF reads SRAM, 1. The boot ROM is still reachable through its alias at 0x1000_0000. 0x0004_0000 is a hole.

Example 3

Window Edges
Input
remap = 1, timer_on = 1
Addresses 0 to 15: 0x40001000, 0x40001fff, 0x40002000, 0x40000fff, 0x40002000, 0x40002fff, 0x40003000, 0x40001fff, 0x40003000, 0x40003fff, 0x40004000, 0x40002fff, 0x40000000, 0x40004000, 0x4fffffff, 0x50000000
Output
decodes = 0xffff4f553544f433

The first four addresses are the edges of the UART. 0x4000_1000 and 0x4000_1FFF read 3, 0x4000_2000 is the first GPIO byte, and 0x4000_0FFF is a hole.

Example 4

A Peripheral with Its Power Off
Input
remap = 1, timer_on = 0
Addresses 0 to 15: 0x40002fff, 0x40003000, 0x40003004, 0x40003fff, 0x40004000, 0x40001000, 0x40001000, 0x40001000, 0x40001000, 0x40001000, 0x40001000, 0x40001000, 0x40001000, 0x40001000, 0x40001000, 0x40001000
Output
decodes = 0x33333333333ffff4

With timer_on at 0, every address of the TIMER window is a hole. 0x4000_2FFF is still the last byte of the GPIO.

Constraints and Contract

  • Keep the module name and the ports. Do not use a clock: the fixture changes addr and reads your outputs 1 ns later.
  • Do not reach outside your ports.

Hints

Hint 1

One if / else if chain in priority order is the whole decoder. The first window that holds the address wins.

Hint 2

Every window is inclusive at both ends. Compare with <= against the last address, not against the first address of the next block.

Hint 3

Put the two conditions of a gated window in the same test. A closed TIMER window must fall through to the hole, not to DRAM.

What the grader checks: Your decoder sees 144 addresses in nine cases, with both values of remap and timer_on. Most of them sit on the edge of a window. Passing shows it matches the map on these addresses, not on all four billion.

9 checks on Icarus · browser samples / server checks. Run the examples first, then check the full regression. Full checks use the server judge. Downloads contain public samples only. A passing result establishes the tested cases, not a proof for all possible inputs.

See all 1 steps and the final capstone

Report a problem with this page

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

Before the Remap

Input
remap = 0, timer_on = 1
Addresses 0 to 15: 0x00000000, 0x00000004, 0x00007fff, 0x00008000, 0x0003fffc, 0x00040000, 0x10000000, 0x10008000, 0x10008000, 0x10008000, 0x10008000, 0x10008000, 0x10008000, 0x10008000, 0x10008000, 0x10008000
Expected output
decodes = 0xfffffffff2f11222

Address 0x0000_0004 is in BOOT and in SRAM. BOOT has priority while remap is 0, so it reads 2. Address 0x0000_8000 is past the boot ROM and still SRAM, so it reads 1. Address 0x1000_8000 is one byte past the alias: a hole, f.

Run samples executes all 4 public checks. Check all tests runs 9 checks on the server.

Icarus · browser samples / server checks