Class: CrossOrigen::OrigenFormat
- Inherits:
-
Object
- Object
- CrossOrigen::OrigenFormat
- Defined in:
- lib/cross_origen/origen_format.rb
Constant Summary collapse
- SUB_BLOCK_ATTRS =
{ base_address: 'IP base address', byte_order: 'Describes endianness of the IP. Values possible are :big_endian and :little_endian', lau: 'IP Least Addressable Unit: Values possible are (1..32)', version: 'IP version', instance: 'IP instance', instance_module: 'IP module', class_name: 'Class name', instance: 'IP instance', instance_module: 'IP module', addr_block_name: 'Address block name', space: 'Address block space' }
- FILE_COMMENTS =
{ class: "\# This file is created by Origen via CrossOrigen::OrigenFormat#export, and is read-only.\n\# If you need to make changes, re-open the class\n", incl: "\# This file is created by Origen via CrossOrigen::OrigenFormat#export, and is read-only" }
Instance Attribute Summary collapse
-
#file_content ⇒ Object
readonly
Returns the value of attribute file_content.
-
#incl_dir ⇒ Object
readonly
Returns the value of attribute incl_dir.
-
#incl_path ⇒ Object
readonly
Returns the value of attribute incl_path.
-
#inst_level ⇒ Object
readonly
Returns the value of attribute inst_level.
-
#obj ⇒ Object
readonly
Returns the value of attribute obj.
-
#output_dir ⇒ Object
readonly
Returns the value of attribute output_dir.
-
#top_level_class ⇒ Object
readonly
Returns the value of attribute top_level_class.
-
#top_level_hierarchy ⇒ Object
readonly
Returns the value of attribute top_level_hierarchy.
-
#top_level_path ⇒ Object
readonly
Returns the value of attribute top_level_path.
Instance Method Summary collapse
- #export ⇒ Object
-
#initialize(options = {}) ⇒ OrigenFormat
constructor
A new instance of OrigenFormat.
Constructor Details
#initialize(options = {}) ⇒ OrigenFormat
Returns a new instance of OrigenFormat.
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/cross_origen/origen_format.rb', line 26 def initialize( = {}) = { obj: $dut, path: "#{Origen.root!}/output", instantiate_level: :top }.update() @obj = [:obj] @output_dir = [:path] @inst_level = [:instantiate_level] fail "@instantiate_level must be either set to ':top' or ':sub_block'" unless [:top, :sub_block].include?(@inst_level) @top_level_path = "#{output_dir}/top_level.rb" @incl_path = "#{output_dir}/sub_blocks.rb" @incl_dir = "#{output_dir}/import" @top_level_hierarchy = get_namespace() @top_level_class = @top_level_hierarchy.keys.last # first key is file type (:bom or :incl) and second is object name @file_content = Hash.new do |h, k| h[k] = {} end end |
Instance Attribute Details
#file_content ⇒ Object (readonly)
Returns the value of attribute file_content.
24 25 26 |
# File 'lib/cross_origen/origen_format.rb', line 24 def file_content @file_content end |
#incl_dir ⇒ Object (readonly)
Returns the value of attribute incl_dir.
24 25 26 |
# File 'lib/cross_origen/origen_format.rb', line 24 def incl_dir @incl_dir end |
#incl_path ⇒ Object (readonly)
Returns the value of attribute incl_path.
24 25 26 |
# File 'lib/cross_origen/origen_format.rb', line 24 def incl_path @incl_path end |
#inst_level ⇒ Object (readonly)
Returns the value of attribute inst_level.
24 25 26 |
# File 'lib/cross_origen/origen_format.rb', line 24 def inst_level @inst_level end |
#obj ⇒ Object (readonly)
Returns the value of attribute obj.
24 25 26 |
# File 'lib/cross_origen/origen_format.rb', line 24 def obj @obj end |
#output_dir ⇒ Object (readonly)
Returns the value of attribute output_dir.
24 25 26 |
# File 'lib/cross_origen/origen_format.rb', line 24 def output_dir @output_dir end |
#top_level_class ⇒ Object (readonly)
Returns the value of attribute top_level_class.
24 25 26 |
# File 'lib/cross_origen/origen_format.rb', line 24 def top_level_class @top_level_class end |
#top_level_hierarchy ⇒ Object (readonly)
Returns the value of attribute top_level_hierarchy.
24 25 26 |
# File 'lib/cross_origen/origen_format.rb', line 24 def top_level_hierarchy @top_level_hierarchy end |
#top_level_path ⇒ Object (readonly)
Returns the value of attribute top_level_path.
24 25 26 |
# File 'lib/cross_origen/origen_format.rb', line 24 def top_level_path @top_level_path end |
Instance Method Details
#export ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/cross_origen/origen_format.rb', line 48 def export # Delete any previous files FileUtils.rm_rf(@incl_dir) if File.exist?(@incl_dir) FileUtils.mkdir_p(@incl_dir) # Check if previous version of top-level files exist and delete them File.delete(@top_level_path) if File.exist?(@top_level_path) File.delete(@incl_path) if File.exist?(@incl_path) # Create the sub_block objects in the top_level.rb file # This method will create each required class file recursively (indirectly) # and will gather all of the information required to create the include file. # In essence it does it all create_bom end |