Add DELAY command for ktest scripts

This adds a way to add a delay (advancing the virtual clock) in a simulator test
script without running Kaleidoscope cycles.

Signed-off-by: Michael Richters <gedankenexperimenter@gmail.com>
pull/1106/head
Michael Richters 3 years ago
parent d59604e98b
commit 381b05e10f
No known key found for this signature in database
GPG Key ID: 1288FD13E4EEF0C0

@ -164,6 +164,25 @@ sub load_from_text {
}
},
delay => sub {
my $content = shift;
if ( $content =~ /^(\d+)\s*(\w*?)$/ ) {
my $count = $1;
my $unit = $2;
if ( $unit =~ /milli|ms/ ) {
return { millis => $count };
}
else {
die
"Line $line_num: failed to parse a 'delay' clause: $content";
}
}
else {
die
"Line $line_num: failed to parse a 'delay' clause: $content";
}
},
};
@ -322,6 +341,7 @@ sub generate_script {
elsif ( $action eq 'press' ) { generate_press($entry) }
elsif ( $action eq 'release' ) { generate_release($entry); }
elsif ( $action eq 'run' ) { generate_run($entry) }
elsif ( $action eq 'delay' ) { generate_delay($entry) }
elsif ( $action eq 'expect' ) { generate_expect_report($entry); }
else {
die "$action unknown on line $entry->{line_num}";
@ -348,6 +368,16 @@ sub generate_run {
}
}
sub generate_delay {
my $action = shift;
if ( $action->{'comment'} ) {
cxx_comment( $action->{'comment'} );
}
if ( $action->{data}->{'millis'} ) {
cxx( 'delay(' . $action->{data}->{'millis'} . ');' );
}
}
sub generate_press {
my $e = shift;

Loading…
Cancel
Save