1 | # -*- coding: utf-8 -*-
|
---|
2 | #
|
---|
3 | # TECS Generator
|
---|
4 | # Generator for TOPPERS Embedded Component System
|
---|
5 | #
|
---|
6 | # Copyright (C) 2008-2017 by TOPPERS Project
|
---|
7 | #--
|
---|
8 | # ä¸è¨èä½æ¨©è
|
---|
9 | ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
|
---|
10 | # ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ã使ç¨ã»è¤è£½ã»æ¹
|
---|
11 | # å¤ã»åé
|
---|
12 | å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
|
---|
13 | # (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
|
---|
14 | # 権表示ï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
|
---|
15 | # ã¹ã³ã¼ãä¸ã«å«ã¾ãã¦ãããã¨ï¼
|
---|
16 | # (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
|
---|
17 | # ç¨ã§ããå½¢ã§åé
|
---|
18 | å¸ããå ´åã«ã¯ï¼åé
|
---|
19 | å¸ã«ä¼´ãããã¥ã¡ã³ãï¼å©ç¨
|
---|
20 | # è
|
---|
21 | ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
|
---|
22 | # ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
|
---|
23 | # (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
|
---|
24 | # ç¨ã§ããªãå½¢ã§åé
|
---|
25 | å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
|
---|
26 | # ã¨ï¼
|
---|
27 | # (a) åé
|
---|
28 | å¸ã«ä¼´ãããã¥ã¡ã³ãï¼å©ç¨è
|
---|
29 | ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
|
---|
30 | # ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
|
---|
31 | # (b) åé
|
---|
32 | å¸ã®å½¢æ
|
---|
33 | ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSããã¸ã§ã¯ãã«
|
---|
34 | # å ±åãããã¨ï¼
|
---|
35 | # (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
|
---|
36 | # 害ãããï¼ä¸è¨èä½æ¨©è
|
---|
37 | ããã³TOPPERSããã¸ã§ã¯ããå
|
---|
38 | 責ãããã¨ï¼
|
---|
39 | # ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
|
---|
40 | # ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
|
---|
41 | ããã³TOPPERSããã¸ã§ã¯ãã
|
---|
42 | # å
|
---|
43 | 責ãããã¨ï¼
|
---|
44 | #
|
---|
45 | # æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
|
---|
46 | ã
|
---|
47 | # ãã³TOPPERSããã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
|
---|
48 | # ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
|
---|
49 | # ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ害ã«é¢ãã¦ãï¼ã
|
---|
50 | # ã®è²¬ä»»ãè² ããªãï¼
|
---|
51 | #
|
---|
52 | # $Id$
|
---|
53 | #++
|
---|
54 |
|
---|
55 | require_tecsgen_lib 'tecslib/plugin/lib/MrubyBridgeCelltypePluginModule.rb'
|
---|
56 |
|
---|
57 | #== MrubyBridgeCompositePlugin
|
---|
58 | class MrubyBridgeCelltypePlugin < CompositePlugin
|
---|
59 | dbgPrint "MrubyBridgeCelltypePlugin loaded\n"
|
---|
60 | include MrubyBridgeCelltypePluginModule
|
---|
61 |
|
---|
62 | def self.gen_post_code( file )
|
---|
63 | MrubyBridgeCelltypePluginModule.gen_post_code file
|
---|
64 | end
|
---|
65 | end
|
---|
66 |
|
---|
67 |
|
---|
68 | #
|
---|
69 | ##== celltype ãã©ã°ã¤ã³ã®å
|
---|
70 | ±éã®è¦ªã¯ã©ã¹
|
---|
71 | #class MrubyBridgeCelltypePlugin < CelltypePlugin
|
---|
72 | #
|
---|
73 | # # ãã©ã°ã¤ã³å¼æ°å => Proc
|
---|
74 | # MrubyBridgePluginArgProc = {
|
---|
75 | # "ignoreUnsigned" => Proc.new { |obj,rhs| obj.set_ignoreUnsigned rhs },
|
---|
76 | # "include_inner_cell" => Proc.new { |obj,rhs| obj.set_include_inner_cell rhs },
|
---|
77 | # "exclude_cell" => Proc.new { |obj,rhs| obj.set_exclude_cell rhs },
|
---|
78 | # "exclude_port" => Proc.new { |obj,rhs| obj.set_exclude_port rhs },
|
---|
79 | # "exclude_port_func" => Proc.new { |obj,rhs| obj.set_exclude_port_func rhs },
|
---|
80 | # "auto_exclude" => Proc.new { |obj,rhs| obj.set_auto_exclude rhs },
|
---|
81 | # }
|
---|
82 | #
|
---|
83 | # require_tecsgen_lib( "MrubyBridgeCellPlugin.rb" )
|
---|
84 | # @@plugin_list = []
|
---|
85 | # @@count = 1
|
---|
86 | #
|
---|
87 | # #celltype:: Celltype ã»ã«ã¿ã¤ãï¼ã¤ã³ã¹ã¿ã³ã¹ï¼
|
---|
88 | # def initialize( celltype, option )
|
---|
89 | # dbgPrint "#{self.class.name}: initialzie: #{celltype.get_name}\n"
|
---|
90 | #
|
---|
91 | # super
|
---|
92 | # @celltype = celltype
|
---|
93 | # @cell_list = []
|
---|
94 | # @include_inner_cell = false
|
---|
95 | # @exclude_cells = []
|
---|
96 | # @exclude_port = []
|
---|
97 | # @exclude_port_func = {}
|
---|
98 | # @b_ignoreUnsigned = false
|
---|
99 | # @b_auto_exclude = true # auto_exclude = true by default
|
---|
100 | # @@plugin_list << self
|
---|
101 | #
|
---|
102 | # @plugin_arg_check_proc_tab = MrubyBridgePluginArgProc
|
---|
103 | # @plugin_arg_str = CDLString.remove_dquote option
|
---|
104 | # parse_plugin_arg
|
---|
105 | #
|
---|
106 | # MrubyBridgeCellPlugin.set_gen_post_code_by_dependent
|
---|
107 | # end
|
---|
108 | #
|
---|
109 | # #=== æ°ããã»ã«
|
---|
110 | # #cell:: Cell ã»ã«
|
---|
111 | # #
|
---|
112 | # # celltype ãã©ã°ã¤ã³ãæå®ãããã»ã«ã¿ã¤ãã®ã»ã«ãçæããã
|
---|
113 | # # ã»ã«ã¿ã¤ããã©ã°ã¤ã³ã«å¯¾ããæ°ããã»ã«ã®å ±å
|
---|
114 | # # generate æã«ããå¼ã³åºãããå ´åãããã¾ã§ã«å®ç¾©ããã cell ã«ã¤ãã¦ã¯ãinitialize ã®ã¿ã¤ãã³ã°ã§å¼ã³åºããã
|
---|
115 | # def new_cell( cell )
|
---|
116 | # dbgPrint "MrubyBridgeCelltypePlugin: new_cell: #{cell.get_name}\n"
|
---|
117 | #
|
---|
118 | # return if @cell_list.include? cell # ãã®è¡ã¯ãæ¬æ¥ä¸è¦ã®ã¯ã
|
---|
119 | # if TECSGEN.post_coded? # post_code 以éã®ã»ã«ã¯å¯¾è±¡ããå¤ã
|
---|
120 | # cdl_info( "I9999 MrubyBridgeCelltypePlugin: $1 is excluded because cell generated after post_coded", cell.get_name )
|
---|
121 | # return
|
---|
122 | # end
|
---|
123 | #
|
---|
124 | # # include_inner_cell option
|
---|
125 | # if cell.is_cloned? && @include_inner_cell == false then
|
---|
126 | # # p "#{cell.get_name} excluded"
|
---|
127 | # cdl_info( "I9999 MrubyBridgeCelltypePlugin: inner cell $1 is excluded", cell.get_name )
|
---|
128 | # return
|
---|
129 | # # else
|
---|
130 | # # p "#{cell.get_name} included"
|
---|
131 | # end
|
---|
132 | #
|
---|
133 | # # exclude_cell option
|
---|
134 | # if @exclude_cells.include?( cell.get_name ) then
|
---|
135 | # return
|
---|
136 | # end
|
---|
137 | #
|
---|
138 | # opt_str = "ignoreUnsigned=#{@b_ignoreUnsigned}, auto_exclude=#{@b_auto_exclude}"
|
---|
139 | # @exclude_port.each{ |port|
|
---|
140 | # opt_str += ",exclude_port=#{port}"
|
---|
141 | # }
|
---|
142 | # @exclude_port_func.each{ |port, funcs|
|
---|
143 | # funcs.each{ |func|
|
---|
144 | # opt_str += ",exclude_port_func=#{port}.#{func}"
|
---|
145 | # }
|
---|
146 | # }
|
---|
147 | #
|
---|
148 | # # p "MrubyBridgeCelltypePlugin: opt_str=#{opt_str}"
|
---|
149 | #
|
---|
150 | # # mikan option, region
|
---|
151 | # fn2 = "#{$gen}/tmp_MrubyBridgeCelltypePlugin_#{@celltype.get_name}_#{@@count}.cdl"
|
---|
152 | # f2 = File.open( fn2, "w" )
|
---|
153 | # f2.print <<EOT
|
---|
154 | #/* MrubyBridgeCelltypePlugin: celltype=#{@celltype.get_name} */
|
---|
155 | #generate( MrubyBridgeCellPlugin, #{cell.get_namespace_path}, "#{opt_str}" );
|
---|
156 | #EOT
|
---|
157 | # f2.close
|
---|
158 | # Import.new "#{fn2}"
|
---|
159 | # @@count += 1
|
---|
160 | # end
|
---|
161 | #
|
---|
162 | #### æå³è§£æ段éã§å¼ã³åºãããã¡ã½ãã ###
|
---|
163 | # #=== CDL ãã¡ã¤ã«ã®çæ
|
---|
164 | # # typedef, signature, celltype, cell ã®ã³ã¼ããçæ
|
---|
165 | # # éè¤ãã¦çæãã¦ã¯ãªããªã
|
---|
166 | # # ãã§ã«çæããã¦ããå ´åã¯åºåããªããã¨ã
|
---|
167 | # # ãããã¯ååã® import ã«ãããéè¤ãé¿ãããã¨ã
|
---|
168 | # #file:: FILE çæãããã¡ã¤ã«
|
---|
169 | # def gen_cdl_file file
|
---|
170 | ## ãã®æ®µéã§å¼ã³ã ã㨠generate æãå¼ã³åºãããåã®ã»ã«ã®ã¿ã®åºåã¨ãªã
|
---|
171 | #
|
---|
172 | ## dbgPrint "MrubyBridgeCelltypePlugin: gen_cdl_file: #{@celltype.get_name}\n"
|
---|
173 | ## file.print <<EOT
|
---|
174 | ##/* MrubyBridgeCelltypePlugin: celltype=#{@celltype.get_name}
|
---|
175 | ## *
|
---|
176 | ## * cell's generate before celltype's generate
|
---|
177 | ## */
|
---|
178 | ##
|
---|
179 | ##EOT
|
---|
180 | ## @celltype.get_cell_list.each { |cell|
|
---|
181 | ## @cell_list << cell
|
---|
182 | ## # mikan option, region
|
---|
183 | ## dbgPrint "MrubyBridgeCelltypePlugin: cell=#{cell.get_name}\n"
|
---|
184 | ## file.print <<EOT
|
---|
185 | ##generate( MrubyBridgeCellPlugin, #{cell.get_namespace_path}, "" );
|
---|
186 | ##EOT
|
---|
187 | ## }
|
---|
188 | #
|
---|
189 | # end
|
---|
190 | #
|
---|
191 | # #=== tCelltype_factory.h ã«æ¿å
|
---|
192 | ¥ããã³ã¼ããçæãã
|
---|
193 | # # file 以å¤ã®ä»ã®ãã¡ã¤ã«ã«ãã¡ã¯ããªã³ã¼ããçæãã¦ããã
|
---|
194 | # # ã»ã«ã¿ã¤ããã©ã°ã¤ã³ãæå®ãããã»ã«ã¿ã¤ãã®ã¿å¼ã³åºããã
|
---|
195 | # def gen_factory file
|
---|
196 | # end
|
---|
197 | #
|
---|
198 | # def get_celltype
|
---|
199 | # @celltype
|
---|
200 | # end
|
---|
201 | #
|
---|
202 | # #=== å¾ãã® CDL ã³ã¼ããçæ
|
---|
203 | # #ãã©ã°ã¤ã³ã®å¾ãã® CDL ã³ã¼ããçæ
|
---|
204 | # #file:: File:
|
---|
205 | # def self.gen_post_code( file )
|
---|
206 | # dbgPrint "#{self.name}: gen_post_code_body\n"
|
---|
207 | # print "#{self.name}: gen_post_code_body\n"
|
---|
208 | ## ãã®æ®µéã§çæããã¨ãåããã¹ãã³ã¼ãã§åºåããã mruby ã®åæåã³ã¼ãã«åæ ãããªã
|
---|
209 | #
|
---|
210 | ## # MrubyBridgeCelltypePlugin ã®çæãã generate æã¯ã
|
---|
211 | ## fn2 = "#{$gen}/tmp_MrubyBridgeCelltypePlugin_post.cdl"
|
---|
212 | ## f2 = File.open( fn2, "w" )
|
---|
213 | ## # è¤æ°ã®ãã©ã°ã¤ã³ã® post_code ãä¸ã¤ã®ãã¡ã¤ã«ã«å«ã¾ããããã以ä¸ã®ãããªè¦åºããã¤ãããã¨
|
---|
214 | ## dbgPrint "MrubyBridgeCelltypePlugin: gen_post_code\n"
|
---|
215 | ## f2.print "/* '#{self.name}' post code */\n"
|
---|
216 | ## @@plugin_list.each{ |plugin|
|
---|
217 | ## plugin.get_celltype.get_cell_list.each{ |cell|
|
---|
218 | ## # mikan option, region
|
---|
219 | ## f2.print <<EOT
|
---|
220 | ##generate( MrubyBridgeCellPlugin, #{cell.get_namespace_path}, "" );
|
---|
221 | ##EOT
|
---|
222 | ## }
|
---|
223 | ## }
|
---|
224 | ## f2.close
|
---|
225 | ## p Import
|
---|
226 | ## Import.new "#{fn2}"
|
---|
227 | #
|
---|
228 | # MrubyBridgeCellPlugin.gen_post_code_body file
|
---|
229 | # end
|
---|
230 | #
|
---|
231 | # #=== ãã©ã°ã¤ã³å¼æ°
|
---|
232 | #
|
---|
233 | # #=== ãã©ã°ã¤ã³å¼æ° ignoreUnsigned
|
---|
234 | # def set_ignoreUnsigned rhs
|
---|
235 | # if rhs == "true" || rhs == nil then
|
---|
236 | # @b_ignoreUnsigned = true
|
---|
237 | # end
|
---|
238 | # end
|
---|
239 | #
|
---|
240 | # def set_include_inner_cell rhs
|
---|
241 | # if rhs == "true" || rhs == nil then
|
---|
242 | # @include_inner_cell = true
|
---|
243 | # end
|
---|
244 | # end
|
---|
245 | #
|
---|
246 | # def set_exclude_cell rhs
|
---|
247 | # cells = rhs.split ','
|
---|
248 | # cells.each{ |rhs_cell|
|
---|
249 | # rhs_cell.gsub!( /\s/, "" )
|
---|
250 | # @exclude_cells << rhs_cell.to_sym
|
---|
251 | # }
|
---|
252 | # end
|
---|
253 | # def set_exclude_port rhs
|
---|
254 | # ports = rhs.split ','
|
---|
255 | # ct = @cell.get_celltype
|
---|
256 | # return if ct == nil # error case
|
---|
257 | # ports.each{ |rhs_port|
|
---|
258 | # obj = ct.find( rhs_port.to_sym )
|
---|
259 | # if( ( ! obj.instance_of? Port ) || obj.get_port_type != :ENTRY ) then
|
---|
260 | # cdl_error( "MRB9999 exclude_port '$1' not found or not entry in celltype '$2'", rhs_port, ct.get_name )
|
---|
261 | # else
|
---|
262 | # # print "MRBBridgeCellPlugin: exclude #{rhs_port}\n"
|
---|
263 | # @exclude_port << rhs_port
|
---|
264 | # end
|
---|
265 | # }
|
---|
266 | # end
|
---|
267 | #
|
---|
268 | # #=== ãã©ã°ã¤ã³å¼æ° exclude_port_func
|
---|
269 | # def set_exclude_port_func rhs
|
---|
270 | # port_funcs = rhs.split ','
|
---|
271 | # ct = @celltype
|
---|
272 | # return if ct == nil # error case
|
---|
273 | # port_funcs.each{ |rhs_port_func|
|
---|
274 | # port_func = rhs_port_func.split( '.' )
|
---|
275 | # if port_func.length != 2 then
|
---|
276 | # cdl_error( "MRB9999 exclude_port_func: '$1' not in 'port.func' form", rhs_port_func )
|
---|
277 | # end
|
---|
278 | # obj = ct.find( port_func[0].to_sym )
|
---|
279 | # if( ( ! obj.instance_of? Port ) || obj.get_port_type != :ENTRY ) then
|
---|
280 | # cdl_error( "MRB9999 exclude_port_func: port '$1' not found in celltype '$2'", rhs_port_func, ct.get_name )
|
---|
281 | # else
|
---|
282 | # signature = obj.get_signature
|
---|
283 | # next if signature == nil # error case
|
---|
284 | # if signature.get_function_head port_func[1].to_sym
|
---|
285 | # # print "MRBBridgeCellPlugin: #{port_func[0]}.#{port_func[1]} exclude\n"
|
---|
286 | # if @exclude_port_func[ port_func[0] ] then
|
---|
287 | # @exclude_port_func[ port_func[0] ] << port_func[1]
|
---|
288 | # else
|
---|
289 | # @exclude_port_func[ port_func[0] ] = [ port_func[1] ]
|
---|
290 | # end
|
---|
291 | # else
|
---|
292 | # cdl_error( "MRB9999 include_port_func: func '$1' not found in port '$2' celltype $3",
|
---|
293 | # port_func[1], port_func[0], ct.get_name )
|
---|
294 | # end
|
---|
295 | # end
|
---|
296 | # }
|
---|
297 | # end
|
---|
298 | #
|
---|
299 | # #=== ãã©ã°ã¤ã³å¼æ° auto_exclude
|
---|
300 | # def set_auto_exclude rhs
|
---|
301 | # # print "MrubyBridgeCellPlugin: auto_exclude=#{rhs}\n"
|
---|
302 | # if rhs == "false" then
|
---|
303 | # @b_auto_exclude = false
|
---|
304 | # elsif rhs == "true" then
|
---|
305 | # @b_auto_exclude = true # auto_exclude = true by default
|
---|
306 | # else
|
---|
307 | # cdl_warning( "MRB9999 auto_exclude: unknown rhs value ignored. specify true or false" )
|
---|
308 | # end
|
---|
309 | # end
|
---|
310 | #end
|
---|
311 | #
|
---|