perl对目录下rtl 包含rtc字符的替换

项目需求:

1.根据项目需要,将2bit 或3bit的rtc进行替换为64bit rtc

难点:

2.由于rtl各层次之间的信号关联会发生变化。

3.不同module之间的rtc名字存在相同性。

解决办法:

1.分析出了lib rtl的输入名都是RTC,因此写脚本的时候把RTC相关的行全部抓出来。

2.除了极少部分的名字采用了特殊命名。绝大部分都是采用rf1p_rtc,rf2p_rtc,sf1p_rtc,sf2p_rtc。因此这对于替换

带来了极大的方便。

3.对于关联信号的变化,需要单独分析,对于rtc = rf1p_rtc这样的赋值变化,要追踪去处。

perl脚本如下。

#! /usr/bin/perl

use 5.010;
use strict;

my @all_files_1 = glob '/proj/../../../../..units/*/src/*.v';
my @all_files_2 = glob '/proj/../../../../../units/*/src/*/*.v';

my @all_files = (@all_files_1,@all_files_2);

my $flag = 0;
my $cnt = 0;

if (-e "good_file.txt") {
say "good_file.txt is exists";
unlink "good_file.txt";
say "good_file.txt is delete";
}

if (-e "store_text_001.txt") {
say "store_text_001.txt is exists";
unlink "store_text_001.txt";
say "store_text_001.txt is delete";
}

foreach my $file_name (@all_files){
    open my $file_text,'<',"$file_name";
    open my $good_file,'>>',"good_file.txt";
    open my $store_text_001,'>>',"store_text_001.txt";
    while(<$file_text>){
        chomp;
        $cnt++;
            if(/rf1p_rtc|rf2p_rtc|sr1p_rtc|sr2p_rtc|rom_rtc|rom_rtc_ref|rtc/i){
                $flag = 1;
                say $store_text_001 "$cnt     $_"; 
                }
        }
    if ($flag == 1){
        $cnt = 0;
        say $good_file "$file_name";
        say $store_text_001 "$file_name"; 
        $flag = 0;
    }else {
        $cnt = 0;
        $flag = 0;
        };
    close $file_text;
    close $good_file;
    close $store_text_001;
    }

&func_rtc;

sub func_rtc{
open my $file,'<',"good_file.txt";
my $cnt;
while(<$file>){
        $cnt++;
#        if($cnt <= 3){
        my $file_name_store = $_;
        `soscmd discardco -F $file_name_store`;
        `soscmd co $_`;
        open my $new_file_text,"$_";
        open my $new_file,'>',"new_file.v";
        while(<$new_file_text>){
            chmod;
        if (s/input\s*\[\d+\:0\]\s*(\brf1p_rtc\b|\brf2p_rtc\b|\bsr1p_rtc\b|\bsr2p_rtc\b)/input  [`NEW_MEM_CTRL-1:0]  \1/){
            printf $new_file "$_";
            }
        elsif (s/output\s*\[\d+\:0\]\s*(\brf1p_rtc\b|\brf2p_rtc\b|\bsr1p_rtc\b|\bsr2p_rtc\b)/output  [`NEW_MEM_CTRL-1:0]   \1/){
            printf $new_file "$_";
            }
        elsif (s/wire\s*\[\d+\:0\]\s*(\brf1p_rtc\b|\brf2p_rtc\b|\bsr1p_rtc\b|\bsr2p_rtc\b)/wire [`NEW_MEM_CTRL-1:0] \1/){
            printf $new_file "$_";
            }
        elsif (s/(\brf1p_rtc\b|\brf2p_rtc\b|\bsr1p_rtc\b|\bsr2p_rtc\b)\s*\[\d+:0\]/\1/){
            printf $new_file "$_";
            }
        elsif (s/input\s*\[\d+\:0\]\s*(\brom_rtc\b)/input  [`NEW_ROM_CTRL-1:0]  \1/){
            printf $new_file "$_";
            }
        elsif (s/output\s*\[\d+\:0\]\s*(\brom_rtc\b)/output  [`NEW_ROM_CTRL-1:0]   \1/){
            printf $new_file "$_";
            }
        elsif (s/wire\s*\[\d+\:0\]\s*(\brom_rtc\b)/wire [`NEW_ROM_CTRL-1:0] \1/){
            printf $new_file "$_";
            }
        elsif (s/(\brom_rtc\b)\s*\[\d+:0\]/\1/){
            printf $new_file "$_";
            }
        elsif (s/wire    \[1\:0\]       (rtc0, rtc1, rtc2, rtc3, rtc4, rtc5, rtc6)/wire [`NEW_MEM_CTRL-1:0] \1/){
            printf $new_file "$_";
            }
        elsif (s/(input|output|wire)\s*\[\d+\:0\]\s*RTC/\1 [`NEW_MEM_CTRL-1:0] RTC/){
            printf $new_file "$_";
            }
        elsif (s/RTC\[\d+\:0\]/RTC/){
            printf $new_file "$_";
            }
        elsif (s/input\s*\[\d+\:0\]\s*(txmod_rf_rtc|rf2p_txmod_rtc)/input  [`NEW_MEM_CTRL-1:0]  \1/){
            #say "$file_name_store";
            #say "$_";
            printf $new_file "$_";
            }
        elsif (s/rf2p_txmod_rtc\[\d+\:0\]/rf2p_txmod_rtc/){
            #say "$file_name_store";
            #say "$_";
            printf $new_file "$_";
            }
        elsif (s/input\s*\[\d+\:0\]\s*\brsd_rtc\b/input  [`NEW_ROM_CTRL-1:0] rsd_rtc/){
            say "$file_name_store";
            say "$_";
            printf $new_file "$_";
            }
        #elsif (s/RTC\s*\(rsd_rtc\[\d+\:0\]\)/RTC     (rsd_rtc)/){
        elsif (s/rsd_rtc\[\d+\:0\]/rsd_rtc/){
            say "$file_name_store";
            say "$_";
            printf $new_file "$_";
            }
        else{
            printf $new_file "$_";
            }
        }
        close $new_file_text;
        close $new_file;
        system("cp new_file.v $file_name_store");
#        `soscmd discardco -F $file_name_store`;
 #      }
    }
close $file;
}

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
iscas2spice spice netlist generation tool -- version 2.2 by Jingye Xu @ VLSI Group, Dept. of ECE, UIC, June, 2008 This tool reads the ISCAS85 benchmark circuit "*.bench" file and translate the file into SPICE netlist using the given technology and the standard cell library. platform: linux x86 sytem Input: ISCAS85 benchmark circuit: *.bench; standard cell library: stdcells.sclb; standard cell models: stdcells.lib; interconnect paramaters: *.int; Output: SPICE netlist: out.sp The whole procedure of the tools can be divided into several steps: 1. Gate replacement: replace the gates that can't be found in the with the gates in the standard cell lib. (break.pl) Output: *.bench, *.bench.bak 2. Generate the GSRC files: generate the GSRC files for the fengshui placer. (gsrcgen.pl) Output: gsrcfile/iscas.* 3. Placement: using the fengshui placement tool to perform the component placement. (fs50) Output: gsrcfile/iscas_fs50.pl 4. Generate ISPD file: tanslate the placement results into ISPD98 format file that can be used as the input of the global router. (gsrc2ispd.pl) Output: gsrcfile/iscas.laby.txt 5. Perform the routing: use the labyrinth global router to perform the routing. (mazeRoute) Output: gsrcfile/output 6. Generate the SPICE netlist: use all the available information to generate the final SPICE netlist. (spicegen.pl) Output: out.sp Usage: iscas2spice.pl Iscas85BenchmarkFile [-C/L/N] options: -C :default value, use the RC model for interconnect -L :use the RLC model for interconnect -N :treat interconnect as short circuit wire This package used the fengshui placement tools and labyrinth global routing tools, for information regarding these two free tools, please vist: http://www.ece.ucsb.edu/~kastner/labyrinth/ http://vlsicad.cs.binghamton.edu/software.html For information regarding this software itself please visit: http://wave.ece.uic.edu/~iscas2spice Many thanks to my advisor Masud H. Chowdhury for his support!

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值