axi_tdl 0.0.10 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (124) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/gem-push.yml +44 -0
  3. data/.github/workflows/ruby.yml +35 -0
  4. data/.gitignore +3 -1
  5. data/.travis.yml +9 -0
  6. data/Gemfile +4 -0
  7. data/README.EN.md +7 -2
  8. data/README.md +6 -2
  9. data/Rakefile +2 -6
  10. data/axi_tdl.gemspec +3 -4
  11. data/lib/axi/AXI4/axi4_direct_B1.sv +23 -23
  12. data/lib/axi/AXI4/axi4_dpram_cache.sv +33 -33
  13. data/lib/axi/AXI4/axis_to_axi4_wr.rb +1 -0
  14. data/lib/axi/AXI4/axis_to_axi4_wr.sv +20 -20
  15. data/lib/axi/AXI4/packet_partition/axi4_partition_rd_verb.sv +32 -32
  16. data/lib/axi/AXI4/packet_partition/data_inf_partition.rb +2 -0
  17. data/lib/axi/AXI4/packet_partition/data_inf_partition.sv +71 -71
  18. data/lib/axi/AXI4/wide_axis_to_axi4_wr.rb +2 -1
  19. data/lib/axi/AXI4/wide_axis_to_axi4_wr.sv +23 -23
  20. data/lib/axi/AXI_stream/axi_stream_split_channel.rb +7 -1
  21. data/lib/axi/AXI_stream/axis_head_cut_verb.sv +6 -2
  22. data/lib/axi/AXI_stream/axis_insert_copy.rb +18 -4
  23. data/lib/axi/AXI_stream/axis_sim_master_model.rb +28 -0
  24. data/lib/axi/AXI_stream/axis_sim_slaver_model.rb +26 -0
  25. data/lib/axi/AXI_stream/axis_sim_verify_by_coe.sv +101 -0
  26. data/lib/axi/AXI_stream/axis_split_channel_verb.rb +2 -0
  27. data/lib/axi/common/common_ram_sim_wrapper.sv +9 -9
  28. data/lib/axi/common/common_ram_wrapper.sv +12 -12
  29. data/lib/axi/data_interface/data_inf_c/data_c_pipe_sync_seam.sv +26 -26
  30. data/lib/axi/data_interface/data_inf_c/data_c_sim_master_model.sv +69 -0
  31. data/lib/axi/data_interface/data_inf_c/data_c_sim_slaver_model.sv +58 -0
  32. data/lib/axi/data_interface/data_inf_c/logic_sim_model.sv +64 -0
  33. data/lib/axi/techbench/tb_axi_stream_split_channel.rb +69 -0
  34. data/lib/axi/techbench/tb_axi_stream_split_channel.sv +149 -0
  35. data/lib/axi/techbench/tb_axis_split_channel_verb.rb +69 -0
  36. data/lib/axi/techbench/tb_axis_split_channel_verb.sv +125 -0
  37. data/lib/axi_tdl.rb +1 -0
  38. data/lib/axi_tdl/version.rb +1 -1
  39. data/lib/tdl/auto_script/autogensdl.rb +16 -5
  40. data/lib/tdl/axi4/axi4_interconnect_verb.rb +4 -2
  41. data/lib/tdl/basefunc.rb +1 -0
  42. data/lib/tdl/class_hdl/hdl_always_comb.rb +4 -3
  43. data/lib/tdl/class_hdl/hdl_always_ff.rb +49 -8
  44. data/lib/tdl/class_hdl/hdl_assign.rb +5 -3
  45. data/lib/tdl/class_hdl/hdl_block_ifelse.rb +11 -9
  46. data/lib/tdl/class_hdl/hdl_foreach.rb +2 -2
  47. data/lib/tdl/class_hdl/hdl_function.rb +4 -2
  48. data/lib/tdl/class_hdl/hdl_generate.rb +5 -4
  49. data/lib/tdl/class_hdl/hdl_initial.rb +11 -10
  50. data/lib/tdl/class_hdl/hdl_module_def.rb +18 -1
  51. data/lib/tdl/class_hdl/hdl_redefine_opertor.rb +35 -14
  52. data/lib/tdl/class_hdl/hdl_struct.rb +1 -1
  53. data/lib/tdl/class_hdl/hdl_verify.rb +1 -1
  54. data/lib/tdl/elements/originclass.rb +6 -1
  55. data/lib/tdl/elements/parameter.rb +1 -1
  56. data/lib/tdl/examples/10_random/exp_random.sv +3 -3
  57. data/lib/tdl/examples/11_test_unit/dve.tcl +155 -2
  58. data/lib/tdl/examples/11_test_unit/exp_test_unit.rb +9 -8
  59. data/lib/tdl/examples/11_test_unit/exp_test_unit.sv +1 -1
  60. data/lib/tdl/examples/11_test_unit/modules/sub_md0.rb +6 -3
  61. data/lib/tdl/examples/11_test_unit/modules/sub_md0.sv +5 -5
  62. data/lib/tdl/examples/11_test_unit/modules/sub_md1.rb +9 -4
  63. data/lib/tdl/examples/11_test_unit/modules/sub_md1.sv +5 -5
  64. data/lib/tdl/examples/11_test_unit/tb_exp_test_unit.sv +1 -3
  65. data/lib/tdl/examples/11_test_unit/tu0.sv +9 -9
  66. data/lib/tdl/examples/11_test_unit/tu1.sv +1 -1
  67. data/lib/tdl/examples/1_define_module/exmple_md.sv +12 -12
  68. data/lib/tdl/examples/2_hdl_class/tmp/always_comb_test.sv +60 -60
  69. data/lib/tdl/examples/2_hdl_class/tmp/always_ff_test.sv +2 -2
  70. data/lib/tdl/examples/2_hdl_class/tmp/case_test.sv +17 -17
  71. data/lib/tdl/examples/2_hdl_class/tmp/head_pkg_module.sv +9 -9
  72. data/lib/tdl/examples/2_hdl_class/tmp/simple_assign_test.sv +1 -1
  73. data/lib/tdl/examples/2_hdl_class/tmp/state_case_test.sv +10 -10
  74. data/lib/tdl/examples/2_hdl_class/tmp/test_foreach.sv +3 -3
  75. data/lib/tdl/examples/2_hdl_class/tmp/test_function.sv +7 -7
  76. data/lib/tdl/examples/2_hdl_class/tmp/test_initial_assert.sv +3 -3
  77. data/lib/tdl/examples/2_hdl_class/tmp/test_module.sv +2 -2
  78. data/lib/tdl/examples/2_hdl_class/tmp/test_module_var.sv +1 -1
  79. data/lib/tdl/examples/2_hdl_class/tmp/test_package.sv +4 -5
  80. data/lib/tdl/examples/2_hdl_class/tmp/test_package2.sv +4 -4
  81. data/lib/tdl/examples/2_hdl_class/tmp/test_struct_function.sv +2 -2
  82. data/lib/tdl/examples/2_hdl_class/tmp/test_vcs_string.sv +1 -1
  83. data/lib/tdl/examples/2_hdl_class/tmp/text_generate.sv +7 -7
  84. data/lib/tdl/examples/4_generate/test_generate.sv +11 -11
  85. data/lib/tdl/examples/5_logic_combin/test_logic_combin.sv +3 -3
  86. data/lib/tdl/examples/7_module_with_package/body_package.sv +3 -4
  87. data/lib/tdl/examples/7_module_with_package/example_pkg.sv +4 -4
  88. data/lib/tdl/examples/7_module_with_package/head_package.sv +3 -4
  89. data/lib/tdl/examples/8_top_module/tb_test_top.sv +1 -2
  90. data/lib/tdl/examples/9_itegration/clock_manage/itgt_module_clock_manage.rb +13 -0
  91. data/lib/tdl/examples/9_itegration/clock_manage/test_clock_bb.sv +34 -0
  92. data/lib/tdl/examples/9_itegration/tb_test_top.sv +2 -2
  93. data/lib/tdl/examples/9_itegration/tb_test_tttop.sv +1 -1
  94. data/lib/tdl/examples/9_itegration/tb_test_tttop_sim.sv +38 -0
  95. data/lib/tdl/examples/9_itegration/test_top.sv +4 -4
  96. data/lib/tdl/examples/9_itegration/test_tttop.sv +4 -4
  97. data/lib/tdl/examples/9_itegration/test_tttop_sim.sv +9 -0
  98. data/lib/tdl/examples/9_itegration/top.rb +1 -0
  99. data/lib/tdl/exlib/axis_eth_ex.rb +95 -0
  100. data/lib/tdl/exlib/axis_verify.rb +264 -0
  101. data/lib/tdl/exlib/clock_reset_verify.rb +29 -0
  102. data/lib/tdl/exlib/dve_tcl.rb +30 -11
  103. data/lib/tdl/exlib/itegration.rb +15 -3
  104. data/lib/tdl/exlib/itegration_verb.rb +166 -129
  105. data/lib/tdl/exlib/logic_verify.rb +88 -0
  106. data/lib/tdl/exlib/test_point.rb +96 -94
  107. data/lib/tdl/exlib/test_point.rb.bak +293 -0
  108. data/lib/tdl/rebuild_ele/ele_base.rb +1 -1
  109. data/lib/tdl/sdlmodule/sdlmodlule_path_db.rb +34 -0
  110. data/lib/tdl/sdlmodule/sdlmodule.rb +18 -14
  111. data/lib/tdl/sdlmodule/sdlmodule_draw.rb +81 -16
  112. data/lib/tdl/sdlmodule/test_unit_module.rb +278 -33
  113. data/lib/tdl/sdlmodule/test_unit_module.rb.bak +143 -0
  114. data/lib/tdl/sdlmodule/top_module.rb +62 -58
  115. data/lib/tdl/sdlmodule/top_module.rb.bak +547 -0
  116. data/lib/tdl/tdl.rb +18 -3
  117. metadata +35 -134
  118. data/Gemfile.lock +0 -28
  119. data/lib/axi/AXI_stream/axi_stream_split_channel.sv +0 -149
  120. data/lib/axi/AXI_stream/axis_head_cut_verc.sv +0 -242
  121. data/lib/axi/AXI_stream/axis_insert_copy.sv +0 -66
  122. data/lib/axi/AXI_stream/axis_pipe_sync_seam.sv +0 -48
  123. data/lib/axi/AXI_stream/axis_rom_contect_sim.sv +0 -113
  124. data/lib/axi/AXI_stream/axis_split_channel_verb.sv +0 -62
@@ -0,0 +1,88 @@
1
+
2
+ module AxiTdl
3
+
4
+ module LogicVerify
5
+
6
+ class Iteration
7
+
8
+ def initialize(length: 1024, data: [0], dsize: 8)
9
+ @data = data.to_a * (length / data.size + 1)
10
+ @length = length
11
+ @dsize = dsize
12
+ end
13
+
14
+ def to_a
15
+ collect = []
16
+ index = 0
17
+ while true
18
+
19
+ collect << [ index, @data[index] ]
20
+
21
+ if @length <= index + 1
22
+ break
23
+ end
24
+ index += 1
25
+ end
26
+
27
+ collect
28
+ end
29
+
30
+ def context
31
+ collect = []
32
+ to_a.each do |index, data|
33
+ u0 = data % (2**@dsize)
34
+ collect << u0
35
+ end
36
+
37
+ collect.map do |e|
38
+ "%0#{(@dsize )/4 + ( ((@dsize)%4 == 0) ? 0 : 1 )}x"%e
39
+ end
40
+ # collect
41
+ end
42
+
43
+ def coe
44
+ collect = []
45
+ xxx = context
46
+ xxx.each_index do |index|
47
+ collect << "@%04x #{xxx[index]}\n"%index
48
+ end
49
+ collect.join("")
50
+ end
51
+
52
+ end
53
+ end
54
+ end
55
+
56
+ class Logic
57
+
58
+ def to_sim_source_coe(data: (0...100).to_a, posedge: nil ,negedge: nil ,loop_coe: true)
59
+ raise TdlError.new(" posedge negedge both nil") unless (posedge || negedge )
60
+ # raise TdlError.new "file cant be empty" unless file
61
+
62
+ file = File.join(AxiTdl::TDL_PATH,"./auto_script/tmp/","#{self.name}_#{globle_random_name_flag}.coe")
63
+ _len = 1000
64
+ ClassHDL::AssignDefOpertor.with_rollback_opertors(:old) do
65
+ require_hdl 'logic_sim_model.sv'
66
+ itr = AxiTdl::LogicVerify::Iteration.new(length: data.size, data: data )
67
+ File.open(file,'w') do |f|
68
+ f.puts itr.coe
69
+ end
70
+ _len = itr.context.size
71
+ end
72
+
73
+ @belong_to_module.instance_exec(self,_len, posedge || 1.b0 , negedge || 1.b0 ,file, loop_coe) do |_self,_len,next_at_posedge_of,next_at_negedge_of,file,loop_coe|
74
+ Instance(:logic_sim_model, "#{_self.name}_sim_model_inst") do |h|
75
+ h.param.LOOP (loop_coe ? "TRUE" : "FALSE")
76
+ h.param.DSIZE _self.dsize
77
+ h.param.RAM_DEPTH _len
78
+ h.input.next_at_negedge_of next_at_negedge_of
79
+ h.input.next_at_posedge_of next_at_posedge_of
80
+ h.input.load_trigger 1.b0
81
+ h.input[32].total_length _len
82
+ h.input[512*8].mem_file File.expand_path(file)
83
+ h.output['DSIZE'].data _self
84
+ end
85
+
86
+ end
87
+ end
88
+ end
@@ -1,113 +1,115 @@
1
- class TdlTestPoint
2
- @@name_collect = []
3
- @@inst_collect = []
4
-
5
- attr_reader :name,:descript,:target,:file,:line
6
- attr_accessor :filter_block
7
- def initialize(target: nil, name: 'test_point',descript: '',file: nil, line: nil)
8
- @name = name.to_s
9
- if @@name_collect.include? @name
10
- raise TdlError.new "Cant redefine test point with name <#{@name}>"
11
- end
12
- @target = target
13
- @descript = descript
14
- @file = File.expand_path(file) if file
15
- @line = line
1
+ # class TdlTestPoint
2
+ # # @@name_collect = []
3
+ # # @@inst_collect = []
16
4
 
17
- unless @target.respond_to? :belong_to_module
18
- raise TdlError.new "Test point<#{@name}> is not respond to belong_to_module"
19
- end
5
+ # # attr_reader :name,:descript,:target,:file,:line
6
+ # # attr_accessor :filter_block
7
+ # # def initialize(target: nil, name: 'test_point',descript: '',file: nil, line: nil)
8
+ # # @name = name.to_s
9
+ # # if @@name_collect.include? @name
10
+ # # raise TdlError.new "Cant redefine test point with name <#{@name}>"
11
+ # # end
12
+ # # @target = target
13
+ # # @descript = descript
14
+ # # @file = File.expand_path(file) if file
15
+ # # @line = line
20
16
 
21
- ## when test unit in topmodule or topmodule techbench
22
- if target.belong_to_module.is_a?(TopModule) || (TopModule.current && (target.belong_to_module == TopModule.current.techbench))
23
- TdlTestPoint.define_singleton_method(name) { target }
24
- end
17
+ # # unless @target.respond_to? :belong_to_module
18
+ # # raise TdlError.new "Test point<#{@name}> is not respond to belong_to_module"
19
+ # # end
20
+
21
+ # # ## when test unit in topmodule or topmodule techbench
22
+ # # if target.belong_to_module.is_a?(TopModule) || (TopModule.current && (target.belong_to_module == TopModule.current.techbench))
23
+ # # TdlTestPoint.define_singleton_method(name) { target }
24
+ # # end
25
25
 
26
- TdlTestPoint.define_singleton_method(target.belong_to_module.module_name ) { target.belong_to_module }
27
- target.belong_to_module.define_singleton_method(name) { target }
28
- _self = self
29
- target.define_singleton_method('tp_instance') { _self }
26
+ # # TdlTestPoint.define_singleton_method(target.belong_to_module.module_name ) { target.belong_to_module }
27
+ # # target.belong_to_module.define_singleton_method(name) { target }
28
+ # # _self = self
29
+ # # target.define_singleton_method('tp_instance') { _self }
30
30
 
31
- @@inst_collect << self
32
- end
31
+ # # @@inst_collect << self
32
+ # # end
33
33
 
34
- def self.echo_list
35
- ml = [' MODULE']
36
- nl = ['NAME']
37
- dl = ['DESCRIPT']
38
- fl = ['FILE']
39
-
40
- mll = 8
41
- nll = 4
42
- dll = 8
43
- @@inst_collect.each do |e|
44
- unless e.target.belong_to_module.top_tb_ref?
45
- next
46
- end
47
- inst_cnt = e.target.belong_to_module.instance_variable_get("@instance_cnt")
48
- if !inst_cnt || inst_cnt == 0
49
- next
50
- end
51
- ml << e.target.belong_to_module.module_name
52
- nl << e.name
53
- dl << e.descript
54
- if e.file
55
- fl << "#{e.file}:#{e.line}"
56
- else
57
- fl << 'Null'
58
- end
34
+ # def self.echo_list
35
+ # # ml = [' MODULE']
36
+ # # nl = ['NAME']
37
+ # # dl = ['DESCRIPT']
38
+ # # fl = ['FILE']
59
39
 
60
- mll = e.target.belong_to_module.module_name.size if e.target.belong_to_module.module_name.size > mll
61
- nll = e.name.size if e.name.size > nll
62
- dll = e.descript.size if e.descript.size > dll
63
- end
40
+ # # mll = 8
41
+ # # nll = 4
42
+ # # dll = 8
43
+ # # @@inst_collect.each do |e|
44
+ # # unless e.target.belong_to_module.top_tb_ref?
45
+ # # next
46
+ # # end
47
+ # # inst_cnt = e.target.belong_to_module.instance_variable_get("@instance_cnt")
48
+ # # if !inst_cnt || inst_cnt == 0
49
+ # # next
50
+ # # end
51
+ # # ml << e.target.belong_to_module.module_name
52
+ # # nl << e.name
53
+ # # dl << e.descript
54
+ # # if e.file
55
+ # # fl << "#{e.file}:#{e.line}"
56
+ # # else
57
+ # # fl << 'Null'
58
+ # # end
64
59
 
65
- ccl = []
66
- ml.each_index do |index|
67
- # if index != 0
68
- ccl << "[#{sprintf("%3d",index)}]#{ml[index]} #{' '*(mll-ml[index].size)}| #{nl[index]} #{' '*(nll-nl[index].size)}| #{dl[index]} #{' '*(dll-dl[index].size)}| #{fl[index]}"
69
- # else
70
- # ccl << "#{ml[index]} #{' '*(mll-ml[index].size)}| #{nl[index]} #{' '*(nll-nl[index].size)}| #{dl[index]} #{' '*(dll-dl[index].size)}| #{fl[index]}"
71
- # end
72
- end
73
- ccl.join("\n")
74
- end
60
+ # # mll = e.target.belong_to_module.module_name.size if e.target.belong_to_module.module_name.size > mll
61
+ # # nll = e.name.size if e.name.size > nll
62
+ # # dll = e.descript.size if e.descript.size > dll
63
+ # # end
75
64
 
76
- def self.inst_collect
77
- @@inst_collect
78
- end
65
+ # # ccl = []
66
+ # # ml.each_index do |index|
67
+ # # # if index != 0
68
+ # # ccl << "[#{sprintf("%3d",index)}]#{ml[index]} #{' '*(mll-ml[index].size)}| #{nl[index]} #{' '*(nll-nl[index].size)}| #{dl[index]} #{' '*(dll-dl[index].size)}| #{fl[index]}"
69
+ # # # else
70
+ # # # ccl << "#{ml[index]} #{' '*(mll-ml[index].size)}| #{nl[index]} #{' '*(nll-nl[index].size)}| #{dl[index]} #{' '*(dll-dl[index].size)}| #{fl[index]}"
71
+ # # # end
72
+ # # end
73
+ # # ccl.join("\n")
79
74
 
80
- end
75
+ # "TODO SOME"
76
+ # end
77
+
78
+ # # def self.inst_collect
79
+ # # @@inst_collect
80
+ # # end
81
+
82
+ # end
81
83
 
82
84
  module TdlSpace
83
85
 
84
- class ExCreateTPSurge
86
+ # class ExCreateTPSurge
85
87
 
86
- def initialize(target: nil, descript: '', file: nil, line: nil)
87
- @target = target
88
- @descript = descript
89
- @file = file
90
- @line = line
91
- end
88
+ # def initialize(target: nil, descript: '', file: nil, line: nil)
89
+ # @target = target
90
+ # @descript = descript
91
+ # @file = file
92
+ # @line = line
93
+ # end
92
94
 
93
- def -(name)
94
- TdlTestPoint.new(target: @target, name: name, descript: @descript, file: @file, line: @line)
95
- end
95
+ # def -(name)
96
+ # TdlTestPoint.new(target: @target, name: name, descript: @descript, file: @file, line: @line)
97
+ # end
96
98
 
97
- def method_missing(method,*args,&block)
98
- if method.to_s !~ /[a-z]\w+/
99
- raise TdlError.new "Test point name<#{method}> is illegal"
100
- end
101
- self - method
102
- end
103
- end
99
+ # def method_missing(method,*args,&block)
100
+ # if method.to_s !~ /[a-z]\w+/
101
+ # raise TdlError.new "Test point name<#{method}> is illegal"
102
+ # end
103
+ # self - method
104
+ # end
105
+ # end
104
106
 
105
107
  module ExCreateTP
106
108
 
107
- def create_tp(desc='',file=nil,line=nil)
108
- # TdlTestPoint.new(target: self, name: name, descript: desc, file: file, line: line)
109
- ExCreateTPSurge.new(target: self, descript: desc, file: file, line: line)
110
- end
109
+ # def create_tp(desc='',file=nil,line=nil)
110
+ # # TdlTestPoint.new(target: self, name: name, descript: desc, file: file, line: line)
111
+ # ExCreateTPSurge.new(target: self, descript: desc, file: file, line: line)
112
+ # end
111
113
 
112
114
  ## 定义获取 信号的绝对路径
113
115
  def root_ref(&block)
@@ -149,7 +151,7 @@ class BaseElm
149
151
  ll << rt[index].inst_name
150
152
  end
151
153
  end
152
- ll << signal
154
+ ll << @name
153
155
  new_name = ll.join('.').to_nq
154
156
  if block_given?
155
157
  if yield(new_name)
@@ -160,7 +162,7 @@ class BaseElm
160
162
  end
161
163
  end
162
164
  else
163
- collects = ["$root.#{@belong_to_module.module_name}.#{signal}".to_nq]
165
+ collects = ["$root.#{@belong_to_module.module_name}.#{@name}".to_nq]
164
166
  end
165
167
  collects
166
168
  end
@@ -0,0 +1,293 @@
1
+ class TdlTestPoint
2
+ @@name_collect = []
3
+ @@inst_collect = []
4
+
5
+ attr_reader :name,:descript,:target,:file,:line
6
+ attr_accessor :filter_block
7
+ def initialize(target: nil, name: 'test_point',descript: '',file: nil, line: nil)
8
+ @name = name.to_s
9
+ if @@name_collect.include? @name
10
+ raise TdlError.new "Cant redefine test point with name <#{@name}>"
11
+ end
12
+ @target = target
13
+ @descript = descript
14
+ @file = File.expand_path(file) if file
15
+ @line = line
16
+
17
+ unless @target.respond_to? :belong_to_module
18
+ raise TdlError.new "Test point<#{@name}> is not respond to belong_to_module"
19
+ end
20
+
21
+ ## when test unit in topmodule or topmodule techbench
22
+ if target.belong_to_module.is_a?(TopModule) || (TopModule.current && (target.belong_to_module == TopModule.current.techbench))
23
+ TdlTestPoint.define_singleton_method(name) { target }
24
+ end
25
+
26
+ TdlTestPoint.define_singleton_method(target.belong_to_module.module_name ) { target.belong_to_module }
27
+ target.belong_to_module.define_singleton_method(name) { target }
28
+ _self = self
29
+ target.define_singleton_method('tp_instance') { _self }
30
+
31
+ @@inst_collect << self
32
+ end
33
+
34
+ def self.echo_list
35
+ ml = [' MODULE']
36
+ nl = ['NAME']
37
+ dl = ['DESCRIPT']
38
+ fl = ['FILE']
39
+
40
+ mll = 8
41
+ nll = 4
42
+ dll = 8
43
+ @@inst_collect.each do |e|
44
+ unless e.target.belong_to_module.top_tb_ref?
45
+ next
46
+ end
47
+ inst_cnt = e.target.belong_to_module.instance_variable_get("@instance_cnt")
48
+ if !inst_cnt || inst_cnt == 0
49
+ next
50
+ end
51
+ ml << e.target.belong_to_module.module_name
52
+ nl << e.name
53
+ dl << e.descript
54
+ if e.file
55
+ fl << "#{e.file}:#{e.line}"
56
+ else
57
+ fl << 'Null'
58
+ end
59
+
60
+ mll = e.target.belong_to_module.module_name.size if e.target.belong_to_module.module_name.size > mll
61
+ nll = e.name.size if e.name.size > nll
62
+ dll = e.descript.size if e.descript.size > dll
63
+ end
64
+
65
+ ccl = []
66
+ ml.each_index do |index|
67
+ # if index != 0
68
+ ccl << "[#{sprintf("%3d",index)}]#{ml[index]} #{' '*(mll-ml[index].size)}| #{nl[index]} #{' '*(nll-nl[index].size)}| #{dl[index]} #{' '*(dll-dl[index].size)}| #{fl[index]}"
69
+ # else
70
+ # ccl << "#{ml[index]} #{' '*(mll-ml[index].size)}| #{nl[index]} #{' '*(nll-nl[index].size)}| #{dl[index]} #{' '*(dll-dl[index].size)}| #{fl[index]}"
71
+ # end
72
+ end
73
+ ccl.join("\n")
74
+ end
75
+
76
+ def self.inst_collect
77
+ @@inst_collect
78
+ end
79
+
80
+ end
81
+
82
+ module TdlSpace
83
+
84
+ class ExCreateTPSurge
85
+
86
+ def initialize(target: nil, descript: '', file: nil, line: nil)
87
+ @target = target
88
+ @descript = descript
89
+ @file = file
90
+ @line = line
91
+ end
92
+
93
+ def -(name)
94
+ TdlTestPoint.new(target: @target, name: name, descript: @descript, file: @file, line: @line)
95
+ end
96
+
97
+ def method_missing(method,*args,&block)
98
+ if method.to_s !~ /[a-z]\w+/
99
+ raise TdlError.new "Test point name<#{method}> is illegal"
100
+ end
101
+ self - method
102
+ end
103
+ end
104
+
105
+ module ExCreateTP
106
+
107
+ # def create_tp(desc='',file=nil,line=nil)
108
+ # # TdlTestPoint.new(target: self, name: name, descript: desc, file: file, line: line)
109
+ # ExCreateTPSurge.new(target: self, descript: desc, file: file, line: line)
110
+ # end
111
+
112
+ ## 定义获取 信号的绝对路径
113
+ def root_ref(&block)
114
+ ClassHDL::AssignDefOpertor.with_rollback_opertors(:old) do
115
+ rels = path_refs(&block)
116
+ if block_given?
117
+ sst = "block given"
118
+ else
119
+ sst = "no block"
120
+ end
121
+
122
+ if rels.size == 1
123
+ rels[0]
124
+ elsif rels.size == 0
125
+ raise TdlError.new "#{self} Cant find root ref {#{sst}}"
126
+ else
127
+ raise TdlError.new "#{self} Find multi root refs {#{sst}} \n#{rels.join("\n")}\n"
128
+ end
129
+ end
130
+ end
131
+ end
132
+
133
+ end
134
+
135
+ class BaseElm
136
+ include TdlSpace::ExCreateTP
137
+
138
+ ## 获取信号的绝对路径
139
+ def path_refs(&block)
140
+ collects = []
141
+ if @belong_to_module != TopModule.current.techbench
142
+ @belong_to_module.parents_inst_tree do |tree|
143
+ ll = ["$root"]
144
+ rt = tree.reverse
145
+ rt.each_index do |index|
146
+ if rt[index].respond_to? :module_name
147
+ ll << rt[index].module_name
148
+ else
149
+ ll << rt[index].inst_name
150
+ end
151
+ end
152
+ ll << @name
153
+ new_name = ll.join('.').to_nq
154
+ if block_given?
155
+ if yield(new_name)
156
+ collects << new_name
157
+ end
158
+ else
159
+ collects << new_name
160
+ end
161
+ end
162
+ else
163
+ collects = ["$root.#{@belong_to_module.module_name}.#{@name}".to_nq]
164
+ end
165
+ collects
166
+ end
167
+
168
+ end
169
+
170
+ module TdlSpace
171
+ class TdlBaseInterface
172
+ include ExCreateTP
173
+
174
+ ## 获取信号的绝对路径
175
+ def path_refs(&block)
176
+ collects = []
177
+ if @belong_to_module != TopModule.current.techbench
178
+ @belong_to_module.parents_inst_tree do |tree|
179
+ ll = ["$root"]
180
+ rt = tree.reverse
181
+ rt.each_index do |index|
182
+ if rt[index].respond_to? :module_name
183
+ ll << rt[index].module_name
184
+ else
185
+ ll << rt[index].inst_name
186
+ end
187
+ end
188
+ ll << inst_name
189
+ new_name = ll.join('.').to_nq
190
+ if block_given?
191
+ if yield(new_name)
192
+ collects << new_name
193
+ end
194
+ else
195
+ collects << new_name
196
+ end
197
+ end
198
+ else
199
+ collects = ["$root.#{@belong_to_module.module_name}.#{inst_name}".to_nq]
200
+ end
201
+ collects
202
+ end
203
+ end
204
+ end
205
+
206
+ module ClassHDL
207
+ class EnumStruct
208
+ include TdlSpace::ExCreateTP
209
+
210
+ def root_ref(nstateq=true,&block)
211
+ ClassHDL::AssignDefOpertor.with_rollback_opertors(:old) do
212
+ rels = path_refs(nstateq,&block)
213
+ if rels.size == 1
214
+ rels[0]
215
+ elsif rels.size == 0
216
+ raise TdlError.new "#{self} Cant find root ref"
217
+ else
218
+ raise TdlError.new "#{self} Find multi root refs \n#{rels.join("\n")}\n"
219
+ end
220
+ end
221
+ end
222
+
223
+ ## 获取信号的绝对路径
224
+ def path_refs(nstateq=true,&block)
225
+ collects = []
226
+ @belong_to_module.parents_inst_tree do |tree|
227
+ ll = ["$root"]
228
+ rt = tree.reverse
229
+ rt.each_index do |index|
230
+ if rt[index].respond_to? :module_name
231
+ ll << rt[index].module_name
232
+ else
233
+ ll << rt[index].inst_name
234
+ end
235
+ end
236
+ if nstateq
237
+ ll << nstate
238
+ else
239
+ ll << cstate
240
+ end
241
+ new_name = ll.join('.').to_nq
242
+ if block_given?
243
+ if yield(new_name)
244
+ collects << new_name
245
+ end
246
+ else
247
+ collects << new_name
248
+ end
249
+ end
250
+ collects
251
+ end
252
+ end
253
+ end
254
+
255
+ # class TdlTestPoint < TdlSpace::TdlTestPoint
256
+
257
+ # end
258
+
259
+ module ClassHDL
260
+ class StructVar
261
+ include TdlSpace::ExCreateTP
262
+
263
+ ## 获取信号的绝对路径
264
+ def path_refs(&block)
265
+ collects = []
266
+ if @belong_to_module != TopModule.current.techbench
267
+ @belong_to_module.parents_inst_tree do |tree|
268
+ ll = ["$root"]
269
+ rt = tree.reverse
270
+ rt.each_index do |index|
271
+ if rt[index].respond_to? :module_name
272
+ ll << rt[index].module_name
273
+ else
274
+ ll << rt[index].inst_name
275
+ end
276
+ end
277
+ ll << self.to_s.to_nq
278
+ new_name = ll.join('.').to_nq
279
+ if block_given?
280
+ if yield(new_name)
281
+ collects << new_name
282
+ end
283
+ else
284
+ collects << new_name
285
+ end
286
+ end
287
+ else
288
+ collects = ["$root.#{@belong_to_module.module_name}.#{self.to_s.to_nq}".to_nq]
289
+ end
290
+ collects
291
+ end
292
+ end
293
+ end