Skip to content
geeksforgeeks
  • Tutorials
    • Python
    • Java
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
    • Practice Coding Problems
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • Aptitude
  • Engineering Mathematics
  • Discrete Mathematics
  • Operating System
  • DBMS
  • Computer Networks
  • Digital Logic and Design
  • C Programming
  • Data Structures
  • Algorithms
  • Theory of Computation
  • Compiler Design
  • Computer Org and Architecture
Open In App
Next Article:
What is Scrambling in Digital Electronics ?
Next article icon

What is Scrambling in Digital Electronics ?

Last Updated : 17 Mar, 2023
Comments
Improve
Suggest changes
Like Article
Like
Report

A computer network is designed to send information from one point to another. Data that we send can either be digital or analog. Also, signals that represent data can also be digital or analog. Thus to send data by using signals, we must be able to convert the data into signals, this conversion can be Analog to Analog, Analog to Digital, Digital to Analog, or Digital to Digital. Digital to Digital conversion involves three techniques - Line Coding, Block Coding, and Scrambling. Line Coding is always needed, whereas Block Coding and Scrambling may or may not be needed depending upon the need. Scrambling is a technique that does not increase the number of bits and does provide synchronization. The problem with techniques like Bipolar AMI(Alternate Mark Inversion) is that continuous sequence of zero's create synchronization problems one solution to this is Scrambling. 

Prerequisite: Block Coding, Line Coding 

There are two common scrambling techniques:

  1. B8ZS(Bipolar with 8-zero substitution)
  2. HDB3(High-density bipolar3-zero)

B8ZS(Bipolar with 8-zero substitution): This technique is similar to Bipolar AMI except when eight consecutive zero-level voltages are encountered they are replaced by the sequence, "000VB0VB". 

Note:

  • V(Violation), is a non-zero voltage which means the signal has the same polarity as the previous non-zero voltage. Thus it is a violation of the general AMI technique.
  • B(Bipolar), is also a non-zero voltage level that is in accordance with the AMI rule (i.e., opposite polarity from the previous non-zero voltage).
Example: Data = 100000000

B8ZS  

Note: Both figures (left and right one) are correct, depending upon the last non-zero voltage signal of the previous data sequence (i.e., sequence before current data sequence "100000000"). 

HDB3(High-density bipolar3-zero): In this technique, four consecutive zero-level voltages are replaced with a sequence "000V" or "B00V". Rules for using these sequences:

  • If the number of nonzero pulses after the last substitution is odd, the substitution pattern will be "000V", this helps in maintaining a total number of nonzero pulses even.
  • If the number of nonzero pulses after the last substitution is even, the substitution pattern will be "B00V". Hence even the number of nonzero pulses is maintained again.

HDB3

Example: Data = 1100001000000000

Output explanation: After representing the first two 1's of data we encounter four consecutive zeros. Since our last substitutions were two 1's(thus the number of non-zero pulses is even). So, we substitute four zeros with "B00V". 

Scrambling is a technique used in digital electronics to provide a known sequence of bits to allow for synchronization and detect errors. The code to implement scrambling will depend on the specific requirements of the system. Here is a simple example of a linear feedback shift register (LFSR) scrambler in C++:

C++
#include <bitset> #include <iostream>  const int LFSR_LENGTH = 8; const int TAP_POSITIONS[] = {8, 7, 6, 1};  int main() {     std::bitset<LFSR_LENGTH> lfsr;     std::cout << "Enter the starting state of the LFSR: ";     std::cin >> lfsr;          for (int i = 0; i < 32; ++i) {         int feedback = 0;         for (const auto tap_position : TAP_POSITIONS) {             feedback ^= lfsr[tap_position];         }                  lfsr = (lfsr << 1) | feedback;         std::cout << lfsr << std::endl;     }          return 0; } 
Java
// Java equivalent import java.util.Arrays;  public class Main {     static final int LFSR_LENGTH = 8;     static final int[] TAP_POSITIONS = {8, 7, 6, 1};     public static void main(String[] args) {         String lfsrStr;         System.out.println("Enter the starting state of the LFSR: ");         lfsrStr = System.console().readLine();         Long lfsr = Long.parseLong(lfsrStr, 2);         for (int i = 0; i < 32; ++i) {             int feedback = 0;             for (int tap_position : TAP_POSITIONS) {                 feedback ^= (lfsr >> tap_position) & 1;             }             lfsr = (lfsr << 1) | feedback;             System.out.println(Long.toBinaryString(lfsr));         }     } } 
C#
// C# equivalent using System;  public class MainClass  {     static readonly int LFSR_LENGTH = 8;     static readonly int[] TAP_POSITIONS = {8, 7, 6, 1};      public static void Main(string[] args)      {         string lfsrStr;         Console.WriteLine("Enter the starting state of the LFSR: ");         lfsrStr = Console.ReadLine();         long lfsr = Convert.ToInt64(lfsrStr, 2);         for (int i = 0; i < 32; ++i)          {             int feedback = 0;             foreach(int tap_position in TAP_POSITIONS)              {                 feedback ^= (int)(lfsr >> tap_position) & 1;             }             lfsr = (lfsr << 1) | feedback;             Console.WriteLine(Convert.ToString(lfsr, 2));         }     } } 

The output of this code will be the scrambled sequence generated by the linear feedback shift register (LFSR) for 32 clock cycles. The exact output will depend on the starting state of the LFSR, which is entered by the user. Here is an example of the output for a starting state of 01100101:

Enter the starting state of the LFSR: 01100101 11000100 01100010 10100010 01010001 10101000 01010100 10101010 01010101 10101101 01011010 10101111 01011110 10111100 01111000 11100000 01000000 10000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000

In this example, the LFSR is initialized with an 8-bit state. The TAP positions, which determine the feedback taps in the LFSR, are specified as {8, 7, 6, 1}. The LFSR is then clocked 32 times to generate the scrambled sequence. The output will be the scrambled sequence, where each line represents the state of the LFSR after each clock cycle.

Note: Zero non-zero pulses are also even.


Next Article
What is Scrambling in Digital Electronics ?

S

sanjal_katiyar
Improve
Article Tags :
  • Misc
  • Digital Logic
Practice Tags :
  • Misc

Similar Reads

    What is Register in Digital Electronics ?
    A register is a small and temporary storage unit inside a computer's (CPU). It plays a vital role in holding the data required by the CPU for immediate processing and is made up of flip-flops. It usually holds a limited amount of data ranging from 8 to 64 bits, depending on the processor architectur
    9 min read
    What is Digital Electronics and Logic Design?
    Digital electronics and logic design form the backbone of modern computing systems, controlling everything from smartphones to advanced computers. Digital electronics focuses on circuits that process binary data (0s and 1s). Logic design involves creating systems that perform specific functions usin
    6 min read
    Logic Synthesis in Digital Electronics
    The process of resolving into component parts or analyzing, interpreting, translating, optimizing (rearranging or rewriting to improve efficiency), and mapping RTL (Register Transfer Level) code into a particular and indicated cell library. Programmed production of logic components in a specific dig
    5 min read
    Digital Electronics and Computer Organisation
    Digital Electronics Half Adder Half Subtractor K-Map Counters Computer Organisation and Architecture Machine Instructions What’s difference between 1’s Complement and 2’s Complement? Addressing Modes Cache Memory Computer Arithmetic | Set – 1 Computer Arithmetic | Set – 2 Cache Organization | Set 1
    1 min read
    Block Coding in Digital Electronics
    The block coding is a technique through which much reliability is injected into the data that is sent over the network or kept in a device. It does this by adding extra information bits to every block of data; hence, it identifies the errors and corrects the same if it happens to occur on the way. B
    8 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences