zoukankan      html  css  js  c++  java
  • 阵列乘法器

    希望大家看看,给指点一下,程序如下:

    library ieee;
    use ieee.std_logic_1164.all;
    use ieee.std_logic_unsigned.all;

    entity ZL_multiplier is
     port(
       clk         : in std_logic;
       reset      : in std_logic;
       mul1     : in std_logic_vector(3 downto 0);
       mul2     : in std_logic_vector(3 downto 0);
       product : out std_logic_vector(7 downto 0)
       );
    end ZL_multiplier;

    architecture behaver of ZL_multiplier is
    component full_adder
     port(
       add1 : in std_logic;
       add2 : in std_logic;
       fc      : in std_logic;
       sum  : out std_logic;
       co     : out std_logic
       );
    end component;

    component half_adder
     port(
       add1 : in std_logic;
       add2 : in std_logic;
       sum  : out std_logic;
       co     : out std_logic
       );
    end component;

    signal a, x : std_logic_vector (3 downto 0);
    signal  p   : std_logic_vector (7 downto 0);
    signal m   : std_logic_vector(11 downto 0);
    signal  c   : std_logic_vector(11 downto 0);

    begin
     x <= mul1;
     a <= mul2;
     product <= p;
     
     p(0) <= x(0) and a(0);
     h0 : half_adder
     port map(a(0) and x(1),a(1) and x(0),m(0),c(0));
     p(1) <= m(0);
     h1 : half_adder
     port map(a(1) and x(1),a(2) and x(0),m(1),c(1));
    f0 : full_adder
     port map(a(0) and x(2),m(1),c(0),m(2),c(2));
     p(2) <= m(2);
    f1 : full_adder
     port map(a(2) and x(1),a(3) and x(0),c(1),m(3),c(3));
    f2 : full_adder
     port map(a(0) and x(3),a(1) and x(2),c(2),m(4),c(4));
    h2 : half_adder
     port map(m(3),m(4),m(5),c(5));
     p(3) <= m(5);
    f3 : full_adder
     port map(a(2) and x(2),a(3) and x(1),c(3),m(6),c(6));
    f4 : full_adder
     port map(a(1) and x(3),m(6),c(4),m(7),c(7));
    h3 : half_adder
     port map(m(7),c(5),m(8),c(8));
     p(4) <= m(8);
    f5 : full_adder
     port map(a(2) and x(3),a(3) and x(2),c(6),m(9),c(9));
    f6 : full_adder
     port map(c(7),c(8),m(9),m(10),c(10));
     p(5) <= m(10);
    f7 : full_adder
     port map(a(3) and x(3),c(9),c(10),m(11),c(11));
     p(6) <= m(11);
     p(7) <= c(11);
     
    end behaver;

  • 相关阅读:
    python中list添加元素的方法append()、extend()和insert()
    Python中的短路计算
    Python文件的读写
    Python匿名函数
    Python中的引用传参
    持续学习大纲
    【Mysql】Datetime和Timestamp区别,及mysql中各种时间的使用
    【JDK源码】 ☞ HashMap源码分析及面试汇总
    算法复杂度实例 -- O(1) O(n) O(logN) O(NlogN)
    Solr使用总结
  • 原文地址:https://www.cnblogs.com/zhongguo135/p/2636833.html
Copyright © 2011-2022 走看看