Skip to content

5.Configuration

Nitish1371 edited this page Nov 30, 2022 · 9 revisions

Global package variables

Table 5.1 Global package variables

Name Type Description
NO_OF_SLAVES integer specifies no of slaves connected to the APB interface
APB_transfer_char_s struct Structure to hold the packet data.
APB_transfer_cfg_s struct Structure to hold the configuration data.
apb_fsm_state_e enum Represents the type of state IDLE SETUP
ACCESS
slave_no_e enum Used to select the one slave at a time by one hot encoding SLAVE_0 = 16'b0000_0000_0000_0001 SLAVE_1 = 16'b0000_0000_0000_0010 SLAVE_2 = 16'b0000_0000_0000_0100 SLAVE_3 = 16'b0000_0000_0000_1000 SLAVE_4 = 16'b0000_0000_0001_000 SLAVE_5 = 16'b0000_0000_0010_0000
endian_e enum LITTLE_ENDIAN=1’b0 : lsb bit will store in first address location BIG_ENDIAN = 1’b1 : msb bit will store in first address location
tx_type_e enum WRITE=1’b1 : write transfer happen READ=1’b0 : read transfer happen
protectiontype_e enum Used to represent the protection type for transaction NORMAL_SECURE_DATA = 3'b000 NORMAL_SECURE_INSTRUCTION = 3'b001 = 3'b010 NORMAL_NONSECURE_INSTRUCTION = 3'b011
PRIVILEGED_SECURE_DATA = 3'b100 PRIVILEGED_SECURE_INSTRUCTION = 3'b101
slave_error_e enum Represents slave error signal NO_ERROR=1’b0;ERROR=1’b1;

Configuration used

  1. Env configuration
  2. Master Agent configuration
  3. Slave Agent configuration

Master agent configuration

Table 5.2 Master_agent_config

Name Type Default value Description
is_active enum VM_ACTIVE It will be used for configuring an agent as an active agent means it has sequencer, driver and monitor or passive agent which has monitor only
no_of_slaves integer ‘d0 Used for specifying the number of slaves connected to the master
has_coverage integer ‘d1 Used for enabling the master agent coverage

Slave agent configuration

Table 5.3 Slave_agent_config

Name Type Default value Description
is_active enum UVM_ACTIVE It will be used for configuring agent as an active agent means it has sequencer,driver and monitor and if it’s a passive agent then it will have only monitor
slave _id integer ‘d0 Used for indicating the ID of this slave e.g. slave 0 is selected.
has_coverage integer ‘d1 Used for enabling the
slave agent coverage.

Environment configuration

Table 5.4 Env_config

Name Type Default value Description
has_scoreboard integer 1 Enables the scoreboard,it usually receives the transaction level objects via TLM ANALYSIS PORT.
has_virtual_sqr integer 1 Enables the virtual sequencer which has master and slave sequencer
no_of_slaves integer ‘h1 Number of slaves connected to

Memory Mapping

Memory-mapping is a mechanism that maps a portion of a file, or an entire file, on disk to a range of addresses within an application's address space.
In APB, the memory mapping means that the slave’s address ranges are stored in the master’s associative arrays so that master has access to each slave’s address range.
image

                                    Fig. 5.5.1: Memory mapping example    

Memory mapping in APB

An example of memory mapping is as shown in fig. 1. Initially in global package, the memory is taken as 4KB, i.e., the slave memory size is taken as 12, because (2^ADDRESS_DEPTH = MEMORY_SIZE) i.e., (2^12 = 4096) as shown in fig. 5.5.2.

Each Slave memory is given a gap of 2 locations, so that each memory mapping can be differentiated easily as shown in fig. 5.5.2.

image

                                     Fig. 5.5.2: Global parameter declaration  

An associative array is used to store the max and min address ranges of every slave in master agent configuration, where [int] is the index type as shown in fig. 5.5.3.
image

                                    Fig.5.5.3: Associative array declaration

In master agent configuration, two functions are written so that the value obtained will be stored in the master array as shown in fig. 5.5.4.

image

                                   Fig.5.5.4: Functions for memory mapping for max and min value  

The memory mapping is done in base_test as shown in fig. 5. In a setup_apb_master_agent_config(), initially, we declare 2 local variables to store the min and max address used for each iteration as shown in fig. 5.5.5.
image

                                   Fig 5.5.5: Local variable declaration in function  

The function setup_apb_master_agent_config will start pushing the maximum and minimum address ranges to the respective associative arrays by adding a memory gap of 4 and making sure that start address is mod of 4 as shown in fig. 5.5.6.
image

                                 Fig 5.5.6: Memory mapping procedure in master agent configuration  

In slave agent configuration, the slave max and min address range is declared as shown in fig. 5.5.7. Created the slave memory of type associative array so that each salve can store the data received from master with the respective address as key.
image

                               Fig 5.5.7: Declaration of slave max and min address range  

Similarly for Slave, the mapping is done as shown in fig. 5.5.8. The same index value is mapped for the slave memory, so that the slave stores the data in the same address range for memory. Each slave’s minimum and maximum addressess are sent to the respective slave agent configurations from the stored maximum and minimum address ranges in the master agent configuration.

image

                                Fig.5.5.8: Memory mapping procedure in slave agent configuration  

Little Endian and Big Endian

ENDIAN CONCEPT

Endian refers to the bytes order in which data is stored in the memory and also describes the order of byte transmission over a digital link.

Basically Endian comes in two types: Little endian and Big endian

imp drawio (13)

                                 Fig. 5.6: Random Data indicating MSB and LSB bits

If your machine is big-endian then the MSB byte store first (means at lower address) and if the machine is the little-endian then LSB byte store first (means at lower address).

Big-endian

In big-endian MSB Byte will store first. It means the MSB Byte will store at the lowest memory address location as shown in table 1.

                       Table 5.6.1: Big-endian 
Address value
00 0x11
01 0x22
02 0x33
03 0x44

Little-endian

In the little endian machine, LSB byte will store first. So the LSB Byte will store at the lowest memory address as shown in table 2.

                  Table 5.6.2: Little-endian
Address value
00 0x44
01 0x33
02 0x22
03 0x11

Clone this wiki locally