Synthesizable Verilog: A Practical Guide for Digital Design with Applications Including Machine Learning
Author(s): Olin Hartin
Edition: 1
Copyright: 2026
Pages: 328
Rather than presenting theoretical abstractions, the text focuses on discussion followed by over 170 code examples. Each example is carefully chosen to illuminate the critical differences between simulation semantics and synthesized hardware, specifically addressing how specific designs are interpreted by synthesis tools.
This practical focus results in a compilation of best practice rules that guide the reader toward a programming style that avoids synthesis-level warnings and focuses on the fundamentals of digital logic.
The treatment of arithmetic is particularly impressive. The book provides detailed methods and solutions for:
• Integer-preserving, fixed-point, and floating-point operations.
• Applications at multiple scales, ranging from digital filtering to modern machine learning kernels.
• Implementation strategies that ensure behavior in simulation matches the resulting physical hardware.
This book reflects a deep commitment to teaching and a thorough grasp of the nuances of microelectronics history and design. I am confident that it will serve as a trusted companion for students and engineers who seek to design hardware with clarity and professional rigor. I wholeheartedly recommend this work to anyone serious about mastering the art of digital design.
Dedication
Forward
Preface
How to Use This Text in a Course
Chapter 1 Introduction
1.1 References
Part I Introduction to the Verilog Language
Chapter 2 Verilog Language Reference
2.1 Structural Models
2.2 Continuous Assign Statements
2.3 Logic Signals
2.4 Arrays of Bits
2.5 Introduction to Multiplexers
2.6 Behavioral Models
2.7 Specifying Constants, and Avoiding Truncation
2.8 Logical, Bitwise and Reduction Boolean Operators
2.9 Conditional Assignments, Ternaries
2.10 Demultiplexers
2.11 Behavioral Models Containing Procedural Code
2.12 Case and MUX Design, Simulation, and Synthesis
2.13 Loops
2.14 Running a Testbench
2.15 Review and Coding Guidelines
2.16 Exercises
2.17 Reference
Chapter 3 Modules and Instantiation
3.1 Module Statements
3.2 Numerical Formats and Adding Binary Numbers
3.3 Negative Number Format 2’s Complement
3.4 Standard Module Example the ALU
3.5 Initialization and Default
3.6 More on Multiplexers
3.7 Review and Guidelines
3.8 Exercises
3.9 Reference
Chapter 4 Synchronous Logic
4.1 SR Flip-Flops
4.2 JK and T Flip-Flops
4.3 Variables, Constants, and Parameters
4.4 Using Replication and Concatenation
4.5 Errors in Verilog
4.6 Review and Focus Points
4.7 Exercises
4.8 References
Part II Boolean Simplification
Chapter 5 Review of Boolean Simplification
5.1 Boolean Properties
5.2 Boolean Simplification
5.3 Karnaugh Maps
5.4 Review
5.5 Exercises
5.6 References
Part III Synthesizable System Verilog
Chapter 6 System Verilog
6.1 Datatype Logic
6.2 Packed and Unpacked Arrays
6.3 Using always_comb, always_ff
6.4 Data Structures
6.5 Globals in System Verilog
6.6 Subroutines
6.7 More on Case Statements
6.8 Loops and Other Controls
6.9 Object-Oriented Code in System Verilog
6.10 Other Coding Simplifications in System Verilog
6.11 When and How to Use System Verilog
6.12 Review
6.13 Exercises
6.14 References
Part IV Fundamental RTL Design Techniques
Chapter 7 Registers and Shift Registers
7.1 Parameterized D Registers
7.2 A Register Storing a Vector of Arrays
7.3 Extending This to a Matrix of Arrays
7.4 Shift Registers
7.5 Review
7.6 Exercises
7.7 References
Chapter 8 Counters and Frequency Dividers
8.1 Verilog Counter Implementation
8.2 Some Rules for Combinational and Sequential Logic
8.3 Verilog Counters as Frequency Dividers
8.4 Pulse Width Modulation (PWM)
8.5 Review
8.6 Exercises
Chapter 9 Finite State Machines
9.1 Moore Machine That Detects Sequence 101 on Input
9.2 Mealy Machine That Detects Sequence 101 on Input
9.3 Using Enumerated Types
9.4 One Hot Coding
9.5 Review
9.6 Exercises
Chapter 10 Arithmetic Operations
10.1 Fast Adders
10.2 Multipliers
10.3 Divider
10.4 Signed Arithmetic
10.5 Arithmetic Using Operators +,−,*,/
10.6 Review
10.7 Exercises
Chapter 11 Testbenches
11.1 Basic Testbenches
11.4 Writing Simulation Results to a File
11.5 Assertions
11.6 Review
11.7 Exercises
Chapter 12 Timing Analysis and More
12.1 Timing Analysis and the SDC File
12.2 Timing Analysis and Slack
12.3 Hand Clocking
12.4 Review
12.5 Exercises
12.6 Reference
Part V Advanced Topics
Chapter 13 Integer Versus Fixed and Floating-Point
13.1 Integer Preserving Calculations
13.2 Fixed-Point
13.3 Review
13.4 Exercises
13.5 References
Chapter 14 Vector Operations Including Filtering Data
14.1 Combinational Loops
14.2 Building a Dot or Inner Product
14.3 Moving Average Filters and FIRs
14.4 ARMA Filters
14.5 Review
14.6 Exercises
14.7 References
Chapter 15 Pipelining
15.1 Pipelining a Full Adder
15.2 Pipelining a MAC
15.3 Pipelining a RISC Microprocessor
15.4 Review
15.5 Exercises
15.6 Reference
Chapter 16 Generating Random Numbers
16.1 Linear Feedback Shift Register (LFSR)
16.2 Review
16.3 Exercises
16.4 Reference
Chapter 17 IP blocks, Counters, and Memory
17.1 RAM, ROM, and ShiftReg
17.2 Multiplexer and Decode
17.3 Counter
17.4 PLL
17.5 MACs
17.6 Floating-Point
17.7 Use LPM_MUX in Quartus Design and Simulation
17.8 Review
17.9 Exercises
17.10 Reference
Chapter 18 Interfaces and Packages
18.1 Interfaces and Modport
18.2 Packages
18.3 Review
18.4 Reference
Chapter 19 Application to Machine Learning
19.1 Deployment of Machine Learning Solutions
19.2 Implementation of the Perceptron
19.3 Deployment of a Perceptron Model
19.4 Training of a Perceptron Model
19.5 Margin Perceptron and Support Vector Machine
19.6 Implementation of Neural Networks
19.7 Multi-Classification and Multi-Layer Neural Networks
19.8 Logistic Regression
19.9 Deploying a Decision Tree
19.10 Deploying a Convolutional Neural Network
19.11 Review
19.12 Exercises
19.13 References
Appendices
Appendix A Using ModelSim/Questa and Quartus
A.1 Downloading the Software
A.2 Installing the Software to Prototype Board Link—usb-Blaster
A.3 Quartus Display Problems
A.4 Entering Code
A.5 Library Work
A.6 Test Without a Testbench
A.7 Using a Testbench
A.8 Binding Errors
A.9 Waveform View
A.10 Synthesizing in Quartus
A.11 Programming the FPGA
A.12 Pin Planning
Appendix B Coding Standards
Appendix C Common Verilog Errors
Appendix D Shortcuts
D.1 Simplified Module Instantiation
D.2 Simplified Constants
Reference
Appendix E Compiler Directives
Appendix F Field Programmable Gate Arrays (or FPGAs)
Appendix G How to Write a Program
G.1 Debugging
Appendix H Studying for This Class (or Any Class)
Appendix I Comparison Between Verilog and VHDL
References
Appendix J Labs
Appendix K Glossary
References
Olin Hartin is a professor of practice in the School of Electrical, Computer and Energy Engineering at Arizona State University. Hartin has more than 30 years of expertise in science and technology for Fortune 500 companies. He has 25 patents on file and has co-authored more than 60 journal articles and conference presentations. His research interests focus on advanced device technologies and materials.
Rather than presenting theoretical abstractions, the text focuses on discussion followed by over 170 code examples. Each example is carefully chosen to illuminate the critical differences between simulation semantics and synthesized hardware, specifically addressing how specific designs are interpreted by synthesis tools.
This practical focus results in a compilation of best practice rules that guide the reader toward a programming style that avoids synthesis-level warnings and focuses on the fundamentals of digital logic.
The treatment of arithmetic is particularly impressive. The book provides detailed methods and solutions for:
• Integer-preserving, fixed-point, and floating-point operations.
• Applications at multiple scales, ranging from digital filtering to modern machine learning kernels.
• Implementation strategies that ensure behavior in simulation matches the resulting physical hardware.
This book reflects a deep commitment to teaching and a thorough grasp of the nuances of microelectronics history and design. I am confident that it will serve as a trusted companion for students and engineers who seek to design hardware with clarity and professional rigor. I wholeheartedly recommend this work to anyone serious about mastering the art of digital design.
Dedication
Forward
Preface
How to Use This Text in a Course
Chapter 1 Introduction
1.1 References
Part I Introduction to the Verilog Language
Chapter 2 Verilog Language Reference
2.1 Structural Models
2.2 Continuous Assign Statements
2.3 Logic Signals
2.4 Arrays of Bits
2.5 Introduction to Multiplexers
2.6 Behavioral Models
2.7 Specifying Constants, and Avoiding Truncation
2.8 Logical, Bitwise and Reduction Boolean Operators
2.9 Conditional Assignments, Ternaries
2.10 Demultiplexers
2.11 Behavioral Models Containing Procedural Code
2.12 Case and MUX Design, Simulation, and Synthesis
2.13 Loops
2.14 Running a Testbench
2.15 Review and Coding Guidelines
2.16 Exercises
2.17 Reference
Chapter 3 Modules and Instantiation
3.1 Module Statements
3.2 Numerical Formats and Adding Binary Numbers
3.3 Negative Number Format 2’s Complement
3.4 Standard Module Example the ALU
3.5 Initialization and Default
3.6 More on Multiplexers
3.7 Review and Guidelines
3.8 Exercises
3.9 Reference
Chapter 4 Synchronous Logic
4.1 SR Flip-Flops
4.2 JK and T Flip-Flops
4.3 Variables, Constants, and Parameters
4.4 Using Replication and Concatenation
4.5 Errors in Verilog
4.6 Review and Focus Points
4.7 Exercises
4.8 References
Part II Boolean Simplification
Chapter 5 Review of Boolean Simplification
5.1 Boolean Properties
5.2 Boolean Simplification
5.3 Karnaugh Maps
5.4 Review
5.5 Exercises
5.6 References
Part III Synthesizable System Verilog
Chapter 6 System Verilog
6.1 Datatype Logic
6.2 Packed and Unpacked Arrays
6.3 Using always_comb, always_ff
6.4 Data Structures
6.5 Globals in System Verilog
6.6 Subroutines
6.7 More on Case Statements
6.8 Loops and Other Controls
6.9 Object-Oriented Code in System Verilog
6.10 Other Coding Simplifications in System Verilog
6.11 When and How to Use System Verilog
6.12 Review
6.13 Exercises
6.14 References
Part IV Fundamental RTL Design Techniques
Chapter 7 Registers and Shift Registers
7.1 Parameterized D Registers
7.2 A Register Storing a Vector of Arrays
7.3 Extending This to a Matrix of Arrays
7.4 Shift Registers
7.5 Review
7.6 Exercises
7.7 References
Chapter 8 Counters and Frequency Dividers
8.1 Verilog Counter Implementation
8.2 Some Rules for Combinational and Sequential Logic
8.3 Verilog Counters as Frequency Dividers
8.4 Pulse Width Modulation (PWM)
8.5 Review
8.6 Exercises
Chapter 9 Finite State Machines
9.1 Moore Machine That Detects Sequence 101 on Input
9.2 Mealy Machine That Detects Sequence 101 on Input
9.3 Using Enumerated Types
9.4 One Hot Coding
9.5 Review
9.6 Exercises
Chapter 10 Arithmetic Operations
10.1 Fast Adders
10.2 Multipliers
10.3 Divider
10.4 Signed Arithmetic
10.5 Arithmetic Using Operators +,−,*,/
10.6 Review
10.7 Exercises
Chapter 11 Testbenches
11.1 Basic Testbenches
11.4 Writing Simulation Results to a File
11.5 Assertions
11.6 Review
11.7 Exercises
Chapter 12 Timing Analysis and More
12.1 Timing Analysis and the SDC File
12.2 Timing Analysis and Slack
12.3 Hand Clocking
12.4 Review
12.5 Exercises
12.6 Reference
Part V Advanced Topics
Chapter 13 Integer Versus Fixed and Floating-Point
13.1 Integer Preserving Calculations
13.2 Fixed-Point
13.3 Review
13.4 Exercises
13.5 References
Chapter 14 Vector Operations Including Filtering Data
14.1 Combinational Loops
14.2 Building a Dot or Inner Product
14.3 Moving Average Filters and FIRs
14.4 ARMA Filters
14.5 Review
14.6 Exercises
14.7 References
Chapter 15 Pipelining
15.1 Pipelining a Full Adder
15.2 Pipelining a MAC
15.3 Pipelining a RISC Microprocessor
15.4 Review
15.5 Exercises
15.6 Reference
Chapter 16 Generating Random Numbers
16.1 Linear Feedback Shift Register (LFSR)
16.2 Review
16.3 Exercises
16.4 Reference
Chapter 17 IP blocks, Counters, and Memory
17.1 RAM, ROM, and ShiftReg
17.2 Multiplexer and Decode
17.3 Counter
17.4 PLL
17.5 MACs
17.6 Floating-Point
17.7 Use LPM_MUX in Quartus Design and Simulation
17.8 Review
17.9 Exercises
17.10 Reference
Chapter 18 Interfaces and Packages
18.1 Interfaces and Modport
18.2 Packages
18.3 Review
18.4 Reference
Chapter 19 Application to Machine Learning
19.1 Deployment of Machine Learning Solutions
19.2 Implementation of the Perceptron
19.3 Deployment of a Perceptron Model
19.4 Training of a Perceptron Model
19.5 Margin Perceptron and Support Vector Machine
19.6 Implementation of Neural Networks
19.7 Multi-Classification and Multi-Layer Neural Networks
19.8 Logistic Regression
19.9 Deploying a Decision Tree
19.10 Deploying a Convolutional Neural Network
19.11 Review
19.12 Exercises
19.13 References
Appendices
Appendix A Using ModelSim/Questa and Quartus
A.1 Downloading the Software
A.2 Installing the Software to Prototype Board Link—usb-Blaster
A.3 Quartus Display Problems
A.4 Entering Code
A.5 Library Work
A.6 Test Without a Testbench
A.7 Using a Testbench
A.8 Binding Errors
A.9 Waveform View
A.10 Synthesizing in Quartus
A.11 Programming the FPGA
A.12 Pin Planning
Appendix B Coding Standards
Appendix C Common Verilog Errors
Appendix D Shortcuts
D.1 Simplified Module Instantiation
D.2 Simplified Constants
Reference
Appendix E Compiler Directives
Appendix F Field Programmable Gate Arrays (or FPGAs)
Appendix G How to Write a Program
G.1 Debugging
Appendix H Studying for This Class (or Any Class)
Appendix I Comparison Between Verilog and VHDL
References
Appendix J Labs
Appendix K Glossary
References
Olin Hartin is a professor of practice in the School of Electrical, Computer and Energy Engineering at Arizona State University. Hartin has more than 30 years of expertise in science and technology for Fortune 500 companies. He has 25 patents on file and has co-authored more than 60 journal articles and conference presentations. His research interests focus on advanced device technologies and materials.