rems-project / sail

Sail architecture definition language
Other
622 stars 116 forks source link

SV: Get RISC-V decoder through the SystemVerilog translation #777

Closed Alasdair closed 1 week ago

Alasdair commented 1 week ago

The RISC-V Sail decoder is hard to generate in SystemVerilog if we try to preserve the order of every single statement, as it has a lot of guards which can read system state (like misa) to check whether certain extensions are enabled or not.

After trying a bunch of things that didn't work, this adds an attribute $[optimize_control_flow_order] which permits the Jib compilation to evaluate the expressions in control flow statements in whichever order it likes, and possibly eagerly, i.e.

if B then X else Y

can be re-written to

let y = Y in let x = X in if B then x else y

where X and Y are always evaluated.

If the function is side-effect free (as the decode is), this shouldn't change the result value, but it can change the order of side effects such as register writes or print statements.

github-actions[bot] commented 1 week ago

Test Results

   10 files  ±0     22 suites  ±0   0s ⏱️ ±0s   716 tests ±0    716 ✅ ±0  0 💤 ±0  0 ❌ ±0  2 247 runs  ±0  2 246 ✅ ±0  1 💤 ±0  0 ❌ ±0 

Results for commit 7fa2bfb1. ± Comparison against base commit 3611e463.

:recycle: This comment has been updated with latest results.