From 84a13e7563588104a10946363c7e04ad9bec2ede Mon Sep 17 00:00:00 2001 From: Paul Selkirk Date: Mon, 23 Nov 2015 17:54:12 -0500 Subject: If we really must byte-swap, try doing it in hardware, to make it easier to do memcpy from software. --- fmc/rtl/novena_fmc_top.v | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'fmc/rtl/novena_fmc_top.v') 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) ); -- cgit v1.2.3