如何在邮箱系统中使用获取功能

时间:2018-08-02 12:21:14

标签: system-verilog

我是systemverilog的初学者,我试图制作一个复杂的代码来比较两个邮箱 这给了我这些模拟错误 enter image description here

//包装代码
     包装类型;
      typedef结构{       int pid;
       }数据包;
        最终包装
        //主要代码

     module mbox;                                                       
    import types::*;                                                 
    //Declare two mailboxes here                                       
    mailbox exp_mb = new(256);             
      mailbox act_mb = new(256);                                            
            // This task supplies stimulus to the two mailboxes           
               task stimulus();                                         
       packet stim_pkt;                                                    
       for (int i = 0; i < 256; i++) begin
stim_pkt.pid = i;

//*** Write stim_pkt to both mailboxes here
exp_mb.put(stim_pkt);
act_mb.put(stim_pkt);
$display("Sending pkt: ",i);                                               
     end                                                                      
       endtask                                                              
         // Add task checker here                                         
         task check(input mailbox exp_mb ,act_mb);                         
             bit com;                                                   
     packet x;                                                          
    packet y;                                                              
    for (int i = 0; i < 256; i++) begin                                  
       x.pid = exp_mb.get(i) ;                                           
       y.pid =  act_mb.get(i);                                             
     com = compare(x,y);                                                    
        if (com == 1)                                                 
           $display ("No Error");                                         
            else                                                      
     $display ("Error in %d", i);                                          
           end                                                         
         endtask                                                            
       // Add function compare here                                   
       function bit unsigned compare (packet a ,b);                         
     if (a.pid == b.pid)                                                
    return 1;                                                             
          else                                                          
          return 0;                                                
            endfunction// Add an initial block to run stimulus & checker tasks simultaneously    
       initial                                                           
       begin                                                              
       fork                                                        
          stimulus();                                             
        check(exp_mb ,act_mb);                                       
       join_none                                                           
       end                                                           
          endmodule

1 个答案:

答案 0 :(得分:0)

错误消息告诉您确切的问题是什么。邮箱get()方法不返回值,而是在其参数中放置一个值。

我相信你想要

exp_mb.get(x) ;                                           
act_mb.get(y);      

此外,一个好主意是将类型添加到您的邮箱中。随着代码的增长和不同数据包类型的数量的增长,它将对获取编译错误而不是运行时错误非常有帮助。

mailbox #(packet) exp_mb = new(256);
mailbox #(packet) act_mb = new(256);
...
task check(mailbox #(packet) exp_mb ,act_mb);         
相关问题