com_max_out_user.vhd

来自「FIFO和计数器以及时钟控制」· VHDL 代码 · 共 53 行

VHD
53
字号
library IEEE;
use IEEE.std_logic_1164.all;
use IEEE.std_logic_arith.all;

entity com_max_out_user is
  port (
    MAX_DATA : out STD_LOGIC_VECTOR(7 downto 0);
    max_usr : out STD_LOGIC_VECTOR(2 downto 0);
	usr_a : in STD_LOGIC_VECTOR(2 downto 0);
	usr_b : in STD_LOGIC_VECTOR(2 downto 0);
   clk : in std_logic;
    D_A : in STD_LOGIC_VECTOR(7 downto 0);
    D_B : in STD_LOGIC_VECTOR(7 downto 0)
  );
end com_max_out_user ;

architecture compare_arch of com_max_out_user is
signal sym_a,sym_b : std_logic;
signal ta ,tb : std_logic_vector(6 downto 0);
begin
sym_a <= d_a(7);
sym_b <= d_b(7);
ta <= d_a(6 downto 0);
tb <= d_b(6 downto 0);
process(clk,ta,tb,sym_a,sym_b)
begin
if rising_edge(clk) then
if sym_a < sym_b then
   max_data <= d_a;
   max_usr <= usr_a;
elsif sym_a > sym_b then
  max_data <= d_b;
  max_usr <= usr_b;
elsif ((sym_a and sym_b) ='1') then
   if ((UNSIGNED(ta) > UNSIGNED(tb)) or ((UNSIGNED(ta) = UNSIGNED(tb)))) then
     max_data <= d_b;
     max_usr <= usr_b;
   else
     max_data <= d_a;
     max_usr <= usr_a;
   end if;
elsif ((sym_a or sym_b) ='0') then
   if ((UNSIGNED(ta) > UNSIGNED(tb)) or ((UNSIGNED(ta) = UNSIGNED(tb)))) then
     max_data <= d_a;
     max_usr <= usr_a;
   else
     max_data <= d_b;
     max_usr <= usr_b;
   end if;
end if;
end if;
end process; 
end architecture compare_arch;  

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?