Home > Community > Forums > Functional Verification > Task implementation outside module or class?

Email

* Required Fields

Recipients email * (separate multiple addresses with commas)

Your name *

Your email *

Message *

Contact Us

* Required Fields
First Name *

Last Name *

Email *

Company / Institution *

Comments: *

 Task implementation outside module or class? 

Last post Sat, Jul 7 2007 3:31 AM by archive. 2 replies.
Started by archive 07 Jul 2007 03:31 AM. Topic has 2 replies and 1103 views
Page 1 of 1 (3 items)
Sort Posts:
  • Sat, Jul 7 2007 3:31 AM

    • archive
    • Top 75 Contributor
    • Joined on Fri, Jul 4 2008
    • Posts 88
    • Points 4,930
    Task implementation outside module or class? Reply

    Hello , Is it possible to decalre Tasks in a seperate file (without module or class) and use the task in a program or module. task.sv: File name ------------------ task test; $display ("In task"); endtask test.sv: Filename ------------------ program test(Interface) `include "task.v" initial test endprogram Inorder to accomodate above implementation what changes to be made in the code. Thanks in advance. Thanks & Regards, Quest Team


    Originally posted in cdnusers.org by sundar_80
    • Post Points: 0
  • Mon, Jul 9 2007 3:46 AM

    • archive
    • Top 75 Contributor
    • Joined on Fri, Jul 4 2008
    • Posts 88
    • Points 4,930
    RE: Task implementation outside module or class? Reply

    i think u may have to import the module or package in which the program exists...
    import::
    this enables u to use all the module properties.... (data types ,functions, tasks.. etc)


    Originally posted in cdnusers.org by catchraghu
    • Post Points: 0
  • Tue, Jul 10 2007 6:11 AM

    • archive
    • Top 75 Contributor
    • Joined on Fri, Jul 4 2008
    • Posts 88
    • Points 4,930
    RE: Task implementation outside module or class? Reply

    Hi,

    You can declare tasks (and functions) in a SystemVerilog package. The package contents can then be imported, one-by-one or with a wildcard, into any program or module. This is a cleaner solution than using Verilog `include. e.g.

    //simple_package.sv
    package simple_package;
       task test();
          $display("This is a test\n");
       endtask // test
    endpackage // simple_package


    //simple_program.sv
    program simple();
       import simple_package::test;

       initial
         begin
            $display("Calling test..");
            test();
         end
    endprogram // simple


    The command "irun *.sv"  generates the following output:
    Calling test..
    This is a test


    Regards,
    Dave

      


    Originally posted in cdnusers.org by dl_doulos
    • Post Points: 0
Page 1 of 1 (3 items)
Sort Posts:
Started by archive at 07 Jul 2007 03:31 AM. Topic has 2 replies.