Feed

Enter your email address:

Delivered by FeedBurner

Showing posts with label SV. Show all posts
Showing posts with label SV. Show all posts

Thursday, October 17, 2013

Run multiple testcases in System Verilog in Questasim

Let there are two test cases.

testcase1 and testcase2

1-First complie them using the command(for questasim)

 vlog  top.sv test_case1.sv
vlog   top.sv   test_case2.sv

2-To run them use command as given below

 vsim top +test_case1
vsim  top  +test_case2


Tuesday, October 8, 2013

System Verilog Inheritance example

/*-----------------------------------BASE CLASS----------------*/

class base;
   logic [7:0] data;

   task increament(logic[7:0] temp);
     data=temp+1;
   endtask // increament

   task random();
      this.data=$random;
   endtask // random

endclass // base

/*-----------------------------------DERIVED CLASS----------------*/
class derived extends base;
   logic[7:0] packet[];
   int size;

   function new(int size);
      this.size=size;
      packet=new[size];
   endfunction // new

endclass // derived

/*-----------------------------------MODULE----------------*/

module top;

   logic[7:0] din=8'b0;
   logic[7:0] dout[];

   reg      clk=0;
   reg      reset=0;
   reg      en=0;
   int      count=0;

   initial
     begin
dout=new[pkt1.size];
     end

   always #50 clk = ~clk;

   always@(posedge clk)
     begin
if(count<pkt1.size)
 begin
    en=1;
    pkt1.increament(din);
    pkt1.packet[count]=pkt1.data;
    count+=1;
    din=din+1;
 end
else
 begin
    en=0;
    dout=pkt1.packet;
 end // else: !if(count<pkt1.size)
     end // always@ (posedge clk)

   derived pkt1 = new(5);

   endmodule