ひでみのアイデア帳

くだらないことなんだけど、忘れないために・・・

CPAN - Perl for verilog

PerlでVerilogをparseするために、下記のようにCPANをインストールする。

% yum install CPAN

% cpan

cpan> install Verilog-Perl

下記のように組んでみると

my $NetList = new Verilog::Netlist;

ReadVerilogFiles($NetList, ''FILENAME''),

foreach my $module ($NetList->modules_sorted) {

    print "\n";

    print '' ''x4, $module->name,'' '', $module->name, " (\n";

    my @ports = $module->ports_sorted;

    for (my $index=0; $index <= $#ports; $index++) {

        print '' ''x8, ''.'', $ports[$index]->name;

        print '' ( '', $ports[$index]->name, '' )'';

        if ($index != $#ports) {

        print ",\n";

        } else {

        print "\n";

        }

    }

    print '' ''x4,"),\n";

}

RTLを読んでこんな風に作れる。

    aq_axi4ls aq_axi4ls (

        .ACLK ( ACLK ),

        .ARADDR ( ARADDR ),

        .ARCACHE ( ARCACHE ),

        .ARESETN ( ARESETN ),

        .ARPROT ( ARPROT ),

        .ARREADY ( ARREADY ),

        .ARVALID ( ARVALID ),

        .AWADDR ( AWADDR ),

        .AWCACHE ( AWCACHE ),

        .AWPROT ( AWPROT ),

        .AWREADY ( AWREADY ),

        .AWVALID ( AWVALID ),

        .BREADY ( BREADY ),

        .BRESP ( BRESP ),

        .BVALID ( BVALID ),

        .CLK ( CLK ),

        .LOCAL_ACK ( LOCAL_ACK ),

        .LOCAL_ADDR ( LOCAL_ADDR ),

        .LOCAL_BE ( LOCAL_BE ),

        .LOCAL_CS ( LOCAL_CS ),

        .LOCAL_RDATA ( LOCAL_RDATA ),

        .LOCAL_RNW ( LOCAL_RNW ),

        .LOCAL_WDATA ( LOCAL_WDATA ),

        .RDATA ( RDATA ),

        .RREADY ( RREADY ),

        .RRESP ( RRESP ),

        .RST_N ( RST_N ),

        .RVALID ( RVALID ),

        .WDATA ( WDATA ),

        .WREADY ( WREADY ),

        .WSTRB ( WSTRB ),

        .WVALID ( WVALID )

    ),

こんな感じでverilog2ipxact.plを作成中!