Engee documentation
Notebook

Restoration of the 5G main data block

This example shows how to use a 5G library to synchronise, demodulate and decode the gNodeB signal. The example decodes the MIB and the first of the system information blocks (SIB1).

Decoding the MIB and SIB1 requires a comprehensive receiver capable of demodulating and decoding most downlink channels and signals.

Let's start with connecting libraries, declaring auxiliary functions and ways to solve this problem.

In [ ]:
Pkg.add(["CSV"])
In [ ]:
# Подключение библиотек
using DataFrames, CSV, Plots
include("Fun_CSV.jl");

# Подключение вспомогательной функции запуска модели
function run_model( name_model, path_to_folder )
    
    Path = path_to_folder * "/" * name_model * ".engee"
    
    if name_model in [m.name for m in engee.get_all_models()] # Проверка условия загрузки модели в ядро
        model = engee.open( name_model ) # Открыть модель
        model_output = engee.run( model, verbose=true ); # Запустить модель
    else
        model = engee.load( Path, force=true ) # Загрузить модель
        model_output = engee.run( model, verbose=true ); # Запустить модель
        engee.close( name_model, force=true ); # Закрыть модель
    end

    return model_output
end

# Пути до папок с файлами
path_csv = "/user/5G/";
path_model = "$(@__DIR__)";

The model of the implemented system is presented below. It can be divided into three parts:

  1. generation of the input signal and superimposition of the communication channel effects on the generated signal,
  2. frequency offset correction followed by SSS search,
  3. PBCH search, BCH decoding and MIB detection.

image_2.png

Let's run the model and log the data from it.

In [ ]:
run_model("MIB_5G", path_model)
Building...
Progress 100%
Out[0]:
Dict{String, DataFrame}()

Then we will read the logged signals from CSV and analyse in more detail the communication system and the principles on the basis of which it is implemented. We will not focus on the input signal generation in this demonstration, but will consider the receiving path itself.

The receiver performs a PSS search and a rough estimate of the frequency offset based on the frequency shift of the received signal, provided that the possible offsets are separated by half a subcarrier.

The received frequency shifted signal is then correlated with each of the three possible PSS (NID) sequences and the strongest correlation peak is extracted.

In addition, the peak indicates which of the three PSS (NID) was detected in the received signal, as well as at which point the best channel conditions were present.

In [ ]:
NID = CSV.read(path_csv * "NID.csv", DataFrame);
print("Cамый сильный пик корреляции: " * string(NID[1,2])) 
Cамый сильный пик корреляции: 0.0

The estimate of the frequency shift below half of the subcarrier is calculated by correlating the cyclic prefix of each OFDM symbol in SSB with the corresponding useful parts of the OFDM symbols.

The phase of this correlation is proportional to the frequency shift of the signal.

In [ ]:
Frequency_offset = CSV.read(path_csv * "Frequency_offset.csv", DataFrame);
print("Смещение частоты на первом кадре: " * string(Frequency_offset[1,2])* " Гц") 
Waveform = Complex_CSV(path_csv * "Waveform.csv");
plot(real(Waveform))
plot!(imag(Waveform))
Смещение частоты на первом кадре: 48.8418354250601 Гц
Out[0]:

The receiver then extracts the SSS related elements from the resulting grid and correlates them with each possible locally generated SSS sequence.

Combining the indices of the strongest PSS and SSS sequences gives the identity of the physical layer mesh, which is required for processing PBCH DM-RS and PBCH.

In [ ]:
SSS_search = CSV.read(path_csv * "SSS_search.csv", DataFrame);
print("SSS: " * string(SSS_search[1,2])) 
SSS: 102

The MIB is mandatory system information that is broadcast by the gNB at a set frequency. During the initial cell selection procedure, the UE assumes that SSB is transmitted by the gNB every 20 ms. The UE obtains the MIB by decoding the PBCH from the SS-PBCH block beam.

In [ ]:
MIB = str2num_CSV(path_csv * "MIB.csv");
In [ ]:
print("MIB: " * string(Int8.(MIB))) ;
MIB: Int8[0, 30, 0, 3, 0, 4, 0, 0]

Conclusion

We have considered the features of the 5G library and the possibilities of interacting with the functionality of this library in the Engee environment.