From 6f1e8377c9e8ec9b8ea89b54ce6d63a2d2a906fd Mon Sep 17 00:00:00 2001 From: Mark Pizzolato Date: Fri, 9 Jan 2015 04:52:21 -0800 Subject: [PATCH] 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. --- scp.c | 39 ++++++++++++++++++++++++++++++++------- sim_defs.h | 5 ++--- 2 files changed, 34 insertions(+), 10 deletions(-) diff --git a/scp.c b/scp.c index e2261b32..5f72ba69 100644 --- a/scp.c +++ b/scp.c @@ -778,6 +778,9 @@ static const char simh_help[] = " 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" " 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" "3NEXT\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" " 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" - "++SEND {after=nn,}{delay=nn,}\"\"\n\n" + "++SEND {-t} {after=nn,}{delay=nn,}\"\"\n\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" " 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" " simulated system as if it was entered by a user.\n\n" - "++SEND :line {after=nn,}{delay=nn,}\"\"\n\n" + "++SEND {-t} :line {after=nn,}{delay=nn,}\"\"\n\n" "4Delay\n" " Specifies a positive integer representing a minimal instruction 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" " and hext character values of the form:\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 *************************/ #define HLP_EXPECT "*Commands Executing_Command_Files Reacting_To_Console_Output" /***************** 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" " character matching for that expression will be case independent.\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" " 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" @@ -5749,6 +5760,8 @@ return r; switches: -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) @@ -5801,6 +5814,8 @@ else if ((flag == RU_STEP) || return SCPE_ARG; } 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 */ t_addr *addrs; @@ -9193,7 +9208,10 @@ if (i != exp->size) { /* Found? */ if (!(ep->switches & EXP_TYP_PERSIST)) /* One shot expect rule? */ 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 */ exp->buf_ins = 0; @@ -9219,9 +9237,9 @@ if (snd->insoff+size > snd->bufsize) { memcpy(snd->buffer+snd->insoff, data, size); snd->insoff += size; if (delay) - snd->delay = delay; + snd->delay = (sim_switches & SWMASK ('T')) ? (uint32)((sim_timer_inst_per_sec()*delay)/1000000.0) : delay; 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) snd->after = snd->delay; snd->next_time = sim_gtime() + snd->after; @@ -9248,8 +9266,15 @@ if (snd->extoff < snd->insoff) { else fprintf (st, "No Pending Input Data\n"); if ((snd->next_time - sim_gtime()) > 0) - fprintf (st, "Minimum of %d instructions befor sending first character\n", (int)(snd->next_time - sim_gtime())); -fprintf (st, "Minimum of %d instructions between characters\n", (int)snd->delay); + 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())); +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); 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) : ""); return SCPE_OK; diff --git a/sim_defs.h b/sim_defs.h index 72c81253..bd6ea0e4 100644 --- a/sim_defs.h +++ b/sim_defs.h @@ -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_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_TIME (SWMASK ('T')) /* halt delay is in microseconds instead of instructions */ #if defined(USE_REGEX) regex_t regex; /* compiled regular expression */ #endif @@ -1228,7 +1229,6 @@ extern int32 sim_asynch_inst_latency; #define AIO_QUEUE_MODE "Lock based asynchronous event queue access" #define AIO_INIT \ if (1) { \ - int tmr; \ pthread_mutexattr_t attr; \ \ pthread_mutexattr_init (&attr); \ @@ -1242,8 +1242,7 @@ extern int32 sim_asynch_inst_latency; sim_asynch_queue = QUEUE_LIST_END; \ sim_wallclock_queue = QUEUE_LIST_END; \ sim_wallclock_entry = NULL; \ - for (tmr=0; tmr