leading values of 1's

note:this program is using dataflow,you can change this program using structural just by calling the components :)
here the equation is obtained using K-map solving :)
while simulating change the radix to unsigned decimal to get count in integers :)
[right click on the output variable,there you will find radix near force constant :) ]


Code:



library ieee;
use ieee.std_logic_1164.all;

entity leadinones is
port(a:in std_logic_vector(3 downto 0);
y:out std_logic_vector(2 downto 0));
end leadinones;

architecture arch_one of leadinones is
begin
y(2)<=(a(3) and a(2) and a(1) and a(0));
y(1)<=(a(3) and a(2) and (a(1) xor a(0)));
y(0)<=((a(3) and (not a(2))) or (a(3) and (not a(0)) and  a(1)));
end arch_one;

Comments