Email: bknpk@hotmail.com Phone: +972-54-7649119


V

 

In this work I show how to build a reference model in systemc using queues, from C++ STD.

  1. Link to the main page of this work. This page explains the test-bench used in this project.
    Two components are instantiated namely DUT and monitor:
    tb(sc_module_name nm): sc_module(nm), u_mul("u_mul"), u_mon("u_mon") {

  2. The test-bench drives the reset:
    void rst_p() {
      rst.write(true);
      wait(50, SC_NS);
      rst.write(false);
      cout << "PKm rst_p ended " << rst << " at " << sc_time_stamp() << endl;
    }

  3. The test-bench generates random data (a debug pattern is also possible).
      void data_drive_p() {
        unsigned ix;

        wait(1, SC_NS);
        do {
          wait();
        } while (rst.read() == 1);

        for(ix=0; ix <= 7; ix++) wait();
        cout << "PKm starts to drive data at " << sc_time_stamp() << endl;

        sc_int<8> data;
        for(ix=0; ix <= 15; ix++) {
          data=std::rand() % 8; a.write(data);
          data=std::rand() % 8; b.write(data);
          data=std::rand() % 8; c.write(data);
          data=std::rand() % 8; d.write(data);
          wait();
          /*
          a.write(1);
          b.write(1);
          c.write(-1);
          d.write(1);
          wait();
          a.write(1);
          b.write(-1);
          c.write(1);
          d.write(1);
          wait();
          */
        }

        sc_stop();
      }
    When generation ends the simulation stopped.


  4. The test-bench also records waves in VCD and generates a clock:
    int sc_main(int ac, char* av[]) {

      sc_clock clk("CLOCK", 50, SC_NS, 0.5, 0.0, SC_NS);
      tb u_tb("tb");
      u_tb.clk(clk);

      //VCD trace
      sc_trace_file *tf;
      tf = sc_create_vcd_trace_file("tb");

      sc_trace(tf, u_tb.u_mul.rst, "rst");
      sc_trace(tf, u_tb.u_mul.clk, "clk");
      sc_trace(tf, u_tb.u_mul.a, "a");
      sc_trace(tf, u_tb.u_mul.b, "b");
      sc_trace(tf, u_tb.u_mul.c, "c");
      sc_trace(tf, u_tb.u_mul.d, "d");
      sc_trace(tf, u_tb.u_mul.oa, "oa");
      sc_trace(tf, u_tb.u_mul.ob, "ob");
      //
      sc_trace(tf, u_tb.u_mon.e_oaq, "m_e_oaq");
      sc_trace(tf, u_tb.u_mon.e_obq, "m_e_obq");
      sc_trace(tf, u_tb.u_mon.cmp_ok, "m_cmp_ok");

      sc_start();
      return 0;
    }

  ...


Search This Site


Feedback This Site




new pages on this site