Task and function in SV

Source: Internet
Author: User

The task and function in the SV do not need to be added with a begin. End to indicate the body.

Task Muliple_line;

... the body ...

Endtask:multiple_line

The subroutine returns when it executes to the last line of the subroutine, assigns the return value to a variable with the same name as the function, or it can call return explicitly.

The sub-programs of module and program in SV are stored statically by default, and when dynamic storage is required, it is still necessary to explicitly indicate with automatic explicitly. (Automatic is the default in class)

The default value for the parameter in the subroutine is logic input. Verilog sub-program parameter processing is, when entering the subroutine, input and inout values are assigned to the subroutine local variables, when the subroutine returns the output and

The value of the inout is assigned to the variable in the module. The SV adds a way to ref, which is specified as a reference instead of a copy. This method can only be used in automatic subroutines, the advantage of which is in the subroutine

Modify the variable to swap with its module is always visible.

Task Bus_read (input logic [31:0] addr, ref logic [31:0]data); Initial fork

                       bus.request = 1 ' b1;                                                                                   bus_read (addr,data);

                       @ (Posedge bus.grant)   BUS.ADDR =addr;                                                     thread2:  begin           //uses the ref type to pass data, which does not require the

                       @ (Posedge bus.enable)   data = bus.data;                                                                     @data     //to wait until the bus_read process finishes,

                       .......                                                                                                                             $display; Thread2 can see the change of data

        endtask:bus_read                                                                                                                   end

Join

Task and function in SV

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.