Decompilation
Decompiling, Adding Pins, & Executing
OrigenTesters
includes the
OrigenTesters::Decompiler
mixin.
In addition to decompiling, this mixin provides some shorthand methods
for adding pins and executing
A quick summary:
# Decompile a pattern source from a file
OrigenTesters.decompile('path/to/src')
OrigenTesters.add_pins('path/to_src')
#=> Queries the pattern's pins and adds any missing pins to the DUT
OrigenTesters.execute('path/to/src')
#=> Executes the pattern source in its entirety.
#add_pins
nor #execute
support input as
a direct source. Use #decompile_text
to get decompiled pattern,
then call #add_pins
or #execute
on that,
as shown in the example.
Decompiling the pattern source is the first step to working with it in Origen. The
#decompile
method, when called on the Decompiler API
, will do two things:
- Using the pattern’s extension, attempt to match the pattern source to the applicable decompiler.
- Decompile the source, returning the decompiled pattern object.
For example, any input ending with .atp
routes to the IGXLBasedTester
decompiler and input ending with .avc
routes to the SmartestBasedTester
decompiler.
pat = OrigenTesters.decompile('path/to/src.atp')
#=> OrigenTesters::IGXLBasedTester::Pattern
pat.decompiled?
#=> true
pat = OrigenTesters.decompile('path/to/src.avc')
#=> OrigenTesters::SmartestBasedTester::Pattern
pat.decompiled?
#=> true
You can also a get a pre-decompiled pattern object using #decompiled_pattern
:
pat = OrigenTesters.decompiled_pattern('path/to/src.atp')
#=> OrigenTesters::IGXLBasedTester::Pattern
pat.decompiled?
#=> false
pat = OrigenTesters.decompiled_pattern('path/to/src.avc')
#=> OrigenTesters::SmartestBasedTester::Pattern
pat.decompiled?
#=> false
If either method cannot find an applicable decompiler given the extension, an exception is raised:
pat = OrigenTesters.decompiled_pattern('path/to/src.blah')
#=> OrigenTesters::Decompiler::NoSuitableDecompiler
#=> Fail in origen_testers: Cannot find a suitable decompiler for pattern source 'pat.blah' ('.blah')
If you want to decompile a source from a String
object directly, use #decompile_text
.
You’ll need to provide the applicable decompiler, as the Decompiler API
is
not able to map a text source to the appropriate decompiler:
pat = OrigenTesters.decompile_text("src as string", decompiler: OrigenTesters::IGXLBasedTester::Pattern)
#=> OrigenTesters::SmartestBasedTester::Pattern
pat.decompiled?
#=> true
Platforms can register themselves as an available decompiler
during bootup.
Discerning the appropriate decompiler boils down to asking each registered
decompiler if it is available to decompile the given source. Each decompiler
will respond yes or no and on the first yes,
that decompiler will be selected. If no decompilers respond yes,
a OrigenTesters::Decompiler::NoSuitableDecompiler
exception is raised.
As a user of the decompiler, simply inputting an appropriately named source should trigger the correct decompiler, but the methods used underneath are available as well:
### See the registered decompilers
OrigenTesters.registered_decompilers
#=> [OrigenTesters::IGXLBasedTester, OrigenTesters::SmartestBasedTester]
### See if an applicable decompiler exists for the pattern source
OrigenTesters.decompiler_for?("pat.atp")
#=> true
OrigenTesters.decompiler_for?("pat.blah")
#=> false
### Given the pattern source, select the appropriate decompiler, or return nil
OrigenTesters.select_decompiler("pat.atp")
#=> OrigenTesters::IGXLBasedTester::Pattern
OrigenTesters.select_decompiler("pat.blah")
#=> nil
### Given the pattern source, select the appropriate decompiler or raise and exception
### (Notice the '!')
OrigenTesters.select_decompiler!("pat.atp")
#=> OrigenTesters::IGXLBasedTester::Pattern
OrigenTesters.select_decompiler!("pat.blah")
#=> OrigenTesters::Decompiler::NoSuitableDecompiler
#=> Fail in origen_testers: Cannot find a suitable decompiler for pattern source 'pat.blah' ('.blah')
### See if the given module provides a decompiler
OrigenTesters.registered_decompiler?(OrigenTesters::IGXLBasedTester)
#=> true
OrigenTesters.registered_decompiler?(Origen)
#=> false
The Decompiler API
supports some short-hand calls to common methods. The calls
here are equivalent to calling #decompile
, then the corresponding method on
that decompiled pattern.
Recall that #add_pins
compares the available pins between the pattern source and
the DUT
and adds any missing pins from the pattern source to the DUT
, returning
any pins that it added. The Decompiler API
has a shorthand method to perform
this operation: OrigenTesters.add_pins('path/to/src')
. This will:
- Decompile the source, using the corresponding platform decompiler.
- Add any missing pins to the
DUT
.
OrigenTesters.add_pins('pat.atp')
# Decompiles the pattern using the .atp decompiler
# Adds the pins to the DUT
# Returns any pins added to the DUT
#=> Array
Recall that #execute
will actually execute the decompiled pattern in the context
of the current DUT
.
Assuming the current DUT
has been instantiated and all timesets are defined,
calling OrigenTesters.execeute('path/to/src')
will:
- Decompile the source, using the corresponding platform decompiler.
- Add any missing pins to the
DUT
. - Execute the pattern.
OrigenTesters.execute('pattern.atp')
# Decompiles the pattern using the .atp decompiler
# Adds the pins to the DUT
# Execute the pattern source
# Returns the decompiled pattern object
#=> OrigenTesters::IGXLBasedTesters::Pattern