Class: VideoInf

Inherits:
CLKInfElm show all
Extended by:
BaseFunc
Includes:
BaseModule
Defined in:
lib/tdl/elements/videoinf.rb,
lib/tdl/elements/videoinf.rb,
lib/tdl/VideoInf/video_to_axi4.rb,
lib/tdl/VideoInf/video_from_axi4.rb,
lib/tdl/VideoInf/simple_video_gen.rb,
lib/tdl/VideoInf/video_stream_2_axi_stream.rb,
lib/tdl/axi_stream/bak/simple_video_gen_A2.rb,
lib/tdl/axi_stream/bak/simple_video_gen_A2_auto.rb

Overview

require_relative “./video_lib” require_relative “.././videoinf” require_relative “.././tdl”

Constant Summary collapse

Synth_REP =

parse text for autogen method and constant ###

Regexp.union(/\(\*\s+videoinf\s*=\s*"true"\s+\*\)/, /\(\*\s+video_native_inf\s*=\s*"true"\s+\*\)/)

Instance Attribute Summary collapse

Attributes inherited from CLKInfElm

#clock, #origin_freqM, #reset

Attributes inherited from InfElm

#dimension

Attributes inherited from BaseElm

#belong_to_module

Class Method Summary collapse

Instance Method Summary collapse

Methods included from BaseFunc

check_same, check_same_class, check_same_clock, check_same_dsize

Methods included from BaseModule

#length, #to_s

Methods inherited from CLKInfElm

#FreqM, #check_freqM, #clock_reset_taps, #freqM, #freq_align_signal, #intf_def_freqM, #use_which_freq_when_copy

Methods inherited from InfElm

#[], #dimension_num, inherited, #port_length, same_name_socket, #signal, subclass

Methods inherited from BaseElm

#matrix, #name_copy, #path_refs, recfg_nc, #s, #signal

Methods included from TdlSpace::ExCreateTP

#root_ref

Methods included from AxiTdl::TestUnitTrack

#tracked_by_dve

Constructor Details

#initialize(name: "video", dsize: 24, clock: nil, reset: nil, port: false, dimension: [], freqM: nil) ⇒ VideoInf

Returns a new instance of VideoInf.



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/tdl/elements/videoinf.rb', line 12

def initialize(name:"video",dsize:24,clock:nil,reset:nil,port:false,dimension:[],freqM:nil)
    name_legal?(name)
    super(dimension:dimension,clock:clock,reset:reset,freqM:freqM)
    @name = name
    @dsize = dsize
    @port = port
    # @id = GlobalParam.CurrTdlModule.BindEleClassVars.VideoInf.id
    # @correlation_proc = ""
    # if @port
    #     GlobalParam.CurrTdlModule.BindEleClassVars.VideoInf.ports << self
    # else
    #     GlobalParam.CurrTdlModule.BindEleClassVars.VideoInf.inst_stack << method(:inst).to_proc
    # end

    # GlobalParam.CurrTdlModule.BindEleClassVars.VideoInf.draw_stack << method(:draw).to_proc
end

Instance Attribute Details

#dsizeObject

Returns the value of attribute dsize.



10
11
12
# File 'lib/tdl/elements/videoinf.rb', line 10

def dsize
  @dsize
end

#ghostObject

Returns the value of attribute ghost.



10
11
12
# File 'lib/tdl/elements/videoinf.rb', line 10

def ghost
  @ghost
end

#idObject

Returns the value of attribute id.



10
11
12
# File 'lib/tdl/elements/videoinf.rb', line 10

def id
  @id
end

#nameObject

Returns the value of attribute name.



10
11
12
# File 'lib/tdl/elements/videoinf.rb', line 10

def name
  @name
end

#portObject

Returns the value of attribute port.



10
11
12
# File 'lib/tdl/elements/videoinf.rb', line 10

def port
  @port
end

Class Method Details

.parse_ports(port_array = nil) ⇒ Object



173
174
175
176
177
178
179
180
181
# File 'lib/tdl/elements/videoinf.rb', line 173

def self.parse_ports(port_array=nil)
    rep = /(?<up_down>\(\*\s+(?<ud_name>video_up|video_down)\s*=\s*"true"\s+\*\))?\s*(video_native_inf\.)(?<modport>compact_out|compact_in)\s+(?<name>\w+)\s*(?<vector>\[.*?\])?/m
    up_stream_rep = /video_up/

    InfElm.parse_ports(port_array,rep,"video_native_inf",up_stream_rep) do |h|
        h[:type] = VideoInf
        yield h
    end
end

.simple_video_gen(video_master: nil, mode: nil, enable: nil, copy_inf: nil, belong_to_module: nil) ⇒ Object



26
27
28
29
30
31
32
# File 'lib/tdl/VideoInf/simple_video_gen.rb', line 26

def self.simple_video_gen(video_master:nil,mode:nil,enable:nil,copy_inf:nil,belong_to_module:nil)
    unless video_master
        video_master = belong_to_module.Def.videoinf(name:copy_inf.name+"_cp",clock:copy_inf.clock,reset:copy_inf.reset,dsize:copy_inf.dsize,dimension:copy_inf.dimension)
    end

    video_master.simple_video_gen(mode:mode,enable:enable)
end

.simple_video_gen_a2(mode: "1080P@60", dsize: 24, enable: "enable", inf: "inf") ⇒ Object



31
32
33
34
# File 'lib/tdl/axi_stream/bak/simple_video_gen_A2.rb', line 31

def self.simple_video_gen_a2(mode:"1080P@60",dsize:24,enable:"enable",inf:"inf")
    NC._simple_video_gen_a2(mode:mode,dsize:dsize,enable:enable,inf:inf)

end

.video_from_axi4(axi4_master: nil, video_slaver: nil, video_master: nil, mode: "LINE", base_addr: nil) ⇒ Object



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/tdl/VideoInf/video_from_axi4.rb', line 32

def self.video_from_axi4(axi4_master:nil,video_slaver:nil,video_master:nil,mode:"LINE",base_addr:nil)
    if video_slaver
        video_name  = video_slaver.name
        video_clock = video_slaver.clock
        video_reset = video_slaver.reset
        video_dsize = video_slaver.dsize
    elsif video_master
        video_name  = video_master.name
        video_clock = video_master.clock
        video_reset = video_master.reset
        video_dsize = video_master.dsize
    else axi4_master
        video_name  = axi4_master.name
        video_clock = axi4_master.clock
        video_reset = axi4_master.reset
        video_dsize = axi4_master.dsize
    end

    unless axi4_master
        new_axi4_master = Axi4.new(name:video_name+"_to_v",clock:video_clock,reset:video_reset,dsize:video_dsize,max_len:2**32,mode:Axi4::ONLY_READ)
    else
        new_axi4_master = axi4_master
    end

    unless video_slaver
        new_video_slaver = VideoInf.new(name:video_name+"_slaver",clock:video_clock,reset:video_reset,dsize:video_dsize)
    else
        new_video_slaver = video_slaver
    end

    unless video_master
        new_video_master = VideoInf.new(name:video_name+"_master",clock:video_clock,reset:video_reset,dsize:video_dsize)
    else
        new_video_master = video_master
    end

    new_video_master.from_axi4(axi4_master:new_axi4_master,video_slaver:new_video_slaver,mode:mode,base_addr:base_addr)

    unless axi4_master
        return new_axi4_master
    end

    unless video_slaver
        return new_video_master
    end

    unless video_master
        return new_video_master
    end
end

.video_stream_2_axi_stream(video_slaver: nil, axis_master: nil, mode: "LINE") ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/tdl/VideoInf/video_stream_2_axi_stream.rb', line 24

def self.video_stream_2_axi_stream(video_slaver:nil,axis_master:nil,mode:"LINE")
    if video_slaver
        if axis_master
            video_slaver.to_axi_stream(axis_master:axis_master,mode:mode)
        else
            new_obj = AxiStream.new(name:video_slaver.name+"_f_v",clock:video_slaver.clock,reset:video_slaver.reset,dsize:video_slaver.dsize)
            video_slaver.to_axi_stream(axis_master:new_obj,mode:mode)
            return new_obj
        end
    elsif axis_master
        if video_slaver
            video_slaver.to_axi_stream(axis_master:axis_master,mode:mode)
        else
            new_obj = VideoInf.new(name:axis_master.name+"_to_as",clock:axis_master.clock,reset:axis_master.reset,dsize:axis_master.dsize)
            new_obj.to_axi_stream(axis_master:axis_master,mode:mode)
        end
    end
end

.video_to_axi4(axi4_master: nil, video_slaver: nil, mode: "LINE", base_addr: nil) ⇒ Object



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/tdl/VideoInf/video_to_axi4.rb', line 30

def self.video_to_axi4(axi4_master:nil,video_slaver:nil,mode:"LINE",base_addr:nil)
    if video_slaver
        if axi4_master
            video_slaver.to_axi4(axi4_master:axi4_master,mode:mode,base_addr:base_addr)
        else
            new_obj = video_slaver.belong_to_module.Def.axi4(name:video_slaver.name+"_f_v",clock:video_slaver.clock,reset:video_slaver.reset,dsize:video_slaver.dsize,max_len:2**32,mode:Axi4::ONLY_WRITE)
            video_slaver.to_axi4(axi4_master:new_obj,mode:mode)
            return new_obj
        end
    elsif axi4_master
        if video_slaver
            video_slaver.to_axi4(axi4_master:axi4_master,mode:mode,base_addr:base_addr)
        else
            new_obj = axi4_master.belong_to_module.Def.videoinf(name:axi4_master.name+"_to_as",clock:axi4_master.clock,reset:axi4_master.reset,dsize:axi4_master.dsize)
            new_obj.to_axi4(axi4_master:axi4_master,mode:mode,base_addr:base_addr)
        end
    end
end

Instance Method Details

#__inf_signal__(name) ⇒ Object

Raises:



187
188
189
190
191
192
193
194
# File 'lib/tdl/elements/videoinf.rb', line 187

def __inf_signal__(name)
    raise TdlError.new("\nARRAY Don't have '#{name}'\n") unless @dimension.empty?
    # puts "--------------"
    # puts $new_m.instance_variable_get("@port_axisinfs")
    # puts "============="
    NqString.new(signal.concat ".#{name}")
    # signal.concat ".#{name}"
end

#_simple_video_gen_a2(mode: "1080P@60", dsize: 24, enable: "enable", inf: "inf") ⇒ Object



9
10
11
12
13
14
15
16
# File 'lib/tdl/axi_stream/bak/simple_video_gen_A2.rb', line 9

def _simple_video_gen_a2(mode:"1080P@60",dsize:24,enable:"enable",inf:"inf")



    $_draw = lambda { _simple_video_gen_a2_draw(mode:mode,dsize:dsize,enable:enable,inf:inf) }
    @correlation_proc += $_draw.call
    return self
end

#_simple_video_gen_a2_draw(mode: "1080P@60", dsize: 24, enable: "enable", inf: "inf") ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/tdl/axi_stream/bak/simple_video_gen_A2.rb', line 18

def _simple_video_gen_a2_draw(mode:"1080P@60",dsize:24,enable:"enable",inf:"inf")
    large_name_len(mode,dsize,enable,inf)
"
simple_video_gen_A2#(
.MODE     (#{align_signal(mode)}),
.DSIZE    (#{align_signal(dsize)})
) simple_video_gen_a2_#{signal}_inst(
/*  input                       */ .enable (#{align_signal(enable,q_mark=false)}),
/*  video_native_inf.compact_out*/ .inf    (#{align_signal(inf,q_mark=false)})
);
"
end

#copy(name: @name.to_s, dsize: @dsize, clock: @clock, reset: @reset, freqM: nil) ⇒ Object



105
106
107
108
109
# File 'lib/tdl/elements/videoinf.rb', line 105

def copy(name:@name.to_s,dsize:@dsize,clock:@clock,reset:@reset,freqM:nil)
    append_name = name_copy(name)
    _freqM = use_which_freq_when_copy(clock,freqM)
    new_obj = VideoInf.new(name:append_name,dsize:dsize,clock:clock,reset:reset,freqM:_freqM)
end

#data(h = nil, l = nil) ⇒ Object

Raises:



165
166
167
# File 'lib/tdl/elements/videoinf.rb', line 165

def data
    signal+".data"
end

#deObject



161
162
163
# File 'lib/tdl/elements/videoinf.rb', line 161

def de
    signal+".de"
end

#drawObject

def left_port_length

("/*  video_native_inf." + @port.to_s + " */ ").length

end

def right_port_length

(".#{@name.to_s} ").length

end

def ex_port(left_align_len = 7,right_align_len = 7)

if left_align_len >=  left_port_length
    sub_left_len = left_align_len -  left_port_length
else
    sub_left_len = 0
end

if right_align_len >=  right_port_length
    sub_right_len = right_align_len -  right_port_length
else
    sub_right_len = 0
end

if @port
    ("/*  video_native_inf." + @port.to_s + " "*sub_left_len + "*/ " + "."+@name.to_s + " "*sub_right_len)
end

end



97
98
99
100
101
102
103
# File 'lib/tdl/elements/videoinf.rb', line 97

def draw
    super
    return ''   if @correlation_proc.empty?
    head_str = "\n//-------->>>> #{signal} <<<<----------------\n"
    end_str  = "\n//========<<<< #{signal} >>>>================\n"
    return head_str+@correlation_proc+end_str
end

#from_axi4(axi4_master: nil, video_slaver: nil, mode: "LINE", base_addr: nil) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/tdl/VideoInf/video_from_axi4.rb', line 7

def from_axi4(axi4_master:nil,video_slaver:nil,mode:"LINE",base_addr:nil)
    unless axi4_master
        axi4_master = Axi4.new(name:@name+"_f_v",clock:@clock,reset:@reset,dsize:@dsize,max_len:2**32,mode:Axi4::ONLY_READ)
    end
    unless video_slaver
        video_slaver = self.copy()
    end
    video_master = self
    $_draw = lambda { video_from_axi4_draw(axi4_master:axi4_master,video_slaver:video_slaver,video_master:video_master,mode:"LINE",base_addr:base_addr) }
    @correlation_proc += $_draw.call
    return axi4_master
end

#hsyncObject



157
158
159
# File 'lib/tdl/elements/videoinf.rb', line 157

def hsync
    signal+".hsync"
end

#instObject

def signal

if @force_name
    @force_name.to_s
elsif @port
    @name.to_s
else
    "video_#{@name}_#{@id}"
end

end



39
40
41
42
43
44
45
46
47
# File 'lib/tdl/elements/videoinf.rb', line 39

def inst
    return "" if @ghost
    large_name_len("")
    if @reset.respond_to?(:low_signal)
        "video_native_inf #( .DSIZE(#{@dsize}),.FreqM(#{intf_def_freqM})) #{signal} (.pclk(#{align_signal(@clock,q_mark=false)}),.prst_n(#{align_signal(@reset.low_signal,q_mark=false)}));\n"
    else
        "video_native_inf #( .DSIZE(#{@dsize}),.FreqM(#{intf_def_freqM})) #{signal} (.pclk(#{align_signal(@clock,q_mark=false)}),.prst_n(#{align_signal(@reset,q_mark=false)}));\n"
    end
end

#inst_portObject

def port_length

("video_native_inf." + @port.to_s + " ").length

end



53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/tdl/elements/videoinf.rb', line 53

def inst_port

    # if @port
    #     ("video_native_inf." + @port.to_s + " " + " "*sub_len + @name.to_s)
    # end
    if @port.to_s =~ /compact/
        str = @port.to_s
    elsif @port.to_s.downcase.eql? "master"
        str = "compact_out"
    elsif @port.to_s.downcase.eql? "slaver"
        str = "compact_in"
    else
        str = @port.to_s
    end

    return ["video_native_inf." + str,@name.to_s,array_inst]
end

#simple_video_gen(mode: "1080P@60", enable: nil) ⇒ Object



7
8
9
10
11
12
13
# File 'lib/tdl/VideoInf/simple_video_gen.rb', line 7

def simple_video_gen(mode:"1080P@60",enable:nil)
    video_master = self
    # $_draw = lambda { simple_video_gen_draw(video_master:video_master,mode:mode,enable:enable) }
    # @correlation_proc += $_draw.call
    belong_to_module.VideoInf_draw << simple_video_gen_draw(video_master:video_master,mode:mode,enable:enable)
    return video_master
end

#simple_video_gen_draw(video_master: self, mode: nil, enable: nil) ⇒ Object



15
16
17
18
19
20
21
22
23
24
# File 'lib/tdl/VideoInf/simple_video_gen.rb', line 15

def simple_video_gen_draw(video_master:self,mode:nil,enable:nil)
    large_name_len(video_master,mode)
"simple_video_gen_A2 #(
.MODE   (#{align_signal(mode)}),
.DSIZE  (#{align_signal(signal,false)}.DSIZE)
)simple_video_gen_A2_#{(signal)}_inst(
/*  input                         */  .enable   (#{align_signal(enable)}),
/*  video_native_inf.compact_out  */  .inf      (#{align_signal(video_master)})
);"
end

#to_axi4(axi4_master: nil, mode: "LINE", base_addr: nil) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
# File 'lib/tdl/VideoInf/video_to_axi4.rb', line 7

def to_axi4(axi4_master:nil,mode:"LINE",base_addr:nil)
    unless axi4_master
        axi4_master = Axi4.new(name:@name+"_f_v",clock:@clock,reset:@reset,dsize:@dsize,max_len:2**32,mode:Axi4::ONLY_WRITE)
    end
    video_slaver = self
    # $_draw = lambda { video_to_axi4_draw(video_slaver:video_slaver,axi4_master:axi4_master,mode:mode,base_addr:base_addr) }
    # @correlation_proc += $_draw.call
    belong_to_module.VideoInf_draw << video_to_axi4_draw(video_slaver:video_slaver,axi4_master:axi4_master,mode:mode,base_addr:base_addr)

    return axi4_master
end

#to_axi_stream(axis_master: nil, mode: "LINE") ⇒ Object



7
8
9
10
11
12
# File 'lib/tdl/VideoInf/video_stream_2_axi_stream.rb', line 7

def to_axi_stream(axis_master:nil,mode:"LINE")
    videos = self
    $_draw = lambda { video_stream_2_axi_stream_draw(videos:videos,axis:axi_master,mode:mode) }
    @correlation_proc += $_draw.call
    return axi_master
end

#video_from_axi4_draw(axi4_master: nil, video_slaver: nil, video_master: self, mode: "LINE", base_addr: nil) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
# File 'lib/tdl/VideoInf/video_from_axi4.rb', line 20

def video_from_axi4_draw(axi4_master:nil,video_slaver:nil,video_master:self,mode:"LINE",base_addr:nil)
    large_name_len(axi4_master,video_slaver,video_master,mode,base_addr)
"\nvideo_from_axi4 #(
.MODE       (#{align_signal(mode)})    //LINE ONCE
)video_from_axi4_#{signal}_inst(
/*  input [31:0]                 */   .base_addr        (#{align_signal(base_addr)}),
/*  video_native_inf.compact_in  */   .in_video_inf     (#{align_signal(video_slaver)}),
/*  video_native_inf.compact_out */   .out_video_inf    (#{align_signal(video_master)}),
/*  axi_inf.master_rd            */   .axi_master       (#{align_signal(axi4_master)})
);\n"
end

#video_stream_2_axi_stream_draw(videos: self, axis: nil, mode: nil) ⇒ Object



14
15
16
17
18
19
20
21
22
# File 'lib/tdl/VideoInf/video_stream_2_axi_stream.rb', line 14

def video_stream_2_axi_stream_draw(videos:self,axis:nil,mode:nil)
    large_name_len(videos,axis,mode)
"\nvideo_stream_2_axi_stream #(
.MODE       (#{align_signal(mode)})       //LINE FRAME
)video_stream_2_axi_stream_#{signal}_inst(
/*  video_native_inf.compact_in */  .video_inf  (#{align_signal(videos)}),
/*  axi_stream_inf.master       */  .axis_out   (#{align_signal(axis)})
);\n"
end

#video_to_axi4_draw(video_slaver: self, axi4_master: nil, mode: nil, base_addr: nil) ⇒ Object



19
20
21
22
23
24
25
26
27
28
# File 'lib/tdl/VideoInf/video_to_axi4.rb', line 19

def video_to_axi4_draw(video_slaver:self,axi4_master:nil,mode:nil,base_addr:nil)
    large_name_len(video_slaver,axi4_master,mode,base_addr)
"\nvideo_to_axi4 #(
.MODE       (#{align_signal(mode)})    //LINE ONCE
)video_to_axi4_#{signal}_inst(
/*  input [31:0]               */  .base_addr   (#{align_signal(base_addr)}),
/*  video_native_inf.compact_in*/  .video_inf   (#{align_signal(video_slaver)}),
/*  axi_inf.master_wr          */  .axi_master  (#{align_signal(axi4_master)})
);\n"
end

#vsyncObject

signal ref



153
154
155
# File 'lib/tdl/elements/videoinf.rb', line 153

def vsync
    signal+".vsync"
end