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

Reply

VHDL - parameterizing number of ports?

 
Thread Tools Search this Thread
Old 05-08-2005, 08:18 PM   #1
Default parameterizing number of ports?


Hi

I want to make the following two simple 4-to-1 and 2-to-1 mux, into one
entity with parameterized ports.
I am trying generic statement, yet with no success --:
Could someone give some idea?
Thankyou


--------------------------------------------------------------
-- 4-to-1 Mux
library IEEE;
use IEEE.std_logic_1164.all;
use IEEE.std_logic_arith.all;

entity mux_gate is
port ( SEL: in STD_LOGIC_VECTOR (1 downto 0);
A,B,C,D: in STD_LOGIC;
SIG: out STD_LOGIC);
end mux_gate;

architecture RTL of mux_gate is
begin
SEL_PROCESS: process (SEL,A,B,C,D)
begin
case SEL is
when "00" => SIG <= A;
when "01" => SIG <= B;
when "10" => SIG <= C;
when others => SIG <= D;
end case;
end process SEL_PROCESS;
end RTL;
---------------------------------------------------
-- 2-to-1 Mux
library IEEE;
use IEEE.std_logic_1164.all;
use IEEE.std_logic_arith.all;

entity mux_gate is
port ( SEL: in STD_LOGIC;
A,B: in STD_LOGIC;
SIG: out STD_LOGIC);
end mux_gate;

architecture RTL of mux_gate is
begin
SEL_PROCESS: process (SEL,A,B)
begin
case SEL is
when "0" => SIG <= A;
when others => SIG <= B;
end case;
end process SEL_PROCESS;
end RTL;
-------------------------------------------------------



Pasacco
  Reply With Quote
Old 05-09-2005, 07:42 AM   #2
Egbert Molenkamp
 
Posts: n/a
Default Re: parameterizing number of ports?
library ieee;
use ieee.std_logic_1164.all;
entity mux is
generic (w : natural:= 2); -- sel_width
port (sel : in std_logic_vector(w-1 downto 0);
d : in std_logic_vector(2**w-1 downto 0);
o : out std_logic);
end mux;

library ieee;
use ieee.numeric_std.all;
architecture bhv of mux is
begin
o <= d (to_integer(unsigned(sel)));
end bhv;

Egbert Molenkamp



"Pasacco" <> wrote in message
news: oups.com...
> Hi
>
> I want to make the following two simple 4-to-1 and 2-to-1 mux, into one
> entity with parameterized ports.
> I am trying generic statement, yet with no success --:
> Could someone give some idea?
> Thankyou
>
>
> --------------------------------------------------------------
> -- 4-to-1 Mux
> library IEEE;
> use IEEE.std_logic_1164.all;
> use IEEE.std_logic_arith.all;
>
> entity mux_gate is
> port ( SEL: in STD_LOGIC_VECTOR (1 downto 0);
> A,B,C,D: in STD_LOGIC;
> SIG: out STD_LOGIC);
> end mux_gate;
>
> architecture RTL of mux_gate is
> begin
> SEL_PROCESS: process (SEL,A,B,C,D)
> begin
> case SEL is
> when "00" => SIG <= A;
> when "01" => SIG <= B;
> when "10" => SIG <= C;
> when others => SIG <= D;
> end case;
> end process SEL_PROCESS;
> end RTL;
> ---------------------------------------------------
> -- 2-to-1 Mux
> library IEEE;
> use IEEE.std_logic_1164.all;
> use IEEE.std_logic_arith.all;
>
> entity mux_gate is
> port ( SEL: in STD_LOGIC;
> A,B: in STD_LOGIC;
> SIG: out STD_LOGIC);
> end mux_gate;
>
> architecture RTL of mux_gate is
> begin
> SEL_PROCESS: process (SEL,A,B)
> begin
> case SEL is
> when "0" => SIG <= A;
> when others => SIG <= B;
> end case;
> end process SEL_PROCESS;
> end RTL;
> -------------------------------------------------------
>





Egbert Molenkamp
  Reply With Quote
Old 05-17-2005, 05:55 AM   #3
Jim Lewis
 
Posts: n/a
Default Re: parameterizing number of ports?
Pasacco,
Perhaps you want to consider using functions to implement
this rather than an entity.

Cheers,
Jim


> Hi
>
> I want to make the following two simple 4-to-1 and 2-to-1 mux, into one
> entity with parameterized ports.
> I am trying generic statement, yet with no success --:
> Could someone give some idea?
> Thankyou
>
>
> --------------------------------------------------------------
> -- 4-to-1 Mux
> library IEEE;
> use IEEE.std_logic_1164.all;
> use IEEE.std_logic_arith.all;
>
> entity mux_gate is
> port ( SEL: in STD_LOGIC_VECTOR (1 downto 0);
> A,B,C,D: in STD_LOGIC;
> SIG: out STD_LOGIC);
> end mux_gate;
>
> architecture RTL of mux_gate is
> begin
> SEL_PROCESS: process (SEL,A,B,C,D)
> begin
> case SEL is
> when "00" => SIG <= A;
> when "01" => SIG <= B;
> when "10" => SIG <= C;
> when others => SIG <= D;
> end case;
> end process SEL_PROCESS;
> end RTL;
> ---------------------------------------------------
> -- 2-to-1 Mux
> library IEEE;
> use IEEE.std_logic_1164.all;
> use IEEE.std_logic_arith.all;
>
> entity mux_gate is
> port ( SEL: in STD_LOGIC;
> A,B: in STD_LOGIC;
> SIG: out STD_LOGIC);
> end mux_gate;
>
> architecture RTL of mux_gate is
> begin
> SEL_PROCESS: process (SEL,A,B)
> begin
> case SEL is
> when "0" => SIG <= A;
> when others => SIG <= B;
> end case;
> end process SEL_PROCESS;
> end RTL;
> -------------------------------------------------------
>



--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~
Jim Lewis
Director of Training private.php?do=newpm&u=
SynthWorks Design Inc. http://www.SynthWorks.com
1-503-590-4787

Expert VHDL Training for Hardware Design and Verification
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~


Jim Lewis
  Reply With Quote
Old 05-17-2005, 07:48 AM   #4
Amit Dua
 
Posts: n/a
Default Re: parameterizing number of ports?


The Vital library provides "VitalMux" function.
You can take a look at it as the vital src code is shipped with standard
simulators. For e.g. ncvhdl/ncsim simulator ships it in
<installation_dir>/tools/inca/files/IEEE.src/prmtvs_b.vhd. It should
also be faster as vital library is accelerated in simulators.

VitalMux calls VInterMux that does the real work.
Look at VInterMux function if you dont want to use vital library.

rgds
-Amit.


Jim Lewis wrote:
> Pasacco,
> Perhaps you want to consider using functions to implement
> this rather than an entity.
>
> Cheers,
> Jim
>
>
>> Hi
>>
>> I want to make the following two simple 4-to-1 and 2-to-1 mux, into one
>> entity with parameterized ports.
>> I am trying generic statement, yet with no success --:
>> Could someone give some idea?
>> Thankyou
>>
>>
>> --------------------------------------------------------------
>> -- 4-to-1 Mux
>> library IEEE;
>> use IEEE.std_logic_1164.all;
>> use IEEE.std_logic_arith.all;
>>
>> entity mux_gate is
>> port ( SEL: in STD_LOGIC_VECTOR (1 downto 0);
>> A,B,C,D: in STD_LOGIC;
>> SIG: out STD_LOGIC);
>> end mux_gate;
>>
>> architecture RTL of mux_gate is
>> begin
>> SEL_PROCESS: process (SEL,A,B,C,D)
>> begin
>> case SEL is
>> when "00" => SIG <= A;
>> when "01" => SIG <= B;
>> when "10" => SIG <= C;
>> when others => SIG <= D;
>> end case;
>> end process SEL_PROCESS;
>> end RTL;
>> ---------------------------------------------------
>> -- 2-to-1 Mux
>> library IEEE;
>> use IEEE.std_logic_1164.all;
>> use IEEE.std_logic_arith.all;
>>
>> entity mux_gate is
>> port ( SEL: in STD_LOGIC;
>> A,B: in STD_LOGIC;
>> SIG: out STD_LOGIC);
>> end mux_gate;
>>
>> architecture RTL of mux_gate is
>> begin
>> SEL_PROCESS: process (SEL,A,B)
>> begin
>> case SEL is
>> when "0" => SIG <= A;
>> when others => SIG <= B;
>> end case;
>> end process SEL_PROCESS;
>> end RTL; -------------------------------------------------------
>>

>
>




Amit Dua
  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
New releases: World Trade Center, Jackass Number Two & Wicker Man: Updated complete downloadable R1 DVD DB & info lists Doug MacLean DVD Video 0 10-24-2006 06:04 AM
This is incredible! jc_ice DVD Video 1 08-13-2006 10:47 AM
Re: USB issue ... some USB 2 ports working only in USB 1 mode hungsolo2005@yahoo.com A+ Certification 0 06-14-2006 08:26 PM
Creating the maximum number of menus and maximum number of stills rossco DVD Video 2 11-24-2005 09:33 PM
Re: 38,000 U.S. KILLED & WOUNDED IN IRAQ & dvd's JA DVD Video 0 03-06-2005 01:16 AM




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