Необходимо конвертировать разные типы данных.
This commit is contained in:
parent
f04720071b
commit
2ece286472
@ -46,10 +46,11 @@ signal cmdBuf : std_logic_vector(15 downto 0) := (others => '0');
|
|||||||
signal fasBuf : std_logic_vector(15 downto 0) := (others => '0');
|
signal fasBuf : std_logic_vector(15 downto 0) := (others => '0');
|
||||||
signal controlBuf : std_logic_vector(15 downto 0) := (others => '0');
|
signal controlBuf : std_logic_vector(15 downto 0) := (others => '0');
|
||||||
|
|
||||||
signal direction : std_logic := '0';
|
signal updatedAddress : std_logic_vector(7 downto 0) := (others => '0');
|
||||||
signal addressToTransmit : std_logic_vector(7 downto 0) := x"00";
|
|
||||||
signal dataToTransmit : std_logic_vector(15 downto 0) := x"0000";
|
signal errorBuf : std_logic_vector(7 downto 0) := x"00";
|
||||||
signal dataFromDevices : std_logic_vector(15 downto 0) := x"0000";
|
signal addrTemp : std_logic_vector(15 downto 0) := x"0000";
|
||||||
|
signal dataTemp : std_logic_vector(15 downto 0) := x"0000";
|
||||||
|
|
||||||
type CommunicationState_start is (Waiting, TransmiteAddress, TransmiteCheck, PreparingToReceiveData, ReceiveData, ReceiveCheck, Timeout, ReceiveCheckTimeout);
|
type CommunicationState_start is (Waiting, TransmiteAddress, TransmiteCheck, PreparingToReceiveData, ReceiveData, ReceiveCheck, Timeout, ReceiveCheckTimeout);
|
||||||
signal CommunicationState : CommunicationState_start := Waiting ;
|
signal CommunicationState : CommunicationState_start := Waiting ;
|
||||||
@ -67,7 +68,7 @@ begin
|
|||||||
if (ce = '0') then -- Если микросхема выбрана
|
if (ce = '0') then -- Если микросхема выбрана
|
||||||
addr := conv_integer(address);
|
addr := conv_integer(address);
|
||||||
if (addr = REG_ADDR_FIRST_FREE_UPPER_BYTE or addr = REG_ADDR_FIRST_FREE_LOWER_BYTE or addr = REG_ADDR_CMD_UPPER_BYTE or addr = REG_ADDR_CMD_LOWER_BYTE
|
if (addr = REG_ADDR_FIRST_FREE_UPPER_BYTE or addr = REG_ADDR_FIRST_FREE_LOWER_BYTE or addr = REG_ADDR_CMD_UPPER_BYTE or addr = REG_ADDR_CMD_LOWER_BYTE
|
||||||
or addr = REG_ADDR_FILL_ADDRESS_SPACE_UPPER_BYTE or addr = REG_ADDR_FILL_ADDRESS_SPACE_LOWER_BYTE or addr = ) then
|
or addr = REG_ADDR_FILL_ADDRESS_SPACE_UPPER_BYTE or addr = REG_ADDR_FILL_ADDRESS_SPACE_LOWER_BYTE or addr = REG_ADDR_CONTROL_UPPER_BYTE or addr = REG_ADDR_CONTROL_LOWER_BYTE) then
|
||||||
if (oe = '0') then -- Если сигнал чтения активен
|
if (oe = '0') then -- Если сигнал чтения активен
|
||||||
case addr is
|
case addr is
|
||||||
when REG_ADDR_FIRST_FREE_UPPER_BYTE =>
|
when REG_ADDR_FIRST_FREE_UPPER_BYTE =>
|
||||||
@ -103,7 +104,7 @@ begin
|
|||||||
fasBuf(15 downto 8) <= data;
|
fasBuf(15 downto 8) <= data;
|
||||||
when REG_ADDR_FILL_ADDRESS_SPACE_LOWER_BYTE =>
|
when REG_ADDR_FILL_ADDRESS_SPACE_LOWER_BYTE =>
|
||||||
fasBuf(7 downto 0) <= data;
|
fasBuf(7 downto 0) <= data;
|
||||||
position := data;
|
position := conv_integer(data);
|
||||||
memoryAddress(position) <= fasBuf(15 downto 8);
|
memoryAddress(position) <= fasBuf(15 downto 8);
|
||||||
when others =>
|
when others =>
|
||||||
data <= (others => 'Z'); -- Запретить запись на шину
|
data <= (others => 'Z'); -- Запретить запись на шину
|
||||||
@ -111,9 +112,9 @@ begin
|
|||||||
else
|
else
|
||||||
data <= (others => 'Z'); -- Запретить запись на шину
|
data <= (others => 'Z'); -- Запретить запись на шину
|
||||||
end if;
|
end if;
|
||||||
elsif (addr >= firstFree and addr <= firstFree + cmdBuf(7 downto 0)) then
|
elsif (addr >= firstFreeBuf and addr <= firstFreeBuf + cmdBuf(7 downto 0)) then
|
||||||
if (oe = '0') then -- Если сигнал чтения активен
|
if (oe = '0') then -- Если сигнал чтения активен
|
||||||
data <= memoryData(addr - firstFree);
|
data <= memoryData(addr - conv_integer(firstFreeBuf));
|
||||||
else
|
else
|
||||||
data <= (others => 'Z'); -- Запретить запись на шину
|
data <= (others => 'Z'); -- Запретить запись на шину
|
||||||
end if;
|
end if;
|
||||||
@ -144,86 +145,91 @@ begin
|
|||||||
pbclk <= '1';
|
pbclk <= '1';
|
||||||
pbce <= '1';
|
pbce <= '1';
|
||||||
pbdata <= (others =>'Z');
|
pbdata <= (others =>'Z');
|
||||||
pbdir <= '1';
|
pbdir <= b"11";
|
||||||
countValue <= 6;
|
countValue := 7;
|
||||||
count <= 0;
|
count := 0;
|
||||||
when TransmiteAddress =>
|
when TransmiteAddress =>
|
||||||
if count < countValue then
|
if count < countValue then
|
||||||
count <= count + 1;
|
if count = 0 then
|
||||||
pbdata(15 downto 8) <= addrTemp;
|
pbdata(15 downto 8) <= addrTemp;
|
||||||
pbdata(7 downto 0) <= not addrTemp;
|
pbdata(7 downto 0) <= not addrTemp;
|
||||||
|
end if;
|
||||||
|
count := count + 1;
|
||||||
else
|
else
|
||||||
pbce <= '0';
|
pbce <= '0';
|
||||||
CommunicationState <= TransmiteCheck;
|
CommunicationState <= TransmiteCheck;
|
||||||
count <= 0;
|
count := 0;
|
||||||
countValue <= 10;
|
countValue := 15;
|
||||||
end if;
|
end if;
|
||||||
when TransmiteCheck =>
|
when TransmiteCheck =>
|
||||||
if count < countValue then
|
if pback = '0' then
|
||||||
count <= count + 1;
|
count := 0;
|
||||||
if pback = '0' then
|
countValue := 1;
|
||||||
count <= 0;
|
pbdata <= (others => 'Z');
|
||||||
countValue <= 15;
|
CommunicationState <= PreparingToReceiveData;
|
||||||
pbdata <= (others => 'Z');
|
else
|
||||||
CommunicationState <= PreparingToReceiveData;
|
if count < countValue then
|
||||||
|
count := count + 1;
|
||||||
|
else
|
||||||
|
CommunicationState <= Waiting;
|
||||||
|
errorBuf(0) <= '1';
|
||||||
end if;
|
end if;
|
||||||
else
|
|
||||||
CommunicationState <= Waiting;
|
|
||||||
errorBuf(0) <= '1';
|
|
||||||
end if;
|
end if;
|
||||||
when PreparingToReceiveData =>
|
when PreparingToReceiveData =>
|
||||||
if count < countValue then
|
if count < countValue then
|
||||||
count <= count + 1;
|
count := count + 1;
|
||||||
else
|
else
|
||||||
|
pbdir <= b"00";
|
||||||
pbclk <= '0';
|
pbclk <= '0';
|
||||||
count <= 0;
|
count := 0;
|
||||||
countValue <= 12;
|
countValue := 15;
|
||||||
CommunicationState <= ReceiveData;
|
CommunicationState <= ReceiveData;
|
||||||
end if;;
|
end if;
|
||||||
when ReceiveData =>
|
when ReceiveData =>
|
||||||
if count < countValue then
|
if pback = '1' then
|
||||||
if pback = '1' then
|
pbclk <= '1';
|
||||||
pbclk <= '1';
|
dataTemp <= pbdata;
|
||||||
dataTemp <= pbdata;
|
CommunicationState <= ReceiveCheck;
|
||||||
CommunicationState <= ReceiveCheck;
|
count := 0;
|
||||||
count <= 0;
|
countValue := 15;
|
||||||
countValue <= 12;
|
else
|
||||||
else
|
if count < countValue then
|
||||||
count <= count + 1;
|
count := count + 1;
|
||||||
|
else
|
||||||
|
CommunicationState <= Waiting;
|
||||||
|
errorBuf(1) <= '1';
|
||||||
end if;
|
end if;
|
||||||
else
|
end if;
|
||||||
CommunicationState <= Waiting;
|
|
||||||
errorBuf(1) <= '1';
|
|
||||||
end if;
|
|
||||||
when ReceiveCheck =>
|
when ReceiveCheck =>
|
||||||
if count < countValue then
|
if pback = '0' then
|
||||||
if pback = '0' then
|
if pbdata = not dataTemp then
|
||||||
if pbdata = not dataTemp then
|
memoryData(position) <= dataTemp(15 downto 8);
|
||||||
memoryData(position) <= dataTemp(15 downto 8);
|
memoryData(position + 1) <= dataTemp(7 downto 0);
|
||||||
memoryData(position + 1) <= dataTemp(7 downto 0);
|
CommunicationState <= Timeout;
|
||||||
CommunicationState <= Timeout;
|
count := 0;
|
||||||
count <= 0;
|
pbce <= '1';
|
||||||
countValue <= 12;
|
countValue := 5;
|
||||||
if position + 1 < cmdBuf(7 downto 0) then
|
if position + 1 < cmdBuf(7 downto 0) then
|
||||||
updatedAddress <= position;
|
updatedAddress <= position;
|
||||||
position <= position + 2;
|
position := position + 2;
|
||||||
else
|
|
||||||
position <= 0;
|
|
||||||
end if;
|
|
||||||
else
|
else
|
||||||
CommunicationState <= Waiting;
|
position := 0;
|
||||||
errorBuf(2) <= '1';
|
|
||||||
end if;
|
end if;
|
||||||
else
|
else
|
||||||
count <= count + 1;
|
CommunicationState <= Waiting;
|
||||||
|
errorBuf(2) <= '1';
|
||||||
|
end if;
|
||||||
|
else
|
||||||
|
if count < countValue then
|
||||||
|
count := count + 1;
|
||||||
|
else
|
||||||
|
CommunicationState <= Waiting;
|
||||||
|
errorBuf(3) <= '1';
|
||||||
end if;
|
end if;
|
||||||
else
|
|
||||||
CommunicationState <= Waiting;
|
|
||||||
errorBuf(3) <= '1';
|
|
||||||
end if;
|
end if;
|
||||||
when Timeout =>
|
when Timeout =>
|
||||||
if count < countValue then
|
if count < countValue then
|
||||||
count <= count + 1;
|
count := count + 1;
|
||||||
else
|
else
|
||||||
CommunicationState <= Waiting;
|
CommunicationState <= Waiting;
|
||||||
end if;
|
end if;
|
||||||
@ -233,8 +239,8 @@ begin
|
|||||||
pbclk <= '1';
|
pbclk <= '1';
|
||||||
pbce <= '1';
|
pbce <= '1';
|
||||||
pbdata <= (others =>'Z');
|
pbdata <= (others =>'Z');
|
||||||
pbdir <= '1';
|
pbdir <= b"11";
|
||||||
position <= 0;
|
position := 0;
|
||||||
errorCount <= 0;
|
errorCount <= 0;
|
||||||
errorBuf <= (others => '0');
|
errorBuf <= (others => '0');
|
||||||
end if;
|
end if;
|
||||||
|
Loading…
Reference in New Issue
Block a user