|
SMOK Example Model ConstructionLast modified: April 12, 2005 |
|
|
CSE Home
|
About Us
|
Search
|
Contact Info
|
This page describes the construction of an model that simply counts cycles using the WinGUI interface. It is not an exhaustive overview, but rather intended to give an idea of how to do simple things.
The SMOK WinGUI interface attempts to be consistent with the Windows standards, so, by and large, doing what you are used to for Windows applications produces expected results, and if you want to do something you don't know how to do, try doing "the natural thing." Menus, single-clicking, double-clicking, and right-clicking are all used in the interface.
1. Start SMOK
Double-click on the desktop icon, or use the Start/Programs menu, or double-click on a SMOK input file (one with extension .smok), or through a DOS command line. (Okay, after this I won't repeat everything we already know about how to use Windows systems.)
If you start SMOK without specifying a data file, you'll see something like this:
The yellow rectangle is a title box. The model title, currently "untitled", is displayed, as is the total cost of the model (the sum of the individual component costs) and the minimum possible cycle time computed as the critical path delays during the ClockUp phase.
2. Add Component
Right-clicking on the (white) background produces a pop-up menu that includes an "Add components..." item. Selecting that produces a list of component types, and selecting one of those inserts a new copy of that component type at the point on the screen where the original right-click took place. Here's a close-up:
Here's the model above after adding the Register. It has a default name ("New Register"), initial value ("0x00000000", i.e., hex 0), and width (32 bits, indicated by the fact that there area 8 hex digits displayed for its value). The register is painted in blue to indicate that it is currently selected; a backspace typed at this point would delete it, for instance. The title box is updated to indicate the new machine cost and minimum cycle time.
3. Modify Component Parameters
Every component has a name parameter, most have a width and value parameters, and some have other parameters as well. The parameters of an individual component are accessible through a dialog box that can be produced by either double-clicking on the component or by right-clicking and choosing the Properties menu item. Here is the dialog for Register components:
The Width parameter is in bits. Valid widths are (usually) 1 to 32 bits. The value parameter is the current value stored in the Register. An invalid input will be rejected when you try to commit the changes, and the corresponding parameter will be left unmodified.
Edit away, and hit OK to commit the changes or Cancel to discard them.
4. Add, Modify, Repeat
Add more components and modify their parameters, for instance resulting in this:
Here I've added an Adder, a Constant Register (i.e., a constant value), and a Halt component, adjusted the widths of the components to be 16 bits (from the default of 32), and modified the Constant Register to have value 1 (instead of the default of 0).
5. Connect the Components
The grey boxes inside the components are their "input ports." Each can be connected to another component. To do this, click once on a specific input port. If it turns blue, you've selected it. If the entire component turns blue you missed and got its containing component, and you should try again.
Here's what it looks like when I've selected the lower of the two Adder inputs:
Now click on the input source you want to connect to while holding down the control key. The connection is established, and the input port becomes unselected. The adder output is also updated to reflect its new inputs (0, from the unconnected input, and 1, from the Constant Register).
If you make a mistake and connect an input port to the wrong component, do any of the following:
- reselect the input port and hit DEL to delete the connection
- select the connection and hit DEL
- type ctrl-Z to undo the last connection made. (ctrl-y is redo.)
- reselect the input port and then select the correct component or output port, while holding down the CTRL key, to move the connection there.
Connect the other components in a similar way, to get:
The Adder now adds the constant 1 to the value in the Register. The Register reads the Adder output, and since it's Write control line is connected to the constant 1, latches the new Adder output each ClockDown phase.
6. Execute Some Cycles
You can execute one cycle with the Step command, or just set the machine running with the Go command. Both are available by either right-clicking on the background (i.e, not on a component) or through the Run menu, or through accelerator keys. But, BE CAREFUL. If you select GO, there is no UI interface to stop the simulation, so it had better stop on its own. That's what the Halt component is for. (See the documentation on the Halt component, or just try double-clicking on it and intuiting what it does.) Because Halt's default parameters would cause it to halt this machine at cycle 0, I've modified them to indicate "Halt the machine when your input is equal to 0x200."
Here's the screen after executing one cycle. The Register value has been updated to 1, the output of the Adder at the end of the cycle 0 ClockUp phase. The machine is paused between the ClockUp and ClockDown phases of cycle 1, so the Adder inputs are now both 1 and its output is 2.

7. Perform Manual Layout Adjustment
SMOK uses a very simple scheme for drawing connections: it draws a horizontal line half way between the heights of the source and destination, and vertical lines at the ends of that horizontal one. This doesn't always make for the most readable model view. You can adjust the view by dragging components where you want them.
To move one component, click-and-drag. It turns blue to indicate that this has also made it the current selection. (All connections to and from it also turn blue as an aid in deciphering dense models.)
To move multiple components together, shift-click (in the usual Windows way) to select the set you want to move, and drag.
Either way, a component cannot be moved outside of its immediate container. For most components, this is the edge of the window. (Ignore those scroll bars, they're decoys - there's nothing out there.) For input ports (the little grey boxes inside other components), this is the bounding box for its containing component. It's sometimes useful to move input ports around inside components to adjust how the connections are drawn.
Here's the same model after I've moved things around a bit:
The Adder input ports are now in perverse positions, but I moved them just to illustrate that it's possible.
8. Want Some Trace Output?
Here's the screen after I've added a DebugOutput component and inserted it in the path between the output of the ALU and the input of the Register:
As further cycles are executed, the values passing into the Debug Output component are written to a text window:
The numbers on the left are cycle numbers; those on the right are the values at the input side of the Debug Output component. All those File / Edit / Help menus may or may not be working by the time you read this.
9. Save Your Work
Right-clicking on the background, or going to the File menu on the main window, allows you to save your model. (The same operations will later let you read in a previously saved model.) Model description files have extent ".smok". They're written in ASCII, so one could imagine looking at the contents of one and maybe even modifying it. But, you'd have to be nuts to do that, because (a) it's harder to do that than to use SMOK to read the model in, modify it, and resave it, and (b) SMOK has almost no error resilience for file input, so if you screw up the editing it's not unlikely it will crash.
But, Save and Open work, and that's the point.
Department of Computer Science & Engineering
University of Washington
Box 352350
Seattle, WA 98195-2350
(206) 543-1695 voice, (206) 543-2969 FAX
[comments to zahorjan@cs.washington.edu]