end if;
when START =>
+ if rx_data >= x"40" then
+ tmp2 := unsigned(rx_data) + x"09";
+ else
+ tmp2 := unsigned(rx_data);
+ end if;
if rx_ready = '1' then
- if rx_data >= x"40" then
- tmp2 := unsigned(rx_data) + x"09";
- else
- tmp2 := unsigned(rx_data);
- end if;
state <= START2;
end if;
when START2 =>
addr_data(bytecount*4+3 downto bytecount*4) <= std_logic_vector(tmp2(3 downto 0));
+ bytecount <= bytecount - 1;
+
if (bytecount = 0 and cmd_wr = '1') or (bytecount = 8 and cmd_rd = '1') then
state <= DO_COMMAND;
else
- bytecount <= bytecount - 1;
state <= START;
end if;
if RESET = '1' or timeout = '1' then
state <= IDLE;
- timer <= (others => '0');
end if;
end process;
signal timer_i : unsigned(31 downto 0) := (others => '0');
signal led_highz : std_logic;
- type led_timer_t is array(0 to 3) of unsigned(24 downto 0);
+ type led_timer_t is array(0 to 3) of unsigned(5 downto 0);
signal led_timer : led_timer_t;
signal led_state : std_logic_vector(3 downto 0);
+ signal led_clk_en : std_logic;
- type counter_arr is array(0 to 7) of unsigned(23 downto 0);
+ type counter_arr is array(0 to 7) of unsigned(15 downto 0);
signal input_counter : counter_arr;
signal select_i : std_logic_vector(3 downto 0);
signal readcounter : unsigned(15 downto 0);
f_read <= '1';
bus_ready <= '0';
when x"ee" => uart_tx_data <= sed_debug;
- when x"ff" => uart_tx_data(15 downto 0) <= std_logic_vector(readcounter);
- readcounter <= readcounter + 1;
+-- when x"ff" => uart_tx_data(15 downto 0) <= std_logic_vector(readcounter);
+-- readcounter <= readcounter + 1;
end case;
if uart_addr(7 downto 4) = x"2" then
- uart_tx_data(31 downto 24) <= uart_addr(3 downto 0) & x"0";
- uart_tx_data(23 downto 0) <= std_logic_vector(input_counter(to_integer(unsigned(uart_addr(3 downto 0)))));
+ uart_tx_data(31 downto 16) <= uart_addr(3 downto 0) & x"000";
+ uart_tx_data(15 downto 0) <= std_logic_vector(input_counter(to_integer(unsigned(uart_addr(3 downto 0)))));
end if;
elsif bus_write = '1' then
case uart_addr is
PROC_LED_STATE : process begin
wait until rising_edge(clk_i);
+ if timer_i(18 downto 0) = 0 then
+ led_clk_en <= '1';
+ else
+ led_clk_en <= '0';
+ end if;
+
for i in 0 to 3 loop
- if (input_reg_2(i) xor input_reg_1(i)) = '1' and (led_timer(i)(23 downto 21) > 0) then
+ if (input_reg_2(i) xor input_reg_1(i)) = '1' and (led_timer(i)(4 downto 2) > 0) then
led_state(i) <= not led_state(i);
led_timer(i) <= 0;
- elsif led_timer(i)(23) = '1' then
+ elsif led_timer(i)(4) = '1' then
led_state(i) <= input_reg_1(i);
- else
+ elsif led_clk_en = '1' then
led_timer(i) <= led_timer(i) + 1;
end if;
end loop;