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