FAUST compiler  0.9.9.6b8
Enumerations | Functions
seqSchema.cpp File Reference
#include "seqSchema.h"
#include <iostream>
#include <assert.h>
Include dependency graph for seqSchema.cpp:

Go to the source code of this file.

Enumerations

enum  { kHorDir, kUpDir, kDownDir }
 

Functions

static double computeHorzGap (schema *a, schema *b)
 Compute the horizontal gap needed to draw the internal wires. More...
 
static int direction (const point &a, const point &b)
 Compute the direction of a connection. More...
 
schemamakeSeqSchema (schema *s1, schema *s2)
 Make a sequential schema. More...
 

Enumeration Type Documentation

anonymous enum
Enumerator
kHorDir 
kUpDir 
kDownDir 

Definition at line 29 of file seqSchema.cpp.

Function Documentation

static double computeHorzGap ( schema a,
schema b 
)
static

Compute the horizontal gap needed to draw the internal wires.

It depends on the largest group of connections that go in the same direction.

Definition at line 325 of file seqSchema.cpp.

References direction(), dWire, schema::height(), schema::inputPoint(), schema::inputs(), kDownDir, kLeftRight, kUpDir, max(), schema::outputPoint(), schema::outputs(), and schema::place().

Referenced by makeSeqSchema().

326 {
327  assert(a->outputs() == b->inputs());
328 
329  if (a->outputs() == 0) {
330  return 0;
331  } else {
332  // store here the size of the largest group for each direction
333  int MaxGroupSize[3]; for(int i=0; i<3; i++) MaxGroupSize[i]=0;
334 
335  // place a and b to have valid connection points
336  double ya = max(0.0, 0.5*(b->height() - a->height()));
337  double yb = max(0.0, 0.5*(a->height() - b->height()));
338  a->place(0,ya,kLeftRight);
339  b->place(0,yb,kLeftRight);
340 
341  // init current group direction and size
342  int gdir = direction(a->outputPoint(0), b->inputPoint(0));
343  int gsize = 1;
344 
345  // analyze direction of remaining points
346  for (unsigned int i=1; i<a->outputs(); i++) {
347  int d = direction(a->outputPoint(i), b->inputPoint(i));
348  if (d == gdir) {
349  gsize++;
350  } else {
351  if (gsize > MaxGroupSize[gdir]) MaxGroupSize[gdir]=gsize;
352  gsize = 1;
353  gdir = d;
354  }
355  }
356 
357  // update for last group
358  if (gsize > MaxGroupSize[gdir]) MaxGroupSize[gdir]=gsize;
359 
360  // the gap required for the connections
361  return dWire * max(MaxGroupSize[kUpDir],MaxGroupSize[kDownDir]);
362  }
363 }
unsigned int outputs() const
Definition: schema.h:129
const double dWire
distance between two wires
Definition: schema.h:33
virtual point inputPoint(unsigned int i) const =0
unsigned int inputs() const
Definition: schema.h:128
double max(double x, double y)
Definition: interval.hh:60
static int direction(const point &a, const point &b)
Compute the direction of a connection.
Definition: seqSchema.cpp:313
virtual void place(double x, double y, int orientation)=0
virtual point outputPoint(unsigned int i) const =0
double height() const
Definition: schema.h:127

Here is the call graph for this function:

Here is the caller graph for this function:

static int direction ( const point a,
const point b 
)
static

Compute the direction of a connection.

Note that Y axis goes from top to bottom

Definition at line 313 of file seqSchema.cpp.

References kDownDir, kHorDir, kUpDir, and point::y.

Referenced by seqSchema::collectInternalWires(), computeHorzGap(), and seqSchema::drawInternalWires().

314 {
315  if (a.y > b.y) return kUpDir; // upward connections
316  if (a.y < b.y) return kDownDir; // downward connection
317  return kHorDir; // horizontal connections
318 }
double y
Definition: schema.h:43

Here is the caller graph for this function:

schema* makeSeqSchema ( schema s1,
schema s2 
)

Make a sequential schema.

May add cables to ensure the internal connections are between the same number of outputs and inputs. Compute an horizontal gap based on the number of upward and downward connections.

Definition at line 43 of file seqSchema.cpp.

References computeHorzGap(), schema::inputs(), makeCableSchema(), makeParSchema(), and schema::outputs().

Referenced by addSchemaInputs(), addSchemaOutputs(), generateAbstractionSchema(), and generateInsideSchema().

44 {
45  unsigned int o = s1->outputs();
46  unsigned int i = s2->inputs();
47 
48  schema* a = (o < i) ? makeParSchema(s1, makeCableSchema(i-o)) : s1;
49  schema* b = (o > i) ? makeParSchema(s2, makeCableSchema(o-i)) : s2;
50 
51  return new seqSchema(a, b, computeHorzGap(a,b));
52 }
unsigned int outputs() const
Definition: schema.h:129
schema * makeParSchema(schema *s1, schema *s2)
Definition: parSchema.cpp:28
unsigned int inputs() const
Definition: schema.h:128
static double computeHorzGap(schema *a, schema *b)
Compute the horizontal gap needed to draw the internal wires.
Definition: seqSchema.cpp:325
Sequential composition.
Definition: seqSchema.h:36
An abstract block diagram schema.
Definition: schema.h:97
schema * makeCableSchema(unsigned int n)
Build n cables in parallel.
Definition: cableSchema.cpp:32

Here is the call graph for this function:

Here is the caller graph for this function: