Site Logo
Find in
This is TikiWiki 1.9.7 -Sirius- © 2002–2006 by the Tiki community Thu 09 of Sep, 2010 [05:47 UTC]
Login
[ register | I forgot my password ]
Menu [hide]
 Home
 Contact us
 Stats
 Categories
 Calendar
Toggle  Wiki
 Wiki Home
 Last Changes
 Dump
 Rankings
 List pages
 Orphan pages
 Sandbox
 Print
Toggle  Blogs
 List blogs
 Rankings

Verilog Lesson 1

3D browser print PDF
English
Verilog Lesson 1 by T. Miller
Picking something out of a hat, I thought today, it would be good to start by discussing nothing but signals. Signals are binary digital numbers. They're wires that go between logic gates. They carry information without performing any computation. Signals are very important for transporting data, and they underlie everything else that we'll do.

The most basic kind of signal is the "wire". The wire is used for continuous assignment. That is, if you have an expression, you can associate the result of that expression with a named wire, and then you can use that wire name in another expression. It's a lot like a variable, but you cannot reassign it. The value of the wire is directly a function of what's assigned to it, and you can only assign one thing.

Here's a single-bit wire:
wire a;

You can assign some other signal, say 'b', to it, like this:
assign a = b;

Or you can define and assign it in the same statement:
wire a = b;

You can have multi-bit wires:
wire [3:0] c;

A multi-bit wire is also called a "bus". Assigning to them just the same:
wire [3:0] d;
assign c = d;

The range of bits in a wire can any two numbers. That is, these are also valid:
wire [11:4] e;
wire [0:255] f;

Given a wire, you can select individual bits, which is to say that you
can pick out a bit from a vector of bits:
wire g;
assign g = f[2];  // assign bit 2 of f to g;

The bit-select can be variable:
wire [7:0] h;
wire i = f[h];

You can do bit slices, but the range must be constants:
wire [3:0] j = e[7:4];

You can also have arrays of wires (in most dialects of Verilog):
wire [7:0] k [0:20];  // An array of twenty-one 8-bit busses

There's another kind of signal element called a "reg". A reg is assigned in behavioral code, which we'll explain later. A reg will be much like a wire for behavioral code that is combinatorial, or it will correspond to a physical register (a flip-flop or group of flip-flops) in synchronous logic.

Regs are defined similarly to wires:
reg [3:0] m;
reg [0:100] n;

They can be treated just like wires on the right-hand-side of an expression:
wire [1:0] p = m[2:1];

You can also have arrays of regs, which we usually refer to as a RAM:
reg [7:0] q [0:15];  // 16-entry memory of 8-bit words

One other sometimes useful kind of signal is the integer. It's like a reg, but it's fixed at 32 bits and is the only signed datatype.
integer loop_count;

Verilog allows you to group logic into blocks. A block of logic is called a "module". Modules have inputs and outputs that behave very much like wires.

Modules first list their ports:
module my_module_name (port_a, port_b, w, y, z);

And then define the directions of their ports:
input port_a;
output [6:0] port_b;
input [0:4] w;
inout y;  // bidirectional signal, mostly used on external pins

Later, we'll see that you can override the wire-ness of an output for behavioral logic by also declaring it to be a reg:
output [3:0] z;
reg [3:0] z;

Now we can treat inputs like wires:
wire r = w[1];

And make continuous assignments to outputs:
assign port_b = h[6:0];

The last kind of 'signal' we'll talk about in this lesson is the constant sort of signal, which is to say a number:
wire [12:0] s = 12;                    // 32-bit decimal that gets truncated
wire [3:0] t = 4'b0101;                // explicitly sized 4-bit binary
wire [63:0] u = 64'hdeadbeefcafebabe;  // 64-bit hex

If you don't specify a size, it's 32 bits, which can cause problems for larger-sized bit vectors.

These numbers are just like any sort of number, which can be used in an expression. Skipping ahead to math, for instance, you can add 1 to a number:
wire [3:0] aa;
wire [3:0] bb;
assign bb = aa + 1;

Created by: hamish last modification: Saturday 06 of October, 2007 [13:34:13 UTC] by asdf


source
history
similar
21 comments

Posted messages

Top Hide all
author message
bartodeo
Make continuous
on: Fri 18 of Jun, 2010 [03:48 UTC] score: 0.00
Make continuous assignments to outputs
TV Episodes Guide


author message
hidebr
Re: Make continuous
on: Sun 22 of Aug, 2010 [13:05 UTC] score: 0.00
> Make continuous assignments to outputs
and criação de sites and desenvolvimento de site and Unhas and Esmaltes and Tokio Hotel and Tokio Hotel Magazine and Escola de Surf and Web site e Home page and Portal and Loja Virtual and E-Commerce and Hotsite em Flash and Integração com Cielo and Configuração Google-Mini and Sistemas Web and Sistemas CRM e ERP and Camisetas and Tshirt


author message
aaddad
cheap ugg boots
on: Wed 18 of Aug, 2010 [11:06 UTC] score: 0.00
http://www.salesuggsboots.com/ugg-classic-cardy-c-5.html|womens ugg boots



author message
vuitton
Re: Make continuous
on: Wed 11 of Aug, 2010 [22:57 UTC] score: 0.00
Thanks a lot for enjoying this beauty article with me. I am apreciating it very much! Looking forward to another great article. Good luck to the author! all the best!
louis vuitton verona mm louis vuitton daniel gm louis vuitton josephine wallet

louis vuitton neverfull gm


author message
bradblack
I was surfing
on: Sat 07 of Aug, 2010 [07:14 UTC] score: 0.00
I was surfing net and fortunately came across this site and found very interesting stuff here. Its really fun to read. I enjoyed a lot. Thanks for sharing this wonderful information. watch resident evil: afterlife online | watch ramona and beezus online | watch salt online | watch cats and dogs: the revenge of kitty galore online | watch charlie st. cloud online


author message
Tarun004
Re: Make continuous
on: Thu 05 of Aug, 2010 [15:06 UTC] score: 0.00
Open graphics project is very nice to see in all scenario for all phase of project creation.
However I am form Programming field but there are a lot of things which I have to understand too.Kidney stones treatmentHome Automation |DUI Lawyer | | government jobs | Freshers Jobs


author message
adword033
Re: Make continuous
on: Tue 03 of Aug, 2010 [15:18 UTC] score: 0.00

Thanks for taking the time to discuss this, I feel strongly about it and love learning more on this topic. If possible, as you gain expertise, would you mind updating your blog with extra information? It is extremely helpful for me.
Golf in Mallorca


author message
EmailMarketing
Email Marketing
on: Mon 26 of Jul, 2010 [14:02 UTC] score: 0.00
I was surfing net and fortunately came across this site and found very interesting stuff here. Its really fun to read. I enjoyed a lot. Thanks for sharing this wonderful information.
Email Marketing



author message
duke
Re: Email Marketing
on: Thu 02 of Sep, 2010 [06:38 UTC] score: 0.00
> I was surfing net and fortunately came across this site and found very interesting stuff here. Its really fun to read. I enjoyed a lot. Thanks for sharing this wonderful information.
> Email Marketing
>
thanks for the link
kidney infection symptoms
make money online
completely free dating sites
adidas goalkeeper gloves


author message
EmailMarketing
Business Gifts
on: Mon 26 of Jul, 2010 [14:02 UTC] score: 0.00
The post is very nicely written and it contains many useful facts. I am happy to find your distinguished way of writing the post. Now you make it easy for me to understand and implement. Thanks for sharing with us.
Business Gifts
SEO Company




Page: 1/2  [next]
1  2 

RSS Wiki RSS Blogs
Übersetzen Sie diese Seite ins Deutsche
Traduzca esta paginación a español
Traduisez cette page en français
Tradurre questa pagina in italiano
Traduza esta página em portuguêses
翻译这页成汉语 (CN)
日本語にこのページを翻訳しなさい (Nihongo)
한국인으로 이 페이지를 번역하십시요 (Hangul)
[ Execution time: 0.84 secs ]   [ Memory usage: 7.47MB ]   [ 158 database queries used ]   [ GZIP Disabled ]   [ Server load: 0.09 ]
How buy cialis 20mg online
kamagra 100mg How download mp3 music online
sex dating