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

📄 pulse_control.vhd

📁 low frequency therapy system control VHDL code
💻 VHD
字号:
--============================================================================
-- Project 		: Low Frequency Therapy
-- Programmer	: Byungchan Son
-- Function		: 
-- Language		: VHDL
--============================================================================
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
use ieee.numeric_std.all;
--============================================================================
-- 涝免仿 器飘 沥狼
--============================================================================
entity pulse_control is
	port(
		-- system signal
		reset : in std_logic;
		clock : in std_logic;
		-- bus control
		p_width : in std_logic_vector(7 downto 0);
		period_flag : in std_logic;
		p_onoff : in std_logic;
		-- pulse out
		p_pp : out std_logic;
		p_pm : out std_logic;
		p_mp : out std_logic;
		p_mm : out std_logic
		-- test signal
		);
end pulse_control;
--============================================================================
-- 备炼 沥狼
--============================================================================
architecture pulse_control_a of pulse_control is
--------------------------------------------------------------------
-- 郴何 葛碘
--------------------------------------------------------------------
--------------------------------------------------------------------
-- 郴何 脚龋
--------------------------------------------------------------------
type pulse_control_state is(
	idle,
	pulse_plus,
	pulse_change,
	pulse_minus,
	pulse_change1
	);

-- state machine signal
signal p_current_state, p_next_state : pulse_control_state;
-- data signal
signal count_10us : std_logic_vector(9 downto 0);
signal count_width : std_logic_vector(7 downto 0);
signal t_pulse_width : std_logic_vector(7 downto 0);
signal dac_clock_count : std_logic_vector(5 downto 0);
signal dac_clock_flag : std_logic;
signal dac_bit_count : std_logic_vector(3 downto 0);
signal t_voltage : std_logic_vector(7 downto 0);
--============================================================================
-- 橇肺技辑 矫累
--============================================================================
begin
	----------------------------------------------------------------
	-- 郴何 葛碘 搬急
	----------------------------------------------------------------
	----------------------------------------------------------------
	-- 妻胶 惯积扁
	----------------------------------------------------------------
	gen_pulse : process(
		reset,
		clock,
		p_current_state,
		p_next_state,
		period_flag,
		count_10us,
		count_width
		)
	begin
		if(reset = '1')then
			p_next_state <= idle;
			-- 寇何 免仿
			p_pp <= '0';
			p_pm <= '0';
			p_mp <= '0';
			p_mm <= '0';
			-- 郴何 脚龋
			count_10us <= (others => '0');
			count_width <= (others => '0');
			t_pulse_width <= (others => '0');
		elsif(clock'event and clock = '1')then
			case p_current_state is
				when idle =>
					if(period_flag = '1' and p_onoff = '1')then
						p_pp <= '1';
						p_pm <= '0';
						p_mp <= '0';
						p_mm <= 'Z';
						count_width <= p_width;
						t_pulse_width <= p_width;
						p_next_state <= pulse_plus;
					end if;
				when pulse_plus =>
					if(count_10us = "1111101000")then
						count_10us <= (others => '0');
						if(count_width = "00000000")then
							count_width <= "00000001";
							p_pp <= '0';
							p_pm <= 'Z';
							p_mp <= '0';
							p_mm <= 'Z';
							p_next_state <= pulse_change;
						else
							count_width <= count_width - 1;
						end if;
					else
						count_10us <= count_10us + 1;
					end if;
				when pulse_change =>
					if(count_10us = "1111101000")then
						count_10us <= (others => '0');
						if(count_width = "00000000")then
							count_width <= t_pulse_width;
							p_pp <= '0';
							p_pm <= 'Z';
							p_mp <= '1';
							p_mm <= '0';
							p_next_state <= pulse_minus;
						else
							count_width <= count_width - 1;
						end if;
					else
						count_10us <= count_10us + 1;
					end if;
				when pulse_minus =>
					if(count_10us = "1111101000")then
						count_10us <= (others => '0');
						if(count_width = "00000000")then
							count_width <= "00000001";
							p_pp <= '0';
							p_pm <= 'Z';
							p_mp <= '0';
							p_mm <= 'Z';
							p_next_state <= pulse_change1;
						else
							count_width <= count_width - 1;
						end if;
					else
						count_10us <= count_10us + 1;
					end if;
				when pulse_change1 =>
					if(count_10us = "1111101000")then
						count_10us <= (others => '0');
						if(count_width = "00000000")then
							p_pp <= '0';
							p_pm <= '0';
							p_mp <= '0';
							p_mm <= '0';
							p_next_state <= idle;
						else
							count_width <= count_width - 1;
						end if;
					else
						count_10us <= count_10us + 1;
					end if;
			end case;
		end if;
		p_current_state <= p_next_state;
	end process;
	----------------------------------------------------------------
	-- 肺流 脚龋
	----------------------------------------------------------------
end pulse_control_a;
--============================================================================
-- 场
--============================================================================


⌨️ 快捷键说明

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