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

📄 gcd.vhd

📁 This is the course for VHDL programming
💻 VHD
字号:
Library IEEE;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;use ieee.std_logic_arith.all;entity gcd is	port(	a,b:in std_logic_vector(7 downto 0);		CLK,RST,START:in std_logic;		c:out std_logic_vector(7 downto 0);		DONE:out std_logic	    );end gcd;architecture dataflow of gcd is	signal x,y:std_logic_vector(7 downto 0);	signal equal:std_logic;	type states is(INIT,STRT,RUN,FINISH);	signal state,next_state:states;begin	process(CLK,RST,NEXT_STATE)	begin	if(RST='1')then STATE <= INIT;	elsif(CLK'event and CLK='1') then		STATE<= NEXT_STATE;	end if;	end process;	NEXT_STATE<= INIT   when STATE = INIT   and START = '0' else			STRT   when STATE = INIT   and START = '1' else			RUN    when STATE = STRT   else			RUN    when STATE = RUN    and EQUAL = '0' else			FINISH when STATE = RUN    and EQUAL = '1' else			INIT   when STATE = FINISH else			STATE;	process(a,b,clk,rst)	begin		if clk'event and clk='1' then			if state = STRT then x<=a;y<=b;equal<='0';			elsif state=RUN then				if    x=y then equal <='1';				elsif x>y then x<=x-y;				else  y<= y-x;				end if;			end if;		end if; 	end process;	done<='1' when STATE = FINISH else '0';	c<=y ; end dataflow;

⌨️ 快捷键说明

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