• 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

Compiler (Views)

Inline Compiler


The conventional use of the compiler generates an output file for every template that is compiled.

Sometimes though it can be useful to invoke the compiler and get the output back as a string so that you can further process it, embed it in another file, or otherwise work with it in some way.

Use the following API to invoke the compiler in an in-line manner such that it will return a string rather than generate a file:

Origen.compile("#{Origen.root}/app/templates/my_template.txt.erb", some_option: 10)

Any options given as shown above will be available in the options hash within the template in the usual way.

The inline compiler will also accept the template in the form of a string:

template =<<-END
X is: 
END

Origen.compile(template, string: true, x: 10)

Changing Scope

The compile command will accept a :scope option to have the template compile such that ‘self’ inside the template will refer to an existing object. i.e. to give the template direct access to all of that objects methods and attributes:

Origen.compile("#{Origen.root}/app/templates/my_template.txt.erb", scope: $dut)

For example let’s say we had a simple template like this to display some information about an ATD block:

# app/templates/atd.txt.erb

Type: <%= type %>
Bits: <%= bits %>

Then in our model let’s say we have two ATD instances:

$dut.atd[0].type    # => :sar
$dut.atd[0].bits    # => 16

$dut.atd[1].type    # => :sigma_delta
$dut.atd[1].bits    # => 8

We can compile our template for each ATD as follows:

template = "#{Origen.root}/app/templates/atd.txt.erb"

Origen.compile(template, scope: $dut.atd[0])  # => "Type: sar\nBits: 16\n"
Origen.compile(template, scope: $dut.atd[1])  # => "Type: sigma_delta\nBits: 8\n"

Comments

Generated with the Origen Semiconductor Developer's Kit

Origen is released under the terms of the MIT license