Class: HDLRuby::Low::TimeWait

Inherits:
Statement show all
Defined in:
lib/HDLRuby/hruby_low.rb,
lib/HDLRuby/hruby_viz.rb,
lib/HDLRuby/hruby_low2hdr.rb,
lib/HDLRuby/hruby_low2vhd.rb,
lib/HDLRuby/hruby_verilog.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_without_subsignals.rb,
lib/HDLRuby/hruby_low_casts_without_expression.rb,
lib/HDLRuby/hruby_low2high.rb,
lib/HDLRuby/hruby_low2c.rb

Overview

Describes a wait statement: not synthesizable!

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, #add_make_block, #behavior, #block, #blocks2seq!, #break_types!, #delete_related!, #delete_unless!, #each_statement, #extract_declares!, #fix_scope_refnames!, #get_signal_splits, #mix?, #par_in_seq2seq!, #parent_system, #replace_expressions!, #replace_names!, #scope, #to_ch, #to_seq!, #to_upper_space!, #top_block, #top_scope, #use_name?, #with_boolean!

Methods included from Hparent

#absolute_ref, #hierarchy, #no_parent!, #scope

Methods included from Low2Symbol

#to_sym

Constructor Details

#initialize(delay) ⇒ TimeWait

Creates a new statement waiting delay.



4251
4252
4253
4254
4255
4256
4257
4258
4259
4260
# File 'lib/HDLRuby/hruby_low.rb', line 4251

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

Instance Attribute Details

#delay ⇒ Object (readonly)

The delay to wait.



4248
4249
4250
# File 'lib/HDLRuby/hruby_low.rb', line 4248

def delay
  @delay
end

Instance Method Details

#boolean_in_assign2select! ⇒ Object

Converts booleans in assignments to select operators.



154
155
156
157
# File 'lib/HDLRuby/hruby_low_bool2select.rb', line 154

def boolean_in_assign2select!
    # Nothing to do.
    return self
end

#casts_without_expression! ⇒ Object

Extracts the expressions from the casts.



138
139
140
141
# File 'lib/HDLRuby/hruby_low_casts_without_expression.rb', line 138

def casts_without_expression!
    # Nothing to do.
    return self
end

#clone ⇒ Object

Clones the TimeWait (deeply)



4287
4288
4289
# File 'lib/HDLRuby/hruby_low.rb', line 4287

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

#each_block(&ruby_block) ⇒ Object

Iterates over the sub blocks.



4308
4309
4310
4311
4312
4313
# File 'lib/HDLRuby/hruby_low.rb', line 4308

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.



4316
4317
4318
4319
4320
4321
# File 'lib/HDLRuby/hruby_low.rb', line 4316

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_deep(&ruby_block) ⇒ Object

Iterates over each object deeply.

Returns an enumerator if no ruby block is given.



4272
4273
4274
4275
4276
4277
4278
4279
# File 'lib/HDLRuby/hruby_low.rb', line 4272

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

#each_node(&ruby_block) ⇒ Object

Iterates over the expression children if any.



4292
4293
4294
4295
4296
4297
# File 'lib/HDLRuby/hruby_low.rb', line 4292

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.



4300
4301
4302
4303
4304
4305
# File 'lib/HDLRuby/hruby_low.rb', line 4300

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.



4324
4325
4326
4327
4328
4329
4330
# File 'lib/HDLRuby/hruby_low.rb', line 4324

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)


4263
4264
4265
4266
4267
# File 'lib/HDLRuby/hruby_low.rb', line 4263

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.



189
190
191
192
# File 'lib/HDLRuby/hruby_low_fix_types.rb', line 189

def explicit_types!
    # Nothing to do.
    return self
end

#extract_selects! ⇒ Object

Extract the Select expressions.



107
108
109
110
# File 'lib/HDLRuby/hruby_low_without_select.rb', line 107

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

#hash ⇒ Object

Hash function.



4282
4283
4284
# File 'lib/HDLRuby/hruby_low.rb', line 4282

def hash
    return [@delay].hash
end

#map_nodes!(&ruby_block) ⇒ Object

Maps on the children (including the condition).



1019
1020
1021
# File 'lib/HDLRuby/hruby_low_mutable.rb', line 1019

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

#set_delay!(delay) ⇒ Object

Sets the delay.



1008
1009
1010
1011
1012
1013
1014
1015
1016
# File 'lib/HDLRuby/hruby_low_mutable.rb', line 1008

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

#signal2subs! ⇒ Object

Decompose the hierarchical signals in the statements.



112
113
114
115
# File 'lib/HDLRuby/hruby_low_without_subsignals.rb', line 112

def signal2subs!
    # Nothing to do.
    return self
end

#to_c(res, level = 0) ⇒ Object

Generates the C text of the equivalent HDLRuby code. level is the hierachical level of the object. def to_c(level = 0)



1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
# File 'lib/HDLRuby/hruby_low2c.rb', line 1888

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

#to_hdr(level = 0) ⇒ Object

Generates the text of the equivalent hdr text. level is the hierachical level of the object.



448
449
450
451
452
453
454
455
# File 'lib/HDLRuby/hruby_low2hdr.rb', line 448

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

#to_high ⇒ Object

Creates a new high wait statement.



344
345
346
# File 'lib/HDLRuby/hruby_low2high.rb', line 344

def to_high
    return HDLRuby::High::TimeWait.new(self.delay.to_high)
end

#to_verilog(spc = 3) ⇒ Object

Enhances TimeWait with generation of verilog code.



1971
1972
1973
# File 'lib/HDLRuby/hruby_verilog.rb', line 1971

def to_verilog(spc = 3)
    return (" " * spc) + 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.



1062
1063
1064
1065
1066
1067
1068
1069
# File 'lib/HDLRuby/hruby_low2vhd.rb', line 1062

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

#to_viz_node(parent) ⇒ Object

Converts the transmit to a Viz flow node under parent.



5133
5134
5135
5136
5137
5138
# File 'lib/HDLRuby/hruby_viz.rb', line 5133

def to_viz_node(parent)
  node = HDLRuby::Viz::Node.new(:wait,parent)
  # And generate the children.
  self.delay.to_viz_node(node)
  return node
end