我是TCL腳本初學者。我正在研究如何將Verilog文件中的數據解析爲xls文件。解析verilog文件中的數據
輸入的Verilog文件包含以下數據:
Inferred components Operator Signedness Inputs Outputs CellArea Line Col Filename ===================================================================================================== apn u_apn_ttp_logic abc u_apn_wgt_op_rd_u_apn_sca_u_part_sel1_sl_69_33 module:shift_right_vlog_unsigned_4662_7709 very_fast/barrel >> x 25x5 25 223.02 69 33 part_select.v ===================================================================================================== apn u_apn_ttp_logic u_apn_wgt_op_rd_u_apn_scale_u_part_sel1_sub00283545 module:sub_signed_4513_5538 very_fast - signed 11x24 25 152.80 0 0 a =====================================================================================================
(這是一個長文件...)
最後一節之後,解析將結束:
===================================================================================================== apn u_apn_start_ctrl_final_adder_add_212_41 module:add_unsigned_carry_882 very_fast + unsigned 32x32x1 32 120.39 212 41 feu_start_ctrl.v =====================================================================================================
我想提取數據如下,考慮第一節
Top name=apn Instance=u_apn_ttp_logic/abc/u_apn_wgt_op_rd_u_feu_scale_u_part_select1_srl_69_33 Module = shift_right_vlog_unsigned_4662_7709 Architecture=very_fast/barrel Operator = >> Sign=x Input Size = 25x5 Output = 25 Area = 223.02 Column = 69 Row = 33 File Name = part_select.v
我在執行此操作時遇到了一些困難。下面
是我相同的方法:輸出topname
和instance
名
set fd "[open "path_data.v" r]"
set flag 0
while {[gets $fd line] !=-1} {
if {[regexp "\===*" $line]} {
while {[gets $fd line] >= 0} {
append data "$line "
if {[regexp "\====*" $line]} {
break
} }
set topname [lindex $data 0]
regexp {(^[a-z]*) (.*) (.*module)} $data match topname instance sub3
puts "top name :$topname "
puts "instance: $instance"
}
close $fd
我能夠只,而不是其他值 還請大家幫我提取這些值。
我不確定這是否適用於真實數據,但至少可以更容易地看到出現問題並驗證碎片。 –
嗨多納爾, 感謝您的支持, 我試着用你的代碼,但有錯誤來了,我也試圖與設置第一,如果循環內的標誌, 還請大家幫我理解下面的命令, 「outputSectionInfo $ top $ instance $ module {*} $ other「 – Krishh