Class: RubyHDL::High::Transmit
- Inherits:
-
Object
- Object
- RubyHDL::High::Transmit
- Defined in:
- lib/HDLRuby/std/sequencer_sw.rb
Overview
Describes a SW implementation of a transmit statement.
Instance Attribute Summary collapse
-
#left ⇒ Object
readonly
Returns the value of attribute left.
-
#right ⇒ Object
readonly
Returns the value of attribute right.
Instance Method Summary collapse
-
#initialize(left, right) ⇒ Transmit
constructor
Create a new transmit statement with left value +left+ and right value +right+.
-
#to_expr ⇒ Object
Convert to expression: transforms the transmit to a comparison.
-
#to_ruby ⇒ Object
Convert to ruby code.
Constructor Details
#initialize(left, right) ⇒ Transmit
Create a new transmit statement with left value +left+ and right value +right+.
1935 1936 1937 1938 1939 1940 1941 |
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 1935 def initialize(left,right) @left = left.to_expr @right = right.to_expr # Add the transmit to the top SW block. # (It will be removed after if it was actually a comparison). RubyHDL::High.top_sblock << self end |
Instance Attribute Details
#left ⇒ Object (readonly)
Returns the value of attribute left.
1931 1932 1933 |
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 1931 def left @left end |
#right ⇒ Object (readonly)
Returns the value of attribute right.
1931 1932 1933 |
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 1931 def right @right end |
Instance Method Details
#to_expr ⇒ Object
Convert to expression: transforms the transmit to a comparison.
1944 1945 1946 1947 1948 1949 |
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 1944 def to_expr # Remove the transmit from the top SW block. RubyHDL::High.top_sblock.delete(self) # And convert it to a comparison. return Binary.new(@left.type,@left,@right) end |
#to_ruby ⇒ Object
Convert to ruby code.
1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 |
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 1952 def to_ruby if (@left.is_a?(RefIndex) or @left.is_a?(RefRange)) then if @left.base.type.base.is_a?(TypeVector) then # Assign inside array. base = @left.final_base.to_ruby return "#{base} ||= []; #{@left.to_ruby} = #{@right.to_ruby}" else # # Compute the final access range. # rng = @left.final_range # Get the access range. rng = @left.range # Compute the writing and clearing masks smask = (1.to_value<<(rng.first+1-rng.last))-1 cmask = ~(smask << rng.last) # Get the final base. base = left.final_base.to_ruby # Generate the ruby code. return "#{base} &= #{cmask.to_ruby}; " + "#{base} |= (((#{@right.to_ruby} & #{smask.to_ruby}) << (#{rng.last.to_ruby})))" end else return "#{@left.to_ruby} = #{@right.to_ruby}" end end |