Sort lines of a C test by where they work. Some work on all four targets, some need a processor, and some give answers that differ by target or by timing.
Hardware context: One C test built for the host (DPI on the bus-manager seat), the core, the VP and the hybrid. Lines that are portable and lines that are not.
The four targets: host-native C on the bus-manager seat, the chip's processor on chip RTL, the virtual platform and the hybrid. Recorded on the host: "sizeof(void ) 00000008 (char)0xff == 0xff: 00000000". On the processor: "sizeof(void ) 00000004 (char)0xff == 0xff: 00000001".
This worksheet uses named constants. The first three entries show how to record your decisions.
Replace each unresolved value of 65535 with your result.
Signals in the Timeline
| Signal | Width | Role |
|---|---|---|
question | 8 | input of each check |
Full specification
| Code | Where the line works |
|---|---|
| 1 | Runs and agrees on all four targets |
| 2 | Works on the core and the platforms, not host-native |
| 3 | Runs everywhere, but the host and RV32 print different results |
| 4 | Runs everywhere, but its result depends on a platform's timing |
Host-native, hal.h's two calls are DPI transfers of the bench's seat. The host test has no processor: no CSR, no RISC-V assembly and no trap. A pointer to a register address is just a host address.
| Entry | Your decision |
|---|---|
| HAL_WRITE | Line: reg_write32(SYSCTL_PINMUX, 0xaaa); |
| POINTER | Line: (volatile unsigned )0x10004010 = 0xaaa; |
| CSR | Line: __asm__ volatile ("csrr %0, mcycle" : "=r"(c)); |
| IRQ | Line: irq_enable(SPI_IRQ, on_spi); |
| POINTER_SIZE | Line: tb_put_hex(sizeof(void *)); |
| CHAR_FF | Line: char c = reg_read32(GPIO_IN); if (c == 0xff) all_high = 1; |
| NOPS | Print mtime ticks across 64 nops |
| POLLS | Print how many polls SPI DONE took |
| PUTS | Line: tb_puts("pass\n"); |
| TOP_BYTE_HOST | On the host build, what is ((unsigned)(int)(char)X) >> 24 for the byte X? (decimal) |
Examples
Example 1
HAL WRITE- Input
Line: reg_write32(SYSCTL_PINMUX, 0xaaa);
- Output
matches = 1
hal.h is the portable layer.
Example 2
POINTER- Input
Line: *(volatile unsigned *)0x10004010 = 0xaaa;
- Output
matches = 1
On the host that address is not the chip.
Example 3
CSR- Input
Line: __asm__ volatile ("csrr %0, mcycle" : "=r"(c));- Output
matches = 1
There is no RISC-V register on the host.
Constraints and Contract
- Keep the parameter and named constants. Use the numeric codes and units on this page.
- For TOP_BYTE_HOST, enter a constant expression using X. Only this entry changes with the parameter. The supported integer range is 65 through 255, inclusive.
Hints
Hint 1
CSRs, assembly, traps and raw addresses need it.
Hint 2
long, pointers and plain char differ between the host and RV32.
Hint 3
Anything counted against time differs between platforms.
What the grader checks: Each check compares the full eight-bit answer. Parameter trials change one condition and keep the other decisions fixed.
14 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 3 problems on this path