lib/HDLRuby/hruby_rcsim.rb in HDLRuby-2.11.12 vs lib/HDLRuby/hruby_rcsim.rb in HDLRuby-3.0.0
- old
+ new
@@ -86,12 +86,12 @@
RCSim.rcsim_main(top.rcsystemT,outpath +"/" + name,outmode)
end
- ## Extends the SystemT class for hybrid Ruby-C simulation.
class SystemT
+ ## Extends the SystemT class for hybrid Ruby-C simulation.
attr_reader :rcsystemT # The access to the C version of the systemT
# Generate the C description of the systemT.
# +rcowner+ is the owner if any.
@@ -139,12 +139,12 @@
return @rcsystemT
end
end
- ## Extends the Scope class for hybrid Ruby-C simulation.
class Scope
+ ## Extends the Scope class for hybrid Ruby-C simulation.
attr_reader :rcscope # The access to the C version of the scope.
# Generate the C description of the scope comming from object
# whose C description is +rcowner+
@@ -183,29 +183,30 @@
# sub.to_rcsim(@rcscope)
sub.to_rcsim(subowner)
end)
end
- # # Create and add the behaviors.
- # if self.each_behavior.any? then
- # RCSim.rcsim_add_scope_behaviors(@rcscope,
- # self.each_behavior.map do |beh|
- # # beh.to_rcsim(@rcscope)
- # beh.to_rcsim(subowner)
- # end)
- # end
-
- # # Create and add the connections.
- # if self.each_connection.any? then
- # RCSim.rcsim_add_scope_behaviors(@rcscope,
- # self.each_connection.map do |cxt|
- # # cxt.to_rcsim(@rcscope)
- # cxt.to_rcsim(subowner)
- # end)
- # end
- rcbehs = self.each_behavior.map {|beh| beh.to_rcsim(subowner)} +
- self.each_connection.map {|cxt| cxt.to_rcsim(subowner) }
+ # Create and add the behaviors and connections.
+ rcbehs = self.each_behavior.map {|beh| beh.to_rcsim(subowner)} # +
+ # self.each_connection.map {|cxt| cxt.to_rcsim(subowner) }
+ self.each_connection do |cnx|
+ # ICIICI
+ if !cnx.right.is_a?(RefObject) then
+ rcbehs << cnx.to_rcsim(subowner)
+ else
+ # puts "cnx.left.object=#{cnx.left.object.fullname} cnx.right.object=#{cnx.right.object.fullname}"
+ rcbehs << cnx.to_rcsim(subowner)
+ if cnx.left.is_a?(RefObject) then
+ sigL = cnx.left.object
+ prtL = sigL.parent
+ if prtL.is_a?(SystemT) and prtL.each_inout.any?{|e| e.object_id == sigL.object_id} then
+ # puts "write to right with sigL=#{sigL.fullname}."
+ rcbehs << Connection.new(cnx.right.clone,cnx.left.clone).to_rcsim(subowner)
+ end
+ end
+ end
+ end
if rcbehs.any? then
RCSim.rcsim_add_scope_behaviors(@rcscope,rcbehs)
end
# Create and add the codes.
@@ -215,12 +216,12 @@
end
end
- ## Extends the Type class for hybrid Ruby-C simulation.
class Type
+ ## Extends the Type class for hybrid Ruby-C simulation.
attr_reader :rctype # The access to the C version of the scope.
# Generate the C description of the type comming from object
# whose C description is +rcowner+.
@@ -236,34 +237,34 @@
end
return @rctype
end
end
- ## Extends the TypeDef class for hybrid Ruby-C simulation.
class TypeDef
+ ## Extends the TypeDef class for hybrid Ruby-C simulation.
# Generate the C description of the type.
def to_rcsim
# Create the type C object.
@rctype = self.def.to_rcsim
return @rctype
end
end
- ## Extends the TypeVector class for hybrid Ruby-C simulation.
class TypeVector
+ ## Extends the TypeVector class for hybrid Ruby-C simulation.
# Generate the C description of the type.
def to_rcsim
# Create the type C object.
@rctype = RCSim.rcsim_get_type_vector(self.base.to_rcsim,self.size)
return @rctype
end
end
- ## Extends the TypeTuple class for hybrid Ruby-C simulation.
class TypeTuple
+ ## Extends the TypeTuple class for hybrid Ruby-C simulation.
# Add the possibility to change the direction.
def direction=(dir)
@direction = dir == :little ? :little : :big
end
@@ -274,12 +275,13 @@
return @rctype
end
end
- ## Extends the TypeStruct class for hybrid Ruby-C simulation.
class TypeStruct
+ ## Extends the TypeStruct class for hybrid Ruby-C simulation.
+
# Add the possibility to change the direction.
def direction=(dir)
@direction = dir == :little ? :little : :big
end
@@ -333,10 +335,22 @@
refs.uniq! { |node| node.fullname }
# Remove the inner signals from the list.
self.block.each_inner do |inner|
refs.delete_if {|r| r.name == inner.name }
end
+ # The get the left references: the will be removed from the
+ # events.
+ left_refs = self.block.each_node_deep.select do |node|
+ node.is_a?(RefObject) && node.leftvalue? &&
+ !node.parent.is_a?(RefObject)
+ end.to_a
+ # Keep only one left ref per signal.
+ left_refs.uniq! { |node| node.fullname }
+ # Remove the left refs.
+ left_refs.each do |l|
+ refs.delete_if {|r| r.fullname == l.fullname }
+ end
# Generate the event.
events = refs.map {|ref| Event.new(:anyedge,ref.clone) }
# Add them to the behavior for further processing.
events.each {|event| self.add_event(event) }
else
@@ -372,23 +386,23 @@
return @rcbehavior
end
end
- ## Extends the Behavior class for hybrid Ruby-C simulation.
class Behavior
+ ## Extends the Behavior class for hybrid Ruby-C simulation.
include RCSimBehavior
end
- ## Extends the TimeBehavior class for hybrid Ruby-C simulation.
class TimeBehavior
+ ## Extends the TimeBehavior class for hybrid Ruby-C simulation.
include RCSimBehavior
end
- ## Extends the Event class for hybrid Ruby-C simulation.
class Event
+ ## Extends the Event class for hybrid Ruby-C simulation.
attr_reader :rcevent
# Generate the C description of the event comming from object
# whose C description is +rcowner+
@@ -402,12 +416,12 @@
return @rcevent
end
end
- ## Extends the SignalI class for hybrid Ruby-C simulation.
class SignalI
+ ## Extends the SignalI class for hybrid Ruby-C simulation.
attr_reader :rcsignalI
# Generate the C description of the signal comming from object
# whose C description is +rcowner+
@@ -434,12 +448,12 @@
return @rcsignalI
end
end
- ## Extends the SignalC class for hybrid Ruby-C simulation.
class SignalC
+ ## Extends the SignalC class for hybrid Ruby-C simulation.
attr_reader :rcsignalC
# Generate the C description of the signal comming from object
# whose C description is +rcowner+
@@ -457,12 +471,12 @@
return @rcsignalC
end
end
- ## Extends the SystemI class for hybrid Ruby-C simulation.
class SystemI
+ ## Extends the SystemI class for hybrid Ruby-C simulation.
attr_reader :rcsystemI
# Generate the C description of the signal comming from object
# whose C description is +rcowner+
@@ -494,35 +508,35 @@
return @rcsystemI
end
end
- ## Extends the Chunk class for hybrid Ruby-C simulation.
class Chunk
+ ## Extends the Chunk class for hybrid Ruby-C simulation.
# TODO!!
end
- ## Extends the Code class for hybrid Ruby-C simulation.
class Code
+ ## Extends the Code class for hybrid Ruby-C simulation.
# TODO!!
end
- ## Extends the Statement class for hybrid Ruby-C simulation.
class Statement
+ ## Extends the Statement class for hybrid Ruby-C simulation.
attr_reader :rcstatement
# Generate the C description of the statement.
def to_rcsim
raise "to_rcsim must be implemented in #{self.class}"
end
end
- ## Extends the Transmit class for hybrid Ruby-C simulation.
class Transmit
+ ## Extends the Transmit class for hybrid Ruby-C simulation.
attr_reader :rcstatement
# Generate the C description of the transmit.
def to_rcsim
# Create the transmit C object.
@@ -532,12 +546,12 @@
return @rcstatement
end
end
- ## Extends the Print class for hybrid Ruby-C simulation.
class Print
+ ## Extends the Print class for hybrid Ruby-C simulation.
attr_reader :rcstatement
# Generate the C description of the print.
def to_rcsim
# Create the print C object.
@@ -552,12 +566,12 @@
return @rcstatement
end
end
- ## Extends the TimeTerminate class for hybrid Ruby-C simulation.
class TimeTerminate
+ ## Extends the TimeTerminate class for hybrid Ruby-C simulation.
attr_reader :rcstatement
# Generate the C description of the terminate.
def to_rcsim
# Create the terminate C object.
@@ -565,19 +579,19 @@
return @rcstatement
end
end
- ## Extends the Configure class for hybrid Ruby-C simulation.
class Configure
+ ## Extends the Configure class for hybrid Ruby-C simulation.
attr_reader :rcstatement
# TODO!!!
end
- ## Extends the If class for hybrid Ruby-C simulation.
class If
+ ## Extends the If class for hybrid Ruby-C simulation.
attr_reader :rcstatement
# Generate the C description of the hardware if.
def to_rcsim
# Create the hardware if C object.
@@ -595,17 +609,17 @@
return @rcstatement
end
end
- ## Extends the When class for hybrid Ruby-C simulation.
class When
+ ## Extends the When class for hybrid Ruby-C simulation.
# Nothing to add.
end
- ## Extends the Case class for hybrid Ruby-C simulation.
class Case
+ ## Extends the Case class for hybrid Ruby-C simulation.
attr_reader :rcstatement
# Generate the C description of the hardware case.
def to_rcsim
# Create the hardware case C object.
@@ -623,17 +637,17 @@
return @rcstatement
end
end
- ## Extends the Delay class for hybrid Ruby-C simulation.
class Delay
+ ## Extends the Delay class for hybrid Ruby-C simulation.
# Nothing to do.
end
- ## Extends the TimeWait class for hybrid Ruby-C simulation.
class TimeWait
+ ## Extends the TimeWait class for hybrid Ruby-C simulation.
attr_reader :rcstatement
# Generate the C description of the time wait.
def to_rcsim
# Create the time wait C object.
@@ -643,12 +657,12 @@
return @rcstatement
end
end
- ## Extends the TimeRepeat class for hybrid Ruby-C simulation.
class TimeRepeat
+ ## Extends the TimeRepeat class for hybrid Ruby-C simulation.
attr_reader :rcstatement
# Generate the C description of the hardware case.
# +owner+ is a link to the C description of the owner behavior if any.
def to_rcsim(owner = nil)
@@ -699,28 +713,29 @@
return @rcstatement
end
end
- ## Extends the Block class for hybrid Ruby-C simulation.
class Block
+ ## Extends the Block class for hybrid Ruby-C simulation.
include RCSimBlock
end
- ## Extends the TimeBlock class for hybrid Ruby-C simulation.
class TimeBlock
+ ## Extends the TimeBlock class for hybrid Ruby-C simulation.
include RCSimBlock
end
- ## Extends the Connection class for hybrid Ruby-C simulation.
class Connection
+ ## Extends the Connection class for hybrid Ruby-C simulation.
attr_reader :rcbehavior
# Add recursively any event to +rcevs+ for activativing the
# connection from signal +sig+ attached to +rcbehavior+
def self.add_rcevents(sig,rcevs,rcbehavior)
+ # puts "add_rcevents for sig=#{sig.fullname}"
# Recurse on sub signals if any.
sig.each_signal do |sub|
Connection.add_rcevents(sub,rcevs,rcbehavior)
end
# Apply on the current node.
@@ -765,24 +780,24 @@
return @rcbehavior
end
end
- ## Extends the Expression class for hybrid Ruby-C simulation.
class Expression
+ ## Extends the Expression class for hybrid Ruby-C simulation.
# attr_reader :rcexpression
# Generate the C description of the expression.
def to_rcsim
raise "to_rcsim must be implemented in #{self.class}"
end
end
- ## Extends the Value class for hybrid Ruby-C simulation.
class Value
+ ## Extends the Value class for hybrid Ruby-C simulation.
# attr_reader :rcexpression
# Generate the C description of the value.
def to_rcsim
# Create the value C object.
@@ -813,23 +828,23 @@
self.content.to_s.reverse)
end
end
end
- ## Extends the StringE class for hybrid Ruby-C simulation.
class StringE
+ ## Extends the StringE class for hybrid Ruby-C simulation.
# Generate the C description of the value.
def to_rcsim
# Create the value C object.
return RCSim.rcsim_make_stringE(self.content);
end
end
- ## Extends the Cast class for hybrid Ruby-C simulation.
class Cast
+ ## Extends the Cast class for hybrid Ruby-C simulation.
# attr_reader :rcexpression
# Generate the C description of the cast.
def to_rcsim
# puts "Cast to width=#{self.type.width} and child=#{self.child}"
@@ -844,29 +859,29 @@
return RCSim.rcsim_make_cast(self.type.to_rcsim,self.child.to_rcsim)
end
end
- ## Extends the Operation class for hybrid Ruby-C simulation.
class Operation
+ ## Extends the Operation class for hybrid Ruby-C simulation.
# Nothing to do.
end
- ## Extends the Unary class for hybrid Ruby-C simulation.
class Unary
+ ## Extends the Unary class for hybrid Ruby-C simulation.
attr_reader :rcexpression
# Generate the C description of the unary operation.
def to_rcsim
# Create the unary C object.
return RCSim.rcsim_make_unary(self.type.to_rcsim,self.operator,
self.child.to_rcsim)
end
end
- ## Extends the Binary class for hybrid Ruby-C simulation.
class Binary
+ ## Extends the Binary class for hybrid Ruby-C simulation.
# attr_reader :rcexpression
# Generate the C description of the binary operation.
def to_rcsim
# Create the binary C object.
@@ -875,12 +890,12 @@
self.right.to_rcsim)
end
end
- ## Extends the Select class for hybrid Ruby-C simulation.
class Select
+ ## Extends the Select class for hybrid Ruby-C simulation.
# attr_reader :rcexpression
# Generate the C description of the select operation.
def to_rcsim
# Create the select C object.
@@ -896,12 +911,12 @@
return rcexpression
end
end
- ## Extends the Concat class for hybrid Ruby-C simulation.
class Concat
+ ## Extends the Concat class for hybrid Ruby-C simulation.
# attr_reader :rcexpression
# Generate the C description of the concat operation.
def to_rcsim
# Create the concat C object.
@@ -918,24 +933,24 @@
end
end
- ## Extends the Ref class for hybrid Ruby-C simulation.
class Ref
+ ## Extends the Ref class for hybrid Ruby-C simulation.
# attr_reader :rcref
# alias_method :rcexpression, :rcref
# Generate the C description of the reference.
def to_rcsim
raise "to_rcsim must be implemented in #{self.class}"
end
end
- ## Extends the RefConcat class for hybrid Ruby-C simulation.
class RefConcat
+ ## Extends the RefConcat class for hybrid Ruby-C simulation.
# attr_reader :rcref
# alias_method :rcexpression, :rcref
# Generate the C description of the reference concat.
def to_rcsim
@@ -951,12 +966,12 @@
return rcref
end
end
- ## Extends the RefIndex class for hybrid Ruby-C simulation.
class RefIndex
+ ## Extends the RefIndex class for hybrid Ruby-C simulation.
# attr_reader :rcref
# alias_method :rcexpression, :rcref
# Generate the C description of the reference index.
def to_rcsim
@@ -965,12 +980,12 @@
self.index.to_rcsim,self.ref.to_rcsim)
end
end
- ## Extends the RefRange class for hybrid Ruby-C simulation.
class RefRange
+ ## Extends the RefRange class for hybrid Ruby-C simulation.
# attr_reader :rcref
# alias_method :rcexpression, :rcref
# Generate the C description of the reference range.
def to_rcsim
@@ -981,29 +996,29 @@
self.ref.to_rcsim)
end
end
- ## Extends the RefName class for hybrid Ruby-C simulation.
class RefName
+ ## Extends the RefName class for hybrid Ruby-C simulation.
# Should not be used with rcsim.
end
- ## Extends the RefThis class for hybrid Ruby-C simulation.
class RefThis
+ ## Extends the RefThis class for hybrid Ruby-C simulation.
# attr_reader :rcref
# alias_method :rcexpression, :rcref
# Generate the C description of the reference range.
def to_rcsim
return nil
end
end
- ## Extends the RefObject class for hybrid Ruby-C simulation.
class RefObject
+ ## Extends the RefObject class for hybrid Ruby-C simulation.
# attr_reader :rcref
# alias_method :rcexpression, :rcref
# Generate the C description of the reference object with sub signals.
def to_rcsim_subs