AleksandarK (talk | contribs) |
AleksandarK (talk | contribs) |
||
Line 14: | Line 14: | ||
endmodule //ending | endmodule //ending | ||
</syntaxhighlight> | </syntaxhighlight> | ||
+ | In Verilog, you use <code>//</code> to add commentary on the line you wish to high lite | ||
+ | |||
+ | Now we are going to make basic AND gate. | ||
+ | First, we need to know how the AND gate looks, what it does and how it operates. When you need to know that about some other module, but you don't, easiest way around it is to google the module. But when you find code, don't copy it, but rather study it. Write down the characteristics of it and start building the module in your head. | ||
+ | |||
+ | AND gate takes A and B input and combines them into output Y, so based on that we do the following | ||
+ | <syntaxhighlight lang="cpp"> | ||
+ | module andgate (a, b, y); // module name | ||
+ | input a, b; //input of the module | ||
+ | output y; //module output | ||
+ | assign y = a & b; //assigned operation of the module | ||
+ | endmodule | ||
+ | </syntaxhighlight> | ||
+ | We can note a few thing from this example. First, at the end of each line, we use semicolon(;). | ||
+ | And second, you may notice that there is assign operation which tells the module what to do. In this case, it told the module that <code>y</code> equaled the sum of <code>a & b</code> |
Revision as of 12:29, 25 March 2018
INTRODUCTION
Verilog is a HDL(Hardware Description Language) and HVL(Hardware Verification Language) made for describing, modeling and simulating circuits. It is used at early front-end IC design.
Verilog has a few iterations: Verilog 95, Verilog 2001, Verilog 2005 and SystemVerilog. All of the new revisions have added something new and useful. The latest update was a SystemVerilog(SV). It was declared that SV is a superset of Verilog, and it is backwards compatible with it. That means that all of Verilog code can be run in SystemVerilog simulators and design tools. Only thing that SV added is better Verification methodology like UVM and OVM style of testbenches.
Syntax
Verilog is a static, weakly typed style language similar to C in some aspects. It is case sensitive(meaning that there is difference between "a" and "A"), has preprocessor and has control flow keywords(allowing for if,else, for, while etc. statements to be implemented).
The basic look of every module is like the following:
module n //module name
module n declaration //declaration of the ports
endmodule //ending
In Verilog, you use //
to add commentary on the line you wish to high lite
Now we are going to make basic AND gate. First, we need to know how the AND gate looks, what it does and how it operates. When you need to know that about some other module, but you don't, easiest way around it is to google the module. But when you find code, don't copy it, but rather study it. Write down the characteristics of it and start building the module in your head.
AND gate takes A and B input and combines them into output Y, so based on that we do the following
module andgate (a, b, y); // module name
input a, b; //input of the module
output y; //module output
assign y = a & b; //assigned operation of the module
endmodule
We can note a few thing from this example. First, at the end of each line, we use semicolon(;).
And second, you may notice that there is assign operation which tells the module what to do. In this case, it told the module that y
equaled the sum of a & b