Quantcast
Channel: UVM SystemVerilog Discussions Forum RSS Feed
Viewing all articles
Browse latest Browse all 410

Any generic method in UVM to find the packet length of incoming packets?

$
0
0
Hello all,
I am receiving serial bits in the monitor from DUT. This is RX path and independent from TX path i.e driver path. Then I have to make parallel data out of it using sipo(serial in parallel out) and then I have to decode the data to form the packet from the decoded bytes. In order to receive the all the bits of all the packets in RX path(monitor class), I have to give packet_length inside the for loop. Right now in order to check he functionality of monitor (in loop back mode), I am sending only one packet(8 bytes) so I know the number of bits, which I can use for packet_length parameter. But I want to make it generic because in real world I wont know how many packets might be coming.
 
So the issue is, Is there any generic way in UVM to calculate the number of bytes(OR serial bits) coming into monitor? Is there any uvm method by which I can find this packet_length in a generic way?
 
 
Packet structure is shown below:
 class transaction extends uvm_sequence_item; 
           rand bit [7:0] sync;
           rand bit [7:0] sof;  
           rand bit [15:0] header; 
           rand bit [7:0] payload[]; 
           rand bit [15:0] crc;
           rand bit [7:0] eof;
 
 
 constraint data_size_c { payload.size inside { [6 : 6]};}; 
                  .............
                  .............
endclass: transaction
 
 class monitor extends uvm_monitor;
         .....
      virtual task run_phase(uvm_phase phase);
          transaction pkt;         
            forever
               begin
               int pkt_len = 130; //This is in bits,HERE I NEED TO PASS THE CALCULATED LENGTH FROM SOME GENERIC UVM FUNCTION,TO START RECEIVING ALL THE SERIAL BITS.
              
           repeat(3)@(dut_vi.clock); 
           for (int j = 0; j < pkt_len; j++)  
             
              begin
                  serialin = dut_vi.data;                                     
                    $display("san14- Display of the serial line serialin %b",serialin); 
                    $display("san15- Display of the Serial Line dut_vi.data %b",dut_vi.data); 
                    
                    sipo(serialin); 
                    
              end  
                void'(decode(bytes));   
              
                pkt = transaction::type_id::create("pkt1");        
                $display("SM447- Display of the bytes array received after decoding %h",decdrout2);  
                void'(pkt.unpack_bytes(decdrout2));
                uvm_report_info(get_full_name(),"Decoded completely 10bits into 8bits ...",UVM_LOW);
                uvm_report_info(get_full_name(),"Started unpacking of received bytes ...",UVM_LOW); 
             
                pkt.print(); 
                uvm_report_info(get_full_name(),"Completed unpacking of received bytes ...",UVM_LOW);          
                        Montr2Agnt_port.write(pkt);
                
           end 
        
          uvm_report_info(get_full_name(),"Sending received packet from monitor to the Scoreboard ...",UVM_LOW);
        
     endtask: run_phase   
        
           ...........
           ..........
 
endclass: monitor
 
 
 
Any help is appreciated, thanks

Viewing all articles
Browse latest Browse all 410

Trending Articles