ASIC/FPGA Design and Verification Out Source Services

Run a perl script from vim on a specified text block and convert verilog registers and wires to VHDL signals.

  1. In this site I have many examples of running a perl script on block of text from within vim.

  2. This page is yet another example, which I used to translate a design written in verilog to VHDL.

  3. In such cases I create small script per each task. In this case the script is used to convert registers and wires to signals syntax.

  4. To invoke the script just mark its borders (with tags) and run the script:
    'a,'b !perl reg_wire_to_signal.pl

  5. The script is shown below:

    1. #!/bin/perl

    2. while (<STDIN>) {
    3.    chomp($_);
    4.    $flg=0;
    5.    if($_ =~ /reg/) {$flg=1;}
    6.    elsif($_ =~ /wire/) {$flg=1;}
    7.    if($flg == 1) {
    8.       $rangeh="";
    9.       $rangel="";
    10.       if($_ =~ /.*\[([ 0-9]*):([ 0-9]*)/) {
    11.          $rangeh=$1; $rangel=$2;
    12.       }
    13.       @a=split(/--/, $_);
    14.       $a[0] =~ s/ *;/;/;
    15.       $sig_name="";
    16.       if($a[0] =~ /.* ([a-zA-Z_0-9]*) *;/) {
    17.          $sig_name=$1;
    18.          while( length($sig_name) < 12) {$sig_name=$sig_name . " ";}
    19.       }
    20.       $comment="";
    21.       if($_ =~ /.*(--.*)/) {
    22.          $comment=$1;
    23.       }
    24.       print(" signal $sig_name : ");
    25.       if($rangeh ne "") {
    26.          print("std_logic_vector($rangeh downto $rangel);");
    27.       } else {
    28.          print("std_logic;");
    29.       }
    30.       print("$comment\n");
    31.    }
    32.    else {
    33.       if($_ =~ /integer *([a-zA-Z_]*)/) {
    34.          print(" signal $1 : integer;\n");
    35.       } else {
    36.          print("$_\n");
    37.       }
    38.    }
    39. }#while


  6. Similar script, which works on a block of VHDL input and outputs, and converts it to verilog IO syntax, can be downloaded from here.
    The script was extended to also be able to convert VHDL signals to verilog equivalence ( without checking if a reg or wire should be used).
    As usual to fire-up the script, you need to mark up a text block, for instance mark a and b and then type:
    'a,'b !perl vim_vhd_io_to_verilog_io.pl

 


Also available on this project:


Home

Some tips for controlling the xterm title


Extending the example from cadance of producer consumer (system C).







Search This Site


Feedback This Site




new pages on this site