Archive-name: rec_to_pkg_nest-1.1-beta
Original-author: Wojciech M. Zabolotny (
wz...@ise.pw.edu.pl )
Submitted-by:
wz...@ise.pw.edu.pl
Last-modified: 2014-09-27 +00:00
Copyright-Notice: PUBLIC DOMAIN or Creative Commons CC0
This is the new, corrected version of the previous rec_to_pkg.py tool.
Basing on the record description file, it generates the VHDL package,
that defines the record type and provides the conversion functions
for conversion of the records into std_logic_vector of tha appropriate
length, and from std_logic vector to the record.
This rec_to_pkg_nest.py may handle the nested records and the arrays of record types.
Additionally it is possible to specify comments, that should be written at the begining
of the generated VHDL package (they should start with double hash '##').
The sources contain the example record definition file, and a testbench
showing the operation.
If you have ghdl and gtkwave installed, run the run_test.sh to see the
demonstration.
Please note that the code is published as PUBLIC DOMAIN or under Creative
Commons CC0 license.
However, if you create any derived work, please provide information
about the original author.
This is a free code. I do not provide any warranty. You use it on your
own risk.
With best regards,
Wojtek
#!/bin/sh
# This is a shell archive (produced by GNU sharutils 4.15.2).
# To extract the files from this archive, save it to some FILE, remove
# everything before the '#!/bin/sh' line above, then type 'sh FILE'.
#
lock_dir=_sh05928
# Made on 2016-09-22 20:57 CEST by <wzab@wzab>.
# Source directory was '/home/wzab/biezace/VHDL/rec_to_pkg_new/publ'.
#
# Existing files will *not* be overwritten, unless '-c' is specified.
#
# This shar contains:
# length mode name
# ------ ---------- ------------------------------------------
# 9247 -rwxr-xr-x rec_to_pkg_nest.py
# 171 -rwxr--r-- run_test.sh
# 591 -rw-r--r-- test.rec
# 8619 -rw-r--r-- test.sav
# 2796 -rw-r--r-- test_tb.vhd
# 1837 -rw-r--r-- test.vhd
# This is the version 1.1
#
import sys
rec_types=[]
arrays=[]
Additionally, the description file may contain the line
defining the array of records:
array array_type_name record_type_name
X
This generates functions converting such arrays to and from stlv
It is assumed, that the array is indexed from 0 to (nitems-1)
The nitems must be delivered as the second argument to the conversion
functions. See the included example for details.
X #We accept the line defining the arrays of records
X if l[0] == "array":
X arrays.append((l[1],l[2]))
X continue
X if l[0] != "record":
X raise Exception("Line: "+td+"\nSyntax error! The first line in the section should have form \"record name_of_type\"")
X type_name=l[1]
X cur_rec=record(type_name)
X rec_dict[type_name]=cur_rec
X rec_types.append(cur_rec)
X #Prepare for analysis of fields
X end_found = False
X #Find the field definitions
X while len(type_desc)>0:
X l=type_desc.pop(0)
X print l
X if l=="end":
X end_found=True
X break
X cur_rec.fields.append(field(cur_rec,l))
X if not end_found:
X raise Exception("Syntax error: no \"end\" found")
#If we got here, probably the syntax was correct
#Lets generate the package
p="""\
-------------------------------------------------------------------------------
-- This file has been automatically generated by the rec_to_pkg_nest.py tool
-- from the """+sys.argv[1]+""" record description file.
-- Don't edit it manually. To introduce any changes, edit the """+sys.argv[1]+""" file
-- and rerun the rec_to_pkg_nest.py
-------------------------------------------------------------------------------
"""
for l in comments:
X p+="--"+l+"\n"
p+="""\
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
"""
p+="package "+pkg_name+" is\n\n"
# Now write definitions of record types
for r in rec_types:
X p+="------------------------------------------------------\n"
X p+="-- type "+
r.name+" declarations\n"
X p+="------------------------------------------------------\n"
X p+="type "+
r.name+" is record\n"
X for f in r.fields:
X if f.ftype=="rec":
X s=" "+f.fname+" : "+f.rec_name+";\n"
X elif f.ftype=="std_logic":
X s=" "+f.fname+" : "+f.ftype+";\n"
X else:
X s=" "+f.fname+" : "+f.ftype+"("
X if f.b1 > f.b2:
X s=s+str(f.b1)+" downto "+str(f.b2)+");\n"
X else:
X s=s+str(f.b1)+" to "+str(f.b2)+");\n"
X p+=s
X p+="end record;\n\n"
X #Write width of our type
X p+="constant "+
r.name+"_width : integer := "+str(r.nof_bits)+";\n\n"
X #Write headers of conversion functions
X p+="function "+
r.name+"_to_stlv(\n"
X p+=" constant din : "+
r.name+")\n"
X p+=" return std_logic_vector;\n\n"
X p+="function stlv_to_"+
r.name+"(\n"
X p+=" constant din : std_logic_vector)\n"
X p+=" return "+
r.name+";\n\n"
# Now we write definitions of array types
for a in arrays:
X p+="------------------------------------------------------\n"
X p+="-- array type "+a[0]+" declarations\n"
X p+="------------------------------------------------------\n"
X # Array type definition
X p+="type "+a[0]+" is array(natural range <>) of "+a[1]+";\n\n"
X # array to stlv conversion
X p+="function "+a[0]+"_to_stlv(\n"
X p+=" constant din : "+a[0]+";\n"
X p+=" constant nitems : integer)\n"
X p+=" return std_logic_vector;\n\n"
X p+="function stlv_to_"+a[0]+"(\n"
X p+=" constant din : std_logic_vector;\n"
X p+=" constant nitems : integer)\n"
X p+=" return "+a[0]+";\n\n"
p+="end "+pkg_name+";\n\n"
#Now the body of the package - the conversion functions
p+="package body "+pkg_name+" is\n\n"
# Iterate over the records
for r in rec_types:
X p+="------------------------------------------------------\n"
X p+="-- type "+
r.name+" conversion implementations\n"
X p+="------------------------------------------------------\n"
# Iterate over the array types
for a in arrays:
X p+="------------------------------------------------------\n"
X p+="-- array type "+a[0]+" conversion implementations\n"
X p+="------------------------------------------------------\n"
X # array to stlv conversion
X p+="function "+a[0]+"_to_stlv(\n"
X p+=" constant din : "+a[0]+";\n"
X p+=" constant nitems : integer)\n"
X p+=" return std_logic_vector is\n"
X p+=" variable res : std_logic_vector("+a[1]+"_width * nitems - 1 downto 0);\n"
X p+="begin\n"
X p+=" for i in 0 to nitems-1 loop\n"
X p+=" res((i+1)*"+a[1]+"_width-1 downto i*"+a[1]+"_width) := "+a[1]+"_to_stlv(din(i));\n"
X p+=" end loop;\n"
X p+=" return res;\n"
X p+="end function "+a[0]+"_to_stlv;\n\n"
X
X p+="function stlv_to_"+a[0]+"(\n"
X p+=" constant din : std_logic_vector;\n"
X p+=" constant nitems : integer)\n"
X p+=" return "+a[0]+" is\n"
X p+=" variable res : "+a[0]+"(0 to nitems-1)\n;"
X p+="begin\n"
X p+=" for i in 0 to nitems-1 loop\n"
X p+=" res(i) := stlv_to_"+a[1]+"(din((i+1)*"+a[1]+"_width-1 downto i*"+a[1]+"_width));\n"
X p+=" end loop;\n"
X p+=" return res;\n"
X p+="end function stlv_to_"+a[0]+";\n\n"
p+="end "+pkg_name+";\n"
X
#The output file name
fout_name=pkg_name+".vhd"
fout=open(fout_name,"w")
fout.write(p)
fout.close()
X
SHAR_EOF
(set 20 16 09 22 20 56 54 'rec_to_pkg_nest.py'
eval "${shar_touch}") && \
chmod 0755 'rec_to_pkg_nest.py'
if test $? -ne 0
then ${echo} "restore of rec_to_pkg_nest.py failed"
fi
if ${md5check}
then (
${MD5SUM} -c >/dev/null 2>&1 || ${echo} 'rec_to_pkg_nest.py': 'MD5 check failed'
) << \SHAR_EOF
e92394794e23e536521b0b47d8ddc13c rec_to_pkg_nest.py
SHAR_EOF
else
test `LC_ALL=C wc -c < 'rec_to_pkg_nest.py'` -ne 9247 && \
${echo} "restoration warning: size of 'rec_to_pkg_nest.py' is not 9247"
X
array test_rec_array test_rec
X
SHAR_EOF
(set 20 16 09 22 19 39 49 'test.rec'
eval "${shar_touch}") && \
chmod 0644 'test.rec'
if test $? -ne 0
then ${echo} "restore of test.rec failed"
fi
if ${md5check}
then (
${MD5SUM} -c >/dev/null 2>&1 || ${echo} 'test.rec': 'MD5 check failed'
) << \SHAR_EOF
16323d821a36bff2b006c2c4a0e8ec45 test.rec
SHAR_EOF
else
test `LC_ALL=C wc -c < 'test.rec'` -ne 591 && \
${echo} "restoration warning: size of 'test.rec' is not 591"
fi
fi
# ============= test.sav ==============
if test -n "${keep_file}" && test -f 'test.sav'
then
${echo} "x - SKIPPING test.sav (file already exists)"
else
${echo} "x - extracting test.sav (text)"
sed 's/^X//' << 'SHAR_EOF' > 'test.sav' &&
[*]
[*] GTKWave Analyzer v3.3.66 (w)1999-2015 BSI
[*] Thu Sep 22 18:46:39 2016
[*]
[dumpfile] "/home/wzab/biezace/VHDL/rec_to_pkg_new/publ/test.ghw"
[dumpfile_mtime] "Thu Sep 22 18:45:09 2016"
[dumpfile_size] 1656
[savefile] "/home/wzab/biezace/VHDL/rec_to_pkg_new/publ/test.sav"
[timestart] 0
[size] 1280 970
[pos] 0 0
*-23.924660 20000000 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
[treeopen] top.
[treeopen] top.test_tb.
[treeopen] top.test_tb.din.
[treeopen] top.test_tb.din.[0].
[treeopen] top.test_tb.din.[0].srec1.
[treeopen] top.test_tb.din.[0].srec2.
[treeopen] top.test_tb.din.[1].
[treeopen] top.test_tb.din.[1].srec1.
[treeopen] top.test_tb.din.[1].srec2.
[treeopen] top.test_tb.din.[2].
[treeopen] top.test_tb.din.[2].srec1.
[treeopen] top.test_tb.din.[2].srec2.
[treeopen] top.test_tb.dout.
[treeopen] top.test_tb.dout.[0].
[treeopen] top.test_tb.dout.[0].srec1.
[treeopen] top.test_tb.dout.[0].srec2.
[treeopen] top.test_tb.dout.[1].
[treeopen] top.test_tb.dout.[1].srec1.
[treeopen] top.test_tb.dout.[1].srec2.
[treeopen] top.test_tb.dout.[2].
[treeopen] top.test_tb.dout.[2].srec1.
[treeopen] top.test_tb.dout.[2].srec2.
[sst_width] 210
[signals_width] 142
[sst_expanded] 1
[sst_vpaned_height] 284
@200
-din0
@28
top.test_tb.din[0].srec1.stb
@22
#{top.test_tb.din[0].srec1.p1[3:0]} top.test_tb.din[0].srec1.p1[3] top.test_tb.din[0].srec1.p1[2] top.test_tb.din[0].srec1.p1[1] top.test_tb.din[0].srec1.p1[0]
#{top.test_tb.din[0].flags[5:1]} top.test_tb.din[0].flags[5] top.test_tb.din[0].flags[4] top.test_tb.din[0].flags[3] top.test_tb.din[0].flags[2] top.test_tb.din[0].flags[1]
@28
top.test_tb.din[0].srec2.f1
#{top.test_tb.din[0].srec2.f3[2:0]} top.test_tb.din[0].srec2.f3[2] top.test_tb.din[0].srec2.f3[1] top.test_tb.din[0].srec2.f3[0]
@22
#{top.test_tb.din[0].srec2.f2[1:4]} top.test_tb.din[0].srec2.f2[1] top.test_tb.din[0].srec2.f2[2] top.test_tb.din[0].srec2.f2[3] top.test_tb.din[0].srec2.f2[4]
#{top.test_tb.din[0].nmbr[5:0]} top.test_tb.din[0].nmbr[5] top.test_tb.din[0].nmbr[4] top.test_tb.din[0].nmbr[3] top.test_tb.din[0].nmbr[2] top.test_tb.din[0].nmbr[1] top.test_tb.din[0].nmbr[0]
@200
-dout0
@28
top.test_tb.dout[0].srec1.stb
@22
#{top.test_tb.dout[0].srec1.p1[3:0]} top.test_tb.dout[0].srec1.p1[3] top.test_tb.dout[0].srec1.p1[2] top.test_tb.dout[0].srec1.p1[1] top.test_tb.dout[0].srec1.p1[0]
#{top.test_tb.dout[0].flags[5:1]} top.test_tb.dout[0].flags[5] top.test_tb.dout[0].flags[4] top.test_tb.dout[0].flags[3] top.test_tb.dout[0].flags[2] top.test_tb.dout[0].flags[1]
@28
top.test_tb.dout[0].srec2.f1
#{top.test_tb.dout[0].srec2.f3[2:0]} top.test_tb.dout[0].srec2.f3[2] top.test_tb.dout[0].srec2.f3[1] top.test_tb.dout[0].srec2.f3[0]
@22
#{top.test_tb.dout[0].srec2.f2[1:4]} top.test_tb.dout[0].srec2.f2[1] top.test_tb.dout[0].srec2.f2[2] top.test_tb.dout[0].srec2.f2[3] top.test_tb.dout[0].srec2.f2[4]
#{top.test_tb.dout[0].nmbr[5:0]} top.test_tb.dout[0].nmbr[5] top.test_tb.dout[0].nmbr[4] top.test_tb.dout[0].nmbr[3] top.test_tb.dout[0].nmbr[2] top.test_tb.dout[0].nmbr[1] top.test_tb.dout[0].nmbr[0]
@200
-din1
@28
top.test_tb.din[1].srec1.stb
@22
#{top.test_tb.din[1].srec1.p1[3:0]} top.test_tb.din[1].srec1.p1[3] top.test_tb.din[1].srec1.p1[2] top.test_tb.din[1].srec1.p1[1] top.test_tb.din[1].srec1.p1[0]
#{top.test_tb.din[1].flags[5:1]} top.test_tb.din[1].flags[5] top.test_tb.din[1].flags[4] top.test_tb.din[1].flags[3] top.test_tb.din[1].flags[2] top.test_tb.din[1].flags[1]
@28
top.test_tb.din[1].srec2.f1
#{top.test_tb.din[1].srec2.f3[2:0]} top.test_tb.din[1].srec2.f3[2] top.test_tb.din[1].srec2.f3[1] top.test_tb.din[1].srec2.f3[0]
@22
#{top.test_tb.din[1].srec2.f2[1:4]} top.test_tb.din[1].srec2.f2[1] top.test_tb.din[1].srec2.f2[2] top.test_tb.din[1].srec2.f2[3] top.test_tb.din[1].srec2.f2[4]
@23
#{top.test_tb.din[1].nmbr[5:0]} top.test_tb.din[1].nmbr[5] top.test_tb.din[1].nmbr[4] top.test_tb.din[1].nmbr[3] top.test_tb.din[1].nmbr[2] top.test_tb.din[1].nmbr[1] top.test_tb.din[1].nmbr[0]
@200
-dout1
@28
top.test_tb.dout[1].srec1.stb
@22
#{top.test_tb.dout[1].srec1.p1[3:0]} top.test_tb.dout[1].srec1.p1[3] top.test_tb.dout[1].srec1.p1[2] top.test_tb.dout[1].srec1.p1[1] top.test_tb.dout[1].srec1.p1[0]
#{top.test_tb.dout[1].flags[5:1]} top.test_tb.dout[1].flags[5] top.test_tb.dout[1].flags[4] top.test_tb.dout[1].flags[3] top.test_tb.dout[1].flags[2] top.test_tb.dout[1].flags[1]
@28
top.test_tb.dout[1].srec2.f1
#{top.test_tb.dout[1].srec2.f3[2:0]} top.test_tb.dout[1].srec2.f3[2] top.test_tb.dout[1].srec2.f3[1] top.test_tb.dout[1].srec2.f3[0]
@22
#{top.test_tb.dout[1].srec2.f2[1:4]} top.test_tb.dout[1].srec2.f2[1] top.test_tb.dout[1].srec2.f2[2] top.test_tb.dout[1].srec2.f2[3] top.test_tb.dout[1].srec2.f2[4]
#{top.test_tb.dout[1].nmbr[5:0]} top.test_tb.dout[1].nmbr[5] top.test_tb.dout[1].nmbr[4] top.test_tb.dout[1].nmbr[3] top.test_tb.dout[1].nmbr[2] top.test_tb.dout[1].nmbr[1] top.test_tb.dout[1].nmbr[0]
@200
-din2
@28
top.test_tb.din[2].srec1.stb
@22
#{top.test_tb.din[2].srec1.p1[3:0]} top.test_tb.din[2].srec1.p1[3] top.test_tb.din[2].srec1.p1[2] top.test_tb.din[2].srec1.p1[1] top.test_tb.din[2].srec1.p1[0]
#{top.test_tb.din[2].flags[5:1]} top.test_tb.din[2].flags[5] top.test_tb.din[2].flags[4] top.test_tb.din[2].flags[3] top.test_tb.din[2].flags[2] top.test_tb.din[2].flags[1]
@28
top.test_tb.din[2].srec2.f1
#{top.test_tb.din[2].srec2.f3[2:0]} top.test_tb.din[2].srec2.f3[2] top.test_tb.din[2].srec2.f3[1] top.test_tb.din[2].srec2.f3[0]
@22
#{top.test_tb.din[2].srec2.f2[1:4]} top.test_tb.din[2].srec2.f2[1] top.test_tb.din[2].srec2.f2[2] top.test_tb.din[2].srec2.f2[3] top.test_tb.din[2].srec2.f2[4]
#{top.test_tb.din[2].nmbr[5:0]} top.test_tb.din[2].nmbr[5] top.test_tb.din[2].nmbr[4] top.test_tb.din[2].nmbr[3] top.test_tb.din[2].nmbr[2] top.test_tb.din[2].nmbr[1] top.test_tb.din[2].nmbr[0]
@200
-dout2
@28
top.test_tb.dout[2].srec1.stb
@22
#{top.test_tb.dout[2].srec1.p1[3:0]} top.test_tb.dout[2].srec1.p1[3] top.test_tb.dout[2].srec1.p1[2] top.test_tb.dout[2].srec1.p1[1] top.test_tb.dout[2].srec1.p1[0]
#{top.test_tb.dout[2].flags[5:1]} top.test_tb.dout[2].flags[5] top.test_tb.dout[2].flags[4] top.test_tb.dout[2].flags[3] top.test_tb.dout[2].flags[2] top.test_tb.dout[2].flags[1]
@28
top.test_tb.dout[2].srec2.f1
#{top.test_tb.dout[2].srec2.f3[2:0]} top.test_tb.dout[2].srec2.f3[2] top.test_tb.dout[2].srec2.f3[1] top.test_tb.dout[2].srec2.f3[0]
@22
#{top.test_tb.dout[2].srec2.f2[1:4]} top.test_tb.dout[2].srec2.f2[1] top.test_tb.dout[2].srec2.f2[2] top.test_tb.dout[2].srec2.f2[3] top.test_tb.dout[2].srec2.f2[4]
#{top.test_tb.dout[2].nmbr[5:0]} top.test_tb.dout[2].nmbr[5] top.test_tb.dout[2].nmbr[4] top.test_tb.dout[2].nmbr[3] top.test_tb.dout[2].nmbr[2] top.test_tb.dout[2].nmbr[1] top.test_tb.dout[2].nmbr[0]
@200
-test_vec
@22
#{top.test_tb.test_vec[71:0]} top.test_tb.test_vec[71] top.test_tb.test_vec[70] top.test_tb.test_vec[69] top.test_tb.test_vec[68] top.test_tb.test_vec[67] top.test_tb.test_vec[66] top.test_tb.test_vec[65] top.test_tb.test_vec[64] top.test_tb.test_vec[63] top.test_tb.test_vec[62] top.test_tb.test_vec[61] top.test_tb.test_vec[60] top.test_tb.test_vec[59] top.test_tb.test_vec[58] top.test_tb.test_vec[57] top.test_tb.test_vec[56] top.test_tb.test_vec[55] top.test_tb.test_vec[54] top.test_tb.test_vec[53] top.test_tb.test_vec[52] top.test_tb.test_vec[51] top.test_tb.test_vec[50] top.test_tb.test_vec[49] top.test_tb.test_vec[48] top.test_tb.test_vec[47] top.test_tb.test_vec[46] top.test_tb.test_vec[45] top.test_tb.test_vec[44] top.test_tb.test_vec[43] top.test_tb.test_vec[42] top.test_tb.test_vec[41] top.test_tb.test_vec[40] top.test_tb.test_vec[39] top.test_tb.test_vec[38] top.test_tb.test_vec[37] top.test_tb.test_vec[36] top.test_tb.test_vec[35] top.test_tb.test_vec[34] top.test_tb.test_vec[33] top.test_tb.test_vec[32] top.test_tb.test_vec[31] top.test_tb.test_vec[30] top.test_tb.test_vec[29] top.test_tb.test_vec[28] top.test_tb.test_vec[27] top.test_tb.test_vec[26] top.test_tb.test_vec[25] top.test_tb.test_vec[24] top.test_tb.test_vec[23] top.test_tb.test_vec[22] top.test_tb.test_vec[21] top.test_tb.test_vec[20] top.test_tb.test_vec[19] top.test_tb.test_vec[18] top.test_tb.test_vec[17] top.test_tb.test_vec[16] top.test_tb.test_vec[15] top.test_tb.test_vec[14] top.test_tb.test_vec[13] top.test_tb.test_vec[12] top.test_tb.test_vec[11] top.test_tb.test_vec[10] top.test_tb.test_vec[9] top.test_tb.test_vec[8] top.test_tb.test_vec[7] top.test_tb.test_vec[6] top.test_tb.test_vec[5] top.test_tb.test_vec[4] top.test_tb.test_vec[3] top.test_tb.test_vec[2] top.test_tb.test_vec[1] top.test_tb.test_vec[0]
[pattern_trace] 1
[pattern_trace] 0
SHAR_EOF
(set 20 16 09 22 20 46 39 'test.sav'
eval "${shar_touch}") && \
chmod 0644 'test.sav'
if test $? -ne 0
then ${echo} "restore of test.sav failed"
fi
if ${md5check}
then (
${MD5SUM} -c >/dev/null 2>&1 || ${echo} 'test.sav': 'MD5 check failed'
) << \SHAR_EOF
514ac59c3619a6be76a0c0e5681f55bf test.sav
SHAR_EOF
else
test `LC_ALL=C wc -c < 'test.sav'` -ne 8619 && \
${echo} "restoration warning: size of 'test.sav' is not 8619"
fi
fi
# ============= test_tb.vhd ==============
if test -n "${keep_file}" && test -f 'test_tb.vhd'
then
${echo} "x - SKIPPING test_tb.vhd (file already exists)"
else
${echo} "x - extracting test_tb.vhd (text)"
sed 's/^X//' << 'SHAR_EOF' > 'test_tb.vhd' &&
-------------------------------------------------------------------------------
-- Title : Testbench for records & record converters generator
-- Project :
-------------------------------------------------------------------------------
-- File : test_tb.vhd
-- Author : Wojciech Zabolotny
-- Company :
-- Created : 2016-09-21
-- Last update: 2016-09-22
X constant nx : integer := 3;
X -- signals
X signal din, dout : test_rec_array(0 to nx-1);
X signal test_vec : std_logic_vector(nx*test_rec_width-1 downto 0);
X
begin -- test1
X test_vec <= test_rec_array_to_stlv(din,nx);
X dout <= stlv_to_test_rec_array(test_vec,nx);
X -- waveform generation
X WaveGen_Proc : process
X begin
X din(0).nmbr <= to_unsigned(1,6);
X din(0).flags <= "11010";
X din(0).srec2.f1 <= '1';
X din(0).srec2.f2 <="1000";
X din(0).srec2.f3 <=to_unsigned(4,3);
X din(0).srec1.p1 <="0101";
X din(0).srec1.stb <= '1';
X
X din(1).nmbr <= to_unsigned(4,6);
X din(1).flags <= "00101";
X din(1).srec2.f1 <= '0';
X din(1).srec2.f2 <="1100";
X din(1).srec2.f3 <=to_unsigned(4,3);
X din(1).srec1.p1 <="1010";
X din(1).srec1.stb <= '0';
X
X din(2).nmbr <= to_unsigned(12,6);
X din(2).flags <= "11100";
X din(2).srec2.f1 <= '1';
X din(2).srec2.f2 <="1001";
X din(2).srec2.f3 <=to_unsigned(4,3);
X din(2).srec1.p1 <="0001";
X din(2).srec1.stb <= '1';
X wait for 10 ns;
X din(0).srec1.stb <= '0';
X din(1).flags <= "10101";
X din(2).srec1.stb <= '1';
X wait for 10 ns;
X din(2).srec2.f2 <= "0111";
X din(0).srec2.f3 <= to_unsigned(5,3);
X din(1).srec1.p1 <= "1100";
X wait for 10 ns;
X din(1).flags <= "00111";
X din(2).nmbr <= to_unsigned(2,6);
X din(1).nmbr <= to_unsigned(37,6);
X din(0).nmbr <= to_unsigned(43,6);
X wait for 10 ns;
X din(0).srec1.p1 <= "1100";
X wait for 10 ns;
X din(1).srec1.stb <= '1';
X wait;
X end process WaveGen_Proc;
X
X
end test1;
X
SHAR_EOF
(set 20 16 09 22 20 45 03 'test_tb.vhd'
eval "${shar_touch}") && \
chmod 0644 'test_tb.vhd'
if test $? -ne 0
then ${echo} "restore of test_tb.vhd failed"
fi
if ${md5check}
then (
${MD5SUM} -c >/dev/null 2>&1 || ${echo} 'test_tb.vhd': 'MD5 check failed'
) << \SHAR_EOF
07c7105b413c6ffcd5007fb8e71dd19b test_tb.vhd
SHAR_EOF
else
test `LC_ALL=C wc -c < 'test_tb.vhd'` -ne 2796 && \
${echo} "restoration warning: size of 'test_tb.vhd' is not 2796"
fi
fi
# ============= test.vhd ==============
if test -n "${keep_file}" && test -f 'test.vhd'
then
${echo} "x - SKIPPING test.vhd (file already exists)"
else
${echo} "x - extracting test.vhd (text)"
sed 's/^X//' << 'SHAR_EOF' > 'test.vhd' &&
--use work.test_pkg.all;
-------------------------------------------------------------------------------
X
entity test_tb is
X
end test_tb;
X
-------------------------------------------------------------------------------
X
architecture test1 of test_tb is
X
X type t_r is array(natural range <>) of integer;
X signal a1 : t_r(10 downto 2);
X signal a2 : t_r(3 to 15);
X signal p : integer;
X function vlen( constant v : t_r) return integer is
X variable res : integer;
X begin
X res := max(v'left-v'right+1, v'right-v'left+1);
X report "len=" & integer'image(res) severity note;
X return res;
X end function vlen;
X
begin -- test1
X -- waveform generation
X WaveGen_Proc : process
X begin
X wait for 10 ns;
X p<= vlen(a1);
X wait for 10 ns;
X p<= vlen(a2);
X wait for 10 ns;
X wait;
X end process WaveGen_Proc;
X
X
end test1;
X
SHAR_EOF
(set 20 16 09 22 20 02 07 'test.vhd'
eval "${shar_touch}") && \
chmod 0644 'test.vhd'
if test $? -ne 0
then ${echo} "restore of test.vhd failed"
fi
if ${md5check}
then (
${MD5SUM} -c >/dev/null 2>&1 || ${echo} 'test.vhd': 'MD5 check failed'
) << \SHAR_EOF
f9b791fb6738ff6d009fd224392d8c21 test.vhd
SHAR_EOF
else
test `LC_ALL=C wc -c < 'test.vhd'` -ne 1837 && \
${echo} "restoration warning: size of 'test.vhd' is not 1837"