SCP: Added -T switch to the EXPECT, SEND and STEP commands to specify that the units of delay/stepping are in microseconds rather than instructions.

This commit is contained in:
Mark Pizzolato 2015-01-09 04:52:21 -08:00
parent e37d0658fa
commit 6f1e8377c9
2 changed files with 34 additions and 10 deletions

35
scp.c
View file

@ -778,6 +778,9 @@ static const char simh_help[] =
" The STEP command (abbreviated S) resumes execution at the current PC for\n" " The STEP command (abbreviated S) resumes execution at the current PC for\n"
" the number of instructions given by its argument. If no argument is\n" " the number of instructions given by its argument. If no argument is\n"
" supplied, one instruction is executed.\n" " supplied, one instruction is executed.\n"
"4Switches\n"
" If the STEP command is invoked with the -T switch, the step command will\n"
" cause execution to run for microseconds rather than instructions.\n"
#define HLP_NEXT "*Commands Running_A_Simulated_Program NEXT" #define HLP_NEXT "*Commands Running_A_Simulated_Program NEXT"
"3NEXT\n" "3NEXT\n"
" The NEXT command (abbreviated N) resumes execution at the current PC for\n" " The NEXT command (abbreviated N) resumes execution at the current PC for\n"
@ -1390,13 +1393,13 @@ ASSERT failure have several different actions:
"3Injecting Console Input\n" "3Injecting Console Input\n"
" The SEND command provides a way to insert input into the console device of\n" " The SEND command provides a way to insert input into the console device of\n"
" a simulated system as if it was entered by a user.\n\n" " a simulated system as if it was entered by a user.\n\n"
"++SEND {after=nn,}{delay=nn,}\"<string>\"\n\n" "++SEND {-t} {after=nn,}{delay=nn,}\"<string>\"\n\n"
" The string argument must be delimited by quote characters. Quotes may\n" " The string argument must be delimited by quote characters. Quotes may\n"
" be either single or double but the opening and closing quote characters\n" " be either single or double but the opening and closing quote characters\n"
" must match. Data in the string may contain escaped character strings.\n\n" " must match. Data in the string may contain escaped character strings.\n\n"
" The SEND command can also insert input into any serial device on a\n" " The SEND command can also insert input into any serial device on a\n"
" simulated system as if it was entered by a user.\n\n" " simulated system as if it was entered by a user.\n\n"
"++SEND <dev>:line {after=nn,}{delay=nn,}\"<string>\"\n\n" "++SEND {-t} <dev>:line {after=nn,}{delay=nn,}\"<string>\"\n\n"
"4Delay\n" "4Delay\n"
" Specifies a positive integer representing a minimal instruction delay\n" " Specifies a positive integer representing a minimal instruction delay\n"
" between characters being sent. The value specified in a delay\n" " between characters being sent. The value specified in a delay\n"
@ -1431,6 +1434,11 @@ ASSERT failure have several different actions:
"++\\n{n{n}} where each n is an octal digit (0-7)\n" "++\\n{n{n}} where each n is an octal digit (0-7)\n"
" and hext character values of the form:\n" " and hext character values of the form:\n"
"++\\xh{h} where each h is a hex digit (0-9A-Fa-f)\n" "++\\xh{h} where each h is a hex digit (0-9A-Fa-f)\n"
"4Switches\n"
" Switches can be used to influence the behavior of SEND commands\n\n"
"5-t\n"
" The -t switch indicates that the Delay and After values are in\n"
" units of microseconds rather than instructions.\n"
/***************** 80 character line width template *************************/ /***************** 80 character line width template *************************/
#define HLP_EXPECT "*Commands Executing_Command_Files Reacting_To_Console_Output" #define HLP_EXPECT "*Commands Executing_Command_Files Reacting_To_Console_Output"
/***************** 80 character line width template *************************/ /***************** 80 character line width template *************************/
@ -1486,6 +1494,9 @@ ASSERT failure have several different actions:
" If a regular expression expect rule is defined with the -i switch,\n" " If a regular expression expect rule is defined with the -i switch,\n"
" character matching for that expression will be case independent.\n" " character matching for that expression will be case independent.\n"
" The -i switch is only valid for regular expression expect rules.\n" " The -i switch is only valid for regular expression expect rules.\n"
"5-t\n"
" The -t switch indicates that the value specified by the HaltAfter\n"
" parameter are in units of microseconds rather than instructions.\n"
"4Determining Which Output Matched\n" "4Determining Which Output Matched\n"
" When an expect rule matches data in the output stream, the rule which\n" " When an expect rule matches data in the output stream, the rule which\n"
" matched is recorded in the environment variable _EXPECT_MATCH_PATTERN.\n" " matched is recorded in the environment variable _EXPECT_MATCH_PATTERN.\n"
@ -5749,6 +5760,8 @@ return r;
switches: switches:
-Q quiet return status -Q quiet return status
-T (only for step), causes the step limit to
be a number of microseconds to run for
*/ */
t_stat run_cmd (int32 flag, char *cptr) t_stat run_cmd (int32 flag, char *cptr)
@ -5801,6 +5814,8 @@ else if ((flag == RU_STEP) ||
return SCPE_ARG; return SCPE_ARG;
} }
else sim_step = 1; else sim_step = 1;
if ((flag == RU_STEP) && (sim_switches & SWMASK ('T')))
sim_step = (int32)((sim_timer_inst_per_sec ()*sim_step)/1000000.0);
} }
else if (flag == RU_NEXT) { /* next */ else if (flag == RU_NEXT) { /* next */
t_addr *addrs; t_addr *addrs;
@ -9193,7 +9208,10 @@ if (i != exp->size) { /* Found? */
if (!(ep->switches & EXP_TYP_PERSIST)) /* One shot expect rule? */ if (!(ep->switches & EXP_TYP_PERSIST)) /* One shot expect rule? */
sim_exp_clr_tab (exp, ep); /* delete it */ sim_exp_clr_tab (exp, ep); /* delete it */
} }
sim_activate (&sim_expect_unit, exp->after); /* schedule simulation stop when indicated */ sim_activate (&sim_expect_unit, /* schedule simulation stop when indicated */
(ep->switches & EXP_TYP_TIME) ?
(int32)((sim_timer_inst_per_sec ()*exp->after)/1000000.0) :
exp->after);
} }
/* Matched data is no longer available for future matching */ /* Matched data is no longer available for future matching */
exp->buf_ins = 0; exp->buf_ins = 0;
@ -9219,9 +9237,9 @@ if (snd->insoff+size > snd->bufsize) {
memcpy(snd->buffer+snd->insoff, data, size); memcpy(snd->buffer+snd->insoff, data, size);
snd->insoff += size; snd->insoff += size;
if (delay) if (delay)
snd->delay = delay; snd->delay = (sim_switches & SWMASK ('T')) ? (uint32)((sim_timer_inst_per_sec()*delay)/1000000.0) : delay;
if (after) if (after)
snd->after = after; snd->after = (sim_switches & SWMASK ('T')) ? (uint32)((sim_timer_inst_per_sec()*after)/1000000.0) : after;
if (snd->after == 0) if (snd->after == 0)
snd->after = snd->delay; snd->after = snd->delay;
snd->next_time = sim_gtime() + snd->after; snd->next_time = sim_gtime() + snd->after;
@ -9248,7 +9266,14 @@ if (snd->extoff < snd->insoff) {
else else
fprintf (st, "No Pending Input Data\n"); fprintf (st, "No Pending Input Data\n");
if ((snd->next_time - sim_gtime()) > 0) if ((snd->next_time - sim_gtime()) > 0)
if ((snd->next_time - sim_gtime()) > (sim_timer_inst_per_sec()/1000000.0))
fprintf (st, "Minimum of %d instructions (%d microseconds) befor sending first character\n", (int)(snd->next_time - sim_gtime()),
(int)((snd->next_time - sim_gtime())/(sim_timer_inst_per_sec()/1000000.0)));
else
fprintf (st, "Minimum of %d instructions befor sending first character\n", (int)(snd->next_time - sim_gtime())); fprintf (st, "Minimum of %d instructions befor sending first character\n", (int)(snd->next_time - sim_gtime()));
if (snd->delay > (sim_timer_inst_per_sec()/1000000.0))
fprintf (st, "Minimum of %d instructions (%d microseconds) between characters\n", (int)snd->delay, (int)(snd->delay/(sim_timer_inst_per_sec()/1000000.0)));
else
fprintf (st, "Minimum of %d instructions between characters\n", (int)snd->delay); fprintf (st, "Minimum of %d instructions between characters\n", (int)snd->delay);
if (snd->dptr && snd->dbit) if (snd->dptr && snd->dbit)
fprintf (st, "Debugging via: SET %s DEBUG%s%s\n", sim_dname(snd->dptr), snd->dptr->debflags ? "=" : "", snd->dptr->debflags ? get_dbg_verb (snd->dbit, snd->dptr) : ""); fprintf (st, "Debugging via: SET %s DEBUG%s%s\n", sim_dname(snd->dptr), snd->dptr->debflags ? "=" : "", snd->dptr->debflags ? get_dbg_verb (snd->dbit, snd->dptr) : "");

View file

@ -667,6 +667,7 @@ struct sim_exptab {
#define EXP_TYP_CLEARALL (SWMASK ('C')) /* clear all rules after matching this rule, default is to once a rule matches, it is removed */ #define EXP_TYP_CLEARALL (SWMASK ('C')) /* clear all rules after matching this rule, default is to once a rule matches, it is removed */
#define EXP_TYP_REGEX (SWMASK ('R')) /* rule pattern is a regular expression */ #define EXP_TYP_REGEX (SWMASK ('R')) /* rule pattern is a regular expression */
#define EXP_TYP_REGEX_I (SWMASK ('I')) /* regular expression pattern matching should be case independent */ #define EXP_TYP_REGEX_I (SWMASK ('I')) /* regular expression pattern matching should be case independent */
#define EXP_TYP_TIME (SWMASK ('T')) /* halt delay is in microseconds instead of instructions */
#if defined(USE_REGEX) #if defined(USE_REGEX)
regex_t regex; /* compiled regular expression */ regex_t regex; /* compiled regular expression */
#endif #endif
@ -1228,7 +1229,6 @@ extern int32 sim_asynch_inst_latency;
#define AIO_QUEUE_MODE "Lock based asynchronous event queue access" #define AIO_QUEUE_MODE "Lock based asynchronous event queue access"
#define AIO_INIT \ #define AIO_INIT \
if (1) { \ if (1) { \
int tmr; \
pthread_mutexattr_t attr; \ pthread_mutexattr_t attr; \
\ \
pthread_mutexattr_init (&attr); \ pthread_mutexattr_init (&attr); \
@ -1242,8 +1242,7 @@ extern int32 sim_asynch_inst_latency;
sim_asynch_queue = QUEUE_LIST_END; \ sim_asynch_queue = QUEUE_LIST_END; \
sim_wallclock_queue = QUEUE_LIST_END; \ sim_wallclock_queue = QUEUE_LIST_END; \
sim_wallclock_entry = NULL; \ sim_wallclock_entry = NULL; \
for (tmr=0; tmr<SIM_NTIMERS; tmr++) \ sim_clock_cosched_queue = QUEUE_LIST_END; \
sim_clock_cosched_queue[tmr] = QUEUE_LIST_END; \
} \ } \
else \ else \
(void)0 (void)0