如何从我的包含文件中删除端口使用Verilog::SigParser



我在Perl中使用Verilog包,因此我可以读取Verilog文件并提取其中的端口。出于这个目的,我使用Verilog::SigParser,如果你是新来的,你应该知道Verilog::SigParser在信号被声明、模块实例化或模块定义时提供回调。您传递的文件显然是一个Verilog文件。这里的问题是,我试图在包含在另一个文件内的文件中使用SigParser(只是它的名称,而不是它的内容,向下滚动以便更好地理解),看起来来自包含文件的端口正在进入我的%arr(),这后来给了我一些错误,因为我当然不能形成测试台。让我给你们看一些代码:

这是我的perl文件

#On top of the file
package MyParser
use Verilog::SigParser
$filename = /user/home/verilog.v
....
use base qw(Verilog::SigParser);
my %arr = (); #In this array, all module inputs and outputs are being saved.

#Process my verilog file
my $vf Verilog::Preproc->new(keep_comments->0);
$vf->open(filename=>$filename) or die $!;
open(FH,'>',/users/home/port_file);
print(FH, %arr()); #HERE IT IS INCLUDING NOT JUST THE PORTS FROM VERILOG.V BUT ALSO THE ONES FROM HAPPY.VP, I want only the ones from verilog.v
close(FH);

顶级文件verilog.v

`include happy.vp
module top();
.
#lots of inputs and outputs
.
.
endmodule

文件happy.vp

module happy();
#some other inputs or outputs I don't want in my ports file. 
endmodule

SystemVerilog包不能访问在该包作用域之外声明的任何日期类型或数据项,除非通过从另一个先前编译的包导入。没有办法从编译单元导入。

typedef int t; // outside space is part of some compilation unit
package p;
t v; // reference to t is illegal
endpackage 

最新更新