source: asp3_tinet_ecnl_rx/trunk/asp3_dcre/tecsgen/tecslib/plugin/ATK1EventPlugin.rb@ 337

Last change on this file since 337 was 337, checked in by coas-nagasima, 6 years ago

ASP3版ECNLを追加

  • Property svn:eol-style set to native
  • Property svn:mime-type set to text/x-ruby;charset=UTF-8
File size: 5.4 KB
Line 
1# -*- coding: utf-8 -*-
2#
3# TECS Generator Cell-type plugin
4# for TOPPERS Embedded Component System
5#
6# Copyright (C) 2008-2014 by TOPPERS Project TECS-WG
7#--
8# 上記著作権者は,以下の(1)~(4)の条件を満たす場合に限り,本ソフトウェ
9# ア(本ソフトウェアを改変したものを含む.以下同じ)を使用・複製・改
10# 変・再配布(以下,利用と呼ぶ)することを無償で許諾する.
11# (1) 本ソフトウェアをソースコードの形で利用する場合には,上記の著作
12# 権表示,この利用条件および下記の無保証規定が,そのままの形でソー
13# スコード中に含まれていること.
14# (2) 本ソフトウェアを,ライブラリ形式など,他のソフトウェア開発に使
15# 用できる形で再配布する場合には,再配布に伴うドキュメント(利用
16# 者マニュアルなど)に,上記の著作権表示,この利用条件および下記
17# の無保証規定を掲載すること.
18# (3) 本ソフトウェアを,機器に組み込むなど,他のソフトウェア開発に使
19# 用できない形で再配布する場合には,次のいずれかの条件を満たすこ
20# と.
21# (a) 再配布に伴うドキュメント(利用者マニュアルなど)に,上記の著
22# 作権表示,この利用条件および下記の無保証規定を掲載すること.
23# (b) 再配布の形態を,別に定める方法によって,TOPPERSプロジェクトに
24# 報告すること.
25# (4) 本ソフトウェアの利用により直接的または間接的に生じるいかなる損
26# 害からも,上記著作権者およびTOPPERSプロジェクトを免責すること.
27# また,本ソフトウェアのユーザまたはエンドユーザからのいかなる理
28# 由に基づく請求からも,上記著作権者およびTOPPERSプロジェクトを
29# 免責すること.
30#
31# 本ソフトウェアは,無保証で提供されているものである.上記著作権者お
32# よびTOPPERSプロジェクトは,本ソフトウェアに関して,特定の使用目的
33# に対する適合性も含めて,いかなる保証も行わない.また,本ソフトウェ
34# アの利用により直接的または間接的に生じたいかなる損害に関しても,そ
35# の責任を負わない.
36#
37# $Id
38#++
39
40#== ATK1 Event celltype プラグインクラス
41class ATK1EventPlugin < CelltypePlugin
42#@@instancies:: [] :セル実体群
43@@instancies = []
44
45 #=== 初期化
46 # 全てのセルの実体を意味解析後に参照する必要があるために
47 # 初期化時に singleton の instancies に格納する
48 #signature:: Celltype シグニチャ(インスタンス)
49 def initialize( celltype, option )
50 super
51 @@instancies << self
52 end
53
54 #=== cellの生成
55 def new_cell cell
56 end
57
58 #=== 意味解析実行後のコード生成
59 def self.gen_post_code file
60
61 @@instancies.each { |inst|
62 inst.gen_oil_code file
63 }
64
65 end
66
67 #=== OILファイル出力
68 def gen_oil_code file
69
70 file2 = CFile.open( "#{$gen}/EVENT_tecsgen.oil", "w" )
71
72 whole_mask = 0
73
74 # EVENT
75 @celltype.get_cell_list.each { |cell|
76
77# if cell.is_generate?
78 join = cell.get_join_list.get_item( :mask )
79
80 # AUTO type search and change to zero
81 if join then
82 #mask_bit = join.get_rhs.to_s.eval_cnst( nil )
83 mask_bit = join.get_rhs.to_s.to_i
84 mask_str = join.get_rhs.to_s
85 if mask_str == "AUTO" then
86 new_rhs = Expression.create_integer_constant( 32, @locale )
87 join.change_rhs new_rhs
88 else
89 mask_pattern = 1 << mask_bit
90 whole_mask |= mask_pattern
91 end
92 else
93 new_rhs = Expression.create_integer_constant( 32, @locale )
94 join = Join.new( :mask, nil, new_rhs )
95 cell.new_join(join)
96 end
97
98# file2.print "\t /* working #{join.get_rhs.to_s} */\n"
99# end
100
101 }
102
103 mask_count = 0;
104 mask_place = 0;
105
106 @celltype.get_cell_list.each { |cell|
107
108# if cell.is_generate?
109 # bit place to mask pattern
110 file2.print "\tEVENT #{cell.get_name} {\n"
111 join = cell.get_join_list.get_item( :mask )
112 if join then
113 mask_bit = join.get_rhs.to_s.to_i
114 if mask_bit == 32 then
115 while 1
116 p("mask_count, current_mask")
117 p mask_count
118 current_mask = (1 << mask_count)
119 p current_mask
120 if 0 == whole_mask & current_mask
121 new_rhs = Expression.create_integer_constant( current_mask, @locale )
122 join.change_rhs new_rhs
123 whole_mask = whole_mask | current_mask
124 mask_place = mask_count
125 break
126 end
127 if current_mask >= 0x8000
128 mask_place = 0
129 break
130 end
131 mask_count = mask_count + 1
132 end
133 else
134 mask_place = join.get_rhs.to_s.to_i
135 current_mask = 1 << mask_place
136 new_rhs = Expression.create_integer_constant( current_mask, @locale )
137 join.change_rhs new_rhs
138 end
139 file2.print "\t\tMASK = #{mask_place.to_s};\n"
140 end
141
142 file2.print "\t};\n"
143 file2.print "\n"
144
145# end
146
147 }
148
149 file2.close
150
151 end
152
153end
154
Note: See TracBrowser for help on using the repository browser.