Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

what's the problem of the following systemverilog code?

Status
Not open for further replies.

brxue

Newbie level 4
Joined
Dec 15, 2010
Messages
5
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,321
Can anyone please help tell me what's the problem of the following systemverilog code?

The values on "a/b/c" of interface instance are all X value.

interface intf(input clk);
logic [7:0] a;
logic [7:0] b;
logic [7:0] c;

modport driver(output a, output b, input c, input clk);
modport receiver(input a, input b, output c, input clk);
endinterface

module tb;


class Driver;
virtual intf.driver port;

function new (virtual intf.driver port);
this.port = port;
endfunction

task run;
int i = 0;
while (i < 10) begin
port.a <= i;
port.b <= i;
i = i + 1;
@(posedge port.clk);
end
endtask

endclass

class Receiver;
virtual intf.receiver port;

function new (virtual intf.receiver port);
this.port = port;
endfunction

task run;
fork
while (1) begin
@(posedge port.clk);
port.c <= port.a + port.b;
end
join
endtask

endclass

bit clk = 0;

intf u_intf (.clk(clk));


initial begin
forever #5 clk += 1;
end
Driver drv;
Receiver rcv;

initial begin
drv = new(u_intf.driver);
rcv = new(u_intf.receiver);
rcv.run;
drv.run;

repeat(100) @(posedge clk);
$finish;
end

endmodule

---------- Post added at 23:22 ---------- Previous post was at 23:16 ----------

It seems the problem existed within the interface instance. I tried that when "rcv.run" is not called, just "c" has X value, "a" and "b" are correct values.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top