Line 39... |
Line 39... |
-- change.
|
-- change.
|
-- Seth Henry 04/16/20 Modified to make use of Open8 bus record
|
-- Seth Henry 04/16/20 Modified to make use of Open8 bus record
|
-- Seth Henry 05/06/20 Modified to eliminate request line and detect idle
|
-- Seth Henry 05/06/20 Modified to eliminate request line and detect idle
|
-- conditions instead
|
-- conditions instead
|
-- Seth Henry 05/23/20 Added the parallel interface
|
-- Seth Henry 05/23/20 Added the parallel interface
|
|
-- Seth Henry 04/07/21 Added checksum to prevent glitching on serial noise
|
|
|
library ieee;
|
library ieee;
|
use ieee.std_logic_1164.all;
|
use ieee.std_logic_1164.all;
|
use ieee.std_logic_unsigned.all;
|
use ieee.std_logic_unsigned.all;
|
use ieee.std_logic_arith.all;
|
use ieee.std_logic_arith.all;
|
Line 105... |
Line 106... |
signal Rx_Idle_Cntr : std_logic_vector(3 downto 0);
|
signal Rx_Idle_Cntr : std_logic_vector(3 downto 0);
|
signal RX_Idle : std_logic;
|
signal RX_Idle : std_logic;
|
signal Rx_Data : DATA_TYPE := x"00";
|
signal Rx_Data : DATA_TYPE := x"00";
|
signal Rx_Valid : std_logic;
|
signal Rx_Valid : std_logic;
|
|
|
type VECTOR_RX_STATES is ( GET_VECTOR_CMD, GET_VECTOR_ARG_LB, GET_VECTOR_ARG_UB,
|
type VECTOR_RX_STATES is ( CHECKSUM_INIT,
|
|
GET_VECTOR_CMD,
|
|
GET_VECTOR_ARG_LB,
|
|
GET_VECTOR_ARG_UB,
|
|
GET_VECTOR_SUM,
|
SEND_INTERRUPT );
|
SEND_INTERRUPT );
|
signal Vector_State : VECTOR_RX_STATES := GET_VECTOR_CMD;
|
signal Vector_State : VECTOR_RX_STATES := GET_VECTOR_CMD;
|
|
|
signal Vec_Req_SR : std_logic_vector(2 downto 0);
|
signal Vec_Req_SR : std_logic_vector(2 downto 0);
|
alias Vec_Req_MS is Vec_Req_SR(2);
|
alias Vec_Req_MS is Vec_Req_SR(2);
|
|
|
signal Vector_Index : DATA_TYPE := x"00";
|
signal Vector_Index : DATA_TYPE := x"00";
|
signal Vector_Data : ADDRESS_TYPE := x"0000";
|
signal Vector_Data : ADDRESS_TYPE := x"0000";
|
alias Vector_Data_LB is Vector_Data(7 downto 0);
|
alias Vector_Data_LB is Vector_Data(7 downto 0);
|
alias Vector_Data_UB is Vector_Data(15 downto 8);
|
alias Vector_Data_UB is Vector_Data(15 downto 8);
|
|
signal Vector_RX_Sum : DATA_TYPE := x"00";
|
|
|
|
constant MAGIC_NUM : DATA_TYPE := x"4D";
|
|
signal Checksum : DATA_TYPE := x"00";
|
|
|
begin
|
begin
|
|
|
Addr_Match <= '1' when Comp_Addr = User_Addr else '0';
|
Addr_Match <= '1' when Comp_Addr = User_Addr else '0';
|
Rd_En_d <= Addr_Match and Open8_Bus.Rd_En;
|
Rd_En_d <= Addr_Match and Open8_Bus.Rd_En;
|
Line 198... |
Line 207... |
|
|
Vector_RX_proc: process( Clock, Reset )
|
Vector_RX_proc: process( Clock, Reset )
|
begin
|
begin
|
if( Reset = Reset_Level )then
|
if( Reset = Reset_Level )then
|
Vec_Req_SR <= (others => '0');
|
Vec_Req_SR <= (others => '0');
|
Vector_State <= GET_VECTOR_CMD;
|
Vector_State <= CHECKSUM_INIT;
|
Vector_Index <= x"00";
|
Vector_Index <= x"00";
|
Vector_Data <= x"0000";
|
Vector_Data <= x"0000";
|
Interrupt <= '0';
|
Interrupt <= '0';
|
elsif( rising_edge(Clock) )then
|
elsif( rising_edge(Clock) )then
|
Vec_Req_SR <= Vec_Req_SR(1 downto 0) & Vec_Req;
|
Vec_Req_SR <= Vec_Req_SR(1 downto 0) & Vec_Req;
|
Line 214... |
Line 223... |
Vector_Data <= Vec_Data;
|
Vector_Data <= Vec_Data;
|
Interrupt <= '1';
|
Interrupt <= '1';
|
end if;
|
end if;
|
|
|
case( Vector_State )is
|
case( Vector_State )is
|
|
when CHECKSUM_INIT =>
|
|
Checksum <= MAGIC_NUM;
|
|
Vector_State <= GET_VECTOR_CMD;
|
|
|
when GET_VECTOR_CMD =>
|
when GET_VECTOR_CMD =>
|
if( Rx_Valid = '1' )then
|
if( Rx_Valid = '1' )then
|
|
Checksum <= Checksum + Rx_Data;
|
Vector_Index <= "00" & Rx_Data(5 downto 0);
|
Vector_Index <= "00" & Rx_Data(5 downto 0);
|
Vector_State <= GET_VECTOR_ARG_LB;
|
Vector_State <= GET_VECTOR_ARG_LB;
|
end if;
|
end if;
|
|
|
when GET_VECTOR_ARG_LB =>
|
when GET_VECTOR_ARG_LB =>
|
if( Rx_Valid = '1' )then
|
if( Rx_Valid = '1' )then
|
|
Checksum <= Checksum + Rx_Data;
|
Vector_Data_LB <= Rx_Data;
|
Vector_Data_LB <= Rx_Data;
|
Vector_State <= GET_VECTOR_ARG_UB;
|
Vector_State <= GET_VECTOR_ARG_UB;
|
end if;
|
end if;
|
|
|
when GET_VECTOR_ARG_UB =>
|
when GET_VECTOR_ARG_UB =>
|
if( Rx_Valid = '1' )then
|
if( Rx_Valid = '1' )then
|
|
Checksum <= Checksum + Rx_Data;
|
Vector_Data_UB <= Rx_Data;
|
Vector_Data_UB <= Rx_Data;
|
|
Vector_State <= GET_VECTOR_SUM;
|
|
end if;
|
|
|
|
when GET_VECTOR_SUM =>
|
|
if( Rx_Valid = '1' )then
|
|
Vector_RX_Sum <= Rx_Data;
|
Vector_State <= SEND_INTERRUPT;
|
Vector_State <= SEND_INTERRUPT;
|
end if;
|
end if;
|
|
|
when SEND_INTERRUPT =>
|
when SEND_INTERRUPT =>
|
|
if( Checksum = Vector_RX_Sum )then
|
Interrupt <= '1';
|
Interrupt <= '1';
|
Vector_State <= GET_VECTOR_CMD;
|
end if;
|
|
Vector_State <= CHECKSUM_INIT;
|
when others => null;
|
when others => null;
|
end case;
|
end case;
|
|
|
if( Rx_Idle = '1' )then
|
if( Rx_Idle = '1' )then
|
Vector_State <= GET_VECTOR_CMD;
|
Vector_State <= CHECKSUM_INIT;
|
end if;
|
end if;
|
|
|
end if;
|
end if;
|
end process;
|
end process;
|
|
|