Go Back   Velocity Reviews > Newsgroups > VHDL
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply

VHDL - Variable to signal assignment

 
Thread Tools Search this Thread
Old 04-29-2005, 10:35 AM   #1
Default Variable to signal assignment


Hello all
I was wondering if it was possible (read synthesizable) to assign a
variable to a signal in a clocked process *outside* the reset/clock
edge condition.

My basic idea is to use a variable instead of an intermediate signal.
Here is what I have in mind (basic "heartbeat" led)

process (clk, rst) is
variable cntr : natural range 0 to DIV - 1;
variable led : std_ulogic;
begin -- process
if rst = '1' then
cntr <= 0;
led := '0';
elsif rising_edge(clk) then
if clk_en = '1' then
if cntr = 0 then
cntr <= DIV - 1;
led := not led;
else
cntr := cntr - 1;
end if;
end if;
end if;
htbt_led <= led; -- <- is this OK?
end process;

Nicolas


Nicolas Matringe
  Reply With Quote
Old 04-29-2005, 11:10 AM   #2
charles.elias@wpafb.af.mil
 
Posts: n/a
Default Re: Variable to signal assignment
Yes.

Best regards,

Charles



charles.elias@wpafb.af.mil
  Reply With Quote
Old 04-29-2005, 03:26 PM   #3
Mike Treseler
 
Posts: n/a
Default Re: Variable to signal assignment
Nicolas Matringe wrote:

> I was wondering if it was possible (read synthesizable) to assign a
> variable to a signal in a clocked process *outside* the reset/clock
> edge condition.


Yes. This works as expected to wire a
variable value to a port or signal output.
It synthesizes a wire cleanly for
all tools I have tested it on.

Because the statement.

htbt_led <= led_v;

is executed for both edges of
clock and reset, the signal/port output
reset style *automatically* matches the
the output variable, and a duplicate
output register is avoided.

Logic other than output assignments
should be kept inside the if statement
to avoid synthesis of flops using
the falling clock edge.

Note that you can accomplish the same
thing *inside* the if statement
by manually matching a signal/port reset to
the output variable, that is

if rst = '1' then
cntr <= 0;
led := '0'; -- variable reset assignment
htbt_led <= '0' -- matching port/signal assignment
elsif rising_edge(clk) then
-- etc


-- Mike Treseler


Mike Treseler
  Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

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

Similar Threads
Thread Thread Starter Forum Replies Last Post
I am having trouble editing a signal in a sub program. Haai Hardware 0 08-28-2007 02:58 PM
Need help on Modelsim VHDL syntax? ASAP:) kaji General Help Related Topics 0 03-14-2007 10:43 PM
Need help on a Modelsim VHDL Syntax? ASAP:) kaji Software 0 03-14-2007 10:43 PM
Need Help on a Modelsim VHDL Syntax....ASAP:) kaji Hardware 0 03-14-2007 10:41 PM
Variable Scope in asp.Net jansi_rk Software 1 09-18-2006 06:05 PM




SEO by vBSEO 3.3.2 ©2009, Crawlability, Inc.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46