Guest
Hello.
Newbie here. I am trying to write a very simple program to simulate a
multiplexer. I am using the xilinx version of the modelsim compiler
viz. Modelsim XE version.
heres my code:
library ieee;
use ieee.std_logic_1164.all;
entity mux is
port(a,b:IN std_logic_vector(7 downto 0);
sel:IN std_logic_vector(1 downto 0);
c : OUT std_logic_vector(7 downto 0));
end mux;
architecture example of mux is
begin
process(a,b,sel)
begin
if(sel = "00") then
c <= "00000000";
elsif (sel = "01") then
c <= a;
elsif (sel = "10") then
c <= b;
else
c <= (OTHERS => 'Z');
end if;
end process;
end example;
entity tb_mux is
end entity;
architecture mux of tb_mux is
signal a,b,c : std_logic_vector(7 downto 0);
signal sel1 : std_logic_vector(1 downto 0);
component muxc is
port(a,b : in std_logic_vector(7 downto 0);
sel : in std_logic_vector(1 downto 0);
c : out std_logic_vector(7 downto 0));
end muxc;
for all:muxc use entity mux(example);
begin
M1:muxc port map(a,b,sel,c);
process
begin
a <= X"11" after 1 ns,
X"AF" after 2 ns,
X"BB" after 3 ns,
X"6F" after 4 ns;
b <= X"01" after 1 ns,
X"2F" after 2 ns,
X"3C" after 3 ns,
X"BE" after 4 ns;
sel <= B"00" after 1 ns,
B"01" after 2 ns,
B"10" after 3 ns,
B"11" after 4 ns;
wait;
end process;
end mux;
When I try to compile my program into a file called mux.vhd in the work
library it gives me errors at all lines where I use std_logic_vector
saying that it is an unknown identifier though I have included the
library and the needed package in the code above.Alongwith that it says
that I should always end a component declaration with a "end component
component_name" instead of just "end component_name" which is perfectly
legal I guess isn't it?
After that when I replace the line containing ' c <= (OTHERS => 'Z');
' with ' c <= 'Z'; ' it says that "Enumeration literal 'Z' is not
of type std_logic_vector.". And the error about the ending of the
component part doesn't come in the picture.
Hoping to hear from you,
Aijaz Baig.
Newbie here. I am trying to write a very simple program to simulate a
multiplexer. I am using the xilinx version of the modelsim compiler
viz. Modelsim XE version.
heres my code:
library ieee;
use ieee.std_logic_1164.all;
entity mux is
port(a,b:IN std_logic_vector(7 downto 0);
sel:IN std_logic_vector(1 downto 0);
c : OUT std_logic_vector(7 downto 0));
end mux;
architecture example of mux is
begin
process(a,b,sel)
begin
if(sel = "00") then
c <= "00000000";
elsif (sel = "01") then
c <= a;
elsif (sel = "10") then
c <= b;
else
c <= (OTHERS => 'Z');
end if;
end process;
end example;
entity tb_mux is
end entity;
architecture mux of tb_mux is
signal a,b,c : std_logic_vector(7 downto 0);
signal sel1 : std_logic_vector(1 downto 0);
component muxc is
port(a,b : in std_logic_vector(7 downto 0);
sel : in std_logic_vector(1 downto 0);
c : out std_logic_vector(7 downto 0));
end muxc;
for all:muxc use entity mux(example);
begin
M1:muxc port map(a,b,sel,c);
process
begin
a <= X"11" after 1 ns,
X"AF" after 2 ns,
X"BB" after 3 ns,
X"6F" after 4 ns;
b <= X"01" after 1 ns,
X"2F" after 2 ns,
X"3C" after 3 ns,
X"BE" after 4 ns;
sel <= B"00" after 1 ns,
B"01" after 2 ns,
B"10" after 3 ns,
B"11" after 4 ns;
wait;
end process;
end mux;
When I try to compile my program into a file called mux.vhd in the work
library it gives me errors at all lines where I use std_logic_vector
saying that it is an unknown identifier though I have included the
library and the needed package in the code above.Alongwith that it says
that I should always end a component declaration with a "end component
component_name" instead of just "end component_name" which is perfectly
legal I guess isn't it?
After that when I replace the line containing ' c <= (OTHERS => 'Z');
' with ' c <= 'Z'; ' it says that "Enumeration literal 'Z' is not
of type std_logic_vector.". And the error about the ending of the
component part doesn't come in the picture.
Hoping to hear from you,
Aijaz Baig.