Chisel Tutorial (Iv.)--function

Source: Internet
Author: User

The following content is based on 2015-7-10 version of Chisel 2.2 Tutorial Finishing


We can define some repetitive logic as functions and then use them in multiple places, for example: a simple function is defined as follows:

def CLB (A:uint, B:uint, C:uint, d:uint) = (A & B) | (~c & D)

The function CLB has four parameters a,b,c,D, where the def is a keyword defined in Scala that defines a function, followed by a colon after each argument, followed by a data type. The return type is defined after the parameter, or it canbe undefined, andchisel automatically guesses that the return type is not defined in the previous example. After the equals sign is the function body. After the function definition, it uses the following method:

Val out = CLB (A, B, C, D)


Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Chisel Tutorial (Iv.)--function

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.