Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > VHDL > Question about conditional assignment

Reply
Thread Tools

Question about conditional assignment

 
 
Rebecca
Guest
Posts: n/a
 
      03-23-2007
Hello, all

I want to implement the following logic
if(C_ControlBits=0) then
NULL;
else
Addr(C_ControlBits-1 downto 0) <= (others=>'0');
end if;
Because C_ControlBits-1 will become -1 when C_ControlBits=0.
C_ControlBits is declared as constant in my design. But what's the
synthesizable VHDL code for this? I tried to put it into process but
failed.

Thanks for any hints,
Rebecca

 
Reply With Quote
 
 
 
 
Jim Lewis
Guest
Posts: n/a
 
      03-23-2007
Rebecca,
I would have to see more code to make a reasonable guess, so
instead I will make a blind guess. Often in a process
I find it handy to first initialize the entire array to
0 and then later over-write only the bits I need to set.

In this situation I would replace the conditional code
with:
Addr <= (others=>'0');
Addr(C_ControlBits+3 downto C_ControlBits) <= "1111" ;


Cheers,
Jim

> Hello, all
>
> I want to implement the following logic
> if(C_ControlBits=0) then
> NULL;
> else
> Addr(C_ControlBits-1 downto 0) <= (others=>'0');
> end if;
> Because C_ControlBits-1 will become -1 when C_ControlBits=0.
> C_ControlBits is declared as constant in my design. But what's the
> synthesizable VHDL code for this? I tried to put it into process but
> failed.
>
> Thanks for any hints,
> Rebecca
>

 
Reply With Quote
 
 
 
 
Brian Drummond
Guest
Posts: n/a
 
      03-24-2007
On 23 Mar 2007 10:34:22 -0700, "Rebecca" <>
wrote:

>Hello, all
>
>I want to implement the following logic
> if(C_ControlBits=0) then
> NULL;
> else
> Addr(C_ControlBits-1 downto 0) <= (others=>'0');
> end if;
>Because C_ControlBits-1 will become -1 when C_ControlBits=0.
>C_ControlBits is declared as constant in my design. But what's the
>synthesizable VHDL code for this? I tried to put it into process but
>failed.
>
>Thanks for any hints,


Another wild guess...
look at "if ... generate" and "for ... generate"

- Brian

 
Reply With Quote
 
Rebecca
Guest
Posts: n/a
 
      03-26-2007
Jim:

I want to implement this
Addr(15 downto C_controlBits) <= SignalB;
if(C_ControlBits=0) then
NULL;
else
Addr(C_ControlBits-1 downto 0) <= (others=>'0');
end if;



And your suggestion is what I can use.
But is that a good idear to overwite it? I know it is handy, but would
it cause problem for syncrounous design because it induces extra delay/
unstable phases and then probably data hazard?

Thanks,
Hongyan

 
Reply With Quote
 
Rebecca
Guest
Posts: n/a
 
      03-26-2007
Sorry I didn't describe it clear, Brian. What I want to implement is

Addr(15 downto C_controlBits) <= SignalB;
if(C_ControlBits=0) then
NULL;
else
Addr(C_ControlBits-1 downto 0) <= (others=>'0');
end if;

I can't use the generated stuff here.

Thank you,
Rebecca

 
Reply With Quote
 
Rebecca
Guest
Posts: n/a
 
      03-26-2007
Jim:

I want to implement this
Addr(15 downto C_controlBits) <= SignalB;
if(C_ControlBits=0) then
NULL;
else
Addr(C_ControlBits-1 downto 0) <= (others=>'0');
end if;

Sorry that I didn't describe it clear and you had to guess. You
suggestion is what I needed.
But is that a good idear to overwite it? I know it is handy, but would
it cause problem for syncrounous design because it induces extra
delay/
unstable phases and then probably data hazard?

Thank you very much,
Rebecca


 
Reply With Quote
 
Andy
Guest
Posts: n/a
 
      03-27-2007
If this has to be sequential code (inside a process), then Jim's
solution works fine:

Addr <= (others => '0');
Addr(15 downto C_controlBits) <= SignalB;

If this is supposed to be concurrent statements, then generate will
work, since C_control_bits must be static because signalB is of static
width.

Addr(15 downto C_controlBits) <= SignalB;
if C_controlBits /= 0 generate
Addr(C_ControlBits-1 downto 0) <= (others=>'0');
end generate;

Take your pick.

andy

On Mar 26, 10:36 am, "Rebecca" <pang.dudu.p...@hotmail.com> wrote:
> Sorry I didn't describe it clear, Brian. What I want to implement is
>
> Addr(15 downto C_controlBits) <= SignalB;
> if(C_ControlBits=0) then
> NULL;
> else
> Addr(C_ControlBits-1 downto 0) <= (others=>'0');
> end if;
>
> I can't use the generated stuff here.
>
> Thank you,
> Rebecca



 
Reply With Quote
 
Rebecca
Guest
Posts: n/a
 
      03-28-2007
Thank you so much, Andy. I need both in my design.
Thanks a lot,
Rebecca

 
Reply With Quote
 
Rebecca
Guest
Posts: n/a
 
      03-28-2007
Thank you so much, Andy. I need both in my design.
Thanks a lot,
Rebecca

 
Reply With Quote
 
 
 
Reply

Thread Tools

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 Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to write a conditional assignment over generic or constant? sm.soimu@gmail.com VHDL 2 04-25-2006 10:00 AM
? ELSE Conditional Comment / Using Conditional Comments Inside Other Tags To Comment Out Attributes Alec S. HTML 10 04-16-2005 02:21 AM
Conditional assignment to signals Johnsy Joseph VHDL 8 09-24-2004 11:02 AM
Comparison of Bit Vectors in a Conditional Signal Assignment Statement Anand P Paralkar VHDL 2 08-04-2003 08:40 PM
Help: conditional attribute assignment itsme VHDL 1 07-23-2003 03:26 PM



Advertisments