video-scrambler
This repository is for "Development of a Composite Baseband Video Signal (CVBS) scrambler" thesis.
Description
This project contains:
- Verilog HDL implementation (Quartus Prime 23.1std project)
- simulation setup (Modelsim Starter Edition 2021.1 project)
- jupyter notebooks for visualization and validation of the algorithms
- KiCAD 9.0 PCB designs for ADV7393 video encoder and TVP5147M1 video decoder
The Verilog implementation is based around line rotation algorithm for scrambling,
Hash DRBG and SHA256 for number generation.
It works with BT656 and SMPTE293M digital signal.
Can synchronise the PRNGs even when the signal is lost.
The scrambling pattern is different for each frame.
The number of frames before the pattern repeats is 2^32.
The delay is ~ 10^-8 s
The PCB design has the following features:
- supplied with > 5V
- has 4 layers
- separated power plains
- all chips pins were wired to external pins (except chroma pins)
- equalized paths
Structure and use
To open each project you need the corresponding IDE
Notebooks
1. notebooks/config_creation
It contains scripts for generating 256-bit seeds and putting them into .mif files for configuring the scrambler.
Generates complementary config files for the scrambler and descramber,
2. notebooks/functional_validation
It was used to rewrite high-level python implementation
into verilog-friendly algorithm
3. notebooks/mp_to_bt656
It contains a notebook used for converting .mp4 video to .bin file compliant with bt656.
Additionally, it is used for visualization the scrambled and descrambled videos and contains the entropy calculations
Also, it has two videos: aperol.mp4 and church.mp4.
For simulation the user must convert the videos to
aperol_f84.bin and church_f218.bin and put them into
FPGA/core/simulation/modelsim/data or FPGA/core/simulation/questa/data
4. notebooks/randomness_validation
It was used to validate that the generated random numbers are random
5. notebooks/resource_usage
It was used to produce plots of resource usage as compiled by Quartus
Verilog HDL implementation
scrambler_mm is the top module
FPGA/core contains the quartus project
FPGA/core/src contains rtl and tb code
FPGA/core/include contains rtl written by other developers
Simulation setup
FPGA/core/simulation/modelsim contains the modelsim project
To provide the data for the simulation
you must put it into FPGA/core/simulation/modelsim/data.
currently the simulations accepts only two types of files: files generated from aperol_f84.bin or church_f218.bin.
if you want to change it, you must modify the testbench with names of your files.
Once they are in there, open the project with modelsim, goto project, see a sim folder and in there run
de/scrambler_mm_sim. Run the scrambler first, and then the descrambler.
The results will be in FPGA/core/simulation/modelsim/data folder.

FPGA/core/simulation/questa is generated by quartus for RTL and Gate Level simulations.
It was only used for GLS of scrambler_mm, because quartus has a bad interface for simulation,
when the top module changes frequently.
When doing the GLS the user MUST CHANGE THE MIF FILE (for the corresponding functionality)
AND UPDATE THE MIF FILE (in quartus) OR RECOMPILE when switching
between scrambling (scrambler_mm_gls_tb)
and descrambling(descrambler_mm_gls_tb) simulations.
This is because in gate level simulation the mif file is compiled into the tested module.
PCB
PCB/ADV7393BCPZ_encoder contains the KiCAD project with the corresponding chip
PCB/TVP5147M1_decoder contains the KiCAD project with the corresponding chip
AND the TVP5147M1_decoder and ADV7393BCPZ_encoder on the same PCB
Results
It contains scrambled and descrambled videos
scrambled

descrambled
