Welcome, To Be Efficient


Saturday, June 27, 2009

Verilog

Introduction
Verilog allows us to describe a system based on a structure of wires, gates, registers, and
delays using a systematic language. This language is unlike most other programming languages,
where they read like steps in a recipe. Instead, Verilog is written so that most components
respond in parallel, simultaneously.
First Verilog Program
By using your favorite text processor, you can type in Verilog code to be run using
Verilog and simulated in SignalScan. The simplest type of Verilog code is similar to that found in
Prog.1.
// Prog.1: Simple Verilog Code.
module top();
wire out;
reg a, b;
assign out = a & b;
initial
begin
a = 1'b0;
b = 1'b0;
#10;
a = 1'b0;
b = 1'b1;
#10;
a = 1'b1;
b = 1'b1;
#10;
a = 1'b1;
b = 1'b0;
#10;
$dumpflush;
end
initial
begin
$monitor("a=%b, b=%b, out=%b, time=%t\n", a, b, out, $time);
$dumpfile("top.dump");
$dumpvars(5, top);
end
endmodule


Comments
Let's start by examining the code step by step. The first line is a comment defined by the
two slashes. In any program, anything that follows two slashes is ignored by Verilog.
Modules
Modules are what define components in Verilog. They are remarkably similar to functions
or procedures in other languages because given input, they can produce specific output. The
module shown, top, has no input and output, making it self contained. It will be the first module
evaluated when Verilog is run because of this.
A more general module follows the following form:
module modulename(in1, in2, ..., inout1, ..., out1, ...)
input in1, in2, ...;
inout inout1, ...;
output out1, ...;

endmodule
The modulename can be replaced with any name of the module. Although the inputs,
input/outputs, and outputs can be placed in any order within the module's parameters, it is good
to be consistent where you place them within the list. The keywords, input, inout, and output are
used to define the direction that data can flow through the node named by the parameter. These
keywords are used just like the wire and reg keywords which we'll discuss in more depth later.
The module body or text is a list of expressions that define the system. Modules are always
terminated by the keyword, endmodule.
Defining Wires and Registers
In this example, single bit wires and registers are used, although Verilog allows multi-bit
sized wires (buses) and registers to be defined. Wires, registers, inputs, input/outputs, and
outputs are all defined in the same fashion. The only difference being the keyword used.
input a, b;
output [2:0] out;
wire wire1, wire2, a, b;
wire [7:0] byte;
reg [31:0] wordreg;
A name by itself represents a single bit, or wire node. To produce buses, or larger arrays
of bits, the bracketed expression is placed before the name. [2:0] defines 3 bits, 2 through 0.
[7:0] defines 8 bits, 7 through 0. [31:0] defines 32 bits, 31 through 0.
Registers and wires cannot be used everywhere. In the simple program, out is a wire, and
a and b are registers. This is required because out appears at the left hand side of an assign
expression, and a and b appear at the left hand side of '=' signs in the initial expression.

No comments:

Post a Comment

Blog Widget by LinkWithin

Disclaimer

.........................................................................................................................................................
The all content are through my experiences, that i have learn in going through my studies and in building projects, some of were taken from some web sites, books and other sources, where i have visited and learn VLSI, I am very thankful to them for having those valuable things, which make me more efficient in VLSI, and i have added those all in my experience. If any of these content violets copyrights, please contact me i will try to resolve and will do the needful assistance. Thank you all very much.
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................