VHDL Programming by Example phần 4

Ví dụ, nếu bạn đang thiết kế một CPU, một khối có thể là một ALU, một ngân hàng khác đăng ký, và shifter một. Mỗi khối đại diện cho một khu vực khép kín của mô hình. Mỗi khối có thể khai báo các tín hiệu địa phương, các loại, các hằng số, và như vậy. | 132 Chapter Five TYPE fourvalvector IS ARRAY natural RANGE OF fourval FUNCTION resolve s fourvalvector RETURN fourval SUBTYPE resfour IS resolve fourval END fourpack USE ENTITY mux2 IS PORT i1 i2 a IN fourval q OUT fourval END mux2 ARCHITECTURE different OF mux2 IS COMPONENT and2 PORT a b IN fourval c OUT fourval END COMPONENT COMPONENT inv PORT a IN fourval b OUT fourval END COMPONENT SIGNAL nota fourval -- resolved signal SIGNAL intq resolve fourval X BEGIN U1 inv PORT MAP a nota U2 and2 PORT MAP i1 a intq U3 and2 PORT MAP i2 nota intq q intq END different The package fourpack declares all of the appropriate types and function declarations so that the resolution function resolve is visible in the entity. In the architecture declaration section signal intq is declared of type fourval using the resolution function resolve. This signal is also given an initial value of X. Signal intq is required to have a resolution function because it is the output signal for components U2 and U3. Each component provides a driver to signal intq. Resolution function resolve is used to determine the end result of the two driver values. Signal nota is not required to have a resolution function because it only has one driver component U1. Subprograms and Packages 133 Procedures In the earlier section describing functions we discussed how functions can have a number of input parameters and always return one value. In contrast procedures can have any number of in out and inout parameters. A procedure call is considered a statement of its own a function usually exists as part of an expression. The most usual case of using a procedure is when more than one value is returned. Procedures have basically the same syntax and rules as functions. A procedure declaration begins with the keyword PROCEDURE followed by the procedure name and then an argument list. The main difference between a function and a procedure is that the procedure argument list most likely has a direction .

Không thể tạo bản xem trước, hãy bấm tải xuống
TỪ KHÓA LIÊN QUAN
TÀI LIỆU MỚI ĐĂNG
86    88    2    28-04-2024
Đã 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.