• Guides
  • Videos
  • Publications
  • API
  • Github
  • Community
  • Release Notes
  • Plugins
Installing Origen
  • Introduction
  • How to Install
  • How to Install (Windows)
  • Company Customization
  • Understanding Gems
  • Invoking Considerations
  • Workspace Management
Getting Started with Origen
  • Core concepts
  • Creating a New App
  • Directory Structure
  • The Initial Commit
  • Creating New Files
  • Understanding Blocks
  • Application Architecture
Runtime Environment
  • Introduction
  • Mode
  • Environment
  • Target
  • Production Targets
  • Global Setup
  • Load Order
  • Programming
Models
  • Introduction
  • Naming
  • Definition & Hierarchy
  • Adding Attributes
  • Versioning
  • Bugs & Features
  • Package, Mode & Configuration
  • Registers
  • Pins
  • Power Domains
  • Hardware Attributes
  • Parameters
  • Specifications
  • Fuses
  • Generic Components
  • Creating Your Own Components
Compiler (Views)
  • Introduction
  • Creating Templates
  • Using Sub-Templates
  • Helpers
  • Running The Compiler
  • Inline Compiler
Controllers
  • Introduction
  • Shadow Controllers
  • Direct Controllers
Pattern Generator
  • Introduction
  • Creating Patterns
  • Pins
  • Timing and Waiting
  • Registers
  • Documenting Patterns
  • Generating by Name
  • Common API
  • J750 API
  • V93K API
  • UltraFlex API
  • STIL & Other Formats
  • Custom Testers
  • Running The PatGen
  • Concurrent Patterns
Test Program Generator
  • Introduction
  • Philosophy
  • Creating Flows
  • Managing Flow Control
  • Creating an Interface
  • Additional Resources
  • Dynamic Custom Code
  • Characterization API
  • J750 API
  • V93K Common API
  • V93K SMT7 API
  • V93K SMT8 API
  • UltraFLEX API
  • Documenting the Program
  • Creating Custom Testers
  • Running the ProgGen
Decompilation
  • Overview & Example
  • Decompiling, Adding Pins, & Executing
  • Working with Decompiled Patterns
  • Platform Specifics
Simulation
  • Introduction
  • How It Works
  • Compiling the DUT
  • AMS Support
  • Environment Setup
  • Application Setup
  • Simulating Patterns
  • Simulating Flows
  • Direct DUT Manipulation
  • Simulator Log Output
  • Artifacts
  • Debugging
Documentation Generator
  • Introduction
  • Markdown
  • Linking
  • Styling
  • Testing
  • API Generation
  • Deploying
Plugins
  • Introduction
  • Using a Plugin
  • Creating a Plugin
  • Current & Default Plugins
  • Dev Environment
  • Dev Considerations
  • Paths & Origen.root
  • Config & Origen.app
Miscellaneous
  • Revision Control
  • Origen Remotes
  • Lint Testing
  • Session Store
  • LSF API
  • Users, Emails & Maillists
  • Utilities & Helpers
  • Ruby Extensions
  • Logger
  • Adding Commands
  • Overriding Commands
  • Callbacks
  • Application Callbacks
  • Miscellaneous Topics
Advanced Topics
  • Introduction
  • Invocation Customization
  • Custom App Generators

Miscellaneous

Overriding Commands


Occasionally you might come across the need to extend Origen’s built in commands with application specific functionality.

In extreme cases the entire command can be overridden entirely by using the procedure described in Adding Commands. However in most scenarios the desire will be to add additional command switches to implement the custom behavior.

This can be achieved by overriding the command as normal and then setting a flag (usually an application attribute or global variable) that your downstream application code can then act on, before handing control back to Origen to complete the command processing as normal.

To document the new option you can pass the details to Origen via the @application_options variable and the new option will appear in the help as if it was a built-in part of the command.

Additionally, you can provide a block to Origen that will be executed if the option is given. The block should be passed as the last element of the array that is pushed to the @application_options variable and can be specified using a lambda sytax lambda { |options| options[:some_option] = true } or alternately ->(options) { options[:some_option] = true }.

Example

In one application we added an MD5 checksum to the names of all generated patterns but sometimes we needed the ability to revert back to the original names.

Such an option could be implemented by using different targets but for something so trivial it is not worth the overhead of requiring duplicate versions of all targets that need this functionality.

A more efficient implementation is therefore to add a runtime option:

# config/application.rb  
# Add an attribute to disable md5 pattern names
attr_accessor :no_md5  
# config/commands.rb
# Add an additional option to the standard command, important not
# to exit here to allow the standard Origen command to run afterwards
when "generate"
  # Option definitions must be pushed into the @application_options array, don't re-assign it!
  @application_options << ["--no_md5", "Don't apply the MD5 checksum to pattern names"]

  # To specify a block to be executed by Origen's option parser (when the option is used), include 
  # a block as the last element
  @application_options << ["--compile", "Compile the pattern", ->(options) { options[:myapp_compile] = true }]
  @application_options << ["--compiler NAME", "Compiler to use", ->(options, compiler) { options[:myapp_compiler] = compiler }]

  # Note that it is important not to delete the argument from ARGV, this is necessary to make Origen
  # fully aware of it, so that it can be passed on to any additional jobs invoked from this process
  Origen.app.no_md5 = true if ARGV.include?("--no_md5")
  # Don't exit here, allow the flow to fall through to Origen to implement the rest of the command

In our application code we then implement something to the effect of:

def pattern_name
  if Origen.app.no_md5
    # code to generate original name 
  else
    # code to generate with MD5
  end
end

Now when we run origen g -h we see our new option alongside the standard options:

Usage: origen g [space separated patterns or lists] [options]
    -t, --target NAME                Override the default target, NAME can be ...
    -l, --lsf [ACTION]               Submit jobs to the LSF, optionally specify ...
    -c, --continue                   Continue on error (to the next pattern)
    -f, --file FILE                  Override the default log file
    -o, --output DIR                 Override the default output directory
    -r, --reference DIR              Override the default reference directory
    -d, --debugger                   Enable the debugger
        --no_md5                     Don't apply the MD5 checksum to pattern names

    -h, --help                       Show this message

Comments

Generated with the Origen Semiconductor Developer's Kit

Origen is released under the terms of the MIT license