[Cryptech-Commits] [user/js/fpga_mkm] branch master updated: 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.

git at cryptech.is git at cryptech.is
Sun Mar 10 16:47:36 UTC 2019


This is an automated email from the git hooks/post-receive script.

joachim at secworks.se pushed a commit to branch master
in repository user/js/fpga_mkm.

The following commit(s) were added to refs/heads/master by this push:
     new 5c1908c  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.
5c1908c is described below

commit 5c1908c8dcf864ba34c616137541bececcd73b27
Author: Joachim Strömbergson <joachim at assured.se>
AuthorDate: Sun Mar 10 17:47:07 2019 +0100

    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.
---
 src/rtl/fpga_mkm.v           | 24 +++++++++++++-------
 src/rtl/fpga_mkm_spi_slave.v | 52 +++++++++++++++++++++++++++++++++++++++++++-
 2 files changed, 67 insertions(+), 9 deletions(-)

diff --git a/src/rtl/fpga_mkm.v b/src/rtl/fpga_mkm.v
index 6dee64a..eb6172d 100644
--- a/src/rtl/fpga_mkm.v
+++ b/src/rtl/fpga_mkm.v
@@ -102,18 +102,26 @@ module fpga_mkm(
   //----------------------------------------------------------------
   // reg_update
   //----------------------------------------------------------------
-  always @ (posedge clk)
+  always @ (posedge clk or negedge tamper)
     begin : reg_update
-      alarm_counter_reg <= alarm_counter_reg + 1;
+      if (!tamper)
+        begin
+          // Zeroise the key material!
 
-      if (alarm_we)
-        alarm_reg <= alarm_new;
+        end
+      else
+        begin
+          alarm_counter_reg <= alarm_counter_reg + 1;
 
-      if (key_loaded_we)
-        key_loaded_reg <= key_loaded_new;
+          if (alarm_we)
+            alarm_reg <= alarm_new;
 
-      if (fpga_mkm_ctrl_we)
-        fpga_mkm_ctrl_reg <= fpga_mkm_ctrl_new;
+          if (key_loaded_we)
+            key_loaded_reg <= key_loaded_new;
+
+          if (fpga_mkm_ctrl_we)
+            fpga_mkm_ctrl_reg <= fpga_mkm_ctrl_new;
+        end
     end
 
 
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;
@@ -157,11 +157,61 @@ module fpga_mkm_spi_slave(
     end
 
 
+  //----------------------------------------------------------------
+  // 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

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Commits mailing list