⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 definitivo.vhd

📁 Sobel--Image Filter (I). An Image filtering is made over data loaded into the on board RAM and prese
💻 VHD
字号:
library IEEE;
use IEEE.std_logic_1164.all;
use IEEE.std_logic_arith.all;
use IEEE.std_logic_signed.all;

entity multycomp is

generic (
G0 : integer :=-1;
G1 : integer :=-1;			-- matriz de sobel
G2 : integer :=-1;
G3 :integer :=-1;
G4 :integer :=8;
G5 : integer :=-1;
G6 :integer  :=-1;
G7 : integer :=-1;
G8 : integer :=-1;
valorlimite: integer :=60
);


 port (
        enable: in STD_LOGIC;
        asinc_reset: in STD_LOGIC;
        clk: in STD_LOGIC;
	fin :out std_logic;
	resultado: out std_logic;				--fin del modulo lectura
        S0 : in std_logic_vector(7 downto 0);
        S1 : in std_logic_vector(7 downto 0);
        S2 : in std_logic_vector(7 downto 0);
        S3 : in std_logic_vector(7 downto 0);
        S4 : in std_logic_vector(7 downto 0);
        S5 : in std_logic_vector(7 downto 0);
        S6 : in std_logic_vector(7 downto 0);
        S7 : in std_logic_vector(7 downto 0);
        S8 : in std_logic_vector(7 downto 0)
        );
end multycomp;

architecture multi of multycomp is
subtype carmen is integer range -1 to 1;
--type dummy is array(1 downto 0) of carmen;
type buffere is array (0 to 8) of std_logic_vector(7 downto 0);
type buf is array (0 to 8) of carmen; --dummy;
type estado is (reposo, multiplica, suma);
signal estado_pres, estado_fut : estado;
signal dato ,dato_p: buffere;

signal resultadob, resultado1 : std_logic;
signal indice,indicep : integer range 0 to 9;
signal totalint : integer range 0 to 256;
signal valorp:std_logic_vector(11 downto 0);
signal total,TOTALP, valor :std_logic_vector(11 downto 0);
begin

		
	comb: process(enable, estado_pres,indice)
	begin
		if (enable ='0') then		--sera el fin del modulo lectura
			estado_fut <= reposo;
		else
			case estado_pres is
				when reposo =>
					estado_fut <= multiplica;
				when multiplica =>
					case indice is
						when 9 => estado_fut <=reposo;
						when others  =>	estado_fut <= suma;
					end case;
				when suma =>
					estado_fut <= multiplica;
			end case;
		end if;
	end process;

	sinc : process(asinc_reset, clk, estado_fut,estado_pres, indice)

	begin
	
			
			if(asinc_reset ='1') then
					
			        total <=(others=>'0');
			        valor <=(others=>'0');
			        dato(0)<=(OTHERS=>'0');	      
				dato(1)<=(OTHERS=>'0');				--Posible implementacion 
				dato(2)<=(OTHERS=>'0');				--bucle for	
				dato(3)<=(OTHERS=>'0');	
				dato(4)<=(OTHERS=>'0');	
				dato(5)<=(OTHERS=>'0');	
				dato(6)<=(OTHERS=>'0');	
				dato(7)<=(OTHERS=>'0');				
				dato(8)<=(OTHERS=>'0');	
				estado_pres <= reposo;
				indice<=0;
				resultado1 <= '0';
	
			elsif ( clk'event and clk ='1') then
				estado_pres <= estado_fut;
				indice <= indicep;
				total <= totalp;
				valor <= valorp;
				resultado1 <= resultadob;
				FOR I IN 0 TO 8 LOOP
				  DATO(I) <= DATO_P(I);
				END LOOP;
			end if;
	end process;
	
	comp : process(total, resultado1, valor, valorp, estado_pres, indice,dato,S0,S1,S2,S3,S4,S5,S6,S7,S8)
	variable auxe: integer range 0 to 2047;
	variable dat,aux,auxp: integer range  -2048 to 2047;
	variable dummy: std_logic_vector(8 downto 0);
	VARIABLE sobel: buf;
	begin 
			sobel(0):=G0;			--Introduzco todos los valores de entrada 
			sobel(1):=G1;			--y la matriz de sobel en dos talas
			sobel(2):=G2;	
			sobel(3):=G3;
			sobel(4):=G4;		
			sobel(5):=G5;
			sobel(6):=G6;
			sobel(7):=G7;								
			sobel(8):=G8;
			valorp <= valor;
			totalp <= total;
			indicep <= indice;
			resultadob <= resultado1;
			fin <= '0';
			dato_P(0)<=DATO(0);	
			dato_P(1)<=DATO(1);			--Posible implementacion 
			dato_P(2)<=DATO(2);			--bucle for	
			dato_P(3)<=DATO(3);	
			dato_P(4)<=DATO(4);	
			dato_P(5)<=DATO(5);	
			dato_P(6)<=DATO(6);	
			dato_P(7)<=DATO(7);					
			dato_p(8)<=DATO(8);			
				
		case estado_pres is 
			when reposo =>
				dato_P(0)<=S0;	
				dato_P(1)<=S1;			--Posible implementacion 
				dato_P(2)<=S2;			--bucle for	
				dato_P(3)<=S3;	
				dato_P(4)<=S4;	
				dato_P(5)<=S5;	
				dato_P(6)<=S6;	
				dato_P(7)<=S7;					
				dato_p(8)<=S8;	
				

				
				if (indice = 9) then
					
				
					auxp:=conv_integer(total);
					auxe:=abs(auxp);
					--totalint<=auxp;
					if (auxe < valorlimite)then
						resultadob<='0';
					else 
						resultadob<='1';
					end if;
					
					indicep <= 0;
					fin    <= '1';
					totalp <=(others=>'0');
					--valor<=(others=>'0');
					valorp <=(others=>'0');
				
				end if;

			when multiplica =>

				dummy(7 downto 0):=dato(indice)(7 downto 0);
				dummy(8):='0';
				dat:=conv_integer(dummy);
				aux:=dat*sobel(indice);
				valorp<=conv_std_logic_vector(aux,12);
				
				
			when suma=>
				
				
				totalp<=valor+total;
				indicep <= indice +1;
			end case;

	end process;
	
	resultado <= resultado1;
	
end multi;

⌨️ 快捷键说明

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