- Config File:
8default_shared_register_polarity = '0'
9default_signal_polarity = '0'
10default_voltage_standard = 3.
3V
11pinout_filename = PINOUT.xdc
14default_time_units = ms
15alias srr is state_reg_rec(0);
16alias state_reg : integer is state_reg_rec(0).state_reg;
20constant baud_rate : integer := us(104);
21constant half_baud_rate : integer := us(52);
25alias byte_ready is state_reg_rec(0).shared_register(8);
26constant baud_rate : integer := us(104);
- VHDL Code (Uart Receiver):
2use ieee.std_logic_1164.
all;
3use ieee.numeric_std.
all;
4use ieee.std_logic_unsigned.
all;
5use work.user_defs_pkg.
all;
6use work.speakhdl_api_pkg.
all;
11 generic (this_sm : integer := -1);
15 sm_input : in std_logic_vector(0 downto 0);
16 sm_output : out std_logic_vector(-1 downto 0);
17 sm_io : inout std_logic_vector(-1 downto 0);
18 next_state_rec : out nsr_array(0 to 0);
19 state_reg_rec : in srr_array(0 to 0)
25architecture arch
of uart_rx
is
27 alias rxd : std_logic is sm_input(0);
28 alias srr is state_reg_rec(0);
29 alias state_reg : integer is state_reg_rec(0).state_reg;
30 constant st_init : integer := 0;
31 constant st_start : integer := 1;
32 constant st_shift : integer := 2;
33 constant st_done : integer := 3;
34 constant baud_rate : integer := us(104);
35 constant half_baud_rate : integer := us(52);
47 RESOURCE_SELECT( sys_clk, next_state_rec, state_reg_rec );
49 SHARED_REGISTER( uart_tx, srr.counter(0).done, next_state_rec, state_reg_rec, 8 );
50 CONFIGURE_COUNTER( 0, 1, no_trans, next_state_rec, state_reg_rec, srr.last_state = st_done );
52sm0: case (state_reg) is
54 SHARED_REGISTER( uart_tx, srr.shift_left(7 downto 0), next_state_rec, state_reg_rec );
55 CONDITIONAL_TRANSITION( 0, rxd = '0', st_start, next_state_rec, state_reg_rec );
57 TRANSITION( st_shift, 1, half_baud_rate, next_state_rec, state_reg_rec );
59 SHIFT_DATA_LEFT( rxd, 1, next_state_rec, state_reg_rec, srr.divide.done );
60 TRANSITION( st_done, 8, baud_rate, next_state_rec, state_reg_rec );
62 TRANSITION( st_init, 1, baud_rate, next_state_rec, state_reg_rec );
- VHDL Code (Uart Transmitter):
2use ieee.std_logic_1164.
all;
3use ieee.numeric_std.
all;
4use ieee.std_logic_unsigned.
all;
5use work.user_defs_pkg.
all;
6use work.speakhdl_api_pkg.
all;
11 generic (this_sm : integer := -1);
15 sm_input : in std_logic_vector(-1 downto 0);
16 sm_output : out std_logic_vector(0 downto 0);
17 sm_io : inout std_logic_vector(-1 downto 0);
18 next_state_rec : out nsr_array(0 to 0);
19 state_reg_rec : in srr_array(0 to 0)
25architecture arch
of uart_tx
is
27 alias txd : std_logic is sm_output(0);
28 alias byte_ready is state_reg_rec(0).shared_register(8);
29 alias srr is state_reg_rec(0);
30 alias state_reg : integer is state_reg_rec(0).state_reg;
31 constant st_init : integer := 0;
32 constant st_start : integer := 1;
33 constant st_shift : integer := 2;
34 constant st_stop : integer := 3;
35 constant baud_rate : integer := us(104);
40 txd <= '0' when (state_reg = st_start) else
41 srr.shift_right(0) when (state_reg = st_shift) else
53 RESOURCE_SELECT( sys_clk, next_state_rec, state_reg_rec );
55 SHARED_REGISTER( this_sm, read_only, next_state_rec, state_reg_rec );
57sm0: case (state_reg) is
59 SHIFT_DATA_RIGHT( srr.shared_register(7 downto 0), reverse_bits, next_state_rec,
61 CONDITIONAL_TRANSITION( 0, byte_ready = '1', st_start, next_state_rec, state_reg_rec );
63 TRANSITION( st_shift, 1, baud_rate, next_state_rec, state_reg_rec );
65 SHIFT_DATA_RIGHT( srr.shared_register(7 downto 0), 1, next_state_rec, state_reg_rec,
67 TRANSITION( st_stop, 8, baud_rate, next_state_rec, state_reg_rec );
69 TRANSITION( st_init, 1, baud_rate, next_state_rec, state_reg_rec );
- See also
- led_blink_example
-
sseg_display_example
-
vga_controller_example