add_accumulator.vhd

来自「ISE7.1」· VHDL 代码 · 共 62 行

VHD
62
字号
--------------------------------------------------------------------------------
-- Company: 
-- Engineer:
--
-- Create Date:    18:27:45 05/30/07
-- Design Name:    
-- Module Name:    add_accumulator - Behavioral
-- Project Name:   
-- Target Device:  
-- Tool versions:  
-- Description:
--
-- Dependencies:
-- 
-- Revision:
-- Revision 0.01 - File Created
-- Additional Comments:
-- 
--------------------------------------------------------------------------------
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;

---- Uncomment the following library declaration if instantiating
---- any Xilinx primitives in this code.
--library UNISIM;
--use UNISIM.VComponents.all;

entity add_accumulator is
	port (
	RESET        :IN std_logic;
	B            :IN std_logic_VECTOR(11 downto 0);
	Q            :OUT std_logic_VECTOR(21 downto 0);
	CLK          :IN std_logic;
	SCLR         :IN std_logic
	     );
end add_accumulator;

architecture Behavioral of add_accumulator is
signal q_buf: std_logic_VECTOR(21 downto 0):=(others=>'0');

	begin
		process(CLK,RESET,SCLR,B)
		variable cnt:integer:=0;
		begin
		   if RESET='0' THEN
		        q_buf<=(others=>'0');
				  Q<=(others=>'0');
		   elsif rising_edge(CLK)	THEN
		        if SCLR='1' THEN 
				     q_buf<=(others=>'0');
		           Q<=(others=>'0');
		        else
		    		  q_buf<=q_buf+B;
		        end if;
				  Q<=q_buf;
		   end if;
		end process;

	end Behavioral;

⌨️ 快捷键说明

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