conv2.vhd

来自「Program to implement convolution of two 」· VHDL 代码 · 共 69 行

VHD
69
字号
------------------------------------------------------------------------------------ Company: -- Engineer: -- -- Create Date:    22:29:34 02/19/2009 -- Design Name: -- Module Name:    conv2 - Behavioral -- Project Name: -- Target Devices: -- 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;package integermath is       type int_vector is array (integer range <>) of natural range 0 to 255;end;use work.integermath.all;entity conv2 isport(x:in int_vector(0 to 3);     clk:in bit;     h:in int_vector(0 to 3);     load:in bit;     y:out int_vector(0 to 3));end;architecture blah of conv2 issignal shiftreg:int_vector(0 to 3);signal temp:int_vector(0 to 3);signal counter:integer range 0 to 7 := 0;begin      process(clk,load)		--variable temp:int_vector(0 to 4);		--variable shiftreg: int_vector(0 to 2);      begin           if load='1' then               shiftreg(0 to 3) <= h(0 to 3);           elsif (clk'event and clk = '1') then                 if counter<4 then                     for i in 0 to 3 loop                         temp(i) <= temp(i)+shiftreg(i)*x(i);                     end loop;                     for j in 0 to 2 loop							    shiftreg(j+1) <= shiftreg(j);                                         end loop;
							shiftreg(0) <= 0;                     counter <= counter+1;                 end if;          end if;      end process;
		y <= temp;end; 

⌨️ 快捷键说明

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