Hello! Welcome to the first lesson in your journey to prepare for the Open Silicon Bootcamp.
Today, we'll start with the absolute foundation of digital logic: number systems. Your goal is to become proficient in digital design and Verilog, and understanding how numbers are represented in hardware is the first crucial step. By the end of this 60-minute lesson, you will be able to confidently convert numbers between the three most important systems in digital electronics: decimal, binary, and hexadecimal.
This knowledge is essential because digital circuits, at their core, operate using binary logic (on/off states). We use decimal for our everyday calculations and hexadecimal as a convenient shorthand for long binary numbers, something you'll encounter constantly when writing Verilog code and debugging designs.
Let's begin!
1. The Big Three: Decimal, Binary, and Hexadecimal
All number systems, including the familiar decimal system, are built on the concept of place value. The position of a digit determines its value, which is based on powers of the system's base (or radix).
- Decimal (Base-10): Uses ten digits (0-9). Each place value is a power of 10.
- Binary (Base-2): Uses two digits (0 and 1). Each place value is a power of 2.
- Hexadecimal (Base-16): Uses sixteen digits (0-9 and A-F). Each place value is a power of 16.
To get a clear overview of these systems and how they relate, please watch the following video.
Number Systems - Converting Decimal, Binary and Hexadecimal
This video provides a great introduction to the concept of number systems and then walks through the process of converting between them. We will watch it in segments.
Watch the following three segments: What is a number system? (0:04 - 1:45): This part uses the decimal system to explain the core idea of place values. Introduction to Binary (1:45 - 3:40): Focus on how binary counting works and how place values are powers of 2. Introduction to Hexadecimal (8:40 - 10:44): Pay attention to the 16 digits used (0-9, A-F) and the crucial relationship between hexadecimal and 4-bit binary numbers.
To help you visualize the relationships, here is a handy conversion table for the numbers 0 through 15. You will find this table invaluable as you work through conversions.

2. Converting Between Systems
Now that you have a conceptual understanding, let's dive into the mechanics of conversion.
Decimal and Binary Conversion
This is the most fundamental conversion, as it connects our human-readable numbers to the machine-readable format.
- Binary to Decimal: To convert a binary number to decimal, you multiply each binary digit by its corresponding power of 2 and sum the results.
- Decimal to Binary: To convert a decimal number to binary, you can use successive division by 2 and record the remainders. The video demonstrates a slightly different but intuitive method of subtracting the largest possible power of 2.
Let's see these methods in action.
Number Systems - Converting Decimal, Binary and Hexadecimal
Let's return to the video from 'Programming and Math Tutorials' to see how to perform these conversions step-by-step.
Watch these two segments carefully: Binary to Decimal Conversion (3:40 - 6:34): Follow the example of converting 10100110 to decimal. The table visualization is very helpful. Decimal to Binary Conversion (6:34 - 8:40): Observe the method used to convert the decimal number 75 to its binary equivalent.
Practice Exercise:
- Convert the binary number
110101to decimal. - Convert the decimal number
53to binary.
Click to see the solutions.
-
Binary
110101to Decimal: -
Decimal
53to Binary:
Using the subtraction method:- The largest power of 2 less than or equal to 53 is 32 (). Remainder:
53 - 32 = 21. (Bit 5 is 1) - The largest power of 2 less than or equal to 21 is 16 (). Remainder:
21 - 16 = 5. (Bit 4 is 1) - 8 () is greater than 5. (Bit 3 is 0)
- The largest power of 2 less than or equal to 5 is 4 (). Remainder:
5 - 4 = 1. (Bit 2 is 1) - 2 () is greater than 1. (Bit 1 is 0)
- The largest power of 2 less than or equal to 1 is 1 (). Remainder:
1 - 1 = 0. (Bit 0 is 1)
Reading the bits from 5 down to 0, we get
110101. - The largest power of 2 less than or equal to 53 is 32 (). Remainder:
Binary and Hexadecimal Conversion
This is the most important conversion pair in digital design. Because 16 is , there is a direct and simple relationship: one hexadecimal digit represents exactly four binary digits (bits).
This makes conversion incredibly fast and is why engineers use hex—it's a compact, human-friendly way to write long binary strings.
The SparkFun tutorial 'Hexadecimal' provides an excellent explanation of this process. Let's focus on the section for converting between binary and hex.
Please read the section titled 'Converting To/From Binary'. Focus on the method of grouping binary digits into sets of four. The examples for converting 0b101111010100001 to hex and 0xDEADBEEF to binary are particularly illustrative.
The image below shows this grouping process visually.

Practice Exercise:
- Convert the binary number
111010010110to hexadecimal. - Convert the hexadecimal number
0x1AFto binary.
Click to see the solutions.
-
Binary
111010010110to Hex:- Group into fours from the right:
111010010110 - Convert each group:
1110= E1001= 90110= 6
- Result:
0xE96
- Group into fours from the right:
-
Hex
0x1AFto Binary:- Convert each hex digit to four bits:
1=0001A=1010F=1111
- Combine them:
000110101111 - Result:
000110101111(leading zeros are often dropped unless a specific width is required, so110101111is also correct).
- Convert each hex digit to four bits:
Decimal and Hexadecimal Conversion
While you can convert between decimal and hex by going through binary, it's also useful to know the direct method.
- Hex to Decimal: Similar to binary-to-decimal, but you use powers of 16.
- Decimal to Hex: Similar to decimal-to-binary, but you use successive division by 16.
Number Systems - Converting Decimal, Binary and Hexadecimal
Let's watch the final segments of the video, which cover these two conversion types.
Watch these two segments: Hexadecimal to Decimal (12:35 - 13:37): See how A7 is converted to decimal using powers of 16. Decimal to Hexadecimal (13:37 - 15:24): Follow the division/remainder method to convert 697 to hexadecimal.
3. A Glimpse into Verilog
You might be wondering how you'll actually use this. In Hardware Description Languages (HDLs) like Verilog, you must specify the size and base of the numbers you are defining. This prevents ambiguity and ensures your hardware behaves as expected.
The syntax in Verilog is '<base><value>. For example:
8'd42: An 8-bit decimal number with the value 42.8'b00101010: The same value, written as an 8-bit binary number.8'h2A: The same value again, written as an 8-bit hexadecimal number.
To see a few more examples, let's look at a short article.
Numbers in Verilog - Project F
This article from Project F shows how numbers are represented in Verilog. You don't need to read the whole thing, just a specific section on number syntax.
Please read the section titled 'Literals'. Focus on the syntax for specifying the width (e.g., 12'b...), the base ('b, 'd, 'h), and how to write numbers in different bases. Don't worry about 'signed' vs 'unsigned' for now; we'll cover that in the next lesson.
This direct application in Verilog is why mastering number systems is not just a theoretical exercise—it's a practical necessity for every digital designer.
Conclusion
Excellent work! You've taken the first step into the world of digital logic. In this lesson, we established the groundwork for everything that follows.
Here are the key takeaways:
- Digital systems use binary (base-2), but we often use hexadecimal (base-16) as a more compact, human-readable format.
- Converting between binary and hexadecimal is a simple matter of grouping or ungrouping sets of 4 bits. This is the most frequent conversion you'll do.
- Converting to and from decimal involves multiplying by powers of the base (for binary/hex to decimal) or using successive division (for decimal to binary/hex).
- In Verilog, you explicitly define a number's bit-width and base (e.g.,
4'b1111is the 4-bit binary equivalent of1'hF).
In our next lesson, we will build directly on this foundation to explore "Binary arithmetic operations using two's complement representation." You'll learn how digital circuits perform addition and subtraction, including how they handle negative numbers.