diff options
| author | Adam Izraelevitz | 2020-08-21 12:02:26 -0700 |
|---|---|---|
| committer | GitHub | 2020-08-21 19:02:26 +0000 |
| commit | 7edba2d10f980016462f917c6d21d64585ddfd6b (patch) | |
| tree | 3eb2a106b0e528b1ae8ed05b54200f828902de09 /docs/src/wiki-deprecated/functional-abstraction.md | |
| parent | 70fd01d4b0ad18a87bc46558ff246254792aa9b8 (diff) | |
Added website docs and mdoc. (#1560)
* Added website docs and mdoc. Removed all warnings
* Updated README and added build to circle ci
* Added how to build documentation, deprecated wiki
* Fix copypasta
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Diffstat (limited to 'docs/src/wiki-deprecated/functional-abstraction.md')
| -rw-r--r-- | docs/src/wiki-deprecated/functional-abstraction.md | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/docs/src/wiki-deprecated/functional-abstraction.md b/docs/src/wiki-deprecated/functional-abstraction.md new file mode 100644 index 00000000..04dde7d1 --- /dev/null +++ b/docs/src/wiki-deprecated/functional-abstraction.md @@ -0,0 +1,29 @@ +--- +layout: docs +title: "Functional Abstraction" +section: "chisel3" +--- +We can define functions to factor out a repeated piece of logic that +we later reuse multiple times in a design. For example, we can wrap +up our earlier example of a simple combinational logic block as +follows: +```scala +def clb(a: UInt, b: UInt, c: UInt, d: UInt): UInt = + (a & b) | (~c & d) +``` + +where ```clb``` is the function which takes ```a```, ```b```, +```c```, ```d``` as arguments and returns a wire to the output of a +boolean circuit. The ```def``` keyword is part of Scala and +introduces a function definition, with each argument followed by a colon then its type, +and the function return type given after the colon following the +argument list. The equals (```=})```sign separates the function argument list from the function +definition. + +We can then use the block in another circuit as follows: +```scala +val out = clb(a,b,c,d) +``` + +We will later describe many powerful ways to use functions to +construct hardware using Scala's functional programming support. |
