Example #1
0
int main(int argc, char **argv, char **env) {
  int i;
  int clk;
  Verilated::commandArgs(argc, argv);
  // init top verilog instance
  Vcounter* top = new Vcounter;
  // init trace dump
  Verilated::traceEverOn(true);
  VerilatedVcdC* tfp = new VerilatedVcdC;
  top->trace (tfp, 99);
  tfp->open ("counter.vcd");
  // initialize simulation inputs
  top->clk = 1;
  top->rst = 1;
  top->cen = 0;
  top->wen = 0;
  top->dat = 0x55;
  // run simulation for 100 clock periods
  for (i=0; i<20; i++) {
    top->rst = (i < 2);
    // dump variables into VCD file and toggle clock
    for (clk=0; clk<2; clk++) {
      tfp->dump (2*i+clk);
      top->clk = !top->clk;
      top->eval ();
    }
    top->cen = (i > 5);
    top->wen = (i == 10);
    if (Verilated::gotFinish())  exit(0);
  }
  tfp->close();
  exit(0);
}
int main(int argc, char **argv, char **env) {
  int i;
  int clk;
  Verilated::commandArgs(argc, argv);
  // init top verilog instance
  Vcmsdk_mcu* top = new Vcmsdk_mcu;
  // init trace dump
  Verilated::traceEverOn(true);
  VerilatedVcdC* tfp = new VerilatedVcdC;
  top->trace (tfp, 99);
  tfp->open ("cmsdk_mcu.vcd");
  // initialize simulation inputs
  top->XTAL1 = 1;
  top->NRST  = 0;
  top->nTRST  = 0;
  top->TDI    = 0;
  top->SWCLKTCK    = 0;
  // run simulation for 100 clock periods
  for (i=0; i<200000; i++) {
    top->NRST = (i > 2);
    // dump variables into VCD file and toggle clock
    for (clk=0; clk<2; clk++) {
      tfp->dump (2*i+clk);
      top->XTAL1 = !top->XTAL1;
      top->eval ();
    }
    if (Verilated::gotFinish())  exit(0);
  }
  tfp->close();
  exit(0);
}
main() {
    cout<<"test: O_LARGEFILE="<<O_LARGEFILE<<endl;

    v1 = v2 = s1 = 0;
    s2[0] = s2[1] = s2[2] = 0;
    tri96[2] = tri96[1] = tri96[0] = 0;
    tri96__tri[2] = tri96__tri[1] = tri96__tri[0] = ~0;
    ch = 0;
    doub = 0;
    {
	VerilatedVcdC* vcdp = new VerilatedVcdC;
	vcdp->spTrace()->addCallback (&vcdInit, &vcdFull, &vcdChange, 0);
	vcdp->open ("test.vcd");
	// Dumping
	vcdp->dump(timestamp++);
	v1 = 0xfff;
	tri96[2] = 4; tri96[1] = 2; tri96[0] = 1;
	tri96__tri[2] = tri96__tri[1] = tri96__tri[0] = ~0;  // Still tri
	doub = 1.5;
	vcdp->dump(timestamp++);
	v2 = 0x1;
	s2[1] = 2;
	tri96__tri[2] = tri96__tri[1] = tri96__tri[0] = 0; // enable w/o data change
	doub = -1.66e13;
	vcdp->dump(timestamp++);
	ch = 2;
	tri96[2] = ~4; tri96[1] = ~2; tri96[0] = ~1;
	doub = -3.33e-13;
	vcdp->dump(timestamp++);
	vcdp->dump(timestamp++);
# ifdef VERILATED_VCD_TEST_64BIT
	vluint64_t bytesPerDump = 15ULL;
	for (vluint64_t i=0; i<((1ULL<<32) / bytesPerDump); i++) {
	    v1 = i;
	    vcdp->dump(timestamp++);
	}
# endif
	vcdp->close();
    }
}
Example #4
0
void launch() {
  int nstime = 0;
  //Verilated::commandArgs(argc, argv);
  Verilated::traceEverOn(traceOn);
  VerilatedVcdC *tfp = new VerilatedVcdC;
  Vbench_rrmux* top = new Vbench_rrmux;

  top->reset = 1;
  if (traceOn) {
    top->trace (tfp, 99);
    tfp->open ("rrmux.vcd");
  }

  while (!Verilated::gotFinish() && (nstime < finishTime)) { 
    if (nstime > 100) top->reset = 0;
    if (nstime & 1) top->clk = 1; 
    else top->clk = 0;
    top->eval(); 
    tfp->dump (nstime);
    nstime++;
  }
  if (traceOn) tfp->close();
}
Example #5
0
int main(int argc, char** argv) {
  Verilated::commandArgs(argc, argv);   // Remember args
  top = new TOP_TYPE;

#if VM_TRACE			// If verilator was invoked with --trace
    Verilated::traceEverOn(true);	// Verilator must compute traced signals
    VL_PRINTF("Enabling waves...\n");
    VerilatedVcdC* tfp = new VerilatedVcdC;
    top->trace (tfp, 99);	// Trace 99 levels of hierarchy
    tfp->open ("dump.vcd");	// Open the dump file
#endif


  top->reset = 1;

  cout << "Starting simulation!\n";

  while (!Verilated::gotFinish() && main_time < timeout) {
    if (main_time > 10) {
      top->reset = 0;   // Deassert reset
    }
    if ((main_time % 10) == 1) {
      top->clock = 1;       // Toggle clock
    }
    if ((main_time % 10) == 6) {
      top->clock = 0;
    }
    top->eval();               // Evaluate model
#if VM_TRACE
	if (tfp) tfp->dump (main_time);	// Create waveform trace for this timestamp
#endif
    main_time++;               // Time passes...
  }

  if (main_time >= timeout) {
      cout << "Simulation terminated by timeout at time " << main_time <<
              " (cycle " << main_time / 10 << ")"<< endl;
      return -1;
  } else {
      cout << "Simulation completed at time " << main_time <<
              " (cycle " << main_time / 10 << ")"<< endl;
  }

  // Run for 10 more clocks
  vluint64_t end_time = main_time + 100;
  while (main_time < end_time) {
    if ((main_time % 10) == 1) {
      top->clock = 1;       // Toggle clock
    }
    if ((main_time % 10) == 6) {
      top->clock = 0;
    }
    top->eval();               // Evaluate model
#if VM_TRACE
	if (tfp) tfp->dump (main_time);	// Create waveform trace for this timestamp
#endif
    main_time++;               // Time passes...
  }

#if VM_TRACE
    if (tfp) tfp->close();
#endif
}
Example #6
0
int main(int argc, char **argv) {
    
    //--------------------------------------------------------------------------
    
    Verilated::commandArgs(argc, argv);
    
    Verilated::traceEverOn(true);
    VerilatedVcdC* tracer = new VerilatedVcdC;
    
    Vmain *top = new Vmain();
    top->trace (tracer, 99);
    //tracer->rolloverMB(1000000);
    tracer->open("main.vcd");

    //reset
    top->clk = 0; top->rst_n = 1; top->eval();
    top->clk = 1; top->rst_n = 1; top->eval();
    top->clk = 1; top->rst_n = 0; top->eval();
    top->clk = 0; top->rst_n = 0; top->eval();
    top->clk = 0; top->rst_n = 1; top->eval();
    
    //--------------------------------------------------------------------------
    
    bool dump_enabled = true;
    
    int cycle = 0;
    
    int pnom[]  = { 0,1,2,3, 0,1,2,3, 0,1,2,3, 0,1,2,3, 0,1,-2,-1, 0,1,-2,-1,  0, 1,-2,-1,  0, 1,-2,-1 };
    int pden[]  = { 0,0,0,0, 1,1,1,1, 2,2,2,2, 3,3,3,3, 0,0, 0, 0, 1,1, 1, 1, -2,-2,-2,-2, -1,-1,-1,-1 };
        
    int nom[]   = { 0,1,2,3, 0,1,2,3, 0,1,2,3, 0,1,2,3,  0,1,4|2,4|3, 0,1,4|2,4|3, 0,  1,  4|2,4|3, 0,  1,  4|2,4|3 };
    int denom[] = { 0,0,0,0, 1,1,1,1, 2,2,2,2, 3,3,3,3,  0,0,0,  0,   1,1,1,  1,   4|2,4|2,4|2,4|2, 4|2,4|2,4|2,4|2 };
    
    int index = 0;
    bool running = false;
    
    while(!Verilated::gotFinish()) {
        
        top->start = 0;
        top->dividend = 0;
        top->divisor = 0;
        
        if(running == false) {
            top->start = 1;
            top->dividend = nom[index];
            top->divisor  = denom[index];
            running = true;
        }
        
        if(top->ready) {
            printf("%02d / %02d = q: %02d r: %02d\n", pnom[index], pden[index], top->quotient, top->remainder);
            running = false;
            index++;
            
            if(index == 32) {
                printf("END\n");
                break;
            }
        }
        
        top->clk = 0;
        top->eval();
        
        cycle++;
        if(dump_enabled) tracer->dump(cycle);
        
        top->clk = 1;
        top->eval();
        
        cycle++;
        if(dump_enabled) tracer->dump(cycle);
        
        tracer->flush();
        //usleep(1);
    }
    delete top;
    return 0;
}