Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

writing a generic Mux in VHDL

Status
Not open for further replies.

anonymous.

Junior Member level 3
Joined
Apr 16, 2012
Messages
27
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,485
I want to make a generic Mux. not just generic in the Width of inputs, But the number of inputs too.
something like this:
Code:
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
----------------------------------------
entity Mux is
	generic
	(
		INPUT_WIDTH			: integer 	:= 8;
		INPUT_COUNT 			: integer 	:= 8;
		SEL_WIDTH 			: integer 	:= 3
	);
	port
	(
		Inputs 				: in 		std_logic_vector((INPUT_WIDTH*INPUT_COUNT)-1 downto 0);
		Sel 				        : in 		std_logic_vector(SEL_WIDTH-1 downto 0);
		Output 				: out 		std_logic_vector(INPUT_WIDTH-1 downto 0)
	);
end entity; -- Mux
----------------------------------------
architecture Arch of Mux is
begin

	assert 2**SEL_WIDTH = INPUT_COUNT 
           report "INPUT_COUNT must be 2**SEL_WIDTH" 
           severity failure;

        Output 		<= Inputs(((to_integer(unsigned(Sel))+1)*INPUT_WIDTH)-1 downto ((to_integer(unsigned(Sel))*INPUT_WIDTH)));

end architecture; -- Arch

the problem with this is that it is not synthesizable, DC says Constant value required. how to write this as synthesizable ??
 

Yes, according to VHDL syntax rules, a slice must use a constant range.

A single bit selection can use a variable range. So you have to combine it with a generate statement or a respective loop statement in a combinational process.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top