diff options
author | Joachim StroĢmbergson <joachim@assured.se> | 2019-03-10 17:47:07 +0100 |
---|---|---|
committer | Joachim StroĢmbergson <joachim@assured.se> | 2019-03-10 17:47:07 +0100 |
commit | 5c1908c8dcf864ba34c616137541bececcd73b27 (patch) | |
tree | 9bddfdc42434b1f7d92394d0da034d103f1bb76f /src/rtl/fpga_mkm_spi_slave.v | |
parent | bd191a2d7a3799f178340df0661f4b3d63ee4e38 (diff) |
Adding bit counters for rx and tx. Since they will be updated the same we should have a single counter though. Created rx shift register.
Diffstat (limited to 'src/rtl/fpga_mkm_spi_slave.v')
-rw-r--r-- | src/rtl/fpga_mkm_spi_slave.v | 52 |
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 |