Skip to content

Instantly share code, notes, and snippets.

@osamaadam
Created July 11, 2019 13:12
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
module mbox();
import types::*;
mailbox exp_mb = new();
mailbox act_mb = new();
task stimulus();
packet stim_pkt;
packet falsePacket;
for (int i = 0; i < 256; i++) begin
stim_pkt.pid = i;
falsePacket.pid = i;
if(i == 250)
falsePacket.pid = stim_pkt.pid + 1;
exp_mb.put(stim_pkt);
act_mb.put(falsePacket);
$display("Sending pkt: %0d",i);
end
endtask
task checker1();
packet a,b;
bit x;
while(1) begin
exp_mb.get(a);
act_mb.get(b);
//$display(a);
//$display(b);
x = fComp(a,b);
//$display(x);
if(!x)
$display("Packets %0d and %0d not matching!!", a.pid, b.pid);
end
endtask
function bit fComp(input packet s,y);
if(s == y)
return 1;
else
return 0;
endfunction
initial begin
fork
stimulus();
checker1();
join_none
end
endmodule
package types;
typedef struct{
int pid;
}packet;
endpackage
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment