Method: AxiStreamBFMModuleBuild#build_master_contect

Defined in:
lib/tdl/bfm/axi_stream/axis_bfm_module_build.rb

#build_master_contect(bfmstream, contect_str, length, dsize) ⇒ Object



73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
# File 'lib/tdl/bfm/axi_stream/axis_bfm_module_build.rb', line 73

def build_master_contect(bfmstream,contect_str,length,dsize)
    random_exp = /random\s*\(\s*(?<a>\d+)\s*,\s*(?<b>\d+)\s*\)/i
    range_exp = /range\s*\(\s*(?<a>\d+)\s*,\s*(?<b>\d+)\s*\)/i
    origin_exp = /^\d+\s*,\s*\d+/

    if contect_str.match random_exp
        str =
        "for(int II=0;II<#{length};II++)
        wdata_queue[II] = $urandom_range(#{$~[:a]},#{$~[:b]})"
    elsif contect_str.match range_exp
        str =
        "for(int II=0;II<#{length};II++)
        wdata_queue[II] = (II) % (#{($~[:a].to_i - $~[:b].to_i).abs}) + #{$~[:a]}"
    elsif contect_str.match origin_exp
        list = contect_str.strip.split(",")
        if list.length < length
            list  = list + list[0,length - list.length]
        end
        str = "wdata_queue    = {>>{#{list[0,length].map { |e| "#{dsize}'d#{e}" }.join(",")}}}"
    end

    bfmstream.exec(str)

end