马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?注册
x
- task fabric_monitor::receive ();
- byte unsigned data_q[$] ;
- byte unsigned data_array[$];
- logic [7:0] data ;
- logic sop = 1;
- logic eop = 0;
- int datasize;
- // fabric_frame frm;
- while((sop == 1)||(eop == 1))begin
- @this.m_itf.cb;
- sop = this.m_itf.sop ;
- data = this.m_itf.data;
- eop = this.m_itf.eop ;
- end
- while ((sop == 0)&&(eop == 0))begin
- @this.m_itf.cb;
- sop = this.m_itf.sop ;
- data = this.m_itf.data;
- eop = this.m_itf.eop ;
- // $display("data = %d", data);
- data_q.push_back (data);
- end
- datasize = data_q.size ();
- $display ("datasize=%d",datasize);
- for (int i = 0; i < datasize; i++)begin
- data_array[i] = data_q[i];
- $display("data_array[%d]=%d", i,data_array[i]);
- end
- this.frm.payload = new[datasize - 8];
- this.frm.unpack_bytes(data_array);
- $display("payload.size=%d",this.frm.payload.size);
- $display("frm.payload[%d]=%d",4,frm.payload[4]);
- $display("frm.uid.frame_id=%d",frm.uid.frame_id);
- this.put_port.put (this.frm);
- 求大神帮我看一下,这个代码哪里出了问题,能够从interface中读出数据,但是无法写入到frm中,unpack_bytes的代码如下:[code] virtual function void unpack_bytes (byte unsigned packet [$]);
- this.uid.sport [ 7: 0] = packet[0];
- this.uid.sport [15: 8] = packet[1];
- this.uid.dport [ 7: 0] = packet[2];
- this.uid.dport [15: 8] = packet[3];
- this.uid.frame_id[ 7: 0] = packet[4];
- this.uid.frame_id[15: 8] = packet[5];
- this.uid.frame_id[23:16] = packet[6];
- this.uid.frame_id[31:24] = packet[7];
- for(int i = 0; i < this.length; i++)begin
- this.payload [i] = packet [i+8];
- end
- endfunction
复制代码
ps,写回到payload中的数据都是0 |