Ejemplo n.º 1
0
void init_dislin(Dislin& g) {

	g.metafl ("cons");
	g.scrmod ("revers");
	g.disini ();
	g.pagera ();
	g.complx ();
	g.axspos (450, 1800);
	g.axslen (2200, 1200);

	g.name   ("X-axis", "x");
	g.name   ("Y-axis", "y");

	g.labdig (-1, "x");
	g.ticks  (9, "x");
	g.ticks  (10, "y");

	g.titlin ("Energy over generations", 1);
	g.titlin ("Energy", 3);

	int ic = g.intrgb (0.95,0.95,0.95);
	g.axsbgd (ic);

	//g.graf   (0.0, 360.0, 0.0, 90.0, -1.0, 1.0, -1.0, 0.5);
	g.setrgb (0.7, 0.7, 0.7);
	g.grid   (1, 1);

	g.color  ("fore");
	g.height (50);
	g.title  ();
}
Ejemplo n.º 2
0
int main( int argc, char *argv[], char *env[] )
{
  Verilated::commandArgs( argc, argv );
  top = new Vsine3;
  top->clk = 0;
  top->eval();

  Dislin g;

  g.itmstr( "Yes!", 1 );  

  g.metafl( "CONS" );
  g.setpag( "da4l" );

  top->period = 64;
  const int period_cnt = 2; // [periods]
  const int res = 100; // [samples/period]
  const int sample_cnt = period_cnt * res; // [samples]
  const double dx = 2.0 * M_PI / (double)res;
  double x[3][sample_cnt]; // [radians]
  double y[3][sample_cnt];

  int n;
  for ( n = 0; n < sample_cnt; ++n )
  {
    x[0][n] = (double)n * dx; // [radians]
    x[1][n] = x[0][n]; // [radians]
    x[2][n] = x[0][n]; // [radians]

    top->in0 = (int)round( x[0][n] * (double)top->period / 2.0 / M_PI );
    top->in1 = (int)round( ( x[1][n] - 2.0 * M_PI / 3.0 ) * (double)top->period / 2.0 / M_PI );
    top->in2 = (int)round( ( x[2][n] + 2.0 * M_PI / 3.0 ) * (double)top->period / 2.0 / M_PI );

    top->eval();

    y[0][n] = ( (double)(signed char)top->out0 );
    y[1][n] = ( (double)(signed char)top->out1 );
    y[2][n] = ( (double)(signed char)top->out2 );

    //printf( "n: %d, in0: %d, out0: %d\n",
    //  n, top->in0, (signed char)top->out0 );
  }

  g.disini();
  g.pagera();
  g.hwfont();
  g.axspos( 450, 1800 );
  g.axslen( 2200, 1200) ;

  g.name( "Phase (radians)", "x" );
  g.name( "Sine (8 bit)", "y" );

  g.labdig( -1, "x" );
  g.ticks( 10, "xy" );

  g.titlin( "Sine simulation", 1 );
  //g.titlin ("SIN(X), COS(X)", 3);

  g.graf( -2.0 * M_PI, ( (double)period_cnt + 1.0 ) * 2.0 * M_PI, 0.0, 90.0, -150, 150, -150, 50 );
  g.title();

  g.color( "red" );
  g.curve( x[0], y[0], sample_cnt );
  g.color( "green" );
  g.curve( x[1], y[1], sample_cnt );
  g.color( "blue" );
  g.curve( x[2], y[2], sample_cnt );

  g.color( "fore" );
  g.dash();
  g.xaxgit();
  g.disfin();

  delete top;
  exit( 0 );
}