Skip to content
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

[DSLX] Auto-format documentation examples, enforce in documentation_test.py #1832

Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 10 additions & 12 deletions docs_src/dslx_ffi.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,7 @@ as well as a implementation that is functionally equivalent. Here, there is one
mapped to the return of the DSLX function:

```dslx
fn foo(a: u32) -> u32 {
a + u32:1
}
fn foo(a: u32) -> u32 { a + u32:1 }
```

You can now add an annotation `#[extern_verilog("...")]` to the DSLX function
Expand All @@ -57,7 +55,7 @@ myfoo {fn} ( // Placeholder for the instantiation name.
); // Semicolon optional, code-generation will always add one.
")]
fn foo(a: u32) -> u32 {
a + u32:1
a + u32:1
}
```

Expand Down Expand Up @@ -96,8 +94,8 @@ myfoo {fn} #(
.out({return})
)
")]
fn foo<WIDTH:u32>(a:bits[WIDTH]) -> bits[WIDTH] {
a + uN[WIDTH]:1
fn foo<WIDTH: u32>(a: bits[WIDTH]) -> bits[WIDTH] {
a + uN[WIDTH]:1
}
```

Expand All @@ -121,8 +119,8 @@ mybar {fn} (
.otherout({return.1})
)
")]
fn bar(a:(s32, s32), b:s32) -> (s32, s32) {
(a.0 + a.1, b)
fn bar(a: (s32, s32), b: s32) -> (s32, s32) {
(a.0 + a.1, b)
}
```

Expand Down Expand Up @@ -160,8 +158,8 @@ mybaz {fn} #(
.out({return})
)
")]
fn baz(a:u32, b:u32, c:u32) -> u32 {
u32:42 // local implementation
fn baz(a: u32, b: u32, c: u32) -> u32 {
u32:42 // local implementation
}
```

Expand Down Expand Up @@ -190,8 +188,8 @@ myquux {fn} (

assign {return} = ({RESULT_BITS})'({return}_adapted_to_module);
")]
fn quux<RESULT_BITS:u32>(a:u32) -> uN[RESULT_BITS] {
a as uN[RESULT_BITS]
fn quux<RESULT_BITS: u32>(a: u32) -> uN[RESULT_BITS] {
a as uN[RESULT_BITS]
}
```

Expand Down
Loading