Defparam usage in OpenGL (passing of parameters of underlying modules (only changed) called by OpenGL)

Source: Internet
Author: User

When a module references another module, the High-Level module can change the parameter value defined by parameter for the lower-level module. The following two methods can be used to change the parameter value of the lower-level module:

1) defparam redefinition Parameters

Syntax: defparam path_name = value;

The parameters of the lower-level module can be redefined through the hierarchical path name, for example:

Module top (.....)
Input ....;
Output ....;
Defparam U1. para1 = 10;
M1 U1 (..........);
Endmodule
Module M1 (....);
Parameter para1 = 5;
Input ...;
Output ...;
......
Endmodule

In the preceding example, the default value of para1 of the module M1 parameter is 5, while that of the module top instance M1 is changed to 10.

2) passing parameters during instantiation

In this method, parameters are passed in during instantiation, as shown in the following example:

Module top (.....)
Input ....;
Output ....;
M1 # (10) U1 (..........);
Endmodule

In this example, the parameter para1 in the previous example is modified with # (10). When multiple parameters exist, separate them with commas (,), for example, # (10, 5,

3) three parameter values are passed.

The module parameter method makes the module more reusable. When the same module needs to be instantiated multiple times in the same design, but the parameter values are different, the module parameter method can be used, instead of generating multiple files because of different parameters.

 

Reference:

Use defparam to define the parameter declaration statement!
Defparam sample module name. Parameter Name 1 = constant expression,
Sample Module name. parameter name 2 = constant expression ,......;
Format
The defparam statement can be used to redefine the parameter value during compilation.
Comprehensive problems: Generally, they cannot be integrated.
Tip: Do not use the defparam statement! When the instance of the module is referenced, the "#" and the parameter syntax can be used to redefine the parameter.

[Example]
Module Mod (Out, INA, INB );
...
Parameter cycle = 8, real_constant = 2.039,
File = "/user1/jmdong/design/mem_file.dat ";
...
Endmodule
Module test;
...
MoD MK (Out, INA, INB); // reference the module mod instance
Defparam Mk. cycle = 6, MK. File = "../my_mem.dat"; // Transfer Parameters
...
Endmodule

5. parameter transfer when a module instance is referenced -- Method 2: Use the special symbol "#"
[Example]
Module Mod (Out, INA, INB );
...
Parameter cycle = 8, real_constant = 2.039,
File = "/user1/jmdong/design/mem_file.dat ";
...
Endmodule
Module test;
...
MoD # (5, 3.20, "../my_mem.dat") MK (Out, INA, INB); // reference the module mod instance
...
Endmodule
Referenced Module
Parameter transfer
It must match the parameters in the referenced module one by one!
This method is recommended!
Referenced Module name # (parameter 1, parameter 2 ,...) Name of the sample module (port list );

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.