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

Reply

VHDL - Multiplexer

 
Thread Tools Search this Thread
Old 06-14-2006, 04:17 PM   #1
Default Multiplexer


Hi,

I am trying to build a multiplexer. It has two select lines . When its
'11', it selects A when its '00' it selects B . Now, i do not want to
select anything else and maintain A or B at its output even the select
line changes to anything else like "01" or "10"... How can I do that .
I saw may examples and found that { when others => A <= ( others =>
'X' ) }

John.



john
  Reply With Quote
Old 06-14-2006, 04:52 PM   #2
Rtafas
 
Posts: n/a
Default Re: Multiplexer
Have you ever considered reading some digital systems book and/or heard
about flip-flops or latches? VHDL and it's "a lot more understandable"
with this knowledge. You shoud *really* do this.

You must use a process to save information. Flip-flops and latches are
generetade only this way. Something like:

process(clk)
begin
if clk'event and clk = '1' then
if sel_lines = "11" then
out <= a;
elsif sel_lines = "00" then
out <= b;
end if;
end if;
end process;

What you have been reading was about assyncronous logic (gates). It
won't save any value for you.

Regards,

Ricardo

john escreveu:

> Hi,
>
> I am trying to build a multiplexer. It has two select lines . When its
> '11', it selects A when its '00' it selects B . Now, i do not want to
> select anything else and maintain A or B at its output even the select
> line changes to anything else like "01" or "10"... How can I do that .
> I saw may examples and found that { when others => A <= ( others =>
> 'X' ) }
>
> John.




Rtafas
  Reply With Quote
Old 06-14-2006, 06:18 PM   #3
john
 
Posts: n/a
Default Re: Multiplexer
Hi Rtafas,
Thanks for ur reply! Have you ever considered to read writers like
shakespear or milton or books like Bible or Quran or intorduction to
ethics. If not, you should read them, before you die. because
engineering or sciences , did take alot of common sense from your
brain.
I had a simple confusion about the mux. I apologize that I put it on
the group. But you do not have to answer it if you think its too simple
for u. why did u bother to answer it. let it answer by other people.
Regards
John



john
  Reply With Quote
Old 06-14-2006, 07:03 PM   #4
Mike Treseler
 
Posts: n/a
Default Re: Multiplexer
john wrote:
> I am trying to build a multiplexer.


http://www.google.com/search?q=vhdl+...xample+process


Mike Treseler
  Reply With Quote
Old 06-14-2006, 07:06 PM   #5
Rtafas
 
Posts: n/a
Default Re: Multiplexer
Hey, calm down buddy. You sound a little nervous.

You had a doubt. I've made some suggestion, and it was a very good and
important one. You really should consider reading a good digital
systems book (that is not an offense, its a resonable hint due to your
question: you do not seem experienced in digital design and if so,
sorry then). Then I´ve replied your question with a piece of code and
I gave you a good explanation. No need for flaming.

Maybe you should take things with a more technical view than a personal
one, because no one is here to flame you. I won't give you a hug after
answering any question.

Sorry for the joke, regards

RTafas

john escreveu:

> Hi Rtafas,
> Thanks for ur reply! Have you ever considered to read writers like
> shakespear or milton or books like Bible or Quran or intorduction to
> ethics. If not, you should read them, before you die. because
> engineering or sciences , did take alot of common sense from your
> brain.
> I had a simple confusion about the mux. I apologize that I put it on
> the group. But you do not have to answer it if you think its too simple
> for u. why did u bother to answer it. let it answer by other people.
> Regards
> John




Rtafas
  Reply With Quote
Old 06-14-2006, 09:02 PM   #6
john
 
Posts: n/a
Default Re: Multiplexer
Hi,
I am sorry that I sounded angry or flaming. I do believe that u do need
to study those books and writers atleast once in ur lifetime for ur own
good. The materail, I mentioned is easily available at barnes and
nobles or any book shop in any counrty of the world. i will recommed
Hamlet by shakespear and bible. Please read them. Thanks again for ur
piece of code and reply.
Bye
John



john
  Reply With Quote
Old 06-14-2006, 11:02 PM   #7
Andy
 
Posts: n/a
Default Re: Multiplexer
You do not have to have an _explicit_ process to save information:

q <= d when rising_edge(clk); -- flip flop

q <= d when en = '1'; -- latch

output <= a when sel = '11' else b when sel = '00'; -- mux + latch

That said, latches are not generally a good idea in ASICs and FPGAs.

Andy


Rtafas wrote:
> Have you ever considered reading some digital systems book and/or heard
> about flip-flops or latches? VHDL and it's "a lot more understandable"
> with this knowledge. You shoud *really* do this.
>
> You must use a process to save information. Flip-flops and latches are
> generetade only this way. Something like:
>
> process(clk)
> begin
> if clk'event and clk = '1' then
> if sel_lines = "11" then
> out <= a;
> elsif sel_lines = "00" then
> out <= b;
> end if;
> end if;
> end process;
>
> What you have been reading was about assyncronous logic (gates). It
> won't save any value for you.
>
> Regards,
>
> Ricardo
>
> john escreveu:
>
> > Hi,
> >
> > I am trying to build a multiplexer. It has two select lines . When its
> > '11', it selects A when its '00' it selects B . Now, i do not want to
> > select anything else and maintain A or B at its output even the select
> > line changes to anything else like "01" or "10"... How can I do that .
> > I saw may examples and found that { when others => A <= ( others =>
> > 'X' ) }
> >
> > John.




Andy
  Reply With Quote
Old 06-14-2006, 11:34 PM   #8
Rtafas
 
Posts: n/a
Default Re: Multiplexer
A very good point. Have you tried using a reset? Something like:

q <= d when clk'event and clk = '1' else '0' when rst = '1';

I imagine that using a clock enable, must be this way.

q <= d when clk'event and clk = '1' and clken = '1' else '0' when rst =
'1';

If synthesizable, it is an interesting aprouch. Have you tried such
situations?


Andy escreveu:

> You do not have to have an _explicit_ process to save information:
>
> q <= d when rising_edge(clk); -- flip flop
>
> q <= d when en = '1'; -- latch
>
> output <= a when sel = '11' else b when sel = '00'; -- mux + latch
>
> That said, latches are not generally a good idea in ASICs and FPGAs.
>
> Andy
>
>
> Rtafas wrote:
> > Have you ever considered reading some digital systems book and/or heard
> > about flip-flops or latches? VHDL and it's "a lot more understandable"
> > with this knowledge. You shoud *really* do this.
> >
> > You must use a process to save information. Flip-flops and latches are
> > generetade only this way. Something like:
> >
> > process(clk)
> > begin
> > if clk'event and clk = '1' then
> > if sel_lines = "11" then
> > out <= a;
> > elsif sel_lines = "00" then
> > out <= b;
> > end if;
> > end if;
> > end process;
> >
> > What you have been reading was about assyncronous logic (gates). It
> > won't save any value for you.
> >
> > Regards,
> >
> > Ricardo
> >
> > john escreveu:
> >
> > > Hi,
> > >
> > > I am trying to build a multiplexer. It has two select lines . When its
> > > '11', it selects A when its '00' it selects B . Now, i do not want to
> > > select anything else and maintain A or B at its output even the select
> > > line changes to anything else like "01" or "10"... How can I do that .
> > > I saw may examples and found that { when others => A <= ( others =>
> > > 'X' ) }
> > >
> > > John.




Rtafas
  Reply With Quote
Old 06-15-2006, 09:15 AM   #9
Jonathan Bromley
 
Posts: n/a
Default Re: Multiplexer
On 14 Jun 2006 10:18:50 -0700, "john" <> wrote:

> Have you ever considered to read writers like
> shakespear or milton or books like Bible or Quran or intorduction to
>ethics. If not, you should read them, before you die. because
>engineering or sciences , did take alot of common sense from your
>brain.


It is entirely possible to be a good engineer who also possesses
common-sense and some familiarity with both high culture and
ethics. It is, however, impossible to be a good engineer
without first finding out something about what other
engineers have done in the past. Consequently, the advice
you received to consult a standard digital design text was
well-considered and highly appropriate.

As others have pointed out, it is perfectly possible to mix
Shakespeare and HDLs:

architecture soliloquy of prince_of_denmark is
signal question: bit_vector (7 downto 0);
begin
question <= X"2B" OR (NOT X"2B");
end;

Milton may be a little trickier, and of course Goedel is
in principle impossible to express in any finite
programming language
--
Jonathan Bromley, Consultant

DOULOS - Developing Design Know-how
VHDL * Verilog * SystemC * e * Perl * Tcl/Tk * Project Services

Doulos Ltd., 22 Market Place, Ringwood, BH24 1AW, UK

http://www.MYCOMPANY.com

The contents of this message may contain personal views which
are not the views of Doulos Ltd., unless specifically stated.


Jonathan Bromley
  Reply With Quote
Old 06-15-2006, 09:53 AM   #10
Martin Thompson
 
Posts: n/a
Default Re: Multiplexer
"Rtafas" <> writes:

> A very good point. Have you tried using a reset? Something like:
>
> q <= d when clk'event and clk = '1' else '0' when rst = '1';
>
> I imagine that using a clock enable, must be this way.
>
> q <= d when clk'event and clk = '1' and clken = '1' else '0' when rst =
> '1';
>
> If synthesizable, it is an interesting aprouch. Have you tried such
> situations?
>


I just stuck this through Synplify, and it's fine with Andy's
original. It doesn't like yours, but it's OK with:
q1 <= '0' when rst = '1' else d1 when rising_edge(clk);
q2 <= '0' when rst = '1' else d2 when rising_edge(clk) and clken =
'1';

Anyone else care to try it on other tools? Here's the full code:

library ieee;
use ieee.std_logic_1164.all;

entity ffs is
port (
clk : in std_logic;
clken : in std_logic;
rst: in std_logic;
d,d1,d2 : in std_logic;
q, q1,q2 : out std_logic
);

end entity ffs adder;
architecture a1 of ffs adder is
begin
q <= d when rising_edge(clk);
q1 <= '0' when rst = '1' else d1 when rising_edge(clk);
q2 <= '0' when rst = '1' else d2 when rising_edge(clk) and clken = '1';
end architecture a1;

Cheers,
Martin

>
> Andy escreveu:
>
> > You do not have to have an _explicit_ process to save information:
> >
> > q <= d when rising_edge(clk); -- flip flop
> >
> > q <= d when en = '1'; -- latch
> >
> > output <= a when sel = '11' else b when sel = '00'; -- mux + latch
> >
> > That said, latches are not generally a good idea in ASICs and FPGAs.
> >
> > Andy
> >
> >
> > Rtafas wrote:
> > > Have you ever considered reading some digital systems book and/or heard
> > > about flip-flops or latches? VHDL and it's "a lot more understandable"
> > > with this knowledge. You shoud *really* do this.
> > >
> > > You must use a process to save information. Flip-flops and latches are
> > > generetade only this way. Something like:
> > >
> > > process(clk)
> > > begin
> > > if clk'event and clk = '1' then
> > > if sel_lines = "11" then
> > > out <= a;
> > > elsif sel_lines = "00" then
> > > out <= b;
> > > end if;
> > > end if;
> > > end process;
> > >
> > > What you have been reading was about assyncronous logic (gates). It
> > > won't save any value for you.
> > >
> > > Regards,
> > >
> > > Ricardo
> > >
> > > john escreveu:
> > >
> > > > Hi,
> > > >
> > > > I am trying to build a multiplexer. It has two select lines . When its
> > > > '11', it selects A when its '00' it selects B . Now, i do not want to
> > > > select anything else and maintain A or B at its output even the select
> > > > line changes to anything else like "01" or "10"... How can I do that .
> > > > I saw may examples and found that { when others => A <= ( others =>
> > > > 'X' ) }
> > > >
> > > > John.

>


--

TRW Conekt - Consultancy in Engineering, Knowledge and Technology
http://www.trw.com/conekt



Martin Thompson
  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