Class: HDLRuby::Low::TimeWait

Inherits:
Statement
  • Object
show all
Defined in:
lib/HDLRuby/hruby_db.rb,
lib/HDLRuby/hruby_low.rb,
lib/HDLRuby/hruby_low2c.rb,
lib/HDLRuby/hruby_low2vhd.rb,
lib/HDLRuby/hruby_verilog.rb,
lib/HDLRuby/hruby_low2high.rb,
lib/HDLRuby/hruby_low_mutable.rb,
lib/HDLRuby/hruby_low_skeleton.rb,
lib/HDLRuby/hruby_low_fix_types.rb,
lib/HDLRuby/hruby_low_bool2select.rb,
lib/HDLRuby/hruby_low_without_select.rb,
lib/HDLRuby/hruby_low_casts_without_expression.rb

Overview

Extends the TimeWait class with functionality for extracting expressions from cast.

Direct Known Subclasses

High::TimeWait

Constant Summary

Constants included from Low2Symbol

Low2Symbol::Low2SymbolPrefix, Low2Symbol::Low2SymbolTable, Low2Symbol::Symbol2LowTable

Instance Attribute Summary collapse

Attributes included from Hparent

#parent

Instance Method Summary collapse

Methods inherited from Statement

#add_blocks_code, #behavior, #block, #blocks2seq!, #break_types!, #delete_related!, #delete_unless!, #extract_declares!, #mix?, #parent_system, #replace_expressions!, #replace_names!, #scope, #to_upper_space!, #top_block, #top_scope, #use_name?, #with_boolean!

Methods included from Low2Symbol

#to_sym

Methods included from Hparent

#scope

Constructor Details

#initialize(delay) ⇒ TimeWait

Creates a new statement waiting +delay+.



3296
3297
3298
3299
3300
3301
3302
3303
3304
# File 'lib/HDLRuby/hruby_low.rb', line 3296

def initialize(delay)
    # Check and set the delay.
    unless delay.is_a?(Delay)
        raise AnyError, "Invalid class for a delay: #{delay.class}."
    end
    @delay = delay
    # And set its parent.
    delay.parent = self
end

Instance Attribute Details

#delayObject (readonly)

The delay to wait.



3293
3294
3295
# File 'lib/HDLRuby/hruby_low.rb', line 3293

def delay
  @delay
end

Instance Method Details

#boolean_in_assign2select!Object

Converts booleans in assignments to select operators.



126
127
128
129
# File 'lib/HDLRuby/hruby_low_bool2select.rb', line 126

def boolean_in_assign2select!
    # Nothing to do.
    return self
end

#casts_without_expression!Object

Extracts the expressions from the casts.



123
124
125
126
# File 'lib/HDLRuby/hruby_low_casts_without_expression.rb', line 123

def casts_without_expression!
    # Nothing to do.
    return self
end

#cloneObject

Clones the TimeWait (deeply)



3319
3320
3321
# File 'lib/HDLRuby/hruby_low.rb', line 3319

def clone
    return TimeWait.new(@delay.clone)
end

#each_block(&ruby_block) ⇒ Object

Iterates over the sub blocks.



3340
3341
3342
3343
3344
3345
# File 'lib/HDLRuby/hruby_low.rb', line 3340

def each_block(&ruby_block)
    # No ruby block? Return an enumerator.
    return to_enum(:each_block) unless ruby_block
    # A ruby block?
    # Nothing to do.
end

#each_block_deep(&ruby_block) ⇒ Object

Iterates over all the blocks contained in the current block.



3348
3349
3350
3351
3352
3353
# File 'lib/HDLRuby/hruby_low.rb', line 3348

def each_block_deep(&ruby_block)
    # No ruby block? Return an enumerator.
    return to_enum(:each_block_deep) unless ruby_block
    # A ruby block?
    # Nothing to do.
end

#each_node(&ruby_block) ⇒ Object

Iterates over the expression children if any.



3324
3325
3326
3327
3328
3329
# File 'lib/HDLRuby/hruby_low.rb', line 3324

def each_node(&ruby_block)
    # No ruby block? Return an enumerator.
    return to_enum(:each_node) unless ruby_block
    # A ruby block?
    # Nothing to do.
end

#each_node_deep(&ruby_block) ⇒ Object

Iterates over the nodes deeply if any.



3332
3333
3334
3335
3336
3337
# File 'lib/HDLRuby/hruby_low.rb', line 3332

def each_node_deep(&ruby_block)
    # No ruby block? Return an enumerator.
    return to_enum(:each_node_deep) unless ruby_block
    # A ruby block? First apply it to current.
    ruby_block.call(self)
end

#each_statement_deep(&ruby_block) ⇒ Object

Iterates over all the statements contained in the current block.



3356
3357
3358
3359
3360
3361
3362
# File 'lib/HDLRuby/hruby_low.rb', line 3356

def each_statement_deep(&ruby_block)
    # No ruby block? Return an enumerator.
    return to_enum(:each_statement_deep) unless ruby_block
    # A ruby block?
    # Apply it on self.
    ruby_block.call(self)
end

#eql?(obj) ⇒ Boolean

Comparison for hash: structural comparison.

Returns:

  • (Boolean)


3307
3308
3309
3310
3311
# File 'lib/HDLRuby/hruby_low.rb', line 3307

def eql?(obj)
    return false unless obj.is_a?(TimeWait)
    return false unless @delay.eql?(obj.delay)
    return true
end

#explicit_types!Object

Explicit the types conversions in the time wait.



143
144
145
146
# File 'lib/HDLRuby/hruby_low_fix_types.rb', line 143

def explicit_types!
    # Nothing to do.
    return self
end

#extract_selects!Object

Extract the Select expressions.



105
106
107
108
# File 'lib/HDLRuby/hruby_low_without_select.rb', line 105

def extract_selects!
    # Nothing to extract.
    return []
end

#hashObject

Hash function.



3314
3315
3316
# File 'lib/HDLRuby/hruby_low.rb', line 3314

def hash
    return [@delay].hash
end

#map_nodes!(&ruby_block) ⇒ Object

Maps on the children (including the condition).



972
973
974
# File 'lib/HDLRuby/hruby_low_mutable.rb', line 972

def map_nodes!(&ruby_block)
    # Nothing to do.
end

#set_delay!(delay) ⇒ Object

Sets the delay.



961
962
963
964
965
966
967
968
969
# File 'lib/HDLRuby/hruby_low_mutable.rb', line 961

def set_delay!(delay)
    # Check and set the delay.
    unless delay.is_a?(Delay)
        raise AnyError, "Invalid class for a delay: #{delay.class}."
    end
    @delay = delay
    # And set its parent.
    delay.parent = self
end

#to_c(level = 0) ⇒ Object

Generates the C text of the equivalent HDLRuby::High code. +level+ is the hierachical level of the object.



1238
1239
1240
1241
1242
1243
1244
1245
1246
# File 'lib/HDLRuby/hruby_low2c.rb', line 1238

def to_c(level = 0)
    # The resulting string.
    res = " " * level*3
    # Generate the wait.
    res << "hw_wait(#{self.delay.to_c(level+1)}," +
        "#{Low2C.behavior_access(self)});\n"
    # Return the resulting string.
    return res
end

#to_high(level = 0) ⇒ Object

Generates the text of the equivalent HDLRuby::High code. +level+ is the hierachical level of the object.



439
440
441
442
443
444
445
446
# File 'lib/HDLRuby/hruby_low2high.rb', line 439

def to_high(level = 0)
    # The resulting string.
    res = " " * (level*3)
    # Generate the wait.
    res << "wait " << self.delay.to_high(level) << "\n" 
    # Return the resulting string.
    return res
end

#to_verilog(mode = nil) ⇒ Object



1700
1701
1702
# File 'lib/HDLRuby/hruby_verilog.rb', line 1700

def to_verilog(mode=nil)
    return self.delay.to_verilog + "\n"
end

#to_vhdl(vars, level = 0) ⇒ Object

Generates the text of the equivalent HDLRuby::High code. +vars+ is the list of the variables and +level+ is the hierachical level of the object.



1010
1011
1012
1013
1014
1015
1016
1017
# File 'lib/HDLRuby/hruby_low2vhd.rb', line 1010

def to_vhdl(vars,level = 0)
    # The resulting string.
    res = " " * (level*3)
    # Generate the wait.
    res << "wait for " << self.delay.to_vhdl(level) << ";\n" 
    # Return the resulting string.
    return res
end