swapnilm Posted April 11, 2013 Report Share Posted April 11, 2013 Hello all, I want to pass the output of one function (10b8b decoder) into the input of another function viz. drive, where in drive function, I am creating the array out of each byte received from decoder. But when I am trying to Return that value from decoder, its not happening. Can someone please tell me how to return the decoder output value and take it in as an input into the drive function? I would appreciate it. Thanks Quote Link to comment Share on other sites More sharing options...
swapnilm Posted April 12, 2013 Author Report Share Posted April 12, 2013 Can someone please put some light on this, would appreciate it. Thanks, Quote Link to comment Share on other sites More sharing options...
adielkhan Posted April 12, 2013 Report Share Posted April 12, 2013 hi, You need to share some code for us to help you. Something like my_decoder_func().drive() is probably what you want to do. Quote Link to comment Share on other sites More sharing options...
swapnilm Posted April 13, 2013 Author Report Share Posted April 13, 2013 Here is the complete code of monitor. Please give me some idea where its going wrong in the code. I would appreciate it. `include "uvm_macros.svh" import uvm_pkg::*; class monitor extends uvm_monitor; //Registration of monitor with the factory. `uvm_component_utils(monitor) virtual dut_if dut_vi; 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 task run_phase(uvm_phase phase); transaction pkt; fork forever begin bit [7:0] decdrout1; bit [7:0] decdrout2[]; int j; int pkt_len = 8; bit [9:0] bq[$]; bit[9:0] bytes[]; $display("san14- Display of the packet contents %h",dut_vi.data); //%d repeat(2)@(dut_vi.clock); for ( int j = 0; j < pkt_len ; j++) // this gives more than 8 bytes but doesnt print pkts.works with this 8 too begin $display("san- Display of the packet contents %h",dut_vi.data); @(dut_vi.clock); $display("san12- Display of the packet contents %h",dut_vi.data); bq.push_back(dut_vi.data); @( dut_vi.clock); $display("san11- Display of the queue contents %p",bq); //%p uvm_report_info(get_full_name(),"Ready to Get out of the Foreach/For loop ...",UVM_LOW); end uvm_report_info(get_full_name(),"Got out of the Foreach loop ...",UVM_LOW); $display("san31- Display of the queue contents %h",bq.size()); bytes = new[bq.size()] (bq); $display("san32- Display of the bytes array contents %p",bytes); //%h pkt = transaction::type_id::create("pkt1"); //void'(decode(bytes)); //,decdrout1); // BYTES ARE THE INCOMING BYTES FROM DRIVER THROUGH INTERFACE decode(bytes); drive(decdrout1); //DECDROUT1 IS THE OUTPUT OF DECODE FUNCTION ABOVE uvm_report_info(get_full_name(),"Started unpacking of received bytes ...",UVM_LOW); void'(pkt.unpack_bytes(decdrout1)); // DECDROUT2 IS THE OUTPUT OF DRIVE FUNCTION //void'(pkt.unpack_bytes(decode)); pkt.print(); uvm_report_info(get_full_name(),"Completed unpacking of received bytes ...",UVM_LOW); Montr2Agnt_port.write(pkt); $display("san34- Display of the bytes array contents %p",bytes); //%h uvm_report_info(get_full_name(),"Sending received packet from monitor to the Scoreboard ...",UVM_LOW); end join endtask: run_phase function decode(bytes); //, output decdrout2,decdrout1); //task bit [9:0]bytes[]; $display("san35- Display of the bytes array received inside the decoder %p",bytes); //%h uvm_report_info(get_full_name(),"Received All 10bits into the Decoder ...",UVM_LOW); // bit [7:0] decdrout2[]; // bit [7:0] decdrout1; uvm_report_info(get_full_name(),"Decoding Each 10bits into 8bits ...",UVM_LOW); foreach (bytes[k]) begin bit dispin ; bit [8:0] dataout ; bit [7:0] decdrout1; bit [7:0] decdrout2[]; bit[7:0]queue[$]; reg[9:0] datain = bytes[k]; logic code_err ; logic disp_err ; logic ai = datain[0] ; logic bi = datain[1] ; logic ci = datain[2] ; logic di = datain[3] ; logic ei = datain[4] ; logic ii = datain[5] ; logic fi = datain[6] ; logic gi = datain[7] ; logic hi = datain[8] ; logic ji = datain[9] ; logic aeqb = (ai & bi) | (!ai & !bi) ; logic ceqd = (ci & di) | (!ci & !di) ; logic p22 = (ai & bi & !ci & !di) | (ci & di & !ai & !bi) | ( !aeqb & !ceqd) ; logic p13 = ( !aeqb & !ci & !di) | ( !ceqd & !ai & !bi) ; logic p31 = ( !aeqb & ci & di) | ( !ceqd & ai & bi) ; //logic p40; //datain = pout; logic p40 = ai & bi & ci & di ; logic p04 = !ai & !bi & !ci & !di ; logic disp6a = p31 | (p22 & dispin) ; // pos disp if p22 and was pos, or p31. logic disp6a2 = p31 & dispin ; // disp is ++ after 4 bits logic disp6a0 = p13 & ! dispin ; // -- disp after 4 bits logic disp6b = (((ei & ii & ! disp6a0) | (disp6a & (ei | ii)) | disp6a2 | (ei & ii & di)) & (ei | ii | di)) ; // The 5B/6B decoding special cases where ABCDE != abcde logic p22bceeqi = p22 & bi & ci & (ei == ii) ; logic p22bncneeqi = p22 & !bi & !ci & (ei == ii) ; logic p13in = p13 & !ii ; logic p31i = p31 & ii ; logic p13dei = p13 & di & ei & ii ; logic p22aceeqi = p22 & ai & ci & (ei == ii) ; logic p22ancneeqi = p22 & !ai & !ci & (ei == ii) ; logic p13en = p13 & !ei ; logic anbnenin = !ai & !bi & !ei & !ii ; logic abei = ai & bi & ei & ii ; logic cdei = ci & di & ei & ii ; logic cndnenin = !ci & !di & !ei & !ii ; //non-zero disparity cases: logic p22enin = p22 & !ei & !ii ; logic p22ei = p22 & ei & ii ; //logic p13in = p12 & !ii ; //logic p31i = p31 & ii ; logic p31dnenin = p31 & !di & !ei & !ii ; //logic p13dei = p13 & di & ei & ii ; logic p31e = p31 & ei ; logic compa = p22bncneeqi | p31i | p13dei | p22ancneeqi | p13en | abei | cndnenin ; logic compb = p22bceeqi | p31i | p13dei | p22aceeqi | p13en | abei | cndnenin ; logic compc = p22bceeqi | p31i | p13dei | p22ancneeqi | p13en | anbnenin | cndnenin ; logic compd = p22bncneeqi | p31i | p13dei | p22aceeqi | p13en | abei | cndnenin ; logic compe = p22bncneeqi | p13in | p13dei | p22ancneeqi | p13en | anbnenin | cndnenin ; logic ao = ai ^ compa ; logic bo = bi ^ compb ; logic co = ci ^ compc ; logic d0 = di ^ compd ; logic eo = ei ^ compe ; logic feqg = (fi & gi) | (!fi & !gi) ; logic heqj = (hi & ji) | (!hi & !ji) ; logic fghj22 = (fi & gi & !hi & !ji) | (!fi & !gi & hi & ji) | ( !feqg & !heqj) ; logic fghjp13 = ( !feqg & !hi & !ji) | ( !heqj & !fi & !gi) ; logic fghjp31 = ( (!feqg) & hi & ji) | ( !heqj & fi & gi) ; logic dispout = (fghjp31 | (disp6b & fghj22) | (hi & ji)) & (hi | ji) ; logic ko = ( (ci & di & ei & ii) | ( !ci & !di & !ei & !ii) | (p13 & !ei & ii & gi & hi & ji) | (p31 & ei & !ii & !gi & !hi & !ji)) ; logic alt7 = (fi & !gi & !hi & // 1000 cases, where disp6b is 1 ((dispin & ci & di & !ei & !ii) | ko | (dispin & !ci & di & !ei & !ii))) | (!fi & gi & hi & // 0111 cases, where disp6b is 0 (( !dispin & !ci & !di & ei & ii) | ko | ( !dispin & ci & !di & ei & ii))) ; logic k28 = (ci & di & ei & ii) | ! (ci | di | ei | ii) ; // k28 with positive disp into fghi - .1, .2, .5, and .6 special cases logic k28p = ! (ci | di | ei | ii) ; logic fo = (ji & !fi & (hi | !gi | k28p)) | (fi & !ji & (!hi | gi | !k28p)) | (k28p & gi & hi) | (!k28p & !gi & !hi) ; logic go = (ji & !fi & (hi | !gi | !k28p)) | (fi & !ji & (!hi | gi |k28p)) | (!k28p & gi & hi) | (k28p & !gi & !hi) ; logic ho = ((ji ^ hi) & ! ((!fi & gi & !hi & ji & !k28p) | (!fi & gi & hi & !ji & k28p) | (fi & !gi & !hi & ji & !k28p) | (fi & !gi & hi & !ji & k28p))) | (!fi & gi & hi & ji) | (fi & !gi & !hi & !ji) ; logic disp6p = (p31 & (ei | ii)) | (p22 & ei & ii) ; logic disp6n = (p13 & ! (ei & ii)) | (p22 & !ei & !ii) ; logic disp4p = fghjp31 ; logic disp4n = fghjp13 ; //assign code_err = p40 | p04 | (fi & gi & hi & ji) | (!fi & !gi & !hi & !ji) | (p13 & !ei & !ii) | (p31 & ei & ii) | (ei & ii & fi & gi & hi) | (!ei & !ii & !fi & !gi & !hi) | (ei & !ii & gi & hi & ji) | (!ei & ii & !gi & !hi & !ji) | (!p31 & ei & !ii & !gi & !hi & !ji) | (!p13 & !ei & ii & gi & hi & ji) | (((ei & ii & !gi & !hi & !ji) | (!ei & !ii & gi & hi & ji)) & ! ((ci & di & ei) | (!ci & !di & !ei))) | (disp6p & disp4p) | (disp6n & disp4n) | (ai & bi & ci & !ei & !ii & ((!fi & !gi) | fghjp13)) | (!ai & !bi & !ci & ei & ii & ((fi & gi) | fghjp31)) | (fi & gi & !hi & !ji & disp6p) | (!fi & !gi & hi & ji & disp6n) | (ci & di & ei & ii & !fi & !gi & !hi) | (!ci & !di & !ei & !ii & fi & gi & hi) ; //assign dataout = {ko, ho, go, fo, eo, d0, co, bo, ao} ; //actual output of Decoder decdrout1 = {ho, go, fo, eo, d0, co, bo, ao}; //OUTPUT OF DECODER ADDED BY ME $display("SM02- Display of the Decoded data contents %h",dataout); $display("SM04- Display of the Decoded data contents %h",decdrout1); //%b decdrout1 // my disp err fires for any legal codes that violate disparity, may fire for illegal codes //assign disp_err = ((dispin & disp6p) | (disp6n & !dispin) | (dispin & !disp6n & fi & gi) | (dispin & ai & bi & ci) | (dispin & !disp6n & disp4p) | (!dispin & !disp6p & !fi & !gi) | (!dispin & !ai & !bi & !ci) | (!dispin & !disp6p & disp4n) | (disp6p & disp4p) | (disp6n & disp4n)) ; uvm_report_info(get_full_name(),"Decoded Each 10bits into 8bits ...",UVM_LOW); $display("SM03- Display of the Decoded data contents %h",decdrout1); // end uvm_report_info(get_full_name(),"Decoded completely 10bits into 8bits ...",UVM_LOW); /* for ( int j = 0; j < 8 ; j++) //I TRIED TO CREATE ARRAY OF DECODER OUTPUT BYTES HERE ALSO BUT ITS NOT WORKING // foreach(decdrout1[i]) //added later //bit[8:0]queue[$];//,decodbytes[]; // added later begin queue.push_back(decdrout1); $display("san111- Display of the queue contents %p",queue); decdrout2 = new[queue.size()] (queue); $display("SM22- Display of the bytes array contents %h",decdrout2); // return decdrout2; // $display("SM273- Display the returned value of function decode %h",decdrout2); end end // $display("SM11- Display of the queue contents %h",queue.size()); //decdrout2 = new[queue.size()] (queue); //$display("SM22- Display of the bytes array contents %h",decdrout2); $display("SM212- Display the returned value of function decode %h",decode); return decode; //, decdrout2; $display("SM22- Display the returned value of function decode %h",decode); // decdrout2 = { << byte {decdrout1}}; //,decdrout2}}; //decdrout2 = { >> {decdrout2,decdrout2,decdrout2,decdrout2,decdrout2,decdrout2,decdrout2,decdrout2}}; //decdrout2 = { >> {decdrout1,decdrout1,decdrout1,decdrout1,decdrout1,decdrout1,decdrout1,decdrout1}}; // return decdrout2; //end */ return decdrout2; //decdrout2 = new[queue.size()] (queue); // end endfunction: decode function drive(input decdrout1); bit [7:0] queue[$],decdrout2[]; int i ; $display("SM44- Display of the bytes contents %h",decdrout1); uvm_report_info(get_full_name(),"Creating pkt from decoder output bytes ...",UVM_LOW); for ( i=0; i<8; i++) // foreach(decdrout1[i]) begin uvm_report_info(get_full_name(),"33Received decoder bytes ...",UVM_LOW); queue.push_back(decdrout1); $display("san111- Display of the queue contents %p",queue); uvm_report_info(get_full_name(),"44Received decoder bytes ....",UVM_LOW); end decdrout2 = new[queue.size()] (queue); $display("SM22- Display of the bytes array to go into unpack function contents %h",decdrout2); return decdrout2; //return drive; $display("SM226- Display of the bytes array contents %h",drive); endfunction : drive endclass: monitor Thanks, Quote Link to comment Share on other sites More sharing options...
omahesh Posted April 15, 2013 Report Share Posted April 15, 2013 Hi, it seems to be that you are returning decrout2 which has no updated value. decrout1 has some updation. Make sure which variable you want to return from the function. regards, mahee. Quote Link to comment Share on other sites More sharing options...
ktmills Posted April 19, 2013 Report Share Posted April 19, 2013 function bit [7:0] decode(bytes); ... return decdrout1; endfunction drive(decode(bytes)); or to return an array typedef bit [7:0] decdrout_array_t []; function decdrout_array_t decode(bytes); ... return decdrout2; endfunction Also its generally good code practice to have a return type for all functions, if nothign is returned then use void as the return type. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.