Verilog Tutorial By Deepak Kumar Tala http://www.com 1 DISCLAIMER I don't makes any claims, promises or guarantees about the accuracy, completeness, or adequacy of the contents of this tutorial and expressly disclaims liability for errors and omissions in the contents of this tutorial. No warranty of any kind, implied, expressed or statutory, including but not limited to the warranties of non−infringement of third party rights, title, merchantability, fitness for a particular purpose and freedom from computer virus, is given with respect to the contents of this tutorial or its hyperlinks to other Internet resources. Reference in this tutorial to any specific commercial products, processes, or services, or the use of any trade, firm or corporation name is for the information, and does not constitute endorsement, recommendation, or favoring by me. All the source code and Tutorials are to be used on your own risk.
All the ideas and views in this tutorial are my own and are not by any means related to my employer.com 2 INTRODUCTION CHAPTER 1 www.com 3 Introduction Verilog is a HARDWARE DESCRIPTION LANGUAGE (HDL). A hardware description Language is a language used to describe a digital system, for example, a network switch, a microprocessor or a memory or a simple flip−flop. This just means that, by using a HDL one can describe any hardware (digital ) at any level. 1// D flip−flop Code 2module d_ff ( d, clk, q, q_bar); 3input d ,clk; 4output q, q_bar; 5wire d ,clk; 6reg q, q_bar; 7 8always @ (posedge clk) 9begin 10 q <= d; 11 q_bar <= !d; 12end 13 14endmodule One can describe a simple Flip flop as that in above figure as well as one can describe a complicated designs having 1 million gates.
Verilog is one of the HDL languages available in the industry for designing the Hardware. Verilog allows us to design a Digital design at Behavior Level, Register Transfer Level (RTL), Gate level and at switch level. Verilog allows hardware designers to express their designs with behavioral constructs, deterring the details of implementation to a later stage of design in the final design. Many engineers who want to learn Verilog, most often ask this question, how much time it will take to learn Verilog?, Well my answer to them is "It may not take more then one week, if you happen to know at least one programming language".
Design Styles Verilog like any other hardware description language, permits the designers to design a design in either Bottom−up or Top−down methodology. Bottom−Up Design The traditional method of electronic design is bottom−up. Each design is performed at the gate−level using the standard gates ( Refer to the Digital Section for more details) With increasing www.com INTRODUCTION 4 complexity of new designs this approach is nearly impossible to maintain. New systems consist of ASIC or microprocessors with a complexity of thousands of transistors.
These traditional bottom−up designs have to give way to new structural, hierarchical design methods. Without these new design practices it would be impossible to handle the new complexity. Top−Down Design The desired design−style of all designers is the top−down design. A real top−down design allows early testing, easy change of different technologies, a structured system design and offers many other advantages.
But it is very difficult to follow a pure top−down design. Due to this fact most designs are mix of both the methods, implementing some key elements of both design styles. Figure shows a Top−Down design approach. Abstraction Levels of Verilog Verilog supports a design at many different levels of abstraction.
Three of them are very important: • Behavioral level www.com INTRODUCTION 5 • Register−Transfer Level • Gate Level Behavioral level This level describes a system by concurrent algorithms (Behavioral). Each algorithm itself is sequential, that means it consists of a set of instructions that are executed one after the other. Functions, Tasks and Always blocks are the main elements. There is no regard to the structural realization of the design.
Register−Transfer Level Designs using the Register−Transfer Level specify the characteristics of a circuit by operations and the transfer of data between the registers. An explicit clock is used. RTL design contains exact timing possibility, operations are scheduled to occur at certain times. Modern definition of a RTL code is "Any code that is synthesizable is called RTL code".
Gate Level Within the logic level the characteristics of a system are described by logical links and their timing properties. All signals are discrete signals. They can only have definite logical values (`0', `1', `X', `Z`). The usable operations are predefined logic primitives (AND, OR, NOT etc gates).
Using gate level modeling might not be a good idea for any level of logic design. Gate level code is generated by tools like synthesis tools and this netlist is used for gate level simulation and for backend.com INTRODUCTION 6 NOTES −− −− −− −− −− −− −− −− −− −− −− −− −− −− −− −− −− −− −− −− −− −− −− −− −− −− −− −− −− −− −− −− −− −− −− −− −− −− www.com INTRODUCTION 7 HISTORY OF VERILOG CHAPTER 2 www.com HISTORY OF VERILOG 8 History Of Verilog Verilog was started initially as a proprietary hardware modeling language by Gateway Design Automation Inc. It is rumored that the original language was designed by taking features from the most popular HDL language of the time, called HiLo as well as from traditional computer language such as C. At that time, Verilog was not standardized and the language modified itself in almost all the revisions that came out within 1984 to 1990.
Verilog simulator was first used beginning in 1985 and was extended substantially through 1987.The implementation was the Verilog simulator sold by Gateway. The first major extension was Verilog−XL, which added a few features and implemented the infamous "XL algorithm" which was a very efficient method for doing gate−level simulation. The time was late 1990. Cadence Design System, whose primary product at that time included Thin film process simulator, decided to acquire Gateway Automation System.
Along with other Gateway product, Cadence now became the owner of the Verilog language, and continued to market Verilog as both a language and a simulator. At the same time, Synopsys was marketing the top−down design methodology, using Verilog. This was a powerful combination. In 1990, Cadence recognized that if Verilog remained a closed language, the pressures of standardization would eventually cause the industry to shift to VHDL.
Consequently, Cadence organized Open Verilog International (OVI), and in 1991 gave it the documentation for the Verilog Hardware Description Language. This was the event which "opened" the language. OVI did a considerable amount of work to improve the Language Reference Manual (LRM), clarifying things and making the language specification as vendor−independent as possible. Soon it was realized, that if there were too many companies in the market for Verilog, potentially everybody would like to do what Gateway did so far − changing the language for their own benefit.
This would defeat the main purpose of releasing the language to public domain. As a result in 1994, the IEEE 1364 working group was formed to turn the OVI LRM into an IEEE standard. This effort was concluded with a successful ballot in 1995, and Verilog became an IEEE standard in December, 1995. When Cadence gave OVI the LRM, several companies began working on Verilog simulators.
In 1992, the first of these were announced, and by 1993 there were several Verilog simulators available from companies other than Cadence. The most successful of these was VCS, the Verilog Compiled Simulator, from Chronologic Simulation. This was a true compiler as opposed to an interpreter, which is what Verilog−XL was. As a result, compile time was substantial, but simulation execution speed was much faster.
In the meantime, the popularity of Verilog and PLI was rising exponentially. Verilog as a HDL found more admirers than well−formed and federally funded VHDL. It was only a matter of time before people in OVI realized the need of a more universally accepted standard. Accordingly, the board of directors of OVI requested IEEE to form a working committee for establishing Verilog as an IEEE standard.
The working committee 1364 was formed in mid 1993 and on October 14, 1993, it had www.com HISTORY OF VERILOG 9 its first meeting. The standard, which combined both the Verilog language syntax and the PLI in a single volume, was passed in May 1995 and now known as IEEE Std. After many years, new features have been added to Verilog, and new version is called Verilog 2001. This version seems to have fixed lot of problems that Verilog 1995 had.
This version is called 1364−2000. Only waiting now is that all the tool vendors implementing it.com HISTORY OF VERILOG 10 NOTES −− −− −− −− −− −− −− −− −− −− −− −− −− −− −− −− −− −− −− −− −− −− −− −− −− −− −− −− −− −− −− −− −− −− −− −− −− −− www.com HISTORY OF VERILOG 11 DESIGN AND TOOL FLOW CHAPTER 3 www.com DESIGN AND TOOL FLOW 12 Introduction Being new to Verilog you might want to try some examples and try designing something new. I have listed the tool flow that could be used to achieve this. I have personally tried this flow and found this to be working just fine for me.
Here I have taken only front end design part of the tool flow and bit of FPGA design flow that can be done without any fat money spent on tools. If you have any suggestions or questions please don't hesitate to mail me. ( Note : I have missed steps in P&R, Will add then shortly) Various stages of ASIC/FPGA • Specification : Word processor like Word, Kwriter, AbiWord, Open Office. • High Level Design : Word processor like Word, Kwriter, AbiWord, for drawing waveform use tools like waveformer or testbencher or Word, Open Office.
• Micro Design/Low level design: Word processor like Word, Kwriter, AbiWord, for drawing waveform use tools like waveformer or testbencher or Word. For FSM StateCAD or some similar tool, Open Office. • RTL Coding : Vim, Emacs, conTEXT, HDL TurboWriter • Simulation : Modelsim, VCS, Verilog−XL, Veriwell, Finsim, iVerilog, VeriDOS. • Synthesis : Design Compiler, FPGA Compiler, Synplify, Leonardo Spectrum.
You can download this from FPGA vendors like Altera and Xilinx for free. • Place & Route : For FPGA use FPGA' vendors P&R tool. ASIC tools require expensive P&R tools like Apollo. Students can use LASI, Magic.
• Post Si Validation : For ASIC and FPGA, the chip needs to be tested in real environment. Board design, device drivers needs to be in place. Figure : Typical Design flow www.com DESIGN AND TOOL FLOW 13 Specification This is the stage at which we define what are the important parameters of the system/design that you are planning to design. Simple example would be, like I want to design a counter, it should be 4 bit wide, should have synchronous reset, with active high enable, When reset is active, counter output should go to "0".
You can use Microsoft Word, or GNU Abiword or Openoffice for entering the specification. High Level Design This is the stage at which you define various blocks in the design and how they communicate. Lets assume that we need to design microprocessor, High level design means splitting the design into blocks based on their function, In our case various blocks are registers, ALU, Instruction Decode, Memory Interface, etc. You can use Microsoft Word, or KWriter or Abiword or Openoffice for entering high level design.com DESIGN AND TOOL FLOW 14 Figure : I8155 High Level Block Diagram Micro Design/Low level design Low level design or Micro design is the phase in which, designer describes how each block is implemented.
It contains details of State machines, counters, Mux, decoders, internal registers. For state machine entry you can use either Word, or special tools like StateCAD.