Class: ClassHDL::GenerateBlock
- Inherits:
-
ClearSdlModule
- Object
- SdlModule
- ClearSdlModule
- ClassHDL::GenerateBlock
- Defined in:
- lib/tdl/class_hdl/hdl_generate.rb
Instance Attribute Summary collapse
-
#block_index ⇒ Object
Returns the value of attribute block_index.
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
- #ELSE(&block) ⇒ Object
- #ELSIF(cond, &block) ⇒ Object
- #IF(cond, &block) ⇒ Object
-
#initialize(belong_to_module) ⇒ GenerateBlock
constructor
A new instance of GenerateBlock.
- #method_missing(name, *args, &block) ⇒ Object
Methods inherited from ClearSdlModule
Methods inherited from SdlModule
#<<, #>>, #Always, #AlwaysComb, #Always_comb, #Always_ff, #Assign, #CASE, #CASEX, #Clock, #CommonCFGReg, #DEFAULT, #Def, #FOR, #FOREACH, #Initial, #Inout, #Input, #Instance, #Itgt_Instance, Main, #NameSpaceAdd, #Output, #Parameter, #Parameters, #Reset, #StateMachine, #TrackInf, #TryDef, #WHEN, #add_children_modules, #add_parent_modules, #add_to_new_module, allmodule_name, #always_ff, #always_sim, #assert, #assert_error, #assert_format_error, #assert_old, #bits, #build_module, #call_instance, call_module, #children_inst_tree, #clog2, #debugLogic, #def_struct, #define_ele, #enum, exist_module?, #function, gen_sv_module, #gen_sv_module, #gen_sv_module_text, #generate, #genvar, #has_inward_inst?, #has_signal?, #implicit_inst_module_method_missing, #initial, #initial_exec, #inout, #input, #instance_draw, #instanced, #inward_inst, #localparam, #logic, #logic_bind_, #macro_add_vcs, #macro_def, #negedge, #output, #parameter, #parents_inst_tree, #port, #posedge, #require_package, #rubyOP, #same_clock_domain, #show_ports, #signal, #top_module_ref?, #top_tb_ref?, #try_call_ele, #urandom_range, #var_common, #vars_define_inst, #vars_exec_inst, #vcs_string, #verify
Constructor Details
#initialize(belong_to_module) ⇒ GenerateBlock
Returns a new instance of GenerateBlock.
19 20 21 22 |
# File 'lib/tdl/class_hdl/hdl_generate.rb', line 19 def initialize(belong_to_module) @belong_to_module = belong_to_module super("genblk#{globle_random_name_flag()}") end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args, &block) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/tdl/class_hdl/hdl_generate.rb', line 25 def method_missing(name,*args,&block) ClassHDL::AssignDefOpertor.with_rollback_opertors(:old) do ## 优先判断 belong_to_module 有没有定义此方法 if root_sdlmodule.respond_to? name root_sdlmodule.send(name,*args,&block) elsif SdlModule.exist_module?(name) # puts root_sdlmodule # if SdlModule.exist_module?(name) ClassHDL::ImplicitInstModule.new(name,self) else @belong_to_module.send(name,*args,&block) end end end |
Instance Attribute Details
#block_index ⇒ Object
Returns the value of attribute block_index.
18 19 20 |
# File 'lib/tdl/class_hdl/hdl_generate.rb', line 18 def block_index @block_index end |
Instance Method Details
#ELSE(&block) ⇒ Object
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 |
# File 'lib/tdl/class_hdl/hdl_generate.rb', line 91 def ELSE(&block) if ClassHDL::AssignDefOpertor.curr_assign_block.is_a? HDLAssignGenerateBlock head_str = "else begin\n" # yield tmp_sm = ClearGenerateSlaverBlock.new(self) tmp_sm.module_name = "generate_sub_block_#{self.block_index}" inst_obj = tmp_sm.instanced("genblk#{self.block_index}",tmp_sm) inst_obj.belong_to_module = tmp_sm add_children_modules(inst_obj:inst_obj ,module_poit: tmp_sm) tmp_sm.instance_exec(&block) ClassHDL::AssignDefOpertor.with_rollback_opertors(:old) do body_str = tmp_sm.instance_draw + tmp_sm.vars_exec_inst gbody_str = body_str.gsub(/^./){ |m| " #{m}"} self.Logic_inst.push(head_str+gbody_str+"end\n") end else super(&block) end end |
#ELSIF(cond, &block) ⇒ Object
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/tdl/class_hdl/hdl_generate.rb', line 66 def ELSIF(cond,&block) if ClassHDL::AssignDefOpertor.curr_assign_block.is_a? HDLAssignGenerateBlock if cond.respond_to?(:instance) head_str = "else if(#{cond.instance(:cond)})begin\n" else head_str = "else if(#{cond})begin\n" end # yield tmp_sm = ClearGenerateSlaverBlock.new(self) tmp_sm.module_name = "generate_sub_block_#{self.block_index}" inst_obj = tmp_sm.instanced("genblk#{self.block_index}",tmp_sm) inst_obj.belong_to_module = tmp_sm add_children_modules(inst_obj:inst_obj ,module_poit: tmp_sm) tmp_sm.instance_exec(&block) ClassHDL::AssignDefOpertor.with_rollback_opertors(:old) do body_str = tmp_sm.instance_draw + tmp_sm.vars_exec_inst gbody_str = body_str.gsub(/^./){ |m| " #{m}"} self.Logic_inst.push(head_str+gbody_str+"end\n") end else super(cond,&block) end end |
#IF(cond, &block) ⇒ Object
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 |
# File 'lib/tdl/class_hdl/hdl_generate.rb', line 40 def IF(cond,&block) if ClassHDL::AssignDefOpertor.curr_assign_block.is_a? HDLAssignGenerateBlock if cond.respond_to?(:instance) head_str = "\nif(#{cond.instance(:cond)})begin\n" else head_str = "\nif(#{cond})begin\n" end # yield tmp_sm = ClearGenerateSlaverBlock.new(self) tmp_sm.module_name = "generate_sub_block_#{self.block_index}" inst_obj = tmp_sm.instanced("genblk#{self.block_index}",tmp_sm) inst_obj.belong_to_module = tmp_sm add_children_modules(inst_obj:inst_obj ,module_poit: tmp_sm) tmp_sm.instance_exec(&block) ClassHDL::AssignDefOpertor.with_rollback_opertors(:old) do body_str = tmp_sm.instance_draw + tmp_sm.vars_exec_inst gbody_str = body_str.gsub(/^./){ |m| " #{m}"} self.Logic_inst.push(head_str+gbody_str+"end ") end else super(cond,&block) end end |