Difference between revisions of "OldInstantiationMethods"

From Genesis2
Jump to: navigation, search
(Created page with "== Older (still supported) Genesis2 Instantiation Methods == Back To Main Genesis2 Instantiation Methods Guide")
 
(Older (still supported) Genesis2 Instantiation Methods)
Line 2: Line 2:
  
 
[[Genesis2#Module_Instantiation_Methods|Back To Main Genesis2 Instantiation Methods Guide]]
 
[[Genesis2#Module_Instantiation_Methods|Back To Main Genesis2 Instantiation Methods Guide]]
 +
 +
; sub unique_inst
 +
: The main function call for  generating (and later instantiating) a new module. Note that this call on its own would not print anything to the output module. Rather, it will return a pointer to the instance module (''$unique_inst'' in the code bellow). Use the ''$unique_inst->instantiate()'' and other methods as described above to query this new module and then decide what to print to the generated module code.
 +
<pre>
 +
//; my $newObj= $self->unique_inst(base_module_name, inst_name, prm1 => val1, prm2 => val2, ...);
 +
</pre>
 +
 +
''Example: Before (SystemVerilog)''
 +
<pre>
 +
Adder#(.w(8),.n(4)) MyAdder(.in1(a),.in2(b),.out(c));
 +
</pre>
 +
 +
''Example: After (Genesis2)''
 +
<pre>
 +
//; my $my_adder = $self->unique_inst('Adder', 'MyAdder', w=>8, n=>4);
 +
`$my_adder->instantiate()` (.in1(a), .in2(b), .out(c));
 +
</pre>

Revision as of 22:45, 8 November 2011

Older (still supported) Genesis2 Instantiation Methods

Back To Main Genesis2 Instantiation Methods Guide

sub unique_inst
The main function call for generating (and later instantiating) a new module. Note that this call on its own would not print anything to the output module. Rather, it will return a pointer to the instance module ($unique_inst in the code bellow). Use the $unique_inst->instantiate() and other methods as described above to query this new module and then decide what to print to the generated module code.
//; my $newObj= $self->unique_inst(base_module_name, inst_name, prm1 => val1, prm2 => val2, ...);

Example: Before (SystemVerilog)

Adder#(.w(8),.n(4)) MyAdder(.in1(a),.in2(b),.out(c));

Example: After (Genesis2)

//; my $my_adder = $self->unique_inst('Adder', 'MyAdder', w=>8, n=>4);
`$my_adder->instantiate()` (.in1(a), .in2(b), .out(c));