axi_tdl 0.0.12 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (175) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/gem-push.yml +4 -2
  3. data/.gitignore +3 -1
  4. data/README.EN.md +7 -2
  5. data/README.md +6 -2
  6. data/Rakefile +8 -1
  7. data/axi_tdl.gemspec +1 -2
  8. data/lib/axi/AXI4/axi4_direct_A1.sv +1 -1
  9. data/lib/axi/AXI4/axi4_direct_B1.sv +23 -23
  10. data/lib/axi/AXI4/axi4_direct_verc.sv +54 -54
  11. data/lib/axi/AXI4/axi4_dpram_cache.sv +34 -34
  12. data/lib/axi/AXI4/axis_to_axi4_wr.rb +1 -0
  13. data/lib/axi/AXI4/axis_to_axi4_wr.sv +24 -24
  14. data/lib/axi/AXI4/odata_pool_axi4_A3.sv +7 -0
  15. data/lib/axi/AXI4/packet_partition/axi4_partition_rd_verb.sv +33 -33
  16. data/lib/axi/AXI4/packet_partition/data_inf_partition.rb +2 -0
  17. data/lib/axi/AXI4/packet_partition/data_inf_partition.sv +72 -72
  18. data/lib/axi/AXI4/wide_axis_to_axi4_wr.rb +2 -1
  19. data/lib/axi/AXI4/wide_axis_to_axi4_wr.sv +21 -21
  20. data/lib/axi/AXI_stream/axi_stream_split_channel.rb +7 -1
  21. data/lib/axi/AXI_stream/axi_stream_split_channel.sv +45 -40
  22. data/lib/axi/AXI_stream/axis_head_cut_verb.sv +6 -2
  23. data/lib/axi/AXI_stream/axis_head_cut_verc.sv +30 -30
  24. data/lib/axi/AXI_stream/axis_insert_copy.rb +18 -4
  25. data/lib/axi/AXI_stream/axis_insert_copy.sv +29 -16
  26. data/lib/axi/AXI_stream/axis_pipe_sync_seam.sv +9 -9
  27. data/lib/axi/AXI_stream/axis_rom_contect_sim.sv +38 -38
  28. data/lib/axi/AXI_stream/axis_sim_master_model.rb +30 -0
  29. data/lib/axi/AXI_stream/axis_sim_master_model.sv +46 -0
  30. data/lib/axi/AXI_stream/axis_sim_slaver_model.rb +26 -0
  31. data/lib/axi/AXI_stream/axis_sim_verify_by_coe.sv +101 -0
  32. data/lib/axi/AXI_stream/axis_split_channel_verb.rb +2 -0
  33. data/lib/axi/AXI_stream/axis_split_channel_verb.sv +4 -4
  34. data/lib/axi/common/common_ram_sim_wrapper.sv +10 -10
  35. data/lib/axi/common/common_ram_wrapper.sv +13 -13
  36. data/lib/axi/data_interface/data_inf_c/data_c_pipe_sync_seam.sv +27 -27
  37. data/lib/axi/data_interface/data_inf_c/data_c_sim_master_model.sv +72 -0
  38. data/lib/axi/data_interface/data_inf_c/data_c_sim_slaver_model.sv +58 -0
  39. data/lib/axi/data_interface/data_inf_c/logic_sim_model.sv +64 -0
  40. data/lib/axi/platform_ip/fifo_36kb_long.sv +1 -1
  41. data/lib/axi/techbench/tb_axi_stream_split_channel.rb +69 -0
  42. data/lib/axi/techbench/tb_axi_stream_split_channel.sv +150 -0
  43. data/lib/axi/techbench/tb_axis_split_channel_verb.rb +69 -0
  44. data/lib/axi/techbench/tb_axis_split_channel_verb.sv +125 -0
  45. data/lib/axi_tdl.rb +1 -0
  46. data/lib/axi_tdl/version.rb +1 -1
  47. data/lib/public_atom_module/CheckPClock.sv +53 -0
  48. data/lib/public_atom_module/LICENSE.md +674 -0
  49. data/lib/public_atom_module/altera_xilinx_always_block_sw.rb +57 -0
  50. data/lib/public_atom_module/bits_decode.sv +71 -0
  51. data/lib/public_atom_module/bits_decode_verb.sv +71 -0
  52. data/lib/public_atom_module/bits_decode_verb_sdl.rb +24 -0
  53. data/lib/public_atom_module/broaden.v +43 -0
  54. data/lib/public_atom_module/broaden_and_cross_clk.v +47 -0
  55. data/lib/public_atom_module/ceiling.v +39 -0
  56. data/lib/public_atom_module/ceiling_A1.v +42 -0
  57. data/lib/public_atom_module/clock_rst.sv +64 -0
  58. data/lib/public_atom_module/cross_clk_sync.v +37 -0
  59. data/lib/public_atom_module/edge_generator.v +50 -0
  60. data/lib/public_atom_module/flooring.v +36 -0
  61. data/lib/public_atom_module/latch_data.v +30 -0
  62. data/lib/public_atom_module/latency.v +48 -0
  63. data/lib/public_atom_module/latency_dynamic.v +83 -0
  64. data/lib/public_atom_module/latency_long.v +84 -0
  65. data/lib/public_atom_module/latency_verb.v +52 -0
  66. data/lib/public_atom_module/once_event.sv +65 -0
  67. data/lib/public_atom_module/pipe_reg.v +93 -0
  68. data/lib/public_atom_module/pipe_reg_2write_ports.v +84 -0
  69. data/lib/public_atom_module/sim/clock_rst_verb.sv +54 -0
  70. data/lib/public_atom_module/sim/latency_long_tb.sv +49 -0
  71. data/lib/public_atom_module/sim/latency_long_tb.sv.bak +49 -0
  72. data/lib/tdl/Logic/logic_edge.rb +1 -1
  73. data/lib/tdl/auto_script/autogensdl.rb +16 -5
  74. data/lib/tdl/axi4/axi4_interconnect_verb.rb +49 -10
  75. data/lib/tdl/basefunc.rb +1 -0
  76. data/lib/tdl/class_hdl/hdl_always_comb.rb +8 -4
  77. data/lib/tdl/class_hdl/hdl_always_ff.rb +49 -8
  78. data/lib/tdl/class_hdl/hdl_assign.rb +12 -4
  79. data/lib/tdl/class_hdl/hdl_block_ifelse.rb +18 -16
  80. data/lib/tdl/class_hdl/hdl_foreach.rb +4 -4
  81. data/lib/tdl/class_hdl/hdl_function.rb +8 -6
  82. data/lib/tdl/class_hdl/hdl_generate.rb +9 -5
  83. data/lib/tdl/class_hdl/hdl_initial.rb +36 -13
  84. data/lib/tdl/class_hdl/hdl_module_def.rb +27 -7
  85. data/lib/tdl/class_hdl/hdl_package.rb +45 -0
  86. data/lib/tdl/class_hdl/hdl_redefine_opertor.rb +117 -24
  87. data/lib/tdl/class_hdl/hdl_struct.rb +3 -3
  88. data/lib/tdl/class_hdl/hdl_verify.rb +1 -1
  89. data/lib/tdl/elements/Reset.rb +5 -9
  90. data/lib/tdl/elements/clock.rb +5 -9
  91. data/lib/tdl/elements/data_inf.rb +0 -17
  92. data/lib/tdl/elements/logic.rb +9 -31
  93. data/lib/tdl/elements/mail_box.rb +6 -1
  94. data/lib/tdl/elements/originclass.rb +23 -48
  95. data/lib/tdl/elements/parameter.rb +6 -7
  96. data/lib/tdl/examples/10_random/exp_random.sv +3 -3
  97. data/lib/tdl/examples/11_test_unit/dve.tcl +6 -0
  98. data/lib/tdl/examples/11_test_unit/exp_test_unit.rb +9 -8
  99. data/lib/tdl/examples/11_test_unit/exp_test_unit.sv +1 -1
  100. data/lib/tdl/examples/11_test_unit/exp_test_unit_sim.sv +9 -0
  101. data/lib/tdl/examples/11_test_unit/modules/sub_md0.rb +6 -3
  102. data/lib/tdl/examples/11_test_unit/modules/sub_md0.sv +5 -5
  103. data/lib/tdl/examples/11_test_unit/modules/sub_md1.rb +9 -4
  104. data/lib/tdl/examples/11_test_unit/modules/sub_md1.sv +5 -5
  105. data/lib/tdl/examples/11_test_unit/tb_exp_test_unit.sv +1 -2
  106. data/lib/tdl/examples/11_test_unit/tb_exp_test_unit_sim.sv +42 -0
  107. data/lib/tdl/examples/11_test_unit/tu0.sv +9 -9
  108. data/lib/tdl/examples/11_test_unit/tu1.sv +1 -1
  109. data/lib/tdl/examples/1_define_module/exmple_md.sv +13 -13
  110. data/lib/tdl/examples/2_hdl_class/tmp/always_comb_test.sv +60 -60
  111. data/lib/tdl/examples/2_hdl_class/tmp/always_ff_test.sv +2 -2
  112. data/lib/tdl/examples/2_hdl_class/tmp/case_test.sv +17 -17
  113. data/lib/tdl/examples/2_hdl_class/tmp/head_pkg_module.sv +9 -9
  114. data/lib/tdl/examples/2_hdl_class/tmp/module_instance_test.sv +1 -1
  115. data/lib/tdl/examples/2_hdl_class/tmp/simple_assign_test.sv +1 -1
  116. data/lib/tdl/examples/2_hdl_class/tmp/state_case_test.sv +10 -10
  117. data/lib/tdl/examples/2_hdl_class/tmp/test_foreach.sv +3 -3
  118. data/lib/tdl/examples/2_hdl_class/tmp/test_function.sv +7 -7
  119. data/lib/tdl/examples/2_hdl_class/tmp/test_initial_assert.sv +3 -3
  120. data/lib/tdl/examples/2_hdl_class/tmp/test_inst_sugar.sv +1 -1
  121. data/lib/tdl/examples/2_hdl_class/tmp/test_module.sv +3 -3
  122. data/lib/tdl/examples/2_hdl_class/tmp/test_module_port.sv +1 -1
  123. data/lib/tdl/examples/2_hdl_class/tmp/test_module_var.sv +1 -1
  124. data/lib/tdl/examples/2_hdl_class/tmp/test_package.sv +2 -2
  125. data/lib/tdl/examples/2_hdl_class/tmp/test_package2.sv +4 -4
  126. data/lib/tdl/examples/2_hdl_class/tmp/test_struct_function.sv +2 -2
  127. data/lib/tdl/examples/2_hdl_class/tmp/test_vcs_string.sv +1 -1
  128. data/lib/tdl/examples/2_hdl_class/tmp/text_generate.sv +7 -7
  129. data/lib/tdl/examples/3_hdl_sdl_instance/main_md.sv +1 -1
  130. data/lib/tdl/examples/3_hdl_sdl_instance/sdl_md.sv +1 -1
  131. data/lib/tdl/examples/4_generate/test_generate.sv +11 -11
  132. data/lib/tdl/examples/5_logic_combin/test_logic_combin.sv +3 -3
  133. data/lib/tdl/examples/6_module_with_interface/inf_collect.sv +1 -1
  134. data/lib/tdl/examples/7_module_with_package/body_package.sv +1 -1
  135. data/lib/tdl/examples/7_module_with_package/example_pkg.sv +5 -5
  136. data/lib/tdl/examples/7_module_with_package/head_package.sv +1 -1
  137. data/lib/tdl/examples/8_top_module/tb_test_top.sv +1 -2
  138. data/lib/tdl/examples/8_top_module/tb_test_top_sim.sv +29 -0
  139. data/lib/tdl/examples/8_top_module/test_top.sv +1 -1
  140. data/lib/tdl/examples/8_top_module/test_top_sim.sv +9 -0
  141. data/lib/tdl/examples/9_itegration/clock_manage/itgt_module_clock_manage.rb +13 -0
  142. data/lib/tdl/examples/9_itegration/clock_manage/test_clock_bb.sv +34 -0
  143. data/lib/tdl/examples/9_itegration/tb_test_top.sv +2 -2
  144. data/lib/tdl/examples/9_itegration/tb_test_tttop.sv +4 -2
  145. data/lib/tdl/examples/9_itegration/tb_test_tttop_sim.sv +39 -0
  146. data/lib/tdl/examples/9_itegration/test_top.sv +4 -4
  147. data/lib/tdl/examples/9_itegration/test_tttop.sv +4 -4
  148. data/lib/tdl/examples/9_itegration/test_tttop_sim.sv +9 -0
  149. data/lib/tdl/examples/9_itegration/top.rb +1 -0
  150. data/lib/tdl/exlib/axis_eth_ex.rb +95 -0
  151. data/lib/tdl/exlib/axis_verify.rb +265 -0
  152. data/lib/tdl/exlib/clock_reset_verify.rb +29 -0
  153. data/lib/tdl/exlib/dve_tcl.rb +30 -11
  154. data/lib/tdl/exlib/itegration.rb +15 -3
  155. data/lib/tdl/exlib/itegration_verb.rb +167 -130
  156. data/lib/tdl/exlib/logic_verify.rb +88 -0
  157. data/lib/tdl/exlib/test_point.rb +96 -94
  158. data/lib/tdl/exlib/test_point.rb.bak +293 -0
  159. data/lib/tdl/rebuild_ele/ele_base.rb +9 -9
  160. data/lib/tdl/sdlmodule/sdlmodlule_path_db.rb +34 -0
  161. data/lib/tdl/sdlmodule/sdlmodule.rb +79 -65
  162. data/lib/tdl/sdlmodule/sdlmodule_arraychain.rb +1 -1
  163. data/lib/tdl/sdlmodule/sdlmodule_draw.rb +81 -16
  164. data/lib/tdl/sdlmodule/sdlmodule_instance.rb +3 -0
  165. data/lib/tdl/sdlmodule/sdlmodule_port_define.rb +6 -6
  166. data/lib/tdl/sdlmodule/sdlmodule_varible.rb +6 -6
  167. data/lib/tdl/sdlmodule/test_unit_module.rb +283 -33
  168. data/lib/tdl/sdlmodule/test_unit_module.rb.bak +143 -0
  169. data/lib/tdl/sdlmodule/top_module.rb +62 -58
  170. data/lib/tdl/sdlmodule/top_module.rb.bak +547 -0
  171. data/lib/tdl/tdl.rb +18 -3
  172. data/lib/tdl/tdlerror/tdlerror.rb +1 -1
  173. metadata +54 -121
  174. data/CODE_OF_CONDUCT.md +0 -74
  175. data/lib/axi/AXI_stream/axis_length_split_writh_user.sv +0 -87
@@ -154,17 +154,16 @@ endmodule\n"
154
154
  end
155
155
 
156
156
  ## 生成 itgt下的子模块文件
157
- # gen_children_modules
158
- @_itgt_collect_.each do |itgt|
159
- itgt.gen_children_modules()
160
- end
157
+ # @_itgt_collect_.each do |itgt|
158
+ # itgt.gen_children_modules()
159
+ # end
161
160
 
162
- if implicit_itgt_collect
163
- ## 执行 itegration_verb 里面的silence
164
- implicit_itgt_collect.each do |itgt|
165
- itgt.gen_children_modules()
166
- end
167
- end
161
+ # if implicit_itgt_collect
162
+ # ## 执行 itegration_verb 里面的silence
163
+ # implicit_itgt_collect.each do |itgt|
164
+ # itgt.gen_children_modules()
165
+ # end
166
+ # end
168
167
 
169
168
  end
170
169
 
@@ -431,9 +430,11 @@ class TopModule
431
430
  # sdlm.gen_sv_module
432
431
  sdlm.gen_sv_module_verb
433
432
  unless sdlm.vcs_path
434
- sdlm.test_unit.gen_dve_tcl(File.join(args[0],"dve.tcl"))
433
+ # sdlm.test_unit.gen_dve_tcl(File.join(args[0],"dve.tcl"))
434
+ SdlModule.gen_dev_wave_tcl File.join(args[0],"dve.tcl")
435
435
  else
436
- sdlm.test_unit.gen_dve_tcl(File.join(sdlm.vcs_path,"dve.tcl"))
436
+ # sdlm.test_unit.gen_dve_tcl(File.join(sdlm.vcs_path,"dve.tcl"))
437
+ SdlModule.gen_dev_wave_tcl File.join(sdlm.vcs_path,"dve.tcl")
437
438
  end
438
439
  sdlm.create_xdc
439
440
  else
@@ -450,55 +451,57 @@ class TopModule
450
451
  end
451
452
 
452
453
  ## 給TopModule 添加单元测试 方法
453
- module TdlSpace
454
- class TopModuleTestUnitRef
454
+ # module TdlSpace
455
+ # class TopModuleTestUnitRef
455
456
 
456
- def collect_unit(tu)
457
- @__collect_units__ ||= []
458
- @__collect_units__ << tu
459
- end
457
+ # def collect_unit(tu)
458
+ # @__collect_units__ ||= []
459
+ # @__collect_units__ << tu
460
+ # end
460
461
 
461
- def echo_units
462
- @__collect_units__ ||= []
463
- index = 1
462
+ # def echo_units
463
+ # @__collect_units__ ||= []
464
+ # index = 1
464
465
 
465
- rels = []
466
- __collect = TdlTestPoint.inst_collect.select { |e| e.target.belong_to_module.top_tb_ref? }
467
- @__collect_units__.each do |ue|
468
- tp_str = ue.origin.dve_wave_signals.map do |ele|
469
- unless __collect.index(ele.tp_instance)
470
- puts ele.name
471
- end
472
- " ->#{__collect.index(ele.tp_instance)+1}< :: #{ele.tp_instance.name} || #{ele.tp_instance.file}:#{ele.tp_instance.line}"
473
- end.join("\n")
474
-
475
- rels << " [#{index}] #{ue.origin.module_name} ::<TestPoints> \n#{tp_str}"
476
- index += 1
477
- end
478
- rels.join("\n")
479
- end
480
-
481
- def dve_wave(name: '', signals: [])
482
- return unless signals
483
- @_dev_wave_ ||= Hash.new
484
- @_dev_wave_[name.to_s] = signals ## Signal is TdlTestPoint
485
- end
486
-
487
- def gen_dve_tcl(filename)
488
- File.open(filename,'w') do |f|
489
- f.puts TdlSpace.gen_dev_wave_tcl(@_dev_wave_ || Hash.new)
490
- end
491
- end
492
-
493
- end
494
- end
495
-
496
- class TopModule
497
- def test_unit
498
- @__test_unit__ ||= TdlSpace::TopModuleTestUnitRef.new
499
- end
500
-
501
- end
466
+ # rels = []
467
+ # # __collect = TdlTestPoint.inst_collect.select { |e| e.target.belong_to_module.top_tb_ref? }
468
+ # # @__collect_units__.each do |ue|
469
+ # # tp_str = ue.origin.dve_wave_signals.select do |e|
470
+ # # e.respond_to? :tp_instance
471
+ # # end.map do |ele|
472
+ # # unless __collect.index(ele.tp_instance)
473
+ # # puts ele.name
474
+ # # end
475
+ # # " ->#{__collect.index(ele.tp_instance)+1}< :: #{ele.tp_instance.name} || #{ele.tp_instance.file}:#{ele.tp_instance.line}"
476
+ # # end.join("\n")
477
+
478
+ # # rels << " [#{index}] #{ue.origin.module_name} ::<TestPoints> \n#{tp_str}"
479
+ # # index += 1
480
+ # # end
481
+ # rels.join("\n")
482
+ # end
483
+
484
+ # def dve_wave(name: '', signals: []) #name => SdlModule instance name
485
+ # return unless signals
486
+ # @_dev_wave_ ||= Hash.new
487
+ # @_dev_wave_[name.to_s] = signals ## Signal is TdlTestPoint
488
+ # end
489
+
490
+ # def gen_dve_tcl(filename)
491
+ # File.open(filename,'w') do |f|
492
+ # f.puts TdlSpace.gen_dev_wave_tcl(@_dev_wave_ || Hash.new)
493
+ # end
494
+ # end
495
+
496
+ # end
497
+ # end
498
+
499
+ # class TopModule
500
+ # def test_unit
501
+ # @__test_unit__ ||= TdlSpace::TopModuleTestUnitRef.new
502
+ # end
503
+
504
+ # end
502
505
 
503
506
  ## 判断 是否被顶层引用
504
507
  class SdlModule
@@ -522,6 +525,7 @@ class SdlModule
522
525
  end
523
526
 
524
527
  def top_tb_ref?
528
+ return false unless TopModule.current
525
529
  if self == TopModule.current.techbench
526
530
  return true
527
531
  end
@@ -0,0 +1,547 @@
1
+ require 'yaml'
2
+ class TopModule < SdlModule
3
+
4
+ attr_accessor :techbench,:sim,:constraint
5
+ @@curr_top_module = nil
6
+ def initialize(name:"tdlmodule",out_sv_path:nil)
7
+ @@curr_top_module = self
8
+ # set sim env
9
+ @sim = TopModule.sim
10
+ @out_sv_path = out_sv_path
11
+ # console_argvs
12
+ # TopModule.sim = @sim
13
+ @constraint = ConstraintsVerb.new
14
+
15
+ if @sim
16
+ rewrite_to_warning(out_sv_path,"#{name}.sv")
17
+
18
+ name = "#{name}_sim"
19
+ else
20
+ rewrite_to_warning(out_sv_path,"#{name}_sim.sv")
21
+ end
22
+
23
+ @techbench = TechBenchModule.new(name:"tb_#{name}",out_sv_path:out_sv_path)
24
+ rtl_top_module = super(name:name,out_sv_path:out_sv_path)
25
+ @techbench.Instance(name,"rtl_top")
26
+ rtl_top_module
27
+ end
28
+
29
+ def self.current
30
+ @@curr_top_module
31
+ end
32
+
33
+ def pins
34
+ @pins_params
35
+ end
36
+
37
+ def load_pins(pins_file)
38
+ pins_params = YAML::load(File.open(pins_file))
39
+
40
+ pins_params = recur_pins_hash(pins_params)
41
+
42
+ pins_params.define_singleton_method("[]") do |index|
43
+ pins_params.fetch(index.to_s)
44
+ end
45
+
46
+ @pins_params = pins_params
47
+ end
48
+
49
+ def recur_pins_hash(hash)
50
+ new_hash = {}
51
+ hash.each do |k,v|
52
+ if v.is_a? Hash
53
+ hash[k] = recur_pins_hash(v)
54
+ else
55
+ if v.is_a?(String) && v=~/\s/
56
+ hash[k] = v.split(/\s+/)
57
+ end
58
+ end
59
+ new_hash[k.to_sym] = hash[k]
60
+ end
61
+ return hash.merge(new_hash)
62
+ end
63
+
64
+ def console_argvs
65
+ # hash = Parser.parse(ARGV)
66
+ hash = $argvs_hash
67
+ if hash[:sim]
68
+ @sim = hash[:sim]
69
+ end
70
+
71
+ bi = Proc.new do
72
+ bp = File.join(@out_sv_path,"program_files/")
73
+ Dir.mkdir(bp) unless File.exist? bp
74
+ bp
75
+ end
76
+
77
+ if hash[:gold]
78
+ @constraint.image(type: :gold,next_addr:hash[:next_cfg_addr],bitpath:bi.call)
79
+ elsif hash[:update]
80
+ @constraint.image(type: :update,bitpath:bi.call)
81
+ end
82
+ end
83
+
84
+ def rewrite_to_warning(path,file_name)
85
+ unless path
86
+ _out_sv_path = './'
87
+ else
88
+ _out_sv_path = path
89
+ end
90
+
91
+ path_file_name = File.join(_out_sv_path,file_name)
92
+
93
+ return unless File.exist? path_file_name
94
+
95
+ basename = File.basename(path_file_name,'.sv')
96
+
97
+ File.open(path_file_name,'w') do |f|
98
+ str =
99
+ "
100
+ `timescale 1ns/1ps
101
+ module #{basename}();
102
+ initial begin
103
+ #(1us);
104
+ $warning(\"Check TopModule.sim,please!!!\");
105
+ $stop;
106
+ end
107
+ endmodule\n"
108
+ f.puts str
109
+ end
110
+
111
+ end
112
+
113
+ public
114
+
115
+ def gen_sv_module
116
+ if @sim
117
+ Tdl.Puts "INFO: JUST GEN SV[#{@module_name}] FOR SIM "
118
+ else
119
+ Tdl.Puts "INFO: JUST GEN TechBench Modules,NO SIM"
120
+ end
121
+ super
122
+ # @techbench.gen_sv_module
123
+
124
+ # exec auto gen sub TechBenchModule
125
+ TechBenchModule.gen_sv_module
126
+ end
127
+
128
+ def mix_itegrations
129
+ ## 执行动态link itgt
130
+ # puts implicit_itgt_collect
131
+ self.link_eval
132
+ self.index_inst
133
+ # if implicit_itgt_collect
134
+ # ## 执行 itgt inst
135
+ # implicit_itgt_collect.reverse.each do |itgt|
136
+ # itgt.inst unless itgt.init_inst
137
+ # end
138
+ # end
139
+ #
140
+ # ## 执行 itgt inst
141
+ # @_itgt_collect_.each do |itgt|
142
+ # itgt.inst unless itgt.init_inst
143
+ # end
144
+ ## 执行 itegration_verb 里面的silence
145
+ @_itgt_collect_.each do |itgt|
146
+ itgt.silence_procs_run if itgt.respond_to?('silence_procs_run')
147
+ end
148
+
149
+ if implicit_itgt_collect
150
+ ## 执行 itegration_verb 里面的silence
151
+ implicit_itgt_collect.each do |itgt|
152
+ itgt.silence_procs_run if itgt.respond_to?('silence_procs_run')
153
+ end
154
+ end
155
+
156
+ ## 生成 itgt下的子模块文件
157
+ # gen_children_modules
158
+ @_itgt_collect_.each do |itgt|
159
+ itgt.gen_children_modules()
160
+ end
161
+
162
+ if implicit_itgt_collect
163
+ ## 执行 itegration_verb 里面的silence
164
+ implicit_itgt_collect.each do |itgt|
165
+ itgt.gen_children_modules()
166
+ end
167
+ end
168
+
169
+ end
170
+
171
+ def gen_sv_module_verb
172
+ mix_itegrations
173
+ ## 添加测试用例 实例化
174
+ _exec_add_test_unit() if TopModule.sim
175
+
176
+ gen_sv_module
177
+ end
178
+
179
+ def parse_pin_prop(prop=nil)
180
+ return [prop["pins"],prop["iostd"],prop["pulltype"],prop["drive"]]
181
+ end
182
+
183
+ def Input(name,dsize:1,dimension:[],pin:[],iostd:[],pin_prop:nil)
184
+ pin,iostd,pulltype,drive = parse_pin_prop(pin_prop) if pin_prop
185
+ a = super(name,dsize:dsize,dimension:dimension,pin:pin,iostd:iostd,pin_prop:pin_prop)
186
+ @constraint.add_property(a,pin,iostd,pulltype,drive)
187
+ a
188
+ end
189
+
190
+ def Output(name,dsize:1,dimension:[],pin:[],iostd:[],pin_prop:nil)
191
+ pin,iostd,pulltype,drive = parse_pin_prop(pin_prop) if pin_prop
192
+ a = super(name,dsize:dsize,dimension:dimension,pin:pin,iostd:iostd,pin_prop:pin_prop)
193
+ @constraint.add_property(a,pin,iostd,pulltype,drive)
194
+ a
195
+ end
196
+
197
+ def Inout(name,dsize:1,dimension:[],pin:[],iostd:[],pin_prop:nil)
198
+ pin,iostd,pulltype,drive = parse_pin_prop(pin_prop) if pin_prop
199
+ a = super(name,dsize:dsize,dimension:dimension,pin:pin,iostd:iostd)
200
+ @constraint.add_property(a,pin,iostd,pulltype,drive)
201
+ a
202
+ end
203
+
204
+ def Clock(name,freqM:100,port: :input,pin:[],iostd:[],dsize:1,pin_prop:nil)
205
+ pin,iostd,pulltype,drive = parse_pin_prop(pin_prop) if pin_prop
206
+ a = super(name,port:port,freqM:freqM,pin:pin,iostd:iostd,dsize:dsize,pin_prop:pin_prop)
207
+ @constraint.add_property(a,pin,iostd,pulltype,drive)
208
+ a
209
+ end
210
+
211
+ def Reset(name,port: :input,active:"low",pin:[],iostd:[],dsize:1,pin_prop:nil)
212
+ pin,iostd,pulltype,drive = parse_pin_prop(pin_prop) if pin_prop
213
+ a = super(name,port:port,active:active,pin:pin,iostd:iostd,dsize:dsize,pin_prop:pin_prop)
214
+ @constraint.add_property(a,pin,iostd,pulltype,drive)
215
+ a
216
+ end
217
+
218
+ def create_xdc
219
+ return if @sim
220
+ fname = "#{module_name}_constraints.xdc"
221
+ fname = File.join(@out_sv_path,fname)
222
+ File.open(fname,'w') do |f|
223
+ f.puts @constraint.xds
224
+ end
225
+ end
226
+
227
+ def create_add_file_tcl
228
+ return if @sim
229
+ fname = "#{module_name}_add_files.tcl"
230
+ fname = File.join(@out_sv_path,fname)
231
+ File.open(fname,'w') do |f|
232
+ f.puts("add_files \\")
233
+ # f.puts Tdl.all_file_paths.map{ |e| e[1].gsub("\\",'/') }.join("\\\n")
234
+ f.puts Tdl.all_file_paths.map{ |k,v| v.gsub("\\",'/') }.join("\\\n")
235
+ end
236
+ end
237
+
238
+ # def self.root_ref_signal(basele,&block) # return proc becuse top module may not be created
239
+ # if basele.is_a? BaseElm
240
+ # Proc.new do
241
+ # @@root_ref_array = []
242
+
243
+ # unless block_given?
244
+ # self.recur_ref(basele.belong_to_module,basele.signal)
245
+ # else
246
+ # self.recur_ref(basele.belong_to_module,yield(basele))
247
+ # end
248
+
249
+ # if @@root_ref_array.any?
250
+ # @@root_ref_array.first
251
+ # else
252
+ # NqString.new("")
253
+ # end
254
+ # end
255
+ # else
256
+ # raise TdlError.new("#{basele} is a #{basele.class} . Type ERROR")
257
+ # basele.to_s
258
+ # end
259
+ # end
260
+
261
+ # def self.root_ref_inst(sub_inst,port_key) # return proc becuse top module may not be created
262
+ # unless sub_inst.is_a? SdlInst
263
+ # raise TdlError.new("[KEY:#{port_key}]root_ref_inst of #{@module_name} must be a SdlInst")
264
+ # end
265
+ # Proc.new do
266
+ # basele = sub_inst[port_key]
267
+ # if basele.is_a? BaseElm
268
+ # @@root_ref_array = []
269
+ # self.recur_ref(basele.belong_to_module,basele.signal)
270
+ # if @@root_ref_array.any?
271
+ # @@root_ref_array.first
272
+ # else
273
+ # basele.to_s
274
+ # end
275
+ # elsif basele.is_a? Proc
276
+ # basele.call
277
+ # else
278
+ # basele
279
+ # end
280
+ # end
281
+ # end
282
+
283
+ # def self.root_ref_proc(block=nil) # return proc becuse top module may not be created
284
+ # Proc.new do
285
+ # if block_given?
286
+ # basele = yield
287
+ # else
288
+ # basele = block.call
289
+ # end
290
+
291
+ # if basele.is_a? BaseElm
292
+ # @@root_ref_array = []
293
+ # self.recur_ref(basele.belong_to_module,basele.signal)
294
+ # if @@root_ref_array.any?
295
+ # @@root_ref_array.first
296
+ # else
297
+ # NqString.new("")
298
+ # end
299
+ # else
300
+ # basele
301
+ # end
302
+ # end
303
+ # end
304
+
305
+ # def self.root_ref_signals(basele) # return proc becuse top module may not be created
306
+ # if basele is_a? BaseElm
307
+ # Proc.new do
308
+ # @@root_ref_array = []
309
+ # self.recur_ref(basele.belong_to_module,basele.signal)
310
+ # @@root_ref_array
311
+ # end
312
+ # else
313
+ # Proc.new { basele }
314
+ # end
315
+ # end
316
+
317
+ # def self.recur_ref(sdlmodule,collect_str)
318
+ # if sdlmodule.is_a? TopModule
319
+ # @@root_ref_array << "$root.#{sdlmodule.techbench.module_name}.#{sdlmodule.instanced_and_parent_module.keys.first}.#{collect_str}"
320
+ # else
321
+ # return nil unless sdlmodule.instanced_and_parent_module
322
+ # sdlmodule.instanced_and_parent_module.each do |k_inst,v_module|
323
+ # next_collect_str = "#{k_inst}.#{collect_str}"
324
+ # self.recur_ref(v_module,next_collect_str)
325
+ # end
326
+ # end
327
+ # end
328
+
329
+ def self.define_global(name,default_value)
330
+ # RedefOpertor.with_normal_operators do
331
+ self.class_variable_set("@@#{name.to_s}",default_value)
332
+
333
+ self.define_singleton_method(name.to_s) do
334
+ self.class_variable_get("@@#{name.to_s}")
335
+ end
336
+
337
+ self.define_singleton_method("#{name.to_s}=") do |a|
338
+ self.class_variable_set("@@#{name.to_s}",a)
339
+ end
340
+ # end
341
+ end
342
+
343
+ define_global("sim",nil)
344
+
345
+ end
346
+ ## 添加 itegration verb
347
+ class TopModule
348
+
349
+ attr_accessor :implicit_itgt_collect
350
+ # attr_accessor :cal_inst_index_proc
351
+
352
+ def itgt_collect
353
+ @_itgt_collect_
354
+ end
355
+
356
+ def add_itegration(itgt_class,nickname:nil,param:{},pins_map:{},implicit:false)
357
+ @_itgt_collect_ ||= []
358
+ if pins_map.is_a? Hash
359
+ pins_map_f = pins_map
360
+ else
361
+ pins_map_f = self.pins[pins_map.to_s] || {}
362
+ end
363
+
364
+ ist = Kernel.const_get(itgt_class).new(nickname,pins_map_f,self)
365
+ @_itgt_collect_ << ist unless implicit
366
+ # ist.top_module = self
367
+ param.each do |k,v|
368
+ ist.send("#{k}=",v)
369
+ end
370
+
371
+ ## 加入新的itgt时,自动link itgt
372
+ # ist.link_eval
373
+ # puts "------------------"
374
+ # ist.names_pool_inst
375
+ ## 如果itgt没有上级 link 和 不是隐性添加 则直接例化
376
+ # if nickname != "implicit"
377
+ col = ist.class.get_itgt_var('itegration_link_collect',[])
378
+ if col && col.empty?
379
+ ist.inst unless ist.init_inst
380
+ ist.init_inst = true
381
+ ist.inst_index = 0
382
+ end
383
+ # end
384
+ # ist.inst
385
+ return ist
386
+ end
387
+
388
+ def link_eval
389
+ @_itgt_collect_ ||= []
390
+
391
+ @_itgt_collect_.each do |i|
392
+ i.link_eval
393
+ end
394
+ end
395
+
396
+ def index_inst
397
+ curr_collect = (implicit_itgt_collect || []) | @_itgt_collect_
398
+
399
+ curr_collect.each do |e|
400
+ if e.init_inst
401
+ e.cal_inst_index(0)
402
+ end
403
+ end
404
+
405
+ curr_collect = curr_collect.sort { |a, b| a.inst_index <=> b.inst_index }
406
+
407
+ curr_collect.each {|e| e.inst unless e.init_inst }
408
+
409
+ end
410
+ end
411
+
412
+ ## 添加 missing
413
+
414
+ class TopModule
415
+ ## vcs path
416
+ attr_accessor :vcs_path
417
+ def self.method_missing(method,*args,&block)
418
+
419
+ sdlm = TopModule.new(name: method,out_sv_path: args[0])
420
+ @@package_names ||= []
421
+ sdlm.head_import_packages = []
422
+ sdlm.head_import_packages += @@package_names
423
+
424
+ @@package_names.each do |e|
425
+ sdlm.require_package(e,false) if e
426
+ end
427
+ @@package_names = []
428
+ sdlm.instance_exec(&block)
429
+
430
+ if args[0] && File.exist?(args[0])
431
+ # sdlm.gen_sv_module
432
+ sdlm.gen_sv_module_verb
433
+ unless sdlm.vcs_path
434
+ sdlm.test_unit.gen_dve_tcl(File.join(args[0],"dve.tcl"))
435
+ else
436
+ sdlm.test_unit.gen_dve_tcl(File.join(sdlm.vcs_path,"dve.tcl"))
437
+ end
438
+ sdlm.create_xdc
439
+ else
440
+ sdlm.origin_sv = true
441
+ end
442
+ sdlm
443
+ end
444
+ ## 定义模块时添加 package
445
+
446
+ def self.with_package(*args)
447
+ @@package_names += args
448
+ return self
449
+ end
450
+ end
451
+
452
+ ## 給TopModule 添加单元测试 方法
453
+ module TdlSpace
454
+ class TopModuleTestUnitRef
455
+
456
+ def collect_unit(tu)
457
+ @__collect_units__ ||= []
458
+ @__collect_units__ << tu
459
+ end
460
+
461
+ def echo_units
462
+ @__collect_units__ ||= []
463
+ index = 1
464
+
465
+ rels = []
466
+ __collect = TdlTestPoint.inst_collect.select { |e| e.target.belong_to_module.top_tb_ref? }
467
+ @__collect_units__.each do |ue|
468
+ tp_str = ue.origin.dve_wave_signals.select do |e|
469
+ e.respond_to? :tp_instance
470
+ end.map do |ele|
471
+ unless __collect.index(ele.tp_instance)
472
+ puts ele.name
473
+ end
474
+ " ->#{__collect.index(ele.tp_instance)+1}< :: #{ele.tp_instance.name} || #{ele.tp_instance.file}:#{ele.tp_instance.line}"
475
+ end.join("\n")
476
+
477
+ rels << " [#{index}] #{ue.origin.module_name} ::<TestPoints> \n#{tp_str}"
478
+ index += 1
479
+ end
480
+ rels.join("\n")
481
+ end
482
+
483
+ def dve_wave(name: '', signals: [])
484
+ return unless signals
485
+ @_dev_wave_ ||= Hash.new
486
+ @_dev_wave_[name.to_s] = signals ## Signal is TdlTestPoint
487
+ end
488
+
489
+ def gen_dve_tcl(filename)
490
+ File.open(filename,'w') do |f|
491
+ f.puts TdlSpace.gen_dev_wave_tcl(@_dev_wave_ || Hash.new)
492
+ end
493
+ end
494
+
495
+ end
496
+ end
497
+
498
+ class TopModule
499
+ def test_unit
500
+ @__test_unit__ ||= TdlSpace::TopModuleTestUnitRef.new
501
+ end
502
+
503
+ end
504
+
505
+ ## 判断 是否被顶层引用
506
+ class SdlModule
507
+
508
+ def top_module_ref?
509
+ if self == TopModule.current.techbench
510
+ return true
511
+ end
512
+ instanced_and_parent_module.values.each do |pm|
513
+ if pm.is_a?(TopModule)
514
+ return true
515
+ else
516
+ if pm.instanced_and_parent_module.any?
517
+ if pm.top_module_ref?
518
+ return true
519
+ end
520
+ end
521
+ end
522
+ end
523
+ return false
524
+ end
525
+
526
+ def top_tb_ref?
527
+ return false unless TopModule.current
528
+ if self == TopModule.current.techbench
529
+ return true
530
+ end
531
+ instanced_and_parent_module.values.each do |pm|
532
+ if pm == TopModule.current.techbench ##pm.is_a?(TechBenchModule)
533
+ return true
534
+ else
535
+ if pm.instanced_and_parent_module.any?
536
+ if pm.top_tb_ref?
537
+ return true
538
+ end
539
+ end
540
+ end
541
+ end
542
+ return false
543
+ end
544
+ end
545
+
546
+
547
+