pc2 / pc2/sus-compiler

`next` keyword to replace `LatencyOffset` and augment `state`

Open
#103 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement Language Design
Dominant language
Rust
Stars
126
Forks
6
PR merge metrics
No merged PRs in 30d

Description

As it stands, lots of bugs are caused by LatencyOffset being too simplistic of an abstraction. The main place such bugs occur is within conditional blocks, because of course the condition at '0 need not be the same as the one at 'OFFSET.

With the next keyword, we could have a condition-aware construct. next would have an optional gen int argument: next(num_nexts).

Example:

module feedback_loop#(int LATENCY) {
  output bool o'0
  
  bool pre_offset_o'LATENCY
  pre_offset_o = false
  o = LatencyOffset#(OFFSET: -LATENCY)(pre_offset_o)
  action set_o'LATENCY {
    pre_offset_o = true
  }
}

could become

module feedback_loop#(int LATENCY) {
  output bool o'0
  
  o = false
  action set_o'LATENCY {
    next(LATENCY) o = true
  }
}

Why call it next? Because we'll integrate it with state like so:
state semantics become "reading is one latency cycle removed from writing". So then writes to state are immediately transparent, unless next is used:

state int x
state int a

x = 5
int y = x      // y is 5

next a = 20
int b = a      // b is previous value of a

Finally, we can also use next together with local actions, and thereby create a sort of state machine.

local action iteration : int cur_iter {
  when ... {
    next iteration(cur_iter + 1)
  }
}

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing how LatencyOffset and state are represented and handled in the compiler. Review the existing semantics for conditional blocks and local actions, then define the implementation scope for next(num_nexts), transparent state reads, and deferred writes. Done means the examples' latency behavior and state-machine use are supported consistently.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.