-- FILE: Flow.mesa
-- Last edited by Ousterhout, August 23, 1983 2:09 pm

-- This file defines several routines used by Crystal to control the direction
-- of information flow through transistors.

DIRECTORY
    Globals,
    Hash,
    Rope;
    
Flow: CEDAR DEFINITIONS =
BEGIN
OPEN Globals;

Mark: CmdProc;
    -- This procedure scans the entire network structure, marking each
    -- transistor with the direction(s) that information can flow through
    -- the transistor.  The marks are set with the flowFromSource and
    -- flowFromDrain flags.  Flow can occur in a particular direction if
    -- there is an information source (chip input) on one side of the
    -- transistor, an information sink (output or transistor gate) on the
    -- other side, and no conflicting flow attribute.  As an additional
    -- side effect, this routine turns fetNEnh transistors into fetNEnhP
    -- transistors or vice versa, depending on whether there is a load
    -- attached to the gate (no load means it's driven through a pass
    -- transistor).
    
Build: PROC[fet: Fet, name: Rope.ROPE, source: BOOLEAN];
    -- This procedure creates a flow by the given name for the
    -- given fet.  The flow is attached to the transistor's source
    -- if source is TRUE, otherwise it is attached to the transistor's
    -- drain.

Lock: PROC[fet: Fet, input: Node] RETURNS [BOOLEAN];
    -- This procedure sees if it is OK for information to flow into
    -- fet from input, given the other flow locks that are currently
    -- set.  TRUE is returned if it is OK;  in this case, information
    -- is set in any flows atached to the transistor to show that they
    -- are locked.  If a conflicting flow lock is already set, then
    -- FALSE is returned and nothing is modified in the flows.
    
Unlock: PROC[fet: Fet, input: Node];
    -- This is the inverse of Lock.  It clears all lock information left
    -- by the corresponding call to Lock.

FlowCmd: CmdProc;
    -- This procedure takes as arguments one of the keywords "in",
    -- "out", "off", "ignore", or "normal", and one or more flow names.
    -- Each of the named flows is marked according to the keyword. 
    -- "In" means only let information flow in at this attribute,  "out"
    -- means only let information flow out at this attribute, "ignore"
    -- means completely ignore this attribute, and "off" means don't
    -- let information flow at all through transistors labelled with
    -- this flow attribute.  "Normal" means go back to the standard
    -- interpretation of the flow attribute.

Stats: PROC[];
    -- Prints out internally-gathered statistics.

FlowTable: Hash.Table
    -- Contains all Flows known to Crystal.

END.