Jump to content

issue regarding 32 bit crc implementation in transaction class of ethernet packets in uvm methodology

Recommended Posts

Hello Friends,

I am samrat Patel from ahmedabad
Currently i am working on a project of ethernet packet using uvm methodology.In project i have to implement a 32 bit crc logic in transaction class . i have seen some material on crc but for 32 bit crc i am not getting properly that how to do XOR calculation between 32 bit crc and 8 bit data.so any one can elaboreate it and help me for this that how can i do crc implemenation?

If u know reply me asap

email id:samrat150590@gmail.com
contact no: 09016464567


Samrat Patel
->Following is my transaction class
//ethernet transaction class declaration 
class eth_transaction extends uvm_sequence_item;
//ethernet packet field ranomization 
  rand bit [55:0] preamble;
  rand bit [7:0] sfd;
  rand bit [47:0] dst_addr;
  rand bit [47:0] src_addr;
  rand bit [15:0] data_len; // this length can accomodate MAXIMUM length of 1500
  rand bit [7:0] payload [];
  rand bit [31:0] crc;    
  rand int unsigned transmit_delay;//transmit delay between transfers
  constraint c_delay {transmit_delay==10;}//constraint on transmit delay-constraint as per need
//constraint on specific field
constraint preamble_con{
constraint sfd_con{
                   sfd== 8'hab;
constraint data_len_con{
                        data_len inside {[46:1500]};
                        solve data_len before payload;
constraint payload_con{
//macro registraton
function new(string name = "eth_transaction");
//display method  
function void display(string strng);
  $display("\n@time=%0g\tpacket displaying from %s",$time,strng);
  $display("|| preamble     || sfd  || dst_addr   || src_addr   ||   data_Len ||   payload_Len ||  crc   ||");
  $display("||%h||  %h  ||%h||%h||    %4d    ||     %6d    ||%h||",preamble,
//pack all bits of ethernet packet field
function void do_pack(uvm_packer packer);
  super.do_pack(packer); // pack super's properties
endfunction : do_pack
//unpack all bits of ethernet packet field
function void do_unpack(uvm_packer packer);
  super.do_unpack(packer); // unpack super's properties
  preamble = packer.unpack_field_int($bits(preamble));
  sfd = packer.unpack_field_int($bits(sfd));
  dst_addr = packer.unpack_field_int($bits(dst_addr));
  src_addr = packer.unpack_field_int($bits(src_addr));
  data_len = packer.unpack_field_int($bits(data_len));
  payload = new[data_len];
  payload = packer.unpack_field_int(8);
  crc = packer.unpack_field_int($bits(crc));
endfunction : do_unpack
//do_compare method -to compare specific field
function bit do_compare(uvm_object rhs,uvm_comparer comparer);
    eth_transaction rhs_;
    bit status=1;
    status &= (preamble == rhs_.preamble);
    status &= (sfd == rhs_.sfd);
    status &= (dst_addr == rhs_.dst_addr);
    status &= (src_addr == rhs_.src_addr);
    status &= (data_len == rhs_.data_len);
    status &= (payload == rhs_.payload);
    status &= (crc == rhs_.crc);
    return status;
endclass: eth_transaction
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.

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...