Monday 29 April 2019

What is Polymorphism?

In this post, I am going to explain very basic details about Polymorphism with an example. Basically, Polymorphism is used to redefine or extend the methods of the base classes and this can be achieved by overriding the base class methods using the methods defined in the derived classes. Following are some of the rules to be taken care for Polymorphism.
1) Place "virtual" keyword with method definition in base class which will to be redefined in child class.
2) Method name, number of arguments in the method and type of arguments in the method should be same as base class method in order to override base class method with derived class method.

Let's take an example of method overriding and see the results.

class base;
  virtual function void display();
    $display("BASE Class display method.");
  endfunction 
endclass

class child extends base;
  function void display();
    $display("CHILD Class display method.");
  endfunction 
endclass

module top();
  initial begin
    base b1;
    child c1;
    c1 =new();
    b1 = c1;
    b1.display();
    c1.display();
  end
endmodule

RESULT:
CHILD Class display method.
CHILD Class display method.

If we remove "virtual" keyword from the base class "display()" method definition then base class method will not get overridden and following is the result.

RESULT:
BASE Class display method.
CHILD Class display method.

Monday 15 April 2019

Wrapping Burst in AXI

In this post, I am going to give some basic details of the AXI WRAP Burst and how to calculate the WRAP boundary. First of all, there are few rules that need to be considered for WRAP Burst, which is stated below.
1) The start address must be aligned to the size of each transfer or in other word, aligned to AxSIZE
2) The Burst length must be 2, 4, 8 or 16 transfers.

Let's understand using one example. Assume, Burst length = 4, Burst size = 1(2 Bytes Data bus width) and Start_Address is 0x24(Aligned to AxSIZE).

First of all, we need to calculate the WRAP boundary using the below equation.

Wrap_Boundary = (INT(Start_Address/(Number_Bytes*Burst_Length))) * (Number_Bytes*Burst_Length)
                           = (INT(36/(2*4))) * (2*4)
Wrap_Boundary = 0x20

In WRAP burst, during any write/read request address gets increment the same as the INCR burst. Now the question is when actual wrapping will take place? So, for a WRAP burst, if (Start_Address_N  == Wrap_Boundary + (Number_Bytes * Burst_Length)) then wrapping will occur i.e. Start_Address_N = Wrap_Boundary.

For the above example, write/read request address increments following way

Start_Address_0 = 0x24
Start_Address_1 = 0x26
Start_Address_2 = 0x20(Wrap_Boundary)  (Why?
Because Start_Address_2 = 0x28 satisfies the equation "Start_Address_N  == Wrap_Boundary + (Number_Bytes * Burst_Length)" and so, Start_Address_2 = 0x20(Wrap_Boundary).)
Start_Address_3 = 0x22

If you have any comments or feedback, please leave it in the comment box. Thank you for reading this blog.

Friday 12 April 2019

What is Burst Length and Burst Size in AXI Protocol

Burst length

Burst length in AXI is the number of transfers for the Read/Write. AXI3 supports burst lengths of 1 to 16 transfers for all burst types (FIXED, INCR and WRAP). AXI4 extends burst length support for INCR burst type to 1 to 256 transfers and remains burst length to 1 to 16 transfers for all other burst types(FIXED and WRAP).

Signal for read transfers -> ARLEN[7:0]
Signal for write transfers -> AWLEN[7:0]

Burst length for AXI3 and AXI4 Write/Read transfer defined as,
Burst length = AxLEN[3:0] + 1
Burst length for INCR burst type of extended AXI4 Write/Read transfer defined as,
Burst length = AxLEN[7:0] + 1

Above definition explains that, AxLEN[3:0] = 0 means burst length is 1, same way AxLEN[7:0] = 255 means burst length is 256.

One rule about burst lengths of wrapping bursts is, its burst length must be 2, 4, 8 or 16.

Burst size

 Burst size is the maximum number of bytes can be transfer in a burst or transfer or a beat. Burst size is nothing but data bus width.

Signal for read transfers -> ARSIZE[2:0]
Signal for write transfers -> AWSIZE[2:0]

Encoding of AxSIZE[2:0] is pasted below.



Total number of transferred bytes can be calculated as, (Bytes in transfer) * (Number of transfers).