求助,为何数据无法写入到帧中去?
时间:10-02
整理:3721RD
点击:
- task fabric_monitor::receive ();
- byteunsigned data_q[$];
- byteunsigned data_array[$];
- logic [7:0]data;
- logicsop= 1;
- logiceop= 0;
- intdatasize;
- //fabric_framefrm;
- 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
for(int i = 0; i < this.length; i++)begin
我猜length的值为0,所以根本没有赋值过。
另外UVM中自己带了unpack_bytes功能,为什么要自己写一个?
确实是这样,没有对length进行赋值,重新写unpack_bytes是因为我导师让我override这个函数的。