Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Scope of variables and signals in VHDL and Verilog

Status
Not open for further replies.

Dijskstra

Newbie level 5
Newbie level 5
Joined
Jun 28, 2014
Messages
9
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Visit site
Activity points
93
Hi all,


I know that in VHDL we can declare local variables like this:

Code:
process(clk, reset)
    variable v : integer;
begin
    if (reset = '1') then
       v := 0;
    elsif rising_edge(clk) then
       v := v + 1;
end process;


In the same way, can we declare local signals like the code below?


Code:
process(clk, reset)
    signal s : integer;
begin
    if (reset = '1') then
       s <= 0;
    elsif rising_edge(clk) then
       s <= s + 1;
end process;


And what about in Verilog?


Thank you

Anders
 

No, a signal declaration is only valid in a declarative context of a region containing parallel processes, such as a block or an entity.

In the declarative part of a process you can only declare sequential stuff such as variables, procedures, functions to be used in that process.

See signal_declaration in the BNF:
http://www.pldworld.com/_hdl/1/www.ireste.fr/fdl/vcl/lesd/Vbnf.htm

It makes sense because signals are mainly used to communicate between processes.
 
To answer the Verilog part of this question, wires are defined in the declarative section of a module, just as signals are in VHDL. However, variables in Verilog may be defined the declarative or procedural section of your code.
 
Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top