I wanted to implement 3xor gates, the output from the first two xor gates should be the input for the last xor gate
xor1--->
xor3----> final output
xor2--->
Here's my code, I'm not sure if what i've done so far is ok and I think i have to declare the arch. when i do the mod. thingys? Cheers for the help!
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
architecture struct of triplexor is
component unit10
port (a0, a1: in bit; o1: out bit); --xor1
end component;
architecture func of unit10 is
begin
o1 <= a0 xor a1;
end func;
component unit11
port (a2, a3: in bit; o2: out bit); --xor2
end component;
architecture func of unit11 is
begin
o2 <= a2 xor a3;
end func;
component unit2
port (i1, i2: in bit; yi: out bit); --xor3
end component;
architecture func of unit2 is
begin
yi <= i1 xor i2;
end func;
signal ya, yb, yout: bit;
begin
mod_unit10: unit10 port map (a, b, ya);
mod_unit11: unit11 port map (a, b, yb);
mod_unit2 : unit2 port map (ya, yb, yout);
output: y<=yout;
end architecture struct;
Here is your code with just 3 instances of the same component:
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity triplexor ...
end entity;
architecture struct of triplexor is
component myXor
port (
i0, i0: in bit;
o: out bit
);
end component;
architecture rtl of myXor is
begin
o <= i0 xor i1;
end rtl;
signal ya, yb, yout: bit;
begin
-- using port mapping by position
inst_xor1: myXor
port map (
a, b,
ya
);
inst_xor2: myXor
port map (
a, b,
yb
);
-- using port mapping by name (I prefer this style - it's safer if someone changes a port list)
inst_xor3: myXor
port map (
i0 => ya,
i1 => yb,
o => yout
);
y <= yout;
end architecture struct;