{
"cells": [
{
"cell_type": "markdown",
"id": "18a7076e",
"metadata": {},
"source": [
"# PRBS\n",
"Tutorial illustrating the use of ROOT::Math::LFSR::GenerateSequence\n",
"can be run with:\n",
"\n",
"```cpp\n",
"root > .x PRBS.C\n",
"root > .x PRBS.C+ with ACLIC\n",
"```\n",
"\n",
"These values match the PRBS sequences generated by a Keysight waveform generator\n",
"except for the N first bits that appear at the end rather than at the beginning\n",
"\n",
"\n",
"\n",
"\n",
"**Author:** Fernando Hueso-González \n",
"This notebook tutorial was automatically generated with ROOTBOOK-izer from the macro found in the ROOT repository on Tuesday, May 19, 2026 at 08:27 PM."
]
},
{
"cell_type": "code",
"execution_count": 1,
"id": "dc0db7b6",
"metadata": {
"collapsed": false,
"execution": {
"iopub.execute_input": "2026-05-19T20:27:08.403598Z",
"iopub.status.busy": "2026-05-19T20:27:08.403489Z",
"iopub.status.idle": "2026-05-19T20:27:08.721588Z",
"shell.execute_reply": "2026-05-19T20:27:08.721026Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n",
"LFSR::GenerateSequence PRBS3, PRBS4 and PRBS5 tests\n",
"==========================\n"
]
}
],
"source": [
"printf(\"\\nLFSR::GenerateSequence PRBS3, PRBS4 and PRBS5 tests\\n\");\n",
"printf(\"==========================\\n\");"
]
},
{
"cell_type": "markdown",
"id": "f2a0b7bb",
"metadata": {},
"source": [
"PRBS3"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "0723ca3d",
"metadata": {
"collapsed": false,
"execution": {
"iopub.execute_input": "2026-05-19T20:27:08.723374Z",
"iopub.status.busy": "2026-05-19T20:27:08.723252Z",
"iopub.status.idle": "2026-05-19T20:27:09.056564Z",
"shell.execute_reply": "2026-05-19T20:27:09.056044Z"
}
},
"outputs": [],
"source": [
"std::array taps3 = {3, 2}; // Exponents of the monic polynomial\n",
"auto prbs3 = ROOT::Math::LFSR::GenerateSequence(std::bitset<3>().flip(), taps3); // Start value all high"
]
},
{
"cell_type": "markdown",
"id": "911a8651",
"metadata": {},
"source": [
"PRBS4"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "fc44aff9",
"metadata": {
"collapsed": false,
"execution": {
"iopub.execute_input": "2026-05-19T20:27:09.058719Z",
"iopub.status.busy": "2026-05-19T20:27:09.058578Z",
"iopub.status.idle": "2026-05-19T20:27:09.264388Z",
"shell.execute_reply": "2026-05-19T20:27:09.263754Z"
}
},
"outputs": [],
"source": [
"std::array taps4 = {4, 3}; // Exponents of the monic polynomial\n",
"auto prbs4 = ROOT::Math::LFSR::GenerateSequence(std::bitset<4>().flip(), taps4); // Start value all high"
]
},
{
"cell_type": "markdown",
"id": "2164750e",
"metadata": {},
"source": [
"PRBS5"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "aaded2ca",
"metadata": {
"collapsed": false,
"execution": {
"iopub.execute_input": "2026-05-19T20:27:09.266435Z",
"iopub.status.busy": "2026-05-19T20:27:09.266305Z",
"iopub.status.idle": "2026-05-19T20:27:09.468746Z",
"shell.execute_reply": "2026-05-19T20:27:09.468129Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"PRBS period 7:\t0 0 1 0 1 1 1 \n",
"PRBS period 15:\t0 0 0 1 0 0 1 1 0 1 0 1 1 1 1 \n",
"PRBS period 31:\t0 0 0 1 1 0 1 1 1 0 1 0 1 0 0 0 0 1 0 0 1 0 1 1 0 0 1 1 1 1 1 \n"
]
}
],
"source": [
"std::array taps5 = {5, 3}; // Exponents of the monic polynomial\n",
"auto prbs5 = ROOT::Math::LFSR::GenerateSequence(std::bitset<5>().flip(), taps5); // Start value all high\n",
"\n",
"for (auto prbs : {prbs3, prbs4, prbs5}) {\n",
" std::cout << \"PRBS period \" << prbs.size() << \":\\t\";\n",
" for (auto p : prbs) {\n",
" std::cout << static_cast(p) << \" \";\n",
" }\n",
" std::cout << std::endl;\n",
"}"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "ROOT C++",
"language": "c++",
"name": "root"
},
"language_info": {
"codemirror_mode": "text/x-c++src",
"file_extension": ".C",
"mimetype": " text/x-c++src",
"name": "c++"
}
},
"nbformat": 4,
"nbformat_minor": 5
}