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

Reply

VHDL - n_bit_demux

 
Thread Tools Search this Thread
Old 12-09-2003, 11:05 AM   #1
Default n_bit_demux


Hi,
I try this:

>entity demultiplex is
> generic(N :integer := 4);
> port(X :in bit;
> Sel :integer range 0 to N-1;
> Y ut bit_vector(N-1 downto 0));
>end demultiplex;
>
>architecture dataflow of demultiplex is
>begin
> Y <= (Sel => X, others => '0');
>end dataflow;


but it does an error:

Y <= (Sel => X, others => '0');
|
non-locally static or null range choice must be only choice



Gietek
  Reply With Quote
Old 12-09-2003, 12:34 PM   #2
Egbert Molenkamp
 
Posts: n/a
Default Re: n_bit_demux
> but it does an error:
>
> Y <= (Sel => X, others => '0');
> |
> non-locally static or null range choice must be only choice


This will work

process
begin
Y <= (others=>'0');
Y(sel) <= X;
end process;

Egbert Molenkamp




Egbert Molenkamp
  Reply With Quote
Old 12-09-2003, 12:38 PM   #3
Nicolas Matringe
 
Posts: n/a
Default Re: n_bit_demux
Gietek a écrit:
> Hi,
> I try this:
>
> >entity demultiplex is
> > generic(N :integer := 4);
> > port(X :in bit;
> > Sel :integer range 0 to N-1;
> > Y ut bit_vector(N-1 downto 0));
> >end demultiplex;
> >
> >architecture dataflow of demultiplex is
> >begin
> > Y <= (Sel => X, others => '0');
> >end dataflow;

>
> but it does an error:
>
> Y <= (Sel => X, others => '0');
> |
> non-locally static or null range choice must be only choice


I suggested not so long ago but I hadn't tested it. It seems this is not
allowed. Use a process instead:

process (X, Sel)
begin
Y <= (others => '0');
Y(Sel) <= X;
end process;

(this works, I used it many times)

Nicolas





Nicolas Matringe
  Reply With Quote
Old 12-09-2003, 04:33 PM   #4
Charles M. Elias
 
Posts: n/a
Default Re: n_bit_demux
Gietek <> wrote in message news:<>...
> Hi,
> I try this:
>
> >entity demultiplex is
> > generic(N :integer := 4);
> > port(X :in bit;
> > Sel :integer range 0 to N-1;
> > Y ut bit_vector(N-1 downto 0));
> >end demultiplex;
> >
> >architecture dataflow of demultiplex is
> >begin
> > Y <= (Sel => X, others => '0');
> >end dataflow;

>
> but it does an error:
>
> Y <= (Sel => X, others => '0');
> |
> non-locally static or null range choice must be only choice


Gietek, try this:

architecture dataflow of demultiplex is
begin
p : process( sel )
begin
for i in 0 to N - 1 loop
if i = sel then
Y( i ) <= X;
else
Y( i ) <= '0';
end if;
end loop;
end process;
end;

Charles


Charles M. Elias
  Reply With Quote
Old 12-09-2003, 10:29 PM   #5
Paul Uiterlinden
 
Posts: n/a
Default Re: n_bit_demux
Egbert Molenkamp wrote:

>
> This will work


Not quite! The sensitivity list is missing.

> process

process(x, sel)
> begin
> Y <= (others=>'0');
> Y(sel) <= X;
> end process;


Paul.



Paul Uiterlinden
  Reply With Quote
Old 12-10-2003, 09:03 AM   #6
Gietek
 
Posts: n/a
Default Re: n_bit_demux

>
> Gietek, try this:
>
> architecture dataflow of demultiplex is
> begin
> p : process( sel )
> begin
> for i in 0 to N - 1 loop
> if i = sel then
> Y( i ) <= X;
> else
> Y( i ) <= '0';
> end if;
> end loop;
> end process;
> end;



Thank, this works. I mean compilation and simulation was successful on
Altera Max2plus. But here I work on Cadence and SimVision doesn't
simulate it. Bits and bit_vectors waveforms are unknown - "???"

>
> Charles




Gietek
  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




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