1 |
107 |
pela |
#---------------------------------------------------------------------
|
2 |
|
|
#--- ----
|
3 |
|
|
#--- PlTbUtils Script for generating test files ----
|
4 |
|
|
#--- ----
|
5 |
|
|
#--- This file is part of the PlTbUtils project ----
|
6 |
|
|
#--- http://opencores.org/project,pltbutils ----
|
7 |
|
|
#--- ----
|
8 |
|
|
#--- Description: ----
|
9 |
|
|
#--- PlTbUtils is a collection of functions, procedures and ----
|
10 |
|
|
#--- components for easily creating stimuli and checking response ----
|
11 |
|
|
#--- in automatic self-checking testbenches. ----
|
12 |
|
|
#--- ----
|
13 |
|
|
#--- This file generates test files for verifying the file check ----
|
14 |
|
|
#--- procedures check_binfile, check_txtfile, check_datfile, etc. ----
|
15 |
|
|
#--- In tb_pltbutils.vhd, there are tests that let these ----
|
16 |
|
|
#--- procedures compare test files (the ones generated by this ----
|
17 |
|
|
#--- script). ----
|
18 |
|
|
#--- ----
|
19 |
|
|
#--- To Do: ----
|
20 |
|
|
#--- - ----
|
21 |
|
|
#--- ----
|
22 |
|
|
#--- Author(s): ----
|
23 |
|
|
#--- - Per Larsson, pela.opencores@gmail.com ----
|
24 |
|
|
#--- ----
|
25 |
|
|
#---------------------------------------------------------------------
|
26 |
|
|
#--- ----
|
27 |
|
|
#--- Copyright (C) 2020 Authors and OPENCORES.ORG ----
|
28 |
|
|
#--- ----
|
29 |
|
|
#--- This source file may be used and distributed without ----
|
30 |
|
|
#--- restriction provided that this copyright statement is not ----
|
31 |
|
|
#--- removed from the file and that any derivative work contains ----
|
32 |
|
|
#--- the original copyright notice and the associated disclaimer. ----
|
33 |
|
|
#--- ----
|
34 |
|
|
#--- This source file is free software; you can redistribute it ----
|
35 |
|
|
#--- and/or modify it under the terms of the GNU Lesser General ----
|
36 |
|
|
#--- Public License as published by the Free Software Foundation; ----
|
37 |
|
|
#--- either version 2.1 of the License, or (at your option) any ----
|
38 |
|
|
#--- later version. ----
|
39 |
|
|
#--- ----
|
40 |
|
|
#--- This source is distributed in the hope that it will be ----
|
41 |
|
|
#--- useful, but WITHOUT ANY WARRANTY; without even the implied ----
|
42 |
|
|
#--- warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR ----
|
43 |
|
|
#--- PURPOSE. See the GNU Lesser General Public License for more ----
|
44 |
|
|
#--- details. ----
|
45 |
|
|
#--- ----
|
46 |
|
|
#--- You should have received a copy of the GNU Lesser General ----
|
47 |
|
|
#--- Public License along with this source; if not, download it ----
|
48 |
|
|
#--- from http://www.opencores.org/lgpl.shtml ----
|
49 |
|
|
#--- ----
|
50 |
|
|
#---------------------------------------------------------------------
|
51 |
|
|
|
52 |
|
|
# File names of test files
|
53 |
|
|
set BINTESTFILE_REFERENCE "../bench/testfiles/bintestfile_reference.bin"
|
54 |
|
|
set BINTESTFILE_CORRECT "../bench/testfiles/bintestfile_correct.bin"
|
55 |
|
|
set BINTESTFILE_ERROR "../bench/testfiles/bintestfile_error.bin"
|
56 |
|
|
set BINTESTFILE_SHORTER "../bench/testfiles/bintestfile_shorter.bin"
|
57 |
|
|
set BINTESTFILE_LONGER "../bench/testfiles/bintestfile_longer.bin"
|
58 |
|
|
|
59 |
|
|
set BINTESTFILE_HEADER "Bintestfile R "
|
60 |
|
|
set BINTESTFILE_HEADER_ERR "Bintestfile E "
|
61 |
|
|
|
62 |
|
|
# Generate test files
|
63 |
|
|
set fp_bin_ref [open $BINTESTFILE_REFERENCE wb]
|
64 |
|
|
set fp_bin_corr [open $BINTESTFILE_CORRECT wb]
|
65 |
|
|
set fp_bin_err [open $BINTESTFILE_ERROR wb]
|
66 |
|
|
set fp_bin_long [open $BINTESTFILE_LONGER wb]
|
67 |
|
|
set fp_bin_short [open $BINTESTFILE_SHORTER wb]
|
68 |
|
|
puts -nonewline $fp_bin_ref $BINTESTFILE_HEADER
|
69 |
|
|
puts -nonewline $fp_bin_corr $BINTESTFILE_HEADER
|
70 |
|
|
puts -nonewline $fp_bin_err $BINTESTFILE_HEADER_ERR
|
71 |
|
|
puts -nonewline $fp_bin_long $BINTESTFILE_HEADER
|
72 |
|
|
puts -nonewline $fp_bin_short $BINTESTFILE_HEADER
|
73 |
|
|
for {set i 0} {$i < 2} {incr i} {
|
74 |
|
|
for {set j 0} {$j < 256} {incr j} {
|
75 |
|
|
puts -nonewline $fp_bin_ref [binary format c $j]
|
76 |
|
|
puts -nonewline $fp_bin_corr [binary format c $j]
|
77 |
|
|
puts -nonewline $fp_bin_err [binary format c $j]
|
78 |
|
|
puts -nonewline $fp_bin_long [binary format c $j]
|
79 |
|
|
if {!($i == 1 && $j == 255)} { ;# Skip last byte in the shorter file
|
80 |
|
|
puts -nonewline $fp_bin_short [binary format c $j]
|
81 |
|
|
}
|
82 |
|
|
}
|
83 |
|
|
}
|
84 |
|
|
puts -nonewline $fp_bin_long L ;# Add extra byte in the longer file
|
85 |
|
|
close $fp_bin_ref
|
86 |
|
|
close $fp_bin_corr
|
87 |
|
|
close $fp_bin_err
|
88 |
|
|
close $fp_bin_long
|
89 |
|
|
close $fp_bin_short
|
90 |
|
|
|