Engee documentation
Notebook

The Scrambler

A scrambler is a software or hardware device (algorithm) that performs scrambling, that is, the reversible transformation of a digital stream without changing the transmission rate in order to obtain the properties of a random sequence.
This example implements scrambling with a "Pseudo Random Binary Sequence" (PRBS). This sequence is calculated due to the LFSR of length 15, given by the associated polynomial 1+ x14+x15 and the initial value 100101010000000. Also below is a picture describing the formula for the operation of a pseudorandom sequence generator.

image.png

Next, let's look at the implemented scrambling and descrambling scheme. It and a bitwise comparison of the operation of this algorithm are shown in the figure below.

image_2.png

Let's run this model using the startup function we described and save the results of the bit error.

In [ ]:
function run_model(name_model)
    Path = string(@__DIR__) * "/" * 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

run_model("Scrambler_descrambler")
Building...
Progress 100%
Out[0]:
Dict{String, DataFrames.DataFrame} with 2 entries:
  "Error Rate Calculation.Out" => 1001×2 DataFrame…
  "Selector.1"                 => 1001×2 DataFrame

Let's analyze the stored values. BER is zero for 1001 steps.

In [ ]:
# Считывание из simout сохранённых сигналов
BER = simout["Scrambler_descrambler/Error Rate Calculation.Out"];
BER = collect(BER)
BER[end-3:end,:]
Out[0]:

4 rows × 2 columns

timevalue
AnyAny
19.97[0.0, 0.0, 998.0]
29.98[0.0, 0.0, 999.0]
39.99[0.0, 0.0, 1000.0]
410.0[0.0, 0.0, 1001.0]

Conclusion

Based on the results of this demonstration, we explored the possibilities of implementing the scrambling method used in the DVB video transmission protocols of the second generation.