📄 uart1.vhd
字号:
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(8 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'("000000000");
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'("000000000000000000000000") & (baud_rate_counter)) - std_logic_vector'("000000000000000000000000000000001")), 9);
end if;
end if;
end if;
end process;
baud_rate_counter_is_zero <= to_std_logic(((std_logic_vector'("00000000000000000000000") & (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;
library altera_vhdl_support;
use altera_vhdl_support.altera_vhdl_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 (8 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;
signal status_wr_strobe : OUT STD_LOGIC;
signal tx_data : OUT STD_LOGIC_VECTOR (7 DOWNTO 0);
signal tx_wr_strobe : OUT STD_LOGIC
);
end entity uart1_regs;
architecture europa of uart1_regs is
signal any_error : STD_LOGIC;
signal control_reg : STD_LOGIC_VECTOR (9 DOWNTO 0);
signal control_wr_strobe : STD_LOGIC;
signal cts_status_bit : STD_LOGIC;
signal d1_rx_char_ready : STD_LOGIC;
signal d1_tx_ready : STD_LOGIC;
signal dcts_status_bit : STD_LOGIC;
signal delayed_unxtx_readyxx4 : STD_LOGIC;
signal divisor_constant : STD_LOGIC_VECTOR (8 DOWNTO 0);
signal do_write_char : STD_LOGIC;
signal eop_status_bit : STD_LOGIC;
signal ie_any_error : STD_LOGIC;
signal ie_break_detect : STD_LOGIC;
signal ie_framing_error : STD_LOGIC;
signal ie_parity_error : STD_LOGIC;
signal ie_rx_char_ready : STD_LOGIC;
signal ie_rx_overrun : STD_LOGIC;
signal ie_tx_overrun : STD_LOGIC;
signal ie_tx_ready : STD_LOGIC;
signal ie_tx_shift_empty : STD_LOGIC;
signal internal_tx_data : STD_LOGIC_VECTOR (7 DOWNTO 0);
signal internal_tx_wr_strobe : STD_LOGIC;
signal qualified_irq : STD_LOGIC;
signal selected_read_data : STD_LOGIC_VECTOR (15 DOWNTO 0);
signal status_reg : STD_LOGIC_VECTOR (12 DOWNTO 0);
begin
process (clk, reset_n)
begin
if reset_n = '0' then
readdata <= std_logic_vector'("0000000000000000");
elsif clk'event and clk = '1' then
if std_logic'(clk_en) = '1' then
readdata <= selected_read_data;
end if;
end if;
end process;
process (clk, reset_n)
begin
if reset_n = '0' then
irq <= std_logic'('0');
elsif clk'event and clk = '1' then
if std_logic'(clk_en) = '1' then
irq <= qualified_irq;
end if;
end if;
end process;
rx_rd_strobe <= (chipselect AND NOT read_n) AND to_std_logic(((address = std_logic_vector'("000"))));
internal_tx_wr_strobe <= (chipselect AND NOT write_n) AND to_std_logic(((address = std_logic_vector'("001"))));
status_wr_strobe <= (chipselect AND NOT write_n) AND to_std_logic(((address = std_logic_vector'("010"))));
control_wr_strobe <= (chipselect AND NOT write_n) AND to_std_logic(((address = std_logic_vector'("011"))));
process (clk, reset_n)
begin
if reset_n = '0' then
internal_tx_data <= std_logic_vector'("00000000");
elsif clk'event and clk = '1' then
if std_logic'(internal_tx_wr_strobe) = '1' then
internal_tx_data <= writedata(7 DOWNTO 0);
end if;
end if;
end process;
process (clk, reset_n)
begin
if reset_n = '0' then
control_reg <= std_logic_vector'("0000000000");
elsif clk'event and clk = '1' then
if std_logic'(control_wr_strobe) = '1' then
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -