Class: ClassHDL::SdlPackage

Inherits:
SdlModule show all
Defined in:
lib/tdl/class_hdl/hdl_package.rb

Instance Attribute Summary

Attributes inherited from SdlModule

#create_tcl, #dont_gen_sv, #ex_down_code, #ex_param, #ex_port, #ex_up_code, #head_import_packages, #instance_and_children_module, #instanced_and_parent_module, #module_name, #origin_sv, #out_sv_path, #path, #real_sv_path, #target_class, #techbench

Instance Method Summary collapse

Methods inherited from SdlModule

#<<, #>>, #Always, #AlwaysComb, #Always_comb, #Always_ff, #Assign, #CASE, #CASEX, #Clock, #CommonCFGReg, #DEFAULT, #Def, #ELSE, #ELSIF, #FOR, #FOREACH, #IF, #Initial, #Inout, #Input, #Instance, #Itgt_Instance, Main, #NameSpaceAdd, #Output, #Parameter, #Parameters, #Reset, #StateMachine, #TrackInf, #TryDef, #WHEN, #__contain_hdl__, #__ref_children_modules__, #_auto_name_incr_index_, #add_children_modules, #add_parent_modules, #add_to_dve_wave, #add_to_new_module, #all_ref_sdlmodules, allmodule_name, #always_ff, #always_sim, #assert, #assert_error, #assert_format_error, #assert_old, base_hdl_ref, #bits, #call_instance, call_module, #children_inst_tree, #clog2, #contain_hdl, #debugLogic, #def_struct, #define_ele, echo_tracked_by_dve, #enum, exist_module?, #function, #gen_dev_wave_tcl, gen_dev_wave_tcl, gen_sv_module, #gen_sv_module, #generate, #genvar, #has_inward_inst?, #has_signal?, #implicit_inst_module_method_missing, #initial, #initial_exec, #initialize, #inout, #input, #instance_draw, #instanced, #inward_inst, #localparam, #logic, #logic_bind_, #macro_add_vcs, #method_missing, #negedge, #output, #parameter, #parents_inst_tree, #path_refs, #port, #posedge, #pretty_ref_hdl_moduls_echo, #ref_modules, #require_hdl, #require_package, #root_ref, #rubyOP, #same_clock_domain, #show_ports, #signal, #top_module_ref?, #top_tb_ref?, #track_signals_hash, tracked_by_dve, #tracked_by_dve, #try_call_ele, #urandom_range, #var_common, #vars_define_inst, #vars_exec_inst, #vcs_string, #verify

Constructor Details

This class inherits a constructor from SdlModule

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class SdlModule

Instance Method Details

#build_module(ex_param: "", ex_port: "", ex_up_code: "", ex_down_code: "") ⇒ Object



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
82
83
84
85
86
87
88
89
90
91
# File 'lib/tdl/class_hdl/hdl_package.rb', line 47

def build_module(ex_param: "",ex_port: "",ex_up_code: "",ex_down_code: "")
    # Tdl.Puts pagination(module_name)
    Tdl.Build_SdlModule_Puts(module_name)
    
    ex_param        = ex_param.to_s     unless ex_param
    ex_port         = ex_port.to_s      unless ex_port
    ex_up_code      = ex_up_code.to_s   unless ex_up_code
    ex_down_code    = ex_down_code.to_s unless ex_down_code
    
    # gen_auto_method     # auto generate class method for interface
    # draw = Tdl.inst + Tdl.draw
    
    instance_draw_str = instance_draw       # It must run before vars_define_inst,because some signals define when inst
    vars_exec_inst_str = vars_exec_inst     # It must run before vars_define_inst,because some signals define when vars exec
    
    post_str = post_inst_stack_call()
    
    unless post_str.strip.empty?
        post_str = pagination("ROOT REF") + post_str
    end
    
    draw = pagination("define") + vars_define_inst + pagination("instance") + instance_draw_str + pagination("expression") + vars_exec_inst_str + post_str
    
    unless ex_up_code.empty?
        ex_up_code = "\n//------>> EX CODE <<-------------------\n" + ex_up_code + "//------<< EX CODE >>-------------------\n"
    end
    
    unless ex_down_code.empty?
        ex_down_code = "//------>> EX CODE <<-------------------\n" + ex_down_code + "//------<< EX CODE >>-------------------\n"
    end
    
    # str = module_head+"module #{@module_name}" + build_params(ex_param) + build_ports(ex_port) + ex_up_code + gen_lite_str() + draw + ex_down_code + "\nendmodule\n"
    # unless GlobalParam.sim
        module_name_str = @module_name
    # else
    #     module_name_str = @module_name+"_sim"
    # end
    
    str = module_head+"package #{module_name_str};\n"  + build_params(ex_param) + ex_up_code + draw + ex_down_code + "\nendpackage:#{module_name_str}\n" + add_sub_module_file_paths
    
    create_vivado_tcl if @create_tcl
    create_constraints_file if @create_sdc
    
    return str
end

#build_module_verb(ex_param: "", ex_port: "", ex_up_code: "", ex_down_code: "") ⇒ Object



93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
# File 'lib/tdl/class_hdl/hdl_package.rb', line 93

def build_module_verb(ex_param: "",ex_port: "",ex_up_code: "",ex_down_code: "")
    # Tdl.Puts pagination(module_name)
    Tdl.Build_SdlModule_Puts(module_name)
    
    ex_param        = ex_param.to_s     unless ex_param
    ex_port         = ex_port.to_s      unless ex_port
    ex_up_code      = ex_up_code.to_s   unless ex_up_code
    ex_down_code    = ex_down_code.to_s unless ex_down_code
    
    # gen_auto_method     # auto generate class method for interface
    # draw = Tdl.inst + Tdl.draw
    
    instance_draw_str = instance_draw       # It must run before vars_define_inst,because some signals define when inst
    vars_exec_inst_str = vars_exec_inst     # It must run before vars_define_inst,because some signals define when vars exec
    
    post_str = post_inst_stack_call()
    
    unless post_str.strip.empty?
        post_str = pagination("ROOT REF") + post_str
    end
    
    draw = pagination("define") + vars_define_inst + pagination("instance") + instance_draw_str + pagination("expression") + vars_exec_inst_str + post_str
    
    unless ex_up_code.empty?
        ex_up_code = "\n//------>> EX CODE <<-------------------\n" + ex_up_code + "//------<< EX CODE >>-------------------\n"
    end
    
    unless ex_down_code.empty?
        ex_down_code = "//------>> EX CODE <<-------------------\n" + ex_down_code + "//------<< EX CODE >>-------------------\n"
    end
    

    module_name_str = @module_name
    
    
    # str = module_head+"package #{module_name_str};\n"  + build_params(ex_param) + ex_up_code + draw + ex_down_code + "\nendpackage:#{module_name_str}\n" + add_sub_module_file_paths
    str = "package #{module_name_str};\n"  + build_params(ex_param) + ex_up_code + draw + ex_down_code + "\nendpackage:#{module_name_str}\n" + add_sub_module_file_paths

    create_vivado_tcl if @create_tcl
    create_constraints_file if @create_sdc
    
    return [module_head_verb,str]
end

#build_params(ex_str = "") ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/tdl/class_hdl/hdl_package.rb', line 9

def build_params(ex_str="")
    "Draw Parameters of sv module"
    str = []
    max_len = 0
    @port_params.each do |k,v|
        if v.port_length > max_len
            max_len = v.port_length;
        end
    end
    
    @port_params.each do |k,v|
        str << v.inst_port(max_len-v.port_length)+";"
    end
    
    unless ex_str.empty?
        head_tap = '//------>> EX PARAMETER <<-------------------'+"\n"
        end_tap = "\n//------<< EX PARAMETER >>-------------------"+"\n"
    else
        head_tap = ""
        end_tap = ""
    end
    
    if str.empty?
        if ex_str.empty?
            return ""
        else
            # ex_str.gsub!(/,\s*$/m,"")
            return head_tap + ex_str + end_tap 
        end
    else
        # if (ex_str !~  /,\s*$/m)
        #     ex_str = ex_str + ",\n" unless ex_str.empty?
        # end
        head_tap + ex_str + end_tap + str.join("\n")
    end
    
end

#macro_defObject



5
6
7
# File 'lib/tdl/class_hdl/hdl_package.rb', line 5

def macro_def
    ''
end