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

📄 uart1.vhd

📁 nois 2cpu 硬件实现编程
💻 VHD
📖 第 1 页 / 共 4 页
字号:
        tx_overrun => unused_overrun,        tx_ready => unused_ready,        tx_shift_empty => unused_empty,        txd => internal_source_rxd,        baud_divisor => baud_divisor,        begintransfer => do_send_stim_data,        clk => clk,        clk_en => clk_en,        do_force_break => module_input1,        reset_n => reset_n,        status_wr_strobe => module_input2,        tx_data => d1_stim_data,        tx_wr_strobe => module_input3      );    module_input1 <= std_logic'('0');    module_input2 <= std_logic'('0');    module_input3 <= std_logic'('1');    process (clk, reset_n)    begin      if reset_n = '0' then        d1_stim_data <= std_logic_vector'("00000000");      elsif clk'event and clk = '1' then        if std_logic'(do_send_stim_data) = '1' then           d1_stim_data <= stim_data;        end if;      end if;    end process;    --uart1_rx_stimulus_source_character_source_rom, which is an e_drom    uart1_rx_stimulus_source_character_source_rom : uart1_rx_stimulus_source_character_source_rom_module      port map(        new_rom => new_rom_pulse,        q => stim_data,        safe => safe,        clk => clk,        incr_addr => do_send_stim_data,        reset_n => reset_n      );    --delayed_unxrx_char_readyxx0, which is an e_register    process (clk, reset_n)    begin      if reset_n = '0' then        delayed_unxrx_char_readyxx0 <= std_logic'('0');      elsif clk'event and clk = '1' then        if std_logic'(clk_en) = '1' then           delayed_unxrx_char_readyxx0 <= rx_char_ready;        end if;      end if;    end process;    pickup_pulse <= NOT (rx_char_ready) AND (delayed_unxrx_char_readyxx0);    do_send_stim_data <= ((pickup_pulse OR new_rom_pulse)) AND safe;--synthesis translate_on--synthesis read_comments_as_HDL on--    internal_source_rxd <= rxd;--synthesis read_comments_as_HDL offend europa;-- turn off superfluous VHDL processor warnings -- altera message_level Level1 -- altera message_off 10034 10035 10036 10037 10230 10240 10030 library altera;use altera.altera_europa_support_lib.all;library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_arith.all;use ieee.std_logic_unsigned.all;entity uart1_rx is         port (              -- inputs:                 signal baud_divisor : IN STD_LOGIC_VECTOR (9 DOWNTO 0);                 signal begintransfer : IN STD_LOGIC;                 signal clk : IN STD_LOGIC;                 signal clk_en : IN STD_LOGIC;                 signal reset_n : IN STD_LOGIC;                 signal rx_rd_strobe : IN STD_LOGIC;                 signal rxd : IN STD_LOGIC;                 signal status_wr_strobe : IN STD_LOGIC;              -- outputs:                 signal break_detect : OUT STD_LOGIC;                 signal framing_error : OUT STD_LOGIC;                 signal parity_error : OUT STD_LOGIC;                 signal rx_char_ready : OUT STD_LOGIC;                 signal rx_data : OUT STD_LOGIC_VECTOR (7 DOWNTO 0);                 signal rx_overrun : OUT STD_LOGIC              );end entity uart1_rx;architecture europa of uart1_rx iscomponent uart1_rx_stimulus_source is            port (                 -- inputs:                    signal baud_divisor : IN STD_LOGIC_VECTOR (9 DOWNTO 0);                    signal clk : IN STD_LOGIC;                    signal clk_en : IN STD_LOGIC;                    signal reset_n : IN STD_LOGIC;                    signal rx_char_ready : IN STD_LOGIC;                    signal rxd : IN STD_LOGIC;                 -- outputs:                    signal source_rxd : OUT STD_LOGIC                 );end component uart1_rx_stimulus_source;                signal baud_clk_en :  STD_LOGIC;                signal baud_load_value :  STD_LOGIC_VECTOR (9 DOWNTO 0);                signal baud_rate_counter :  STD_LOGIC_VECTOR (9 DOWNTO 0);                signal baud_rate_counter_is_zero :  STD_LOGIC;                signal d1_source_rxd :  STD_LOGIC;                signal delayed_unxrx_in_processxx3 :  STD_LOGIC;                signal delayed_unxsync_rxdxx1 :  STD_LOGIC;                signal delayed_unxsync_rxdxx2 :  STD_LOGIC;                signal do_start_rx :  STD_LOGIC;                signal got_new_char :  STD_LOGIC;                signal half_bit_cell_divisor :  STD_LOGIC_VECTOR (8 DOWNTO 0);                signal internal_rx_char_ready :  STD_LOGIC;                signal is_break :  STD_LOGIC;                signal is_framing_error :  STD_LOGIC;                signal raw_data_in :  STD_LOGIC_VECTOR (7 DOWNTO 0);                signal rx_in_process :  STD_LOGIC;                signal rx_rd_strobe_onset :  STD_LOGIC;                signal rxd_edge :  STD_LOGIC;                signal rxd_falling :  STD_LOGIC;                signal rxd_shift_reg :  STD_LOGIC_VECTOR (9 DOWNTO 0);                signal sample_enable :  STD_LOGIC;                signal shift_reg_start_bit_n :  STD_LOGIC;                signal source_rxd :  STD_LOGIC;                signal stop_bit :  STD_LOGIC;                signal sync_rxd :  STD_LOGIC;                signal unused_start_bit :  STD_LOGIC;                signal unxshiftxrxd_shift_regxshift_reg_start_bit_nxx6_in :  STD_LOGIC_VECTOR (9 DOWNTO 0);                signal unxshiftxrxd_shift_regxshift_reg_start_bit_nxx6_out :  STD_LOGIC_VECTOR (9 DOWNTO 0);begin  --the_uart1_rx_stimulus_source, which is an e_instance  the_uart1_rx_stimulus_source : uart1_rx_stimulus_source    port map(      source_rxd => source_rxd,      baud_divisor => baud_divisor,      clk => clk,      clk_en => clk_en,      reset_n => reset_n,      rx_char_ready => internal_rx_char_ready,      rxd => rxd    );  process (clk, reset_n)  begin    if reset_n = '0' then      d1_source_rxd <= std_logic'('0');      sync_rxd <= std_logic'('0');    elsif clk'event and clk = '1' then      if std_logic'(clk_en) = '1' then         d1_source_rxd <= source_rxd;        sync_rxd <= d1_source_rxd;      end if;    end if;  end process;  --delayed_unxsync_rxdxx1, which is an e_register  process (clk, reset_n)  begin    if reset_n = '0' then      delayed_unxsync_rxdxx1 <= std_logic'('0');    elsif clk'event and clk = '1' then      if std_logic'(clk_en) = '1' then         delayed_unxsync_rxdxx1 <= sync_rxd;      end if;    end if;  end process;  rxd_falling <= NOT (sync_rxd) AND (delayed_unxsync_rxdxx1);  --delayed_unxsync_rxdxx2, which is an e_register  process (clk, reset_n)  begin    if reset_n = '0' then      delayed_unxsync_rxdxx2 <= std_logic'('0');    elsif clk'event and clk = '1' then      if std_logic'(clk_en) = '1' then         delayed_unxsync_rxdxx2 <= sync_rxd;      end if;    end if;  end process;  rxd_edge <= (sync_rxd) XOR (delayed_unxsync_rxdxx2);  rx_rd_strobe_onset <= rx_rd_strobe AND begintransfer;  half_bit_cell_divisor <= baud_divisor(9 DOWNTO 1);  baud_load_value <= A_WE_StdLogicVector((std_logic'((rxd_edge)) = '1'), (std_logic_vector'("0") & (half_bit_cell_divisor)), baud_divisor);  process (clk, reset_n)  begin    if reset_n = '0' then      baud_rate_counter <= std_logic_vector'("0000000000");    elsif clk'event and clk = '1' then      if std_logic'(clk_en) = '1' then         if std_logic'((baud_rate_counter_is_zero OR rxd_edge)) = '1' then           baud_rate_counter <= baud_load_value;        else          baud_rate_counter <= A_EXT (((std_logic_vector'("00000000000000000000000") & (baud_rate_counter)) - std_logic_vector'("000000000000000000000000000000001")), 10);        end if;      end if;    end if;  end process;  baud_rate_counter_is_zero <= to_std_logic(((std_logic_vector'("0000000000000000000000") & (baud_rate_counter)) = std_logic_vector'("00000000000000000000000000000000")));  process (clk, reset_n)  begin    if reset_n = '0' then      baud_clk_en <= std_logic'('0');    elsif clk'event and clk = '1' then      if std_logic'(clk_en) = '1' then         if std_logic'(rxd_edge) = '1' then           baud_clk_en <= std_logic'('0');        else          baud_clk_en <= baud_rate_counter_is_zero;        end if;      end if;    end if;  end process;  sample_enable <= baud_clk_en AND rx_in_process;  process (clk, reset_n)  begin    if reset_n = '0' then      do_start_rx <= std_logic'('0');    elsif clk'event and clk = '1' then      if std_logic'(clk_en) = '1' then         if std_logic'((NOT rx_in_process AND rxd_falling)) = '1' then           do_start_rx <= std_logic'('1');        else          do_start_rx <= std_logic'('0');        end if;      end if;    end if;  end process;  rx_in_process <= shift_reg_start_bit_n;  (stop_bit, raw_data_in(7), raw_data_in(6), raw_data_in(5), raw_data_in(4), raw_data_in(3), raw_data_in(2), raw_data_in(1), raw_data_in(0), unused_start_bit) <= rxd_shift_reg;  is_break <= NOT (or_reduce(rxd_shift_reg));  is_framing_error <= NOT stop_bit AND NOT is_break;  --delayed_unxrx_in_processxx3, which is an e_register  process (clk, reset_n)  begin    if reset_n = '0' then      delayed_unxrx_in_processxx3 <= std_logic'('0');    elsif clk'event and clk = '1' then      if std_logic'(clk_en) = '1' then         delayed_unxrx_in_processxx3 <= rx_in_process;      end if;    end if;  end process;  got_new_char <= NOT (rx_in_process) AND (delayed_unxrx_in_processxx3);  process (clk, reset_n)  begin    if reset_n = '0' then      rx_data <= std_logic_vector'("00000000");    elsif clk'event and clk = '1' then      if std_logic'(got_new_char) = '1' then         rx_data <= raw_data_in;      end if;    end if;  end process;  process (clk, reset_n)  begin    if reset_n = '0' then      framing_error <= std_logic'('0');    elsif clk'event and clk = '1' then      if std_logic'(clk_en) = '1' then         if std_logic'(status_wr_strobe) = '1' then           framing_error <= std_logic'('0');        elsif std_logic'((got_new_char AND is_framing_error)) = '1' then           framing_error <= Vector_To_Std_Logic(-SIGNED(std_logic_vector'("00000000000000000000000000000001")));        end if;      end if;    end if;  end process;  process (clk, reset_n)  begin    if reset_n = '0' then      break_detect <= std_logic'('0');    elsif clk'event and clk = '1' then      if std_logic'(clk_en) = '1' then         if std_logic'(status_wr_strobe) = '1' then           break_detect <= std_logic'('0');        elsif std_logic'((got_new_char AND is_break)) = '1' then           break_detect <= Vector_To_Std_Logic(-SIGNED(std_logic_vector'("00000000000000000000000000000001")));        end if;      end if;    end if;  end process;  process (clk, reset_n)  begin    if reset_n = '0' then      rx_overrun <= std_logic'('0');    elsif clk'event and clk = '1' then      if std_logic'(clk_en) = '1' then         if std_logic'(status_wr_strobe) = '1' then           rx_overrun <= std_logic'('0');        elsif std_logic'((got_new_char AND internal_rx_char_ready)) = '1' then           rx_overrun <= Vector_To_Std_Logic(-SIGNED(std_logic_vector'("00000000000000000000000000000001")));        end if;      end if;    end if;  end process;  process (clk, reset_n)  begin    if reset_n = '0' then      internal_rx_char_ready <= std_logic'('0');    elsif clk'event and clk = '1' then      if std_logic'(clk_en) = '1' then         if std_logic'(rx_rd_strobe_onset) = '1' then           internal_rx_char_ready <= std_logic'('0');        elsif std_logic'(got_new_char) = '1' then           internal_rx_char_ready <= Vector_To_Std_Logic(-SIGNED(std_logic_vector'("00000000000000000000000000000001")));        end if;      end if;    end if;  end process;  parity_error <= std_logic'('0');  --_reg, which is an e_register  process (clk, reset_n)  begin    if reset_n = '0' then      unxshiftxrxd_shift_regxshift_reg_start_bit_nxx6_out <= std_logic_vector'("0000000000");    elsif clk'event and clk = '1' then      if std_logic'(clk_en) = '1' then         unxshiftxrxd_shift_regxshift_reg_start_bit_nxx6_out <= unxshiftxrxd_shift_regxshift_reg_start_bit_nxx6_in;      end if;    end if;  end process;  unxshiftxrxd_shift_regxshift_reg_start_bit_nxx6_in <= A_WE_StdLogicVector((std_logic'((do_start_rx)) = '1'), A_REP(std_logic'('1'), 10), A_WE_StdLogicVector((std_logic'((sample_enable)) = '1'), Std_Logic_Vector'(A_ToStdLogicVector(sync_rxd) & unxshiftxrxd_shift_regxshift_reg_start_bit_nxx6_out(9 DOWNTO 1)), unxshiftxrxd_shift_regxshift_reg_start_bit_nxx6_out));  rxd_shift_reg <= unxshiftxrxd_shift_regxshift_reg_start_bit_nxx6_out;  shift_reg_start_bit_n <= unxshiftxrxd_shift_regxshift_reg_start_bit_nxx6_out(0);  --vhdl renameroo for output signals  rx_char_ready <= internal_rx_char_ready;end europa;-- turn off superfluous VHDL processor warnings -- altera message_level Level1 -- altera message_off 10034 10035 10036 10037 10230 10240 10030 library altera;use altera.altera_europa_support_lib.all;library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_arith.all;use ieee.std_logic_unsigned.all;library std;use std.textio.all;entity uart1_regs is         port (              -- inputs:                 signal address : IN STD_LOGIC_VECTOR (2 DOWNTO 0);                 signal break_detect : IN STD_LOGIC;                 signal chipselect : IN STD_LOGIC;                 signal clk : IN STD_LOGIC;                 signal clk_en : IN STD_LOGIC;                 signal framing_error : IN STD_LOGIC;                 signal parity_error : IN STD_LOGIC;                 signal read_n : IN STD_LOGIC;                 signal reset_n : IN STD_LOGIC;                 signal rx_char_ready : IN STD_LOGIC;                 signal rx_data : IN STD_LOGIC_VECTOR (7 DOWNTO 0);                 signal rx_overrun : IN STD_LOGIC;                 signal tx_overrun : IN STD_LOGIC;                 signal tx_ready : IN STD_LOGIC;                 signal tx_shift_empty : IN STD_LOGIC;                 signal write_n : IN STD_LOGIC;                 signal writedata : IN STD_LOGIC_VECTOR (15 DOWNTO 0);              -- outputs:                 signal baud_divisor : OUT STD_LOGIC_VECTOR (9 DOWNTO 0);                 signal dataavailable : OUT STD_LOGIC;                 signal do_force_break : OUT STD_LOGIC;                 signal irq : OUT STD_LOGIC;                 signal readdata : OUT STD_LOGIC_VECTOR (15 DOWNTO 0);                 signal readyfordata : OUT STD_LOGIC;                 signal rx_rd_strobe : OUT STD_LOGIC;

⌨️ 快捷键说明

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