完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
#!/usr/bin/perl
if(@ARGV == 0) { printf ("********************************n"); printf ("* Usage: ./vcd2vec.pl VCD_NAME *n"); printf ("********************************n"); exit; } $vcd_name = $ARGV[0]; open(VCD, $vcd_name); $vec_name = $vcd_name.".vec"; open(VEC, ">$vec_name"); my %signal_width; my %signal_fname; my %signal_value; my @sarray; my @array; my @sub_array; my $item; my $sub_item; my $line; my $full_name; my $dump_beg; my $unit = 1; my $ts_en; while($line = { if($line =~ /^$timescale$/) { $ts_en = 1; } if($line =~ /^$end$/) { $ts_en = 0; } if($ts_en == 1 && $line =~ /^s*(d+)ps$/) { $unit = 1000/$1; } if($line =~ /^$scopes+(S+)s+(S+)s+$ends*$/) { push(@array, $2); #printf("@arrayn"); } if($line =~ /^$upscopes+$ends*$/) { pop(@array); #printf("@arrayn"); } if($line =~ /^^$vars+(S+)s+(S+)s+(S+)s+(S+)s+$end$/) { $full_name = &array2hir(@array)."$4"; #printf ("$full_namen"); $signal_fname{$3} = $full_name; $signal_width{$3} = $2; } if($line =~ /^$dumpvars$/) { $dump_beg = 1; @sarray = &Sig2Arr(%signal_width); &prt_hdr_vec(VEC, %signal_fname); $str = "0 "; &myprt(VEC, $str, 16); } if($dump_beg==1) { if ($line =~ /^#(d+)$/) { foreach $item (@sarray) { if(!exists($signal_value{$item})) { printf ("Signal names Wrongn"); exit; } if($signal_width{$item} == 1) { printf VEC (" $signal_value{$item}"); }else { @sub_array = split("", $signal_value{$item}); foreach $sub_item (@sub_array) { printf VEC (" $sub_item"); } } } printf VEC ("n"); $str = $1/$unit." " ; &myprt(VEC, $str, 16); } if ($line =~ /^([01xz])(S+)$/) { $signal_value{$2} = $1; } if ($line =~ /^b(S+)s+(S+)$/) { $signal_value{$2} = $1 } } } foreach $item (@sarray) { if(!exists($signal_value{$item})) { printf ("Signal names Wrongn"); exit; } if($signal_width{$item} == 1) { printf VEC (" $signal_value{$item}"); }else { @sub_array = split("", $signal_value{$item}); foreach $sub_item (@sub_array) { printf VEC (" $sub_item"); } } } close(VCD); close(VEC); printf ("Output File: $vec_namen"); sub array2hir { my @array = @_; my $hir; my $len = @array; for $i(0..$len-1) { $hir .= "$array[$i]/"; } return $hir; } sub get_name { my $src_name = @_; my @array = split(".", $src_name); my $len = @array; my $name; foreach my $i (0 .. $len-2) { $name .= "$array[$i]"; } return $name; } sub myprt { my ($FHANDLE, $str, $len) = @_; $len = $len-1-length($str); foreach $i (0..$len) { printf $FHANDLE (" "); } printf $FHANDLE ("$str"); } sub Sig2Arr { my (%signal_width) = @_; my @sarray; foreach my $item (keys(%signal_width)) { push(@sarray, $item); } return @sarray; } sub prt_hdr_vec { my ($FHANDLE, %signal_fname) = @_; printf $FHANDLE ("logichv 1n"); printf $FHANDLE ("logichv 0n"); my $str; my $len; $str = "signal "; printf $FHANDLE ("$str"); foreach $item(keys(%signal_fname)) { $str = $signal_fname{$item}; $len = length($str) + 1; &myprt($FHANDLE, $str, $len); } $str = "nradix "; printf $FHANDLE ("$str"); foreach $item(keys(%signal_fname)) { $str = $signal_fname{$item}; $len = length($str) + 1; $str = "1"; &myprt($FHANDLE, $str, $len); } $str = "nio "; printf $FHANDLE ("$str"); foreach $item(keys(%signal_fname)) { $str = $signal_fname{$item}; $len = length($str) + 1; $str = "b"; &myprt($FHANDLE, $str, $len); } printf $FHANDLE ("n"); } |
|
|
|
只有小组成员才能发言,加入小组>>
2883 浏览 3 评论
27668 浏览 2 评论
3460 浏览 2 评论
3975 浏览 4 评论
基于采用FPGA控制MV-D1024E系列相机的图像采集系统设计
2322 浏览 3 评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-4 03:06 , Processed in 0.984834 second(s), Total 43, Slave 33 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号