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.
-
In this site I have many examples of running a perl
script on block of text from within vim.
-
This page is yet another example, which I used to
translate a design written in verilog to VHDL.
-
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.
-
To invoke the script just mark its borders (with
tags) and run the script:
'a,'b !perl reg_wire_to_signal.pl
-
The script is shown below:
- #!/bin/perl
- while (<STDIN>) {
- chomp($_);
- $flg=0;
- if($_ =~ /reg/) {$flg=1;}
- elsif($_ =~ /wire/) {$flg=1;}
- if($flg == 1) {
- $rangeh="";
- $rangel="";
- if($_ =~ /.*\[([ 0-9]*):([ 0-9]*)/) {
- $rangeh=$1; $rangel=$2;
- }
- @a=split(/--/, $_);
- $a[0] =~ s/ *;/;/;
- $sig_name="";
- if($a[0] =~ /.* ([a-zA-Z_0-9]*) *;/) {
- $sig_name=$1;
- while( length($sig_name) < 12) {$sig_name=$sig_name . " ";}
- }
- $comment="";
- if($_ =~ /.*(--.*)/) {
- $comment=$1;
- }
- print(" signal $sig_name : ");
- if($rangeh ne "") {
- print("std_logic_vector($rangeh downto $rangel);");
- } else {
- print("std_logic;");
- }
- print("$comment\n");
- }
- else {
- if($_ =~ /integer *([a-zA-Z_]*)/) {
- print(" signal $1 : integer;\n");
- } else {
- print("$_\n");
- }
- }
- }#while
-
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:
|
|