怎么指定组合逻辑门的分布方式

2020-02-02 12:24发布

大家好,请教一个问题。
首先,背景是我用VHDL编程经验并不多,现在写了一个组合逻辑的比较器,代码如下:
  1. LIBRARY IEEE;
  2. USE IEEE.STD_LOGIC_1164.ALL;
  3. USE IEEE.STD_LOGIC_UNSIGNED.ALL;
  4. USE IEEE.STD_LOGIC_ARITH.ALL;

  5. ENTITY com_8 IS
  6. PORT
  7. (
  8.     datax : in std_logic_vector(7 downto 0);        --比较数据x
  9.     datay : in std_logic_vector(7 downto 0);        --比较数据y
  10.     c_out : out std_logic;                          --比较结果,x>y 输出1,否则输出0
  11.     e_out : out std_logic;                          --比较结果,x=y 输出1,否则输出0
  12.     c_in : in std_logic;                            --比较结果输入,用于级联 --大于
  13.     e_in : in std_logic;                             --比较结构输入,用于级联 --相等
  14.     --clk : in std_logic
  15. );
  16. END com_8;

  17. ARCHITECTURE behavior OF com_8 IS

  18. signal b_c, b_e : std_logic;
  19. signal buff_e : std_logic_vector(7 downto 0);
  20. signal equ : std_logic_vector(7 downto 0);

  21. BEGIN

  22.         process(clk)

  23.         begin
  24.                 if(clk'event and clk='1') then
  25.                         e_out <= b_e;
  26.                         c_out <= b_c;
  27.                 end if;
  28.        
  29.         end process;
  30.        
  31.         buff_e(0) <= datax(0) xnor datay(0);
  32.         buff_e(1) <= datax(1) xnor datay(1);
  33.         buff_e(2) <= datax(2) xnor datay(2);
  34.         buff_e(3) <= datax(3) xnor datay(3);
  35.         buff_e(4) <= datax(4) xnor datay(4);
  36.         buff_e(5) <= datax(5) xnor datay(5);
  37.         buff_e(6) <= datax(6) xnor datay(6);
  38.         buff_e(7) <= datax(7) xnor datay(7);
  39.        
  40.        
  41. --        equ(0) <= (buff_e(7) and (datax(6) and(not datay(6))));
  42. --        equ(1) <= (buff_e(7) and buff_e(6) and (datax(5) and(not datay(5))));
  43. --        equ(2) <= (buff_e(7) and buff_e(6) and buff_e(5) and (datax(4) and(not datay(4))));
  44. --        equ(3) <= (buff_e(7) and buff_e(6) and buff_e(5) and buff_e(4) and (datax(3) and(not datay(3))));
  45. --        equ(4) <= (buff_e(7) and buff_e(6) and buff_e(5) and buff_e(4) and buff_e(3) and (datax(2) and(not datay(2))));
  46. --        equ(5) <= (buff_e(7) and buff_e(6) and buff_e(5) and buff_e(4) and buff_e(3) and buff_e(2) and (datax(1)and(not datay(1))));
  47. --        equ(6) <= (buff_e(7) and buff_e(6) and buff_e(5) and buff_e(4) and buff_e(3) and buff_e(2) and buff_e(1) and (datax(0)and(not datay(0))));
  48. --        equ(7) <= (buff_e(7) and buff_e(6) and buff_e(5) and buff_e(4) and buff_e(3) and buff_e(2) and buff_e(1) and buff_e(0) and c_in);
  49.        
  50.         b_e <= buff_e(0) and buff_e(1) and buff_e(2) and buff_e(3) and buff_e(4) and buff_e(5) and buff_e(6) and buff_e(7) and e_in;
  51.        
  52.         --b_c <= (datax(7)and(not datay(7))) or equ(0) or equ(1) or equ(2) or equ(3) or equ(4) or equ(5) or equ(6) or equ(7);
  53.        
  54.        
  55.         b_c <= (datax(7)and(not datay(7))) or
  56.                         (buff_e(7) and (datax(6) and(not datay(6)))) or
  57.                         (buff_e(7) and buff_e(6) and (datax(5) and(not datay(5)))) or
  58.                         (buff_e(7) and buff_e(6) and buff_e(5) and (datax(4) and(not datay(4)))) or
  59.                         (buff_e(7) and buff_e(6) and buff_e(5) and buff_e(4) and (datax(3) and(not datay(3)))) or
  60.                         (buff_e(7) and buff_e(6) and buff_e(5) and buff_e(4) and buff_e(3) and (datax(2) and(not datay(2)))) or
  61.                         (buff_e(7) and buff_e(6) and buff_e(5) and buff_e(4) and buff_e(3) and buff_e(2) and (datax(1)and(not datay(1)))) or
  62.                         (buff_e(7) and buff_e(6) and buff_e(5) and buff_e(4) and buff_e(3) and buff_e(2) and buff_e(1) and (datax(0)and(not datay(0)))) or
  63.                         (buff_e(7) and buff_e(6) and buff_e(5) and buff_e(4) and buff_e(3) and buff_e(2) and buff_e(1) and buff_e(0) and c_in);

  64. END behavior;
复制代码
但是,生成的RTL电路结构并非我想要的形式,实际生成的RTL电路采用了多级级联的与方式,这样导致了仿真出现很多毛刺,RTL 电路如下图:
adf.png
我的想法是这些逻辑与门应该是多输入的方式存在,而非级联,就算浪费点,速度也不会太慢。
想请教大家的是,我该如何做呢?或是如何设置呢?
0条回答

一周热门 更多>