Jump to content

How to deal with sipo task to form the bytes out of it, plz suggest?


Recommended Posts

Hello all UVM geeks,

I am working on SIPO(serial in parallel out) in monitor class. Its not working properly and data is not being shifted in the shift registers. Can someone please guide me how to correct this problem so that I can make 10 bits byte out of SIPO. Following is the code for sipo part.

 


  task sipo(serialin);
         // task sipo(dut_vi.data);
                       reg [9:0] pout;
                      // automatic logic [9:0] temp = 0; //reg replaced by logic
                       reg [9:0] temp;
                       reg [4:0] counter_m = 0;
                        //repeat(2) 
                       //always
                       @(posedge dut_vi.clock)  //removed posedge
                       // for (int i = 0; i < 10 ; i++)
                        begin
                         // temp[9:0] <= {temp[8:0], serialin}; //THIS LINE DOESNT WORK, GIVES ERROR:  Error: monitor.sv(167): LHS in non-blocking assignment may not be an automatic variable
                          //temp[9:0] <<<= {temp[8:0], serialin};  //compiles but dont give any result
                               //@(posedge dut_vi.clock)
                                temp[0] = serialin;      //temp[8];
       $display("san480- Display of the temp %b",temp); 
 
                          temp[1] = temp[0];
                          $display("san481- Display of the temp %b",temp); 
 
  temp[2] = temp[1];
  $display("san482- Display of the temp %b",temp); 
  // @(posedge dut_vi.clock)
       temp[3] = temp[2];
  $display("san483- Display of the temp %b",temp); 
//  @(posedge dut_vi.clock)
       temp[4] = temp[3];
       $display("san484- Display of the temp %b",temp); 
//  @(posedge dut_vi.clock)
  temp[5] = temp[4];
  $display("san485- Display of the temp %b",temp); 
  // @(posedge dut_vi.clock)
  temp[6] = temp[5];
  $display("san486- Display of the temp %b",temp); 
       // @(posedge dut_vi.clock)
  temp[7] = temp[6];
  $display("san487- Display of the temp %b",temp); 
  // @(posedge dut_vi.clock)
  temp[8] = temp[7];
  $display("san488- Display of the temp %b",temp); 
       // @(posedge dut_vi.clock)
       temp[9] = temp[8]; 
                   $display("san489- Display of the temp %b",temp); 
                  // repeat(10)@( dut_vi.clock)
                //  $display("san489- Display of the temp %b",temp);
                   counter_m = counter_m + 1;
                   $display("san490- Display of the counter_m %d",counter_m); //%h
                       end
                          @(posedge dut_vi.clock)
                          //assign
                          pout = temp;
                          
                          $display("san466- Display of the Paralled data out of SIPO %b",pout); //%h
         uvm_report_info(get_full_name(),"Display of SIPO output parallel data.....",UVM_NONE);
         
                          bq.push_back(pout); 
 @( dut_vi.clock); 
 $display("san467- Display of the queue contents %h",bq.size());
 bytes = new[bq.size()] (bq);  
 
      $display("san453- Display of the bytes array contents %p",bytes); //%h
          endtask: sipo   
 

 

Any help is appreciated. Thanks
Link to comment
Share on other sites

Wow, that's a lot of code...

 

If I've understood correctly, surely you just need

 

 

 

task sipo (ref serialin);  // must be a ref if you want to read it during the task
  logic [9:0] pout;
  for (int i = 0; i<10; i++) begin
    pout = {pout[8:0], serialin};   // assuming called just after a posedge?
    @(posedge dut_vi.clock);
  end
  $display ("Pout is %b", pout);
endtask : sipo

 

You may need to mess about with the timing of when you call the task.

 

regards

Alan

http://www.doulos.com

Link to comment
Share on other sites

Hello Mr. Alan,

 

Thanks for your reply. I appreciate it. I am finding one more error. The bits are not being received properly at every clock edge from (dut_vi.data) dut_interface. I am trying to assign the serialin with dut_vi.data in run phase() but its not working. It gives following error also:

 

** Error: monitor82.sv(51): An automatic var. or elem. of a dynamic var. (this) may not be the LHS of a non-blocking assignment.

 

 
class monitor extends uvm_monitor; 
         //Registration of monitor with the factory.
                `uvm_component_utils(monitor)
        
       virtual dut_if dut_vi; 
         
          bit [7:0] decdrout1;
         bit [7:0] decdrout2[];                 
         bit[7:0]queue[$]; 
         //automatic 
         logic serialin;
         //bit serialin;
         reg [9:0] pout;
         bit [9:0] bq[$]; 
                 bit[9:0] bytes[]; 
        
                uvm_analysis_port #(transaction) Montr2Agnt_port;         
        
           //constructor by using keyword new
                function new(string name, uvm_component parent);
                    super.new(name, parent);
                endfunction: new               
        
                function void build_phase(uvm_phase phase);
                    super.build_phase(phase);  
                    assert( uvm_config_db #(virtual dut_if)::get(this, "", "dut_vi", dut_vi) );
                    Montr2Agnt_port = new("Montr2Ag", this);            
                endfunction : build_phase
        
        
        
      virtual task run_phase(uvm_phase phase);
          transaction pkt;         
           // fork              
             forever
               begin
              //automatic 
             // logic serialin;
              //bit [7:0] decdrout1;
               int j;
               int pkt_len = 8; 
              //bit [9:0] bq[$]; 
              //bit[9:0] bytes[]; 
         
                 //repeat(10)
                 @( dut_vi.clock); //removed posedge
                  serialin <= dut_vi.data;  //This line gives following error too,             
                 // ** Error: monitor82.sv(51): An automatic var. or elem. of a dynamic var. (this) may not be the LHS of a non-blocking assignment.
                  
                  $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);
                  //sipo(dut_vi.data);                
                void'(decode(bytes));        
                pkt = transaction::type_id::create("pkt1");        
                $display("SM447- Display of the bytes array received after decoding %h",decdrout2);  //%h
                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); 
               // void'(pkt.unpack_bytes(decdrout2));
                pkt.print(); //keep it here uncommented
                uvm_report_info(get_full_name(),"Completed unpacking of received bytes ...",UVM_LOW);          
                  Montr2Agnt_port.write(pkt);
           end //paired with forever
        
          uvm_report_info(get_full_name(),"Sending received packet from monitor to the Scoreboard ...",UVM_LOW);
        
     endtask: run_phase   
           
        virtual task sipo (ref serialin);  // must be a ref if you want to read it during the task
                         logic [9:0] pout;
                         reg [3:0] counter_m = 0;
                         $display ("san488- Serialin is %b", serialin);
                         for (int i = 0; i<10; i++) begin
                            pout = {pout[8:0], serialin};   // assuming called just after a posedge?
                            $display ("san491- Pout is %b", pout);
                            $display ("san492- Pout is %h", pout);
                            counter_m = counter_m + 1;
                           $display("san490- Display of the counter_m %d",counter_m); //%h
                            @(posedge dut_vi.clock);
                         end
                   $display ("san493- Pout is %b", pout);
                 
          endtask : sipo
      
                
            // function decode(bytes);
          function decode(bytes); 
                    ......
                    .......
           endfunction: decode
 
endclass: monitor
 

 

I am not getting why the bits are not being received properly by dut_vi.data and serialin because I can see the bits coming properly untill dut_interface.

Please guide me through what am I missing in the run task to get all the bits serially in and then in sipo function.

 

Thanks,

Link to comment
Share on other sites

You can't make a non-blocking assignment to a class member - serialin is a member of the class.

The easiest solution is to change it to blocking, i.e.

 

 

serialin = dut_vi.data;
 

 

Regarding getting your code to work, I think you'll just have to debug it. In class-based code, the single-step / breakpoint features of the simulator are very useful,

 

regards

Alan

 

P.S. Actually non-blocking assignment to class members is allowed in 1800-2012 - but that doesn't mean you should use it :-)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...