SMOKUtils is a small collection of small perl scripts
intended to:
SMOK
scripting interface.
SMOK scripting interface
with some possibly useful, higher level functions.
The SMOKUtils module is contained in file SMOKUtils.pm
in the SMOK install directory. It is simply a text
file, so is easily viewed and editted. To keep the function interfaces simple,
little attention is given to making them customizable through an extensive set
of parameters. Instead, we expect that users may want to modify the library routines
to suit their particular tastes. If you do that, keep in mind that future
SMOK distributions will contain the SMOKUtils.pm
file, which will be overwritten on installation. It would probably be best to
rename and move the file, and to set your PERLLIB environment variable
appropriately.
Because these functions are not part of the SMOK package, they are not
invoked using object syntax. Instead, the SMOK object
involved is passed as the first argument, as in
$alu = SMOKUtils::FindComponentByType( $smok, "ALU" );
The descriptions that follow all assume that the following code has executed before the example code given:
use SMOK; $smok = SMOK::CreateSMOK( "example-setup", 1 ); $smok->OpenModelFile( "smalltest.smok" ); # from the SMOK distribution
| Description | Prints the number of instances of each SMOK component type in the model. |
| Example Invocation | SMOKUtils::Counts( $smok ); |
| Example Output | 1 Adder |
FindComponentByName()| Description | Returns the first component of the specified name encountered
when enumerating all model components using the SMOK
interface. Because components names may not be unique in a model,
and because the order in which components are delivered by the
underlying iterator may change from one invocation to the next,
the result is repeatable only if you guarantee that there is only
a single component with that name in the model. |
| Example Invocation | my $sum = SMOKUtils::FindComponentByName( $smok, "SUM" ); |
| Example Output | None from this command.
Following it withprint $sum->GetType();Register |
FindComponentByType()| Description | Returns the first component of the specified type encountered
when enumerating all model components using the SMOK
interface. Because component types may not be unique in a model,
and because the order in which components are delivered by the
underlying iterator may change from one invocation to the next,
the result is repeatable only if you guarantee that there is only
a single component with that type in the model.See GetType() for the list of type values. |
| Example Invocation | my $sum = SMOKUtils::FindComponentByName( $smok, "SMOK::Register" ); |
| Example Output | Register |
ListModel()| Description | Prints the name, type, and current value of each component in the model. (If the current value, as returned by GetValue() is 0x80000000, it is assumed to mean that no value is associated with this component, and so it is not printed.) |
| Example Invocation | SMOKUtils::ListModel( $smok ); |
| Example Output |
SMOKMachine SMOKMachine
SMOKMachine TitleBox
New ConstantReg ConstantReg 1
OutputPort 1
New Halt Halt
InputPort 0
New ADDER Adder 1
InputPort 0
InputPort 1
OutputPort 1
SUM Register 0
InputPort 1
W InputPort 1
OutputPort 0
SUM -> New ADDER Connection
SUM -> New Halt Connection
New ADDER -> SUM Connection
New ConstantReg -> SUM\W Connection
New ConstantReg -> New ADDER Connection
|
RunAll()| Description |
This function takes a directory name as its argument, and does not
require a SMOK object.
|
| Example Invocation | SMOKUtils::RunAll( "C:\\Program Files\\University of Washington CSE\\SMOK\\SampleDataFiles" ); |
| Example Output |
C:\Program Files\University of Washington CSE\SMOK\SampleDataFiles\ControllerTest.smok
Space: 2097385 Time: 16
Halted execution after 10000000 steps
C:\Program Files\University of Washington CSE\SMOK\SampleDataFiles\JavaTraceTest.smok
Space: 2209 Time: 172
Halted execution after 9 steps
C:\Program Files\University of Washington CSE\SMOK\SampleDataFiles\TraceTest.smok
Space: 2209 Time: 172
Halted execution after 9 steps
C:\Program Files\University of Washington CSE\SMOK\SampleDataFiles\smalltest.smok
Space: 752 Time: 164
Halted execution after 10 steps
|