V

 

ASIC/FPGA Design and Verification Out Source Services

Run a perl script from vim on a specified text block and convert vhdl std_logic to specman signal map format.

  1. While coding an eVC for a complex UDP IP , I needed to convert the DUT interface (input and output) from VHDL to specman signal map format.
    This is a large device making a manual work to a very tedious one. So the vim feature of :execute a perl script on block of text ideal.

  2. The input format has the following format:

    reset            : in STD_LOGIC;
    our_ip_address   : in STD_LOGIC_VECTOR (31 downto 0);
    our_mac_address  : in std_logic_vector (47 downto 0);

    A few notes about the input format:
    1. The text is case insensitive.
    2. Spaces can be anywhere.
    3. Single bit or vector signals are used.


  3. The output format is shown below:

    -- UDP TX signals
    udp_tx_start_p out simple_port of bit is instance;
    keep bind(udp_tx_start_p, external);


  4. The perl script is shown below:

    #!/bin/perl

    while (<STDIN>) {
      chomp($_);
      if($_ =~ /downto/) {
        if($_ =~ /^[\t\s]*([a-zA-Z0-9_]*).*:.*[\s\t]\(([0-9]*)[\s\t]*downto.*/) {
          $b1=$1; $b2=$2;
          $b2++;
          $buf="";
          $buf=" " .
          $b1 . "_p out simple_port of uint(bits:" . $b2 . ") is instance;";
          print("$buf\n");
          $buf=" keep bind(" . $b1 . "_p, external);";
          print("$buf\n");
        }
      }
      elsif($_ =~ /^[\t\s]*([a-zA-Z0-9_]*).*:.*/) {
        $b1=$1;
        $buf="";
        $buf=" " .
        $b1 . "_p out simple_port of bit is instance;";
        print("$buf\n");
        $buf=" keep bind(" . $b1 . "_p, external);";
        print("$buf\n");
    }


  5. Script launch from within vim:

    'a,'b !perl ../e/sig_map.pl
    Once the input text block was marked with marks a and b.


  6. The conversion from VHDL assert to specman assert statement is even easier using the following script:

    input:
    assert udp_tx_result = UDPTX_RESULT_NONE report "udp_tx_result not initialised correctly on reset";
    output:
    assert udp_tx_result = UDPTX_RESULT_NONE else dut_error("udp_tx_result not initialised correctly on reset");



    #!/bin/perl

    while (<STDIN>) {
      chomp($_);
      if($_ =~ /.*assert ([a-zA-Z].*)[\t\s]*report (".*");.*/) {
        $b1=$1; $b2=$2;
        $buf=" assert " . $b1 . " else dut_error(" . $b2 . ");";
        print("$buf\n");
      }
    }#while


 


Also available on this project:


Home

Run a perl script from vim on a specified text block and convert binary word to hex








Search This Site


Feedback This Site




new pages on this site