diff options
author | Paul Selkirk <paul@psgd.org> | 2015-11-23 17:54:12 -0500 |
---|---|---|
committer | Paul Selkirk <paul@psgd.org> | 2015-11-23 17:54:12 -0500 |
commit | 84a13e7563588104a10946363c7e04ad9bec2ede (patch) | |
tree | afa37f8f8add1c3daca7d841a5855f26266eac15 /fmc/rtl | |
parent | a4737cc9305cbab9bb9c044fad48d75dff37568c (diff) |
If we really must byte-swap, try doing it in hardware, to make it easier to do memcpy from software.hardware_htonl
Diffstat (limited to 'fmc/rtl')
-rw-r--r-- | fmc/rtl/novena_fmc_top.v | 18 |
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) ); |