emit.vhd

来自「这是一个超声波发射的控制电路的设计,可以发出连续的单载波脉冲.」· VHDL 代码 · 共 49 行

VHD
49
字号
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity emit is
	port(
		clr1:in std_logic;
		clk1, clk2:in std_logic;     --由XR-2206产生的频率可调的方波
		out_a:out std_logic;
		out_b:out std_logic
		);
end emit;
architecture bhv of emit is
signal counter_4:    std_logic_vector(3 downto 0);
signal clr2,Q1:      std_logic;
signal outa,outb:    std_logic;

begin 

clr2<=Q1;

	process(clr1,clk1)
		begin
			if(clr1='0')then
				counter_4<="0000";   --没有必要把Q1也置为零
			 elsif(clk1'event and clk1='1')then
				if(counter_4>="0000" and counter_4<="0010")then  --此处不能仅为大于0
					counter_4<=counter_4+1;    --这种编法只在需要时为计数器,而其他情况下不计数
					Q1<='1';
				else
					Q1<='0';
				end if;
			end if;	
	end process;

	process(clk2,clr2)
		begin
			if(clr2='1')then
				outa<=clk2;
				outb<=not(clk2);
			else
				outa<='0';
				outb<='0';
			end if;
        out_a<=not(outa);
        out_b<=not(outb);

	end process;
end bhv;

⌨️ 快捷键说明

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