一,设计如下图所示电路
外围封装的输入输出信号就D1(输入信号1),D2(输入信号2),CLK(就一个时钟,内部封装我没画,实际上是应该连着),RST(就一个复位),Q(一个输出)五个,
内部封装:我把第一排寄存器命名为R11,R12,R13,第二排寄存器命名为R21,R22,R23,复用器命名为M1,M2,M3,加法器命名为A1,A2,最后还有一个R3。比如说,从寄存器R11到复用器M1的输出线路,我表示为R11_M1。以上表示在图中标出。
输入输出位:输入D1是6位的,所以我们写(5 downto 0);输入D2是4位的;经过复用器,复用器输出是6+4=10位(9 downto 0);加法器A1是11位(10位输入+10位输入=10位输出+1位的进数位=11位);同理加法器A2是12位(11位+10位=11位+1位的进数位=12位);然后R3输入12位输出还是12位。
以下是我的电路结构设计代码
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity dat is
port (
clk : in std_logic;
rst : in std_logic;
D1 : in std_logic_vector(5 downto 0); --6bits
D2 : in std_logic_vector(3 downto 0); --4bits
q : out std_logic_vector(10 downto 0) --4+6+1=11bits
);
end entity;
architecture behave of dat is
signal R11_R12 : std_logic_vector(5 downto 0); --Output
signal R12_M2 : std_logic_vector(5 downto 0);
signal R21_R22 : std_logic_vector(3 downto 0);
signal R22_M2 : std_logic_vector(3 downto 0);
signal M1_A1 : std_logic_vector(9 downto 0);
signal M2_A1 : std_logic_vector(9 downto 0);
signal A1_R3 : std_logic_vector(10 downto 0);
begin
R1 : process (rst,clk) --Row Register1
begin
if rst = '1' then
R11_R12 <= (others => '0');
R12_M2 <= (others => '0');
elsif rising_edge (clk) then
R11_R12 <= D1;
R12_M2 <= R11_R12;
end if;
end process;
R2 : process (rst,clk) --Row Register2
begin
if rst = '1' then