## Inner product in vector space

The inner product is an operation that measures the similarity between vectors.  In a general way, the inner product could be defined as an operation of 2 operands, which are elements of a vector space. The result is a scalar in the set of the complex numbers:

$\left \langle \cdot, \cdot \right \rangle : V \times V \rightarrow \mathbb{C}$

## Formal properties

For $$x, y, z \in V$$ and $$\alpha \in \mathbb{C}$$, the inner product must fulfill the following rules:

To be distributive to vector addition:

$$\left \langle x+y, z \right \rangle = \left \langle x, z \right \rangle + \left \langle y, z \right \rangle$$

Conmutative with conjugate (applies when vectors are complex):

$$\left \langle x,y \right \rangle = \left \langle y, x \right \rangle^*$$

Distributive respect scalar multiplication:

$$\left \langle \alpha x, y \right \rangle = \alpha^* \left \langle x, u \right \rangle$$

$$\left \langle x, \alpha y \right \rangle = \alpha \left \langle x, u \right \rangle$$

The self inner product must be necessarily a real number:

$$\left \langle x, x \right \rangle \geq 0$$

The self inner product can be zero only when the element is the null element:

$$\left \langle x,x \right \rangle = 0 \Leftrightarrow x = 0$$

## Inner product in $$\mathbb{R}^2$$

The inner product in $$\mathbb{R}^2$$ is defined as follows:

$$\left \langle x, y \right \rangle = x_0 y_0 + x_1 y_1$$

In self inner product represents the squared norm of the vector:

$$\left \langle x, x \right \rangle = x^2_0 + y^2_0 = \left \| x \right \|^2$$

## Inner product in finite length signals

In this case, the inner product is defined as:

$\left \langle x ,y \right \rangle = \sum_{n= 0}^{N-1} x^*[n] y[n]$

## Properties of vector spaces

Vector spaces must meet the following rules:
$$x + y = y + x$$

$$(x+y)+z = x + (y + z)$$

Scalar multiplication to be distributive with respect to vector addition:
$$\alpha\left(x + y \right) = \alpha x + \alpha y$$

Scalar multiplication to be distributive with respect to vector the addition of field scalars:
$$\left( \alpha + \beta \right) x = \alpha x + \beta y$$

Scalar multiplication to be associative:
$$\alpha\left(\beta x \right) = \left(\alpha \beta \right) x$$

It must exist a null element:
$$\exists 0 \in V \ \ | \ \ x + 0 = 0 + x = x$$

It must exist an inverse element for every element in the vector space:
$$\forall x \in V \exists (-x)\ \ | \ \ x + (-x) = 0$$

## The uvm_object class

The uvm_object class is the base class for all UVM classes. From it, all the rest of classes are extended. It provides basic functionalities such as print, compare, copy and similar methods.

This class can be used when defining reusable parts of a sequence items. For example, in a packet like uvm_sequence_item, we could define a uvm_object extended object for defining the header. This would be:

This packet_header could be included in a packet class for conforming the uvm_sequence_item (the transaction) which will compose the sequences:

## Pseudo-random number generator with Fibonacci sequence

$s_k = (k\cdot A) \bmod B$

$$s_k$$ is the pseudo-random number and $$A$$ and $$B$$ are prime numbers. $$k$$ is in the range $$[0,B-1]$$. If $$k$$ is greater than $$B-1$$, the results will be repeat as $$B$$ is the period of the sequence.
For example, $$A = 7$$ and $$B = 17$$. This sequence written in MATLAB could be:

## Cordic in MATLAB

Let’s z be a 2D point in the space as $$z = x + jy$$, if we want to rotate this point a given angle $$\theta$$, we get the following expressions:
$e^{j\theta} \cdot z = \left(\cos{\theta} + j \sin{\theta}\right)\left(x+jy\right) \\ = x\cos{\theta}-y\sin{\theta} + j \left(y \cos{\theta} + x \sin{\theta} \right) \\ = x’ + j y’$

Then, for a generic point, the rotation can be expressed as an equation system, where $$x’$$ and $$y’$$ are the new coordinates, $$\theta$$ is the rotation angle and $$x$$ and $$y$$ are the original coordinates:
$\begin{bmatrix} x’\\ y’ \end{bmatrix}= \begin{bmatrix} \cos{\theta} & -\sin{\theta}\\ \sin{\theta} & \cos{\theta} \end{bmatrix}\begin{bmatrix} x\\ y \end{bmatrix}$

This rotation can be coded in MATLAB as:

A possible implementation of the cordic algorithm could be:

I have coded an interactive applet to illustrate the algorithm. It has been done using the p5.js library. The error limit has been set to $$0.5$$.

## Install Quartus in Ubuntu 16.04

1. Open http://dl.altera.com/?edition=lite
4. Extract Quartus installer.
5. Run setup.sh: ./setup.sh
6. Select desired devices.
7. For launching modelsim, install libxft2 32 bit version library: sudo apt install libxft2:i386. Then execute ./vsim in the path intelFPGA_lite/17.1/modelsim_ase/linuxaloem/

## Rounding in C

Example:

The console output is:

## Phases in UVM

UVM introduces the concept of phases to ensure that all objects are properly configured and connected before starting the runtime simulation. Phases contribute to a better synchronised simulation and enable to the verification engineer to get better modularity of the testbench.

UVM phases consists of:

1. build
2. connect
3. end_of_elaboration
4. start_of_simulation
5. run
1. reset
2. configure
3. main
4. shutdown
6. extract
7. check
8. report
9. final

The run phase has been simplified to get a better picture of how phases worked. Nevertheless, all subphases in the run phase have a pre_ and post_ phase to add flexibility. Therefore, the run phase is actually composed by the following phases:

1. run
1. pre_reset
2. reset
3. post_reset
4. pre_configure
5. configure
6. post_configure
7. pre_main
8. main
9. post_main
10. pre_shutdown
11. shutdown
12. post_shutdown

Although all phases play an important role, the most relevant phases are:

• build_phase: objects are created
• connect_phase: interconnection between objects are hooked
• run_phase: the test starts. The run_phase is the only phase which is a task instead of a function, and therefore is the only one that can consume time in the simulation.

UVM phases are executed from a hierarchical point of view from top to down fashion. This means that the first object that executes a phase is the top object, usually

testbench  test  environment agent {monitor, driver, sequencer, etc}

Nevertheless, in the connect phase, this happens the other way round in a down to top fashion.

{monitor, driver, sequencer} agent environment test testbench

The uvm_pkg is contained in the uvm_pkg.sv that must be passed to the compiler. Therefore, it is necessary to indicate the UVM path to the compiler. In Cadence Incisive Enterprise Simulator (IES) is as easy as to specify -uvm switch.