Class: AxiStreamBFMModuleBuild

Inherits:
Object
  • Object
show all
Defined in:
lib/tdl/bfm/axi_stream/axis_bfm_module_build.rb

Instance Method Summary collapse

Instance Method Details

#buidl_master_burst(bfmstream, bhash, dsize) ⇒ Object



55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/tdl/bfm/axi_stream/axis_bfm_module_build.rb', line 55

def buidl_master_burst(bfmstream,bhash,dsize)
    bfmstream.exec("wdata_queue = {}")
    if(bhash['repeat'])
        bfmstream.repeat(bhash['repeat'].to_i) do
            bfmstream.exec("#(#{(bhash["pre_wait"])})") if bhash["pre_wait"]
            build_master_contect(bfmstream,bhash['contect'],bhash['length'].to_i,dsize.to_i)
            bfmstream.gen_axi_stream(len:0,rate:bhash['persent'].to_i)
            bfmstream.exec("#(#{(bhash["post_wait"])})") if bhash["post_wait"]
        end
    else
        bfmstream.exec("#(#{(bhash["pre_wait"])})") if bhash["pre_wait"]
        build_master_contect(bfmstream,bhash['contect'],bhash['length'].to_i,dsize.to_i)
        bfmstream.gen_axi_stream(len:0,rate:bhash['persent'].to_i)
        bfmstream.exec("#(#{(bhash["post_wait"])})") if bhash["post_wait"]
    end

end

#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

#build_single_master_stream_bfm(sdlm, stream_name, stream_hash) ⇒ Object



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/tdl/bfm/axi_stream/axis_bfm_module_build.rb', line 31

def build_single_master_stream_bfm(sdlm,stream_name,stream_hash)
    # sdlm.instance_exec(stream_name) do |stream_name|
    #
    #     Def().bfm_stream(name:)
    # end
    a = sdlm.AxiStream.master(stream_name,freqM:   stream_hash["FreqM"].to_f)

    ba = sdlm.Def.bfm_stream(name:"#{stream_name}_b",freqM:  stream_hash["FreqM"].to_f,clock: a.aclk,reset: a.aresetn, dsize: stream_hash["dsize"].to_i )

    a.direct(up_stream: ba)

    set_bfm_pkg_import(ba)

    ba.masterbfm(info:stream_hash["info"],wait: nil,wait_every_raising: nil,wdata_name: "wdata_queue") do |b|
        b.init_exec("#(#{stream_hash["wait"]})") if stream_hash["wait"]

        stream_hash["queue"].each do |burst|
            buidl_master_burst(ba,burst,stream_hash['dsize'].to_i)
        end

    end
    @__AXI_BFM_IMPORT__ = true
end

#build_single_slaver_stream_bfm(sdlm, stream_name, stream_hash) ⇒ Object



98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
# File 'lib/tdl/bfm/axi_stream/axis_bfm_module_build.rb', line 98

def build_single_slaver_stream_bfm(sdlm,stream_name,stream_hash)
    a = sdlm.AxiStream.slaver(stream_name,freqM:   stream_hash["FreqM"].to_f)

    ba = sdlm.Def.bfm_stream(name:"#{stream_name}_b",freqM:  stream_hash["FreqM"].to_f,clock: a.aclk,reset: a.aresetn, dsize: stream_hash["dsize"].to_i )
    set_bfm_pkg_import(ba)

    a.direct(down_stream: ba)

    if stream_hash['info']
        info_str = 1
    else
        info_str = 0
    end

    ba.slaverbfm do |b|
        ba.init_exec("#(#{stream_hash['wait']})")
        stream_hash['queue'].each do |burst|
            ba.add_slaver_bfm_recv(repeat:burst['repeat'],rate:burst['persent'].to_i,info:info_str)
        end
    end
end

#build_streams_bfm(sdlm, yaml_hash) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/tdl/bfm/axi_stream/axis_bfm_module_build.rb', line 13

def build_streams_bfm(sdlm,yaml_hash)
    yaml_hash.each do |k,v|

        if(v['type'] == "master")
            build_single_master_stream_bfm(sdlm,k,v)
        elsif v['type'] == "slaver"
            build_single_slaver_stream_bfm(sdlm,k,v)
        else
            raise TdlError.new(" Error type[#{v['type']}] for #{k}")
        end
    end
end

#set_bfm_pkg_import(bfmstream) ⇒ Object



26
27
28
29
# File 'lib/tdl/bfm/axi_stream/axis_bfm_module_build.rb', line 26

def set_bfm_pkg_import(bfmstream)
    bfmstream.instance_variable_set("@__AXI_BFM_IMPORT__",true) if @__AXI_BFM_IMPORT__
    @__AXI_BFM_IMPORT__ = true
end

#use_yaml_bfm(yaml_file) ⇒ Object



4
5
6
7
8
9
10
11
# File 'lib/tdl/bfm/axi_stream/axis_bfm_module_build.rb', line 4

def use_yaml_bfm(yaml_file)

    sdlm = TechBenchModule.new(name:File.basename(yaml_file,".*"),out_sv_path:File.expand_path(File.dirname(yaml_file)))
    axis_bp = AxiStreamBFMParse.new(yaml_file)
    AxiStreamBFMModuleBuild.new.build_streams_bfm(sdlm,axis_bp.hash)

    return sdlm
end