-
Notifications
You must be signed in to change notification settings - Fork 0
spec: signatures #280
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
spec: signatures #280
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
ff399c6
spec: list all interaction signatures
erik-3milabs a88e9b4
Update spec/signatures.typ
erik-3milabs a25be10
spec: signatures: fix LOAD signature
erik-3milabs 8744a67
spec: signatures: make IS_BIT's cond a BaseField
erik-3milabs 61c7aad
spec: signatures: make ECALL's syscallnr a DWordWL
erik-3milabs d09ebe6
spec: signatures: preemptively introduce NEG signature (see #270)
erik-3milabs fadecdf
spec: signatures: fix DWordDL typo
erik-3milabs File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,90 @@ | ||
| #import "/book.typ": book-page | ||
| #import "/src.typ": load_signatures, load_config | ||
|
|
||
| #show: book-page("signatures.typ") | ||
|
|
||
| #let config = load_config() | ||
| #let signatures = load_signatures(config) | ||
|
|
||
| // Render a signature | ||
| #let render_signature(sig) = { | ||
| let (lb, rb) = if sig.kind == "interaction" { | ||
| (`[`, `]`) | ||
| } else if sig.kind == "template" { | ||
| (`<`, `>`) | ||
| } | ||
|
|
||
| let cond = sig.at("cond", default: none) | ||
| let cond_str = if cond != none { | ||
| raw(cond) + ` => ` | ||
| } else {``} | ||
|
|
||
| let input_str = sig.input.map(elt => { | ||
| if type(elt) == array { | ||
| raw(elt.at(0)) + `[` + raw(str(elt.at(1))) + `]` | ||
| } else { | ||
| raw(elt) | ||
| } | ||
| }).join(`, `) | ||
|
|
||
| let output = sig.at("output", default: none) | ||
| let output_str = if output != none { | ||
| if type(output) == array { | ||
| raw(output.at(0)) + `[` + raw(str(output.at(1))) + `]` | ||
| } else { | ||
| raw(output) | ||
| } + `; ` | ||
| } else {``} | ||
|
|
||
| return [#cond_str#raw(sig.tag)#lb#output_str#input_str#rb] | ||
| } | ||
|
|
||
| // Compute the bus size of an interaction | ||
| #let interaction_bus_size(sig) = { | ||
| let vars = sig.input + if "output" in sig { (sig.output, )} else {()} | ||
|
|
||
| return vars.map(v => { | ||
| let (label, factor) = if type(v) == array { | ||
| (v.at(0), v.at(1)) | ||
| } else { | ||
| (v, 1) | ||
| } | ||
| config.variables.types.filter(type => type.label == label).first().subtypes.len() * factor | ||
| }) | ||
| .sum() | ||
| } | ||
|
|
||
| #let interactions = signatures.signatures.filter(s => s.kind == "interaction") | ||
| The following lists signatures of the #interactions.len() interactions in this VM. | ||
| #figure( | ||
| table( | ||
| columns: (1fr, auto), | ||
| inset: 7pt, | ||
| align: (top+left, center), | ||
| stroke: none, | ||
| table.header([*Signature*], [*Bus size*]), | ||
| table.hline(stroke: 1pt), | ||
| table.vline(stroke: 1pt, x: 1), | ||
| ..for sig in interactions { | ||
| ([#render_signature(sig)], [#interaction_bus_size(sig)]) | ||
| }, | ||
| ), | ||
| caption: "Signature overview of interactions", | ||
| ) | ||
|
|
||
| #let templates = signatures.signatures.filter(s => s.kind == "template") | ||
| Below, we list the signatures of the #templates.len() templates in this VM. | ||
| #figure( | ||
| table( | ||
| columns: 1fr, | ||
| inset: 7pt, | ||
| align: (top+left, center), | ||
| stroke: none, | ||
| table.header([*Signature*]), | ||
| table.hline(stroke: 1pt), | ||
| ..for sig in templates { | ||
| ([#render_signature(sig)], ) | ||
| }, | ||
| ), | ||
| caption: "Signature overview of templates", | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,178 @@ | ||
| # cond => IS_BIT<X> | ||
| [[signatures]] | ||
| tag = "IS_BIT" | ||
| kind = "template" | ||
| input = ["BaseField"] | ||
| cond = "BaseField" | ||
|
|
||
| # cond => ADD<sum; lhs, rhs> | ||
| [[signatures]] | ||
| tag = "ADD" | ||
| kind = "template" | ||
| input = ["DWordWL", "DWordWL"] | ||
| output = "DWordWL" | ||
| cond = "BaseField" | ||
|
|
||
| # cond => SUB<diff; lhs, rhs> | ||
| [[signatures]] | ||
| tag = "SUB" | ||
| kind = "template" | ||
| input = ["DWordWL", "DWordWL"] | ||
| output = "DWordWL" | ||
| cond = "BaseField" | ||
|
|
||
| # cond => NEG<neg; X> | ||
| [[signatures]] | ||
| tag = "NEG" | ||
| kind = "template" | ||
| input = ["DWordHL"] | ||
| output = "DWordWL" | ||
| cond = "Bit" | ||
|
|
||
| # SIGN<sign; X, signed> | ||
| [[signatures]] | ||
| tag = "SIGN" | ||
| kind = "template" | ||
| input = ["Half", "Bit"] | ||
| output = "Bit" | ||
|
|
||
| # DECODE[pc, imm, packed_decode] | ||
| [[signatures]] | ||
| tag = "DECODE" | ||
| kind = "interaction" | ||
| input = ["DWordWL", "DWordWL", "BaseField"] | ||
|
|
||
| # SHIFT[out; in, shift, direction, signed, word_instr] | ||
| [[signatures]] | ||
| tag = "SHIFT" | ||
| kind = "interaction" | ||
| input = ["DWordHL", "Byte", "Bit", "Bit", "Bit"] | ||
| output = "DWordWL" | ||
|
|
||
| # BRANCH[next_pc; pc, offset, register, JALR] | ||
| [[signatures]] | ||
| tag = "BRANCH" | ||
| kind = "interaction" | ||
| input = ["DWordWL", "Word", "DWordWL", "Bit"] | ||
| output = "DWordWL" | ||
|
|
||
| # MEMW[old; is_register, base_address, value, timestamp, write2, write4, write8] | ||
| [[signatures]] | ||
| tag = "MEMW" | ||
| kind = "interaction" | ||
| input = ["Bit", "DWordWL", ["BaseField", 8], "DWordWL", "Bit", "Bit", "Bit"] | ||
| output = ["BaseField", 8] | ||
|
|
||
| # MEMW[is_register, base_address, value, timestamp, write2, write4, write8] | ||
| [[signatures]] | ||
| tag = "MEMW" | ||
| kind = "interaction" | ||
| input = ["Bit", "DWordWL", ["BaseField", 8], "DWordWL", "Bit", "Bit", "Bit"] | ||
|
|
||
| # LT[lt; lhs, rhs, signed] | ||
| [[signatures]] | ||
| tag = "LT" | ||
| kind = "interaction" | ||
| input = ["DWordWL", "DWordWL", "Bit"] | ||
| output = "Bit" | ||
|
|
||
| # MUL[lo/hi; lhs, lhs_signed, rhs, rhs_signed, 0/1] | ||
| [[signatures]] | ||
| tag = "MUL" | ||
| kind = "interaction" | ||
| input = ["DWordHL", "Bit", "DWordHL", "Bit", "Bit"] | ||
| output = "DWordWL" | ||
|
|
||
| # DVRM[q/r; n, d, signed, 0/1] | ||
| [[signatures]] | ||
| tag = "DVRM" | ||
| kind = "interaction" | ||
| input = ["DWordHL", "DWordHL", "Bit", "Bit"] | ||
| output = "DWordWL" | ||
|
|
||
| # LOAD[res; base_address, timestamp, read2, read4, read8, signed] | ||
| [[signatures]] | ||
| tag = "LOAD" | ||
| kind = "interaction" | ||
| input = ["DWordWL", "DWordWL", "Bit", "Bit", "Bit", "Bit"] | ||
| output = "DWordWL" | ||
|
|
||
| # ECALL[timestamp, syscallnr] | ||
| [[signatures]] | ||
| tag = "ECALL" | ||
| kind = "interaction" | ||
| input = ["DWordWL", "DWordWL"] | ||
|
|
||
| # AND_BYTE[res; X, Y] | ||
| [[signatures]] | ||
| tag = "AND_BYTE" | ||
| kind = "interaction" | ||
| input = ["Byte", "Byte"] | ||
| output = "Byte" | ||
|
|
||
| # OR_BYTE[res; X, Y] | ||
| [[signatures]] | ||
| tag = "OR_BYTE" | ||
| kind = "interaction" | ||
| input = ["Byte", "Byte"] | ||
| output = "Byte" | ||
|
|
||
| # XOR_BYTE[res; X, Y] | ||
| [[signatures]] | ||
| tag = "XOR_BYTE" | ||
| kind = "interaction" | ||
| input = ["Byte", "Byte"] | ||
| output = "Byte" | ||
|
|
||
| # MSB8[msb; X] | ||
| [[signatures]] | ||
| tag = "MSB8" | ||
| kind = "interaction" | ||
| input = ["Byte"] | ||
| output = "Bit" | ||
|
|
||
| # MSB16[msb; X] | ||
| [[signatures]] | ||
| tag = "MSB16" | ||
| kind = "interaction" | ||
| input = ["Half"] | ||
| output = "Bit" | ||
|
|
||
| # ZERO[is_zero; X] | ||
| [[signatures]] | ||
| tag = "ZERO" | ||
| kind = "interaction" | ||
| input = ["B20"] | ||
| output = "Bit" | ||
|
|
||
| # IS_BYTE[X] | ||
| [[signatures]] | ||
| tag = "IS_BYTE" | ||
| kind = "interaction" | ||
| input = ["Byte"] | ||
|
|
||
| # IS_HALF[X] | ||
| [[signatures]] | ||
| tag = "IS_HALF" | ||
| kind = "interaction" | ||
| input = ["Half"] | ||
|
|
||
| # IS_B20[X] | ||
| [[signatures]] | ||
| tag = "IS_B20" | ||
| kind = "interaction" | ||
| input = ["B20"] | ||
|
|
||
| # HWSL[res; X, shift] | ||
| [[signatures]] | ||
| tag = "HWSL" | ||
| kind = "interaction" | ||
| input = ["Half", "B4"] | ||
| output = "Half" | ||
|
|
||
| # HWSLC[res; X, shift] | ||
| [[signatures]] | ||
| tag = "HWSLC" | ||
| kind = "interaction" | ||
| input = ["Half", "B4"] | ||
| output = "Half" | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.