class Handshaker
A class for a handshake transmission.
Public Class Methods
new(type)
click to toggle source
Create a new handshaker for transmitting type
data.
# File lib/HDLRuby/hdr_samples/with_class.rb, line 6 def initialize(type) # Sets the date type. type = type.to_type @type = type buffer = read_valid = read_ready = write_valid = write_ready = nil HDLRuby::High.cur_system.open do # Declares the registers used for the handshake # The data buffer. buffer = type.inner(HDLRuby.uniq_name) # Declares the handshake control singals. read_valid = inner(HDLRuby.uniq_name) read_ready = inner(HDLRuby.uniq_name) write_valid = inner(HDLRuby.uniq_name) write_ready = inner(HDLRuby.uniq_name) end @buffer = buffer @read_valid = read_valid @read_ready = read_ready @write_valid = write_valid @write_ready = write_ready # puts "@buffer=#{@buffer}" # puts "@read_valid=#{@read_valid}" end
Public Instance Methods
get_port()
click to toggle source
Gets the port of the handshaker as a list of signals.
# File lib/HDLRuby/hdr_samples/with_class.rb, line 96 def get_port return [@buffer,@read_valid,@read_ready,@write_valid,@write_ready] end
Also aliased as: to_a
input()
click to toggle source
Declares the signals used for input from the handshaker and
do the connections of the upper SystemI
# File lib/HDLRuby/hdr_samples/with_class.rb, line 48 def input ibuffer = iread_valid = iread_ready = iwrite_valid = iwrite_ready =nil type = @type buffer = @buffer read_valid = @read_valid read_ready = @read_ready write_valid = @write_valid write_ready = @write_ready HDLRuby::High.cur_system.open do # Declares the input signals ibuffer = type.input(HDLRuby.uniq_name) iread_valid = input(HDLRuby.uniq_name) iread_ready = input(HDLRuby.uniq_name) iwrite_valid = output(HDLRuby.uniq_name) iwrite_ready = output(HDLRuby.uniq_name) end @ibuffer = ibuffer @iread_valid = iread_valid @iread_ready = iread_ready @iwrite_valid = iwrite_valid @iwrite_ready = iwrite_ready end
output()
click to toggle source
Declares the signals used for output to the handshaker and
do the connections of the upper SystemI
# File lib/HDLRuby/hdr_samples/with_class.rb, line 73 def output obuffer = oread_valid = oread_ready = owrite_valid = owrite_ready =nil type = @type buffer = @buffer read_valid = @read_valid read_ready = @read_ready write_valid = @write_valid write_ready = @write_ready HDLRuby::High.cur_system.open do obuffer = type.output(HDLRuby.uniq_name) oread_valid = output(HDLRuby.uniq_name) oread_ready = output(HDLRuby.uniq_name) owrite_valid = input(HDLRuby.uniq_name) owrite_ready = input(HDLRuby.uniq_name) end @obuffer = obuffer @oread_valid = oread_valid @oread_ready = oread_ready @owrite_valid = owrite_valid @owrite_ready = owrite_ready end
read(target,&blk)
click to toggle source
Generates a blocking read.
# File lib/HDLRuby/hdr_samples/with_class.rb, line 102 def read(target,&blk) ibuffer = @ibuffer iread_valid = @iread_valid iread_ready = @iread_ready iwrite_valid = @iwrite_valid iwrite_ready = @iwrite_ready HDLRuby::High.cur_block.open do hif(iread_valid) do iwrite_valid <= 0 iwrite_ready <= 0 hif(iread_ready) do target <= ibuffer iwrite_valid <= 1 blk.call if blk end end helse do iwrite_ready <= 1 end end end
reset()
click to toggle source
Generate the reset of the handshaker.
# File lib/HDLRuby/hdr_samples/with_class.rb, line 31 def reset read_valid = @read_valid read_ready = @read_ready write_valid = @write_valid write_ready = @write_ready HDLRuby::High.cur_system.open do par do read_valid <= 0 read_ready <= 0 write_valid <= 1 write_ready <= 1 end end end
write(target,&blk)
click to toggle source
Generates a blocking write.
# File lib/HDLRuby/hdr_samples/with_class.rb, line 125 def write(target,&blk) obuffer = @obuffer oread_valid = @oread_valid oread_ready = @oread_ready owrite_valid = @owrite_valid owrite_ready = @owrite_ready HDLRuby::High.cur_block.open do hif(owrite_valid) do oread_valid <= 0 oread_ready <= 0 hif(owrite_ready) do obuffer <= target oread_valid <= 1 blk.call if blk end end helse do oread_ready <= 1 end end end