SMOK

SMOK Introduction

Last modified: April 12, 2005
Sloop Cebollita
  CSE Home  About Us    Search    Contact Info 

Overview

SMOK is the machine organization simulator component of the Sloop Machine architecture course project.  SMOK components are modelled after (and include all) those found in "Computer Organization and Design: The Hardware / Software Interface," by Patterson and Hennessy.  For those without a copy of that book at hand, components are things like and gates, registers, and muxes, and more complicated components like ALUs and register files.  SMOK model simulation is much higher level than  that  provided by gate-level simulators, and much lower level than a typical student would write if asked to simulate a processor in software.  Here's a picture of a SMOK model that simply counts.  (The Halt component is a SMOK artifice to allow termination of the simulation.)

SMOK simulates these components at a functional level.  SMOK models do not use detailed timing information, in the sense that path lengths are irrelevant (and, more or less, assumed to be zero).  Rather, each clock cycle has a "clock up" and a "clock down" edge.  All combinational components are settled during clock up, with SMOK automatically ensuring that stable inputs are available to them before advertising outputs.  Latched components latch on "clock down."   SMOK allows the user to specify component delays by component type, and uses these to compute a minimum possible cycle time for the machine organization, but this is a static evaluation and those delays are not used in any way to drive the simulation.  (SMOK also evaluates machine "cost," using per-component-type costs that can be set by the user.)

SMOK supports the Sloop Machine,  a low-level RISC architecture designed to allow  pipelining of the Atari 6502 (think "game console") and its software (think "Donkey Kong") through on-the-fly translation of 6502 instructions into Sloop instructions (think "Pentium Pro").  Details on the Sloop are forthcoming.

The Sloop/SMOK software is designed to be portable to multiple user interfaces.  The original interface was as a C-library, requiring the user to specify the target machine organization as a set of C++ new's of SMOK components, and then simulating that organization.  Output was in the form of a trace file that the simulator would spend all its time writing instead of getting any simulation done.

The current version of Sloop/SMOK comes with a Windows front-end.

Basic Simulation Operation

This section gives an overview of SMOK simulation.  The information presented here is independent of the SMOK UI used.  UI dependent operations, such as how to define or edit a model, are presented in sections on the various UI's (of which there are currently one).

Each cycle is divided into two phases, ClockUp and ClockDown.  

When the simulator is paused (it has two states, simulating and paused, so whenever it's not simulating it's paused), it is held in a state equivalent to being after the ClockUp phase of the next cycle but before the ClockDown.  This means that as the machine configuration is modified, for instance by adding components or by changing connections among them or by altering the values of latched components, the values advertised stay consistent with each other and the operation of the individual components.  For this reason, the "current cycle" information available while paused indicates the next cycle to be executed.  (Cycles are numbered starting at zero.)

How Do I Know My Model Is Working?

If you don't give your users any way to see the values produced by your simulator, it's possible to perform remarkably fast simulations of very complex models.  Appealing as this may be, we took a more middle road, providing outputs at the cost of some simulation speed.

Model outputs are, to an extent, dependent on the UI used with SMOK.  However, SMOK contains a component type intended solely to produce debugging output.  This component, called a DebugOutput component, has no functional purpose in the machine organization (and isn't in Patterson and Hennessy).  It can be attached to the output of any other component in the model, and can itself be attached to (so that it can be spliced into a functional connection as a kind of passive probe).  During simulation, it writes its input value during the ClockUp phase of each cycle (following the usual rule of always reading an updated input for that cycle).  Where it writes is dependent on the UI.  In WinGUI it writes to a dedicated window (one per DebugOutput component); the information in that window can be printed or cut-and-paste'd into some other application.

SMOK provides two other components not part of real machines.  The DebugInput component is an way of soliciting input from the terminal each ClockUp phase.  It cannot be connected to any other model component (since it's connected to the keyboard), but other components can connect to it for their input.

The final simulation-only component is the Halt component.  It provides conditional termination of simulation depending on the state of the simulator.  In particular, a Halt component has an internal value that is compared each ClockUp against the value read from its input.  The Halt component can be configured to stop the simulation when the two values are equal, or unequal.


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]