aboutsummaryrefslogtreecommitdiff
path: root/fmc/rtl/novena_fmc_top.v
diff options
context:
space:
mode:
Diffstat (limited to 'fmc/rtl/novena_fmc_top.v')
-rw-r--r--fmc/rtl/novena_fmc_top.v18
1 files changed, 16 insertions, 2 deletions
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)
);