aboutsummaryrefslogtreecommitdiff
path: root/src/rtl/fpga_mkm_spi_slave.v
diff options
context:
space:
mode:
Diffstat (limited to 'src/rtl/fpga_mkm_spi_slave.v')
-rw-r--r--src/rtl/fpga_mkm_spi_slave.v52
1 files changed, 51 insertions, 1 deletions
diff --git a/src/rtl/fpga_mkm_spi_slave.v b/src/rtl/fpga_mkm_spi_slave.v
index 92eb510..7838b23 100644
--- a/src/rtl/fpga_mkm_spi_slave.v
+++ b/src/rtl/fpga_mkm_spi_slave.v
@@ -141,7 +141,7 @@ module fpga_mkm_spi_slave(
mosi_reg <= mosi_sample1_reg;
if (rx_byte_we)
- rx_byte_reg <= rx_byte_new;
+ rx_byte_reg <= {rx_byte_reg[], mosi_reg};
if (rx_bit_ctr_we)
rx_bit_ctr_reg <= rx_bit_ctr_new;
@@ -158,10 +158,60 @@ module fpga_mkm_spi_slave(
//----------------------------------------------------------------
+ // rx_bit_ctr
+ //----------------------------------------------------------------
+ always @*
+ begin : rx_bit_ctr
+ rx_bit_ctr_new = 3'h0;
+ rx_bit_ctr_we = 1'h0;
+
+ if (rx_bit_ctr_rst)
+ begin
+ rx_bit_ctr_new = 3'h0;
+ rx_bit_ctr_we = 1'h1;
+ end
+
+ if (rx_bit_ctr_inc)
+ begin
+ rx_bit_ctr_new = rx_bit_ctr_reg + 1'h1;
+ rx_bit_ctr_we = 1'h0;
+ end
+ end
+
+
+ //----------------------------------------------------------------
+ // tx_bit_ctr
+ //----------------------------------------------------------------
+ always @*
+ begin : tx_bit_ctr
+ tx_bit_ctr_new = 3'h0;
+ tx_bit_ctr_we = 1'h0;
+
+ if (tx_bit_ctr_rst)
+ begin
+ tx_bit_ctr_new = 3'h0;
+ tx_bit_ctr_we = 1'h1;
+ end
+
+ if (tx_bit_ctr_inc)
+ begin
+ tx_bit_ctr_new = tx_bit_ctr_reg + 1'h1;
+ tx_bit_ctr_we = 1'h0;
+ end
+ end
+
+
+ //----------------------------------------------------------------
// spi_slave_ctrl_fsm
//----------------------------------------------------------------
always @*
begin : spi_slave_ctrl_fsm
+ rx_bit_ctr_rst = 1'h0;
+ rx_bit_ctr_inc = 1'h0;
+ tx_bit_ctr_rst = 1'h0;
+ tx_bit_ctr_inc = 1'h0;
+ rx_byte_we = 1'h0;
+
end
endmodule // fpga_mkm_spi_slave