[Cryptech-Commits] [core/platform/novena] 01/01: If we really must byte-swap, try doing it in hardware, to make it easier to do memcpy from software.

git at cryptech.is git at cryptech.is
Tue Dec 1 16:52:23 UTC 2015


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

paul at psgd.org pushed a commit to branch hardware_htonl
in repository core/platform/novena.

commit 84a13e7563588104a10946363c7e04ad9bec2ede
Author: Paul Selkirk <paul at psgd.org>
Date:   Mon Nov 23 17:54:12 2015 -0500

    If we really must byte-swap, try doing it in hardware, to make it easier to do memcpy from software.
---
 eim/rtl/novena_eim.v     | 19 +++++++++---
 fmc/build/.gitignore     | 80 ++++++++++++++++++++++++------------------------
 fmc/rtl/novena_fmc_top.v | 18 +++++++++--
 3 files changed, 71 insertions(+), 46 deletions(-)

diff --git a/eim/rtl/novena_eim.v b/eim/rtl/novena_eim.v
index 8feec20..b9db09f 100644
--- a/eim/rtl/novena_eim.v
+++ b/eim/rtl/novena_eim.v
@@ -143,12 +143,23 @@ module novena_top
    //----------------------------------------------------------------
    // Core Selector
    //
-   // This multiplexer is used to map different types of cores, such as
-   // hashes, RNGs and ciphers to different regions (segments) of memory.
+   // This multiplexer maps read and write requests to the appropriate
+   // core.
    //----------------------------------------------------------------
 
+   // A note on byte-swapping:
+   // i.MX6 is little-endian, while the register interface here is
+   // big-endian. The software reads and writes 32-bit integer values,
+   // which means transmitting the least significant byte first. Up to
+   // now, we've been doing byte-swapping in software, which is
+   // inefficient, especially for bulk data transfer. So now we're doing
+   // the byte-swapping in hardware.
+
+   wire [31:0] 		tmp_write_data;
+   assign tmp_write_data = {sys_eim_dout[7:0], sys_eim_dout[15:8], sys_eim_dout[23:16], sys_eim_dout[31:24]};
+
    wire [31 : 0] 	tmp_read_data;
-   assign sys_eim_din = tmp_read_data;
+   assign sys_eim_din = {tmp_read_data[7:0], tmp_read_data[15:8], tmp_read_data[23:16], tmp_read_data[31:24]};
 
    core_selector cores
      (
@@ -158,7 +169,7 @@ module novena_top
       .sys_eim_addr(sys_eim_addr),
       .sys_eim_wr(sys_eim_wr),
       .sys_eim_rd(sys_eim_rd),
-      .sys_write_data(sys_eim_dout),
+      .sys_write_data(tmp_write_data),
       .sys_read_data(tmp_read_data),
 
       .noise(ct_noise),
diff --git a/fmc/build/.gitignore b/fmc/build/.gitignore
index 66d2673..cb45db8 100644
--- a/fmc/build/.gitignore
+++ b/fmc/build/.gitignore
@@ -1,51 +1,51 @@
 coregen-tmp
 *.xrpt
-novena_fmc.mcs
-novena_fmc.cfi
-novena_fmc.prm
-novena_fmc.bgn
-novena_fmc.bit
-novena_fmc.drc
-novena_fmc_bd.bmm
-novena_fmc_par.ncd
-novena_fmc_par.par
-novena_fmc_par.pad
-novena_fmc_par_pad.csv
-novena_fmc_par_pad.txt
-novena_fmc_par.grf
-novena_fmc_par.ptwx
-novena_fmc_par.unroutes
-novena_fmc_par.xpi
-novena_fmc.ncd
-novena_fmc.pcf
-novena_fmc.ngm
-novena_fmc.mrp
-novena_fmc.map
+*.mcs
+*.cfi
+*.prm
+*.bgn
+*.bit
+*.drc
+*_bd.bmm
+*_par.ncd
+*_par.par
+*_par.pad
+*_par_pad.csv
+*_par_pad.txt
+*_par.grf
+*_par.ptwx
+*_par.unroutes
+*_par.xpi
+*.ncd
+*.pcf
+*.ngm
+*.mrp
+*.map
 smartguide.ncd
-novena_fmc.psr
-novena_fmc_summary.xml
-novena_fmc_usage.xml
-novena_fmc.ngd
-novena_fmc.bld
+*.psr
+*_summary.xml
+*_usage.xml
+*.ngd
+*.bld
 xlnx_auto*
-novena_fmc_top.lso
-novena_fmc.srp
+*_top.lso
+*.srp
 netlist.lst
 xst
-novena_fmc.ngc
-novena_fmc.prj
-novena_fmc.scr
-novena_fmc.post_map.twr
-novena_fmc.post_map.twx
+*.ngc
+*.prj
+*.scr
+*.post_map.twr
+*.post_map.twx
 smartpreview.twr
-novena_fmc.twr
-novena_fmc.twx
+*.twr
+*.twx
 smartpreview.twr
-novena_fmc_err.twr
-novena_fmc_err.twx
-novena_fmc.lso
-novena_fmc_bitgen.xwb
-novena_fmc_bitgen.xwbt
+*_err.twr
+*_err.twx
+*.lso
+*_bitgen.xwb
+*_bitgen.xwbt
 usage_statistics_webtalk.html
 par_usage_statistics.html
 webtalk.log
diff --git a/fmc/rtl/novena_fmc_top.v b/fmc/rtl/novena_fmc_top.v
index 37fdc49..2d640ca 100644
--- a/fmc/rtl/novena_fmc_top.v
+++ b/fmc/rtl/novena_fmc_top.v
@@ -217,6 +217,20 @@ module novena_fmc_top
    // hashes, RNGs and ciphers to different regions (segments) of memory.
    //----------------------------------------------------------------
 
+   // A note on byte-swapping:
+   // STM32 is little-endian, while the register interface here is
+   // big-endian. The software reads and writes 32-bit integer values,
+   // which means transmitting the least significant byte first. Up to
+   // now, we've been doing byte-swapping in software, which is
+   // inefficient, especially for bulk data transfer. So now we're doing
+   // the byte-swapping in hardware.
+
+   wire [31:0] 		tmp_write_data;
+   assign tmp_write_data = {sys_fmc_dout[7:0], sys_fmc_dout[15:8], sys_fmc_dout[23:16], sys_fmc_dout[31:24]};
+
+   wire [31 : 0] 	tmp_read_data;
+   assign sys_fmc_din = {tmp_read_data[7:0], tmp_read_data[15:8], tmp_read_data[23:16], tmp_read_data[31:24]};
+
    core_selector cores
      (
       .sys_clk(sys_clk),
@@ -225,8 +239,8 @@ module novena_fmc_top
       .sys_eim_addr(sys_fmc_addr[16:0]),	// XXX parameterize
       .sys_eim_wr(sys_fmc_wren),
       .sys_eim_rd(sys_fmc_rden),
-      .sys_write_data(sys_fmc_dout),
-      .sys_read_data(sys_fmc_din),
+      .sys_write_data(tmp_write_data),
+      .sys_read_data(tmp_read_data),
 
       .noise(ct_noise)
       );  



More information about the Commits mailing list