n_bit_demux

G

Gietek

Hi,
I try this:
entity demultiplex is
generic(N :integer := 4);
port(X :in bit;
Sel :integer range 0 to N-1;
Y :eek: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
 
E

Egbert Molenkamp

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
 
N

Nicolas Matringe

Gietek a écrit:
Hi,
I try this:


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
 
C

Charles M. Elias

Gietek said:
Hi,
I try this:


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
 
G

Gietek

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 - "???"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,159
Messages
2,570,879
Members
47,416
Latest member
LionelQ387

Latest Threads

Top