FPGA Central - World's 1st FPGA / CPLD Portal

FPGA Central

World's 1st FPGA Portal

 

Go Back   FPGA Groups > NewsGroup > Verilog

Verilog comp.lang.verilog newsgroup / usenet

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 03-07-2005, 05:42 AM
thomasc
Guest
 
Posts: n/a
Default global variables in Verilog

I want to find out if it is possible to use global variables in verilog
that are accessible from all the modules in a project(like in C) and if
so, how I can do it. Can anyone please explain using global variables in
Verilog?
Thanks much in advance!

Reply With Quote
  #2 (permalink)  
Old 03-07-2005, 01:08 PM
Neo
Guest
 
Posts: n/a
Default Re: global variables in Verilog

declare parameters in a seperate file and then use 'include <filename>
in all other files.

Reply With Quote
  #3 (permalink)  
Old 03-07-2005, 07:08 PM
Jason Zheng
Guest
 
Posts: n/a
Default Re: global variables in Verilog

thomasc wrote:
> I want to find out if it is possible to use global variables in verilog
> that are accessible from all the modules in a project(like in C) and if
> so, how I can do it. Can anyone please explain using global variables in
> Verilog?
> Thanks much in advance!
>

In a sense all variables in verilog are globally accessible by means of
hierarchical referencing. Hence you can conveniently declare all the
variables that you would like to consider "global" in your top-level
module, e.g. top.v. Then you can access them by top.a, top.b, etc.

-jz
Reply With Quote
  #4 (permalink)  
Old 03-08-2005, 12:13 AM
MysticSage
Guest
 
Posts: n/a
Default Re: global variables in Verilog

I hope this question is in regarding to simulation and modeling only.
Because for synthesis, global variable doesn't make sense.

Anyway in verilog, there is no sense of global variable as compared to
C. But you can have defines for some constant values (which are not
variable .

Parameters and other data types "has to" be declared inside a <module>.
And these can behave as "global" for tasks declared inside the
<module>. But it is not same as C.

Reply With Quote
  #5 (permalink)  
Old 03-08-2005, 12:32 AM
Jason Zheng
Guest
 
Posts: n/a
Default Re: global variables in Verilog

MysticSage wrote:
> I hope this question is in regarding to simulation and modeling only.
> Because for synthesis, global variable doesn't make sense.
>
> Anyway in verilog, there is no sense of global variable as compared to
> C. But you can have defines for some constant values (which are not
> variable .
>
> Parameters and other data types "has to" be declared inside a <module>.
> And these can behave as "global" for tasks declared inside the
> <module>. But it is not same as C.
>

That's true, my comment reguarding putting your global variables in the
top-level really only applies to test benches. In real RTL design you
should not reference signals across modular boundary, use an
input/output port instead.

jz
Reply With Quote
  #6 (permalink)  
Old 03-08-2005, 02:58 AM
thomasc
Guest
 
Posts: n/a
Default Re: global variables in Verilog

Thanks for the reply.

Even if I imagine a hardware, I guess it should be possible to have a
global variable and/or constants in a memory. Is it possible to design
hardware in such a way using Verilog?

Reply With Quote
  #7 (permalink)  
Old 03-08-2005, 07:14 AM
Andrew Dyer
Guest
 
Posts: n/a
Default Re: global variables in Verilog

On Mon, 07 Mar 2005 20:58:26 -0500, thomasc wrote:

> Thanks for the reply.
>
> Even if I imagine a hardware, I guess it should be possible to have a
> global variable and/or constants in a memory. Is it possible to design
> hardware in such a way using Verilog?


It's certainly possible to distribute a set of signals through
your code. Say you have a hierarchy like this:

top
core
cpu
alu
control
registers
uart
tx
rx
clkgen

if you had a bus coming from top.core.cpu.alu you would make it
an output port. In top.core.cpu you would hook up the output port
from the alu to an output port also and run it up to the top.core
level. You might also hook it to an input port on the registers
or control.

Then you could feed the bus as an input port back down into
top.core.uart.tx and rx and clkgen.

It ends up being a lot of 'plumbing', but because of the way
logic synthesizers are used, and the way blocks are laid out
in real chips, most of the time those wires really exist and
need to be accounted for - they have capacitance and inductance
and if you use too many of them your design slows down or area
used goes up.


Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
monitor variables without displaying them Schmigz Verilog 2 12-05-2004 07:37 AM
PKS 5.0/Ambit (Verilog) global define? hmmmm Verilog 0 06-21-2004 12:43 AM
Bits access of variables Anton Ng Verilog 0 05-08-2004 08:50 AM
Value of variables Johnsy Joseph Verilog 6 03-03-2004 11:26 PM
Updating global reg's from inside functions/tasks Jay Bhadra Verilog 1 11-18-2003 11:30 PM


All times are GMT +1. The time now is 01:27 PM.


Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2021, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0
Copyright 2008 @ FPGA Central. All rights reserved