Engee documentation
Notebook

Restoration of the main 5G information block

This example shows how to use the 5G library to synchronize, demodulate, and decode the gNodeB signal. In the example, the MIB and the first of the system information blocks (SIB1) are decoded.

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

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

In [ ]:
# Подключение библиотек
neededLibs = ["CSV"]
for lib in neededLibs
    try
        eval(Meta.parse("using $lib"))
    catch ex
        Pkg.add(lib)
        eval(Meta.parse("using $lib"))
    end
end
In [ ]:
# Пути до папок с файлами
path_model = "$(@__DIR__)/";

# Подключение библиотек
using DataFrames, CSV, Plots
include(path_model*"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;

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

  1. generation of the input signal and superimposition of the effects of the communication channel 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 generate data from it.

In [ ]:
run_model("MIB_5G", path_model)
Building...
Progress 0%
Progress 100%

Next, we will read the encoded signals from the CSV and analyze the communication system in more detail and the principles on the basis of which it is implemented. We will not focus on the generation of the input signal in this demonstration, but rather 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 spaced by half of the subcarrier.

Next, the received frequency-shifted signal is 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 what point the channel conditions were better.

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

The frequency shift estimate below half of the subcarrier is calculated by correlating the cyclic prefix of each OFDM symbol in the 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_model * "Frequency_offset.csv", DataFrame);
print("Смещение частоты на первом кадре: " * string(Frequency_offset[1,2])* " Гц") 
Waveform = Complex_CSV(path_model * "Waveform.csv");
plot(real(Waveform))
plot!(imag(Waveform))
Смещение частоты на первом кадре: 163.77603980991532 Гц
Out[0]:

Next, the receiver extracts the SSS-related elements from the resulting grid and correlates them with each possible SSS sequence generated locally.

Combining the indexes of the strongest PSS and SSS sequences gives the physical layer cell identity, which is necessary for processing PBCH DM-RS and PBCH.

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

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

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

Conclusion

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