TAILIEUCHUNG - Verilog Programming part 26

Functions Functions are declared with the keywords function and endfunction. Functions are used if all of the following conditions are true for the procedure | Functions Functions are declared with the keywords function and endfunction. Functions are used if all of the following conditions are true for the procedure There are no delay timing or event control constructs in the procedure. The procedure returns a single value. There is at least one input argument. There are no output or inout arguments. There are no nonblocking assignments. Function Declaration and Invocation The syntax for functions is follows Example 8-6 Syntax for Functions function_declaration function automatic signed range_or_type function_identifier function_item_declaration function_item_declaration function_statement endfunction function automatic signed range_or_type function_identifier function_port_list block_item_declaration block_item_declaration function_statement endfunction function_item_declaration block_item_declaration tf_input_declaration function_port_list attribute_instance tf_input_declaration attribute_instance tf_input_declaration range_or_type range integer real realtime time There are some peculiarities of functions. When a function is declared a register with name function_identifer is declared implicitly inside Verilog. The output of a function is passed back by setting the value of the register function_identifer appropriately. The function is invoked by specifying function name and input arguments. At the end of function execution the return value is placed where the function was invoked. The optional range_or_type specifies the width of the internal register. If no range or type is specified the default bit width is 1. Functions are very similar to FUNCTION in FORTRAN. Notice that at least one input argument must be defined for a function. There are no output arguments for functions because the implicit register function_identifer contains the output value. Also functions cannot invoke other tasks. They can invoke only other functions. Function Examples We will discuss two examples. The first example models a

TAILIEUCHUNG - Chia sẻ tài liệu không giới hạn
Địa chỉ : 444 Hoang Hoa Tham, Hanoi, Viet Nam
Website : tailieuchung.com
Email : tailieuchung20@gmail.com
Tailieuchung.com là thư viện tài liệu trực tuyến, nơi chia sẽ trao đổi hàng triệu tài liệu như luận văn đồ án, sách, giáo trình, đề thi.
Chúng tôi không chịu trách nhiệm liên quan đến các vấn đề bản quyền nội dung tài liệu được thành viên tự nguyện đăng tải lên, nếu phát hiện thấy tài liệu xấu hoặc tài liệu có bản quyền xin hãy email cho chúng tôi.
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.