From Genesis2
Revision as of 23:18, 8 November 2011 by Shacham (talk | contribs) (Older (still supported) Genesis2 Instantiation Methods)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

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));

sub clone_inst
An API method for replicating a module based on an existing instance (i.e., get a handle, or object, which is another instance/copy of an existing one).
//; my $clonedObj = $self->clone_inst($src_inst, 'new_inst_name');

Note that <src_inst> can either be a path (e.g., top.subinst.subsubinst) or it can be just an instance object (like the ones returned by unique_inst or clone_inst)

sub ununique_inst
It turns out that some people want to generate only the base module. For example, Mrs. F. in her mixed signal chip wanted to generate only one type of her analog.vp module as that module needs to be replaced with an analog macro at PNR. Furthermore, she prefers if it remains with the name analog and not be renamed to analog_unq1 as genesis generally does at elaboration. To facilitate that, we created the new ununique_inst method. ununique_inst will generate the base module and not anything else.
  • If you generate multiple instances of a module using ununique_inst, genesis is still smart enough to make sure that you are always generating exactly the same module, and otherwise through an error that you can't generate the same un-uniquified module twice in two different ways.
  • You CAN use both the unique instantiation (i.e., unique_inst) and the non-unique instantiation (i.e., ununique_inst) in the same code. No contradictions here.
//; my $MyAnalog_obj = $self->ununique_inst('Analog', 'MyAnalog', w=>8, n=>4);
`$MyAnalog_obj ->instantiate` (.in1(a), .in2(b), .out(c));