Skip to content

Commit

Permalink
Deny access to the SPI master in app mode
Browse files Browse the repository at this point in the history
  • Loading branch information
dehanj committed Nov 14, 2024
1 parent 15ccb60 commit 9028a57
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions hw/application_fpga/core/tk1/rtl/tk1.v
Original file line number Diff line number Diff line change
Expand Up @@ -467,8 +467,8 @@ module tk1 (
spi_start = 1'h0;
spi_tx_data_vld = 1'h0;

spi_enable = write_data[0];
spi_tx_data = write_data[7 : 0];
spi_enable = write_data[0] & ~system_mode_reg;
spi_tx_data = write_data[7 : 0] & ~{8{system_mode_reg}};

if (cs) begin
tmp_ready = 1'h1;
Expand Down Expand Up @@ -545,15 +545,21 @@ module tk1 (
end

if (address == ADDR_SPI_EN) begin
spi_enable_vld = 1'h1;
if (!system_mode_reg) begin
spi_enable_vld = 1'h1;
end
end

if (address == ADDR_SPI_XFER) begin
spi_start = 1'h1;
if (!system_mode_reg) begin
spi_start = 1'h1;
end
end

if (address == ADDR_SPI_DATA) begin
spi_tx_data_vld = 1'h1;
if (!system_mode_reg) begin
spi_tx_data_vld = 1'h1;
end
end

end
Expand Down Expand Up @@ -609,11 +615,15 @@ module tk1 (
end

if (address == ADDR_SPI_XFER) begin
tmp_read_data[0] = spi_ready;
if (!system_mode_reg) begin
tmp_read_data[0] = spi_ready;
end
end

if (address == ADDR_SPI_DATA) begin
tmp_read_data[7 : 0] = spi_rx_data;
if (!system_mode_reg) begin
tmp_read_data[7 : 0] = spi_rx_data;
end
end

end
Expand Down

0 comments on commit 9028a57

Please sign in to comment.