Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
vecs
FIJI Public
Commits
50281717
Commit
50281717
authored
Jun 24, 2015
by
Christian Fibich
Committed by
Stefan Tauner
Aug 29, 2016
Browse files
File path handling fixed
parent
736bae76
Changes
4
Hide whitespace changes
Inline
Side-by-side
FIJI/Tests.pm
View file @
50281717
...
...
@@ -16,6 +16,7 @@ use Data::Dumper;
use
Clone
qw(clone)
;
use
FIJI::
Settings
;
use
FIJI
qw(:all)
;
use
File::
Spec
;
## @function new ($phase, $fiji_ini_file, $existing_settings)
# Create a new settings instance.
...
...
@@ -51,7 +52,8 @@ sub new ($;$$) {
# If there is a file given, try to read it. Else just create a default instance.
if
(
defined
(
$fiji_ini_file
))
{
$fiji_settings_ref
=
read_settingsfile
(
$phase
,
$fiji_ini_file
,
$fiji_settings_ref
);
$fiji_settings_ref
=
read_settingsfile
(
$phase
,
$fiji_ini_file
,
$fiji_settings_ref
);
if
(
!
ref
(
$fiji_settings_ref
))
{
return
$fiji_settings_ref
;
# actually an error message
}
...
...
@@ -208,6 +210,8 @@ sub read_settingsfile ($$$) {
my
$logger
=
get_logger
();
my
(
$phase
,
$fiji_ini_file
,
$existing_settings
)
=
@_
;
my
$fiji_ini
;
my
$global_settings_filename
;
eval
{
$fiji_ini
=
new
Config::
Simple
(
$fiji_ini_file
)
};
# pesky library tries to die on syntax errors
if
(
!
defined
(
$fiji_ini
))
{
my
$submsg
=
defined
(
$@
)
?
$@
:
Config::
Simple
->
error
();
...
...
@@ -260,7 +264,14 @@ sub read_settingsfile ($$$) {
return
$msg
;
}
$fiji_settings_ref
->
{'
ext
'}
->
{'
global_settings
'}
=
_read_fiji_cfg
(
$design_ref
->
{'
FIJI_CFG
'});
if
(
!
File::
Spec
->
file_name_is_absolute
(
$design_ref
->
{'
FIJI_CFG
'}))
{
my
(
$volume
,
$directories
,
$file
)
=
File::
Spec
->
splitpath
(
$fiji_ini_file
);
$global_settings_filename
=
File::
Spec
->
catpath
(
$volume
,
$directories
,
$design_ref
->
{'
FIJI_CFG
'});
}
else
{
$global_settings_filename
=
$design_ref
->
{'
FIJI_CFG
'};
}
$fiji_settings_ref
->
{'
ext
'}
->
{'
global_settings
'}
=
_read_fiji_cfg
(
$global_settings_filename
);
$fiji_settings_ref
->
{'
ext
'}
->
{'
TESTPATMAP
'}
=
_generate_testpatmap
(
$fiji_settings_ref
);
$fiji_settings_ref
->
{'
design
'}
=
$design_ref
;
$fiji_settings_ref
->
{'
tests
'}
=
[]
;
...
...
@@ -675,4 +686,91 @@ sub _sanitize_design {
return
$consts_ref
;
}
sub
export_as_sim_script
($$$)
{
my
$logger
=
get_logger
();
my
(
$self
,
$sim_file_name
,
$last_test
,
$num_repetitions
)
=
@_
;
my
$script_text
=
"
# Sim script generated
"
.
localtime
.
"
\n
source random_force.tcl
\n
";
my
$msg
;
my
$global_settings_ref
=
$self
->
{'
ext
'}
->
{'
global_settings
'};
my
$time
=
0
;
my
$indent
=
"
";
open
(
my
$sfd
,"
>
",
$sim_file_name
);
if
(
!
defined
$sfd
)
{
$msg
=
"
Could not open file
$sim_file_name
for writing: $!
";
return
$msg
;
}
if
(
$global_settings_ref
->
{'
design
'}
->
{'
RESET_DUT_OUT_EN
'}
==
1
)
{
$script_text
.=
"
Wait until
";
$script_text
.=
$global_settings_ref
->
{'
design
'}
->
{'
RESET_DUT_OUT_NAME
'};
$script_text
.=
"
is not '
";
$script_text
.=
$global_settings_ref
->
{'
design
'}
->
{'
RESET_DUT_IN_ACTIVE
'};
$script_text
.=
"
'
\n
";
}
for
(
my
$ri
=
0
;
$ri
<=
$num_repetitions
;
$ri
++
)
{
$script_text
.=
"
#
\n
# Repetition
$ri
\n
#
\n
";
my
$start
=
(
$ri
==
0
)
?
0
:
$self
->
{'
design
'}
->
{'
REPEAT_OFFSET
'};
my
$end
=
(
$ri
==
$num_repetitions
)
?
$last_test
:
(
$self
->
{'
design
'}
->
{'
NUM_TESTS
'}
-
1
);
for
(
my
$ti
=
$start
;
$ti
<=
$end
;
$ti
++
)
{
$script_text
.=
"
#
\n
# Test
$ti
\n
#
\n
";
my
$ie
;
my
$act
;
my
$test
=
@
{
$self
->
{'
tests
'}
}[
$ti
];
if
(
$test
->
{'
RESET_DUT_AFTER_CONFIG
'})
{
$script_text
.=
"
Force
"
.
$global_settings_ref
->
{'
design
'}
->
{'
RESET_DUT_IN_NAME
'};
$script_text
.=
"
to
";
$script_text
.=
"
'
"
.
$global_settings_ref
->
{'
design
'}
->
{'
RESET_DUT_IN_ACTIVE
'}
.
"
'
\n
";
}
if
(
$test
->
{'
TRIGGER
'}
ne
"
NONE
")
{
if
(
$test
->
{'
TRIGGER
'}
eq
"
INT
")
{
$ie
=
"
int
";
$act
=
$global_settings_ref
->
{'
design
'}
->
{'
TRIGGER_DUT_ACTIVE
'};
}
else
{
$ie
=
"
ext
";
$act
=
$global_settings_ref
->
{'
design
'}
->
{'
TRIGGER_EXT_ACTIVE
'};
}
$script_text
.=
"
Force
${ie}
ernal trigger to
$act
\n
";
}
for
(
my
$ci
=
1
;
$ci
<=
$global_settings_ref
->
{'
design
'}
->
{'
CFGS_PER_MSG
'};
$ci
++
)
{
$script_text
.=
"
#
\n
# Pattern
$ci
\n
#
\n
";
$time
+=
(
$test
->
{"
TIMER_VALUE_
$ci
"}
/
$global_settings_ref
->
{'
design
'}
->
{'
FREQUENCY
'})
*
(
10
**
12
);
my
$action_text
=
"";
for
(
my
$fi
=
0
;
$fi
<
$global_settings_ref
->
{'
design
'}
->
{'
FIU_NUM
'};
$fi
++
)
{
# export patterns to simulator commands
$action_text
.=
$indent
;
my
$pattern
=
$test
->
{"
FIU_
${fi}
_PATTERN_
${ci}
"};
if
(
$pattern
eq
"
STUCK_AT_0
")
{
$action_text
.=
"
force -freeze
"
.
@
{
$global_settings_ref
->
{'
fius
'}}[
$fi
]
->
{'
FIU_NET_NAME
'}
.
"
'0';
\\\n
";
}
elsif
(
$pattern
eq
"
STUCK_AT_1
")
{
$action_text
.=
"
force -freeze
"
.
@
{
$global_settings_ref
->
{'
fius
'}}[
$fi
]
->
{'
FIU_NET_NAME
'}
.
"
'1';
\\\n
";
}
elsif
(
$pattern
eq
"
STUCK_OPEN
")
{
#FIXME think of something better than setting to 'U'
$action_text
.=
"
force
"
.
@
{
$global_settings_ref
->
{'
fius
'}}[
$fi
]
->
{'
FIU_NET_NAME
'}
.
"
'U'
\\\n
";
}
elsif
(
$pattern
eq
"
SEU
")
{
$action_text
.=
"
force -freeze
"
.
@
{
$global_settings_ref
->
{'
fius
'}}[
$fi
]
->
{'
FIU_NET_NAME
'}
.
"
\\\n
";
$action_text
.=
"
${indent}${indent}
[modval_bool
"
.
@
{
$global_settings_ref
->
{'
fius
'}}[
$fi
]
->
{'
FIU_NET_NAME
'}
.
"
]
";
$action_text
.=
"
-cancel
"
.
((
10
**
12
)
/
(
$global_settings_ref
->
{'
design
'}
->
{'
FREQUENCY
'}))
.
"
ps;
\\\n
";
}
elsif
(
$pattern
eq
"
DELAY
")
{
#FIXME think of something better than setting to 'X'
$action_text
.=
"
force
"
.
@
{
$global_settings_ref
->
{'
fius
'}}[
$fi
]
->
{'
FIU_NET_NAME
'}
.
"
'X';
\\\n
";
}
else
{
$action_text
.=
"
noforce
"
.
@
{
$global_settings_ref
->
{'
fius
'}}[
$fi
]
->
{'
FIU_NET_NAME
'}
.
"
;
\\\n
";
}
}
$script_text
.=
"
when -fast {
\$
now ==
\@
$time
ps} {
\\\n
"
.
$action_text
.
"
};
\n
"
if
$action_text
ne
"";
}
}
}
print
$sfd
$script_text
;
close
(
$sfd
);
return
$msg
;
}
1
;
fiji_download.pl
View file @
50281717
...
...
@@ -211,8 +211,10 @@ sub _auto {
if
(
$halt
==
1
)
{
$msg
=
"
Halt because of HALT_ON_xxx. Failed test:
$ti
, repetition
$ri
.
";
#FIXME remove the following line
#FIXME remove the following line
(aplay)
system
("
/usr/bin/aplay lib/error.wav
");
my
$rv
=
$fiji_tests
->
export_as_sim_script
("
sim.script
",
$ti
,
$ri
);
$logger
->
error
(
$rv
)
if
defined
(
$rv
);
return
$msg
;
}
}
...
...
fiji_instrument.pl
View file @
50281717
...
...
@@ -12,6 +12,8 @@ use FIJI::Settings;
use
FIJI::
Netlist
;
use
Data::
Dumper
;
use
FIJI::
VHDL
;
use
File::
Spec
;
use
File::
Path
;
use
Getopt::
Long
;
...
...
@@ -24,7 +26,24 @@ sub main {
my
%hash
;
my
$self
=
bless
(
\
%hash
);
####
if
(
!
(
-
d
$options
->
{'
output_dir
'}))
{
make_path
(
$options
->
{'
output_dir
'},{
error
=>
\
my
$err
});
if
(
@$err
)
{
my
$msg
=
"
Could not create output directory: $!
";
return
$msg
;
}
}
my
$export_nl_filename
=
File::
Spec
->
catfile
(
$options
->
{'
output_dir
'}
,
$options
->
{'
file_prefix
'}
.
"
_instrumented.vqm
");
my
$export_cfg_filename
=
File::
Spec
->
catfile
(
$options
->
{'
output_dir
'}
,
$options
->
{'
file_prefix
'}
.
"
_download.cfg
");
my
$export_wrapper_filename
=
File::
Spec
->
catfile
(
$options
->
{'
output_dir
'}
,
$options
->
{'
file_prefix
'}
.
"
_wrapper.vhd
");
my
$export_pkg_filename
=
File::
Spec
->
catfile
(
$options
->
{'
output_dir
'}
,
$options
->
{'
file_prefix
'}
.
"
_config_pkg.vhd
");
my
$settings_ref
=
FIJI::
Settings
->
new
("
setup
",
$options
->
{'
fiji_settings_file
'});
my
$netlist_filename
=
$options
->
{'
netlist_file
'};
...
...
@@ -34,11 +53,14 @@ sub main {
}
$self
->
{'
settings
'}
=
$settings_ref
;
my
$nl
=
new
FIJI::
Netlist
();
if
(
$nl
->
read_file
(
$netlist_filename
)
!=
0
)
{
my
$msg
=
"
Netlist could not be loaded correctly from
\"
$netlist_filename
\"
.
";
$logger
->
error
(
$msg
);
return
1
;
}
#
...
...
@@ -219,16 +241,16 @@ sub main {
$logger
->
info
(
sprintf
("
Design ID chosen to be 0x%04X.
",
$id
));
#
# Generate download cfg file
# FIXME should we overwrite the original file?
# FIXME should we overwrite the original file
instead
?
#
$settings_ref
->
{'
design
'}
->
{'
ID
'}
=
$id
;
$settings_ref
->
save
(
$
options
->
{'
file_prefix
'}
.
"
_download.cfg
"
);
$settings_ref
->
save
(
$
export_cfg_filename
);
#
# output netlist
#
$rv
=
$nl
->
export
(
$
options
->
{'
file_prefix
'}
.
"
_instrumented.vqm
"
,
$id
);
$rv
=
$nl
->
export
(
$
export_nl_filename
,
$id
);
if
(
defined
$rv
)
{
$logger
->
error
(
$rv
);
...
...
@@ -241,8 +263,8 @@ sub main {
my
$wrapper_config
=
{};
$wrapper_config
->
{'
netlist
'}
=
$nl
->
{'
nl
'};
$wrapper_config
->
{'
dut_toplevel_module_name
'}
=
$options
->
{'
toplevel_module
'};
$wrapper_config
->
{'
fiji_settings_filename
'}
=
$options
->
{'
file_prefix
'}
.
"
_download.cfg
";
#$options->{'fiji_settings
_file
'}
;
$wrapper_config
->
{'
vhdl_filename
'}
=
$options
->
{'
file_prefix
'}
.
"
_wrapper.vhd
"
;
$wrapper_config
->
{'
fiji_settings_filename
'}
=
$export_cfg
_file
name
;
$wrapper_config
->
{'
vhdl_filename
'}
=
$export_wrapper_filename
;
$rv
=
FIJI::
VHDL
->
generate_wrapper_module
(
$wrapper_config
);
...
...
@@ -254,7 +276,7 @@ sub main {
#
# Generate cfg vhd
#
$rv
=
FIJI::
VHDL
->
generate_config_package
(
$
options
->
{'
file_prefix
'}
.
"
_download.cfg
",
$options
->
{'
file_prefix
'}
.
"
_config_pkg.vhd
"
);
$rv
=
FIJI::
VHDL
->
generate_config_package
(
$
export_cfg_filename
,
$export_pkg_filename
);
if
(
defined
$rv
)
{
$logger
->
error
(
$rv
);
...
...
@@ -301,6 +323,38 @@ sub splitnet ($$) {
}
sub
usage
{
my
(
$help
,
$err
)
=
@_
;
my
$msg
=
<<USAGE;
Usage: $0 [PARAMETERS]
Required parameters:
--fiji_settings_file=<filename> the cfg file with FIJI settings
--netlist_file=<filename> the netlist file to instrument
--toplevel_module=<modname> the name of the toplevel module in the netlist
Optional parameters:
--file_prefix=<prefix> prefix for all generated files
The toplevel module name is used if unused
--output_dir=<path> the directory where the generated files are put
the directory will be created if necessary
files are put in the current directory if unused
--help display this help and exit
USAGE
if
(
defined
$help
)
{
print
STDOUT
$msg
;
return
0
;
}
else
{
print
STDERR
$msg
;
return
-
1
;
}
}
Log::Log4perl::
init_and_watch
('
logger.conf
',
'
HUP
');
my
$logger
=
get_logger
();
my
$name
=
$
0
;
...
...
@@ -312,12 +366,16 @@ $logger->debug(sprintf("%d argument(s)%s", scalar(@ARGV), scalar(@ARGV) > 0 ? ":
my
$options
=
{
fiji_settings_file
=>
undef
,
netlist_file
=>
undef
,
toplevel_module
=>
undef
,
file_prefix
=>
undef
};
file_prefix
=>
undef
,
output_dir
=>
"
.
"};
my
$help
=
undef
;
GetOptions
("
fiji_settings_file=s
"
=>
\
$options
->
{'
fiji_settings_file
'},
"
netlist_file=s
"
=>
\
$options
->
{'
netlist_file
'},
"
toplevel_module=s
"
=>
\
$options
->
{'
toplevel_module
'},
"
file_prefix=s
"
=>
\
$options
->
{'
file_prefix
'});
"
file_prefix=s
"
=>
\
$options
->
{'
file_prefix
'},
"
output_dir=s
"
=>
\
$options
->
{'
output_dir
'},
"
help
"
=>
\
$help
);
for
my
$k
(
keys
(
%
{
$options
}))
{
if
(
!
defined
$options
->
{
$k
})
{
...
...
@@ -330,6 +388,13 @@ for my $k (keys (%{$options})) {
}
}
exit
(
-
1
)
if
$break
;
exit
(
usage
(
$help
,
$break
))
if
(
defined
$help
||
defined
$break
);
# clean up the passed paths
# FIXME needed ?
$options
->
{'
fiji_settings_file
'}
=
File::
Spec
->
canonpath
(
$options
->
{'
fiji_settings_file
'});
$options
->
{'
netlist_file
'}
=
File::
Spec
->
canonpath
(
$options
->
{'
netlist_file
'});
$options
->
{'
output_dir
'}
=
File::
Spec
->
canonpath
(
$options
->
{'
output_dir
'});
exit
main
(
$options
);
fiji_setup.pl
View file @
50281717
...
...
@@ -8,6 +8,7 @@ use Tk;
use
Tk::
widgets
qw(LabFrame Label Entry Button Dialog FBox Checkbutton)
;
use
Tk::
PNG
;
use
Clone
qw(clone)
;
use
File::
Spec
;
use
FIJI::
Settings
;
use
Tk::
FIJISettingsViewer
;
...
...
@@ -32,6 +33,10 @@ sub main {
my
%hash
;
my
$self
=
bless
(
\
%hash
);
my
$abspath
=
File::
Spec
->
rel2abs
(
__FILE__
);
my
(
$vol
,
$basedir
,
$file
)
=
File::
Spec
->
splitpath
(
$abspath
);
my
$libdir
=
File::
Spec
->
catdir
(
$basedir
,"
lib
");
# my %cfg;
# my $cfgname = $name . ".cfg";
# if (!Config::Simple->import_from($cfgname, \%cfg)) {
...
...
@@ -68,9 +73,9 @@ sub main {
my
$icon_base
;
if
(
$^O
eq
"
MSWin32
")
{
$icon_base
=
'
lib
/fiji_logo
';
$icon_base
=
File::
Spec
->
catpath
(
$vol
,
$libdir
,'
/fiji_logo
'
)
;
}
else
{
$icon_base
=
'
lib
/fiji_logo_hires
';
$icon_base
=
File::
Spec
->
catpath
(
$vol
,
$libdir
,'
/fiji_logo_hires
'
)
;
# The .xbm is needed for transparency, generate with e.g. GIMP
my
$iconmask_path
=
"
$icon_base
-mask.xbm
";
$mw
->
iconmask
("
\@
$iconmask_path
")
if
-
r
$iconmask_path
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment