TAILIEUCHUNG - Verilog Programming part 28

Overriding Parameters Parameters can be defined in a module definition, as was discussed earlier in Section , Parameters. However, during compilation | Overriding Parameters Parameters can be defined in a module definition as was discussed earlier in Section Parameters. However during compilation of Verilog modules parameter values can be altered separately for each module instance. This allows us to pass a distinct set of parameter values to each module during compilation regardless of predefined parameter values. There are two ways to override parameter values through the defparam statement or through module instance parameter value assignment. defparam Statement Parameter values can be changed in any module instance in the design with the keyword defparam. The hierarchical name of the module instance can be used to override parameter values. Consider Example 9-2 which uses defparam to override the parameter values in module instances. Example 9-2 Defparam Statement Define a module hello_world module hello_world parameter id_num 0 define a module identification number 0 initial display the module identification number display Displaying hello_world id number d id_num endmodule define top-level module module top change parameter values in the instantiated modules Use defparam statement defparam 1 2 instantiate two hello_world modules hello_world w1 hello_world w2 endmodule In Example 9-2 the module hello_world was defined with a default id_num 0. However when the module instances w1 and w2 of the type hello_world are created their id_num values are modified with the defparam statement. If we simulate the above design we would get the following output Displaying hello_world id number 1 Displaying hello_world id number 2 Multiple defparam statements can appear in a module. Any parameter can be overridden with the defparam statement. The defparam construct is now considered to be a bad coding style and it is recommended that alternative styles be used in Verilog HDL code. Note that the module hello_world can also be defined using an ANSI C style parameter declaration. Figure 9-3 .

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.