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.
-
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.
-
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:
- The text is case insensitive.
- Spaces can be anywhere.
- Single bit or vector signals are used.
-
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);
-
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");
}
-
Script launch from within vim:
'a,'b !perl ../e/sig_map.pl
Once the input text block was marked with marks a and b.
-
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:
|
|