Permalink
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
94 lines (91 sloc) 2.81 KB
################################################################################
##
## Filename: bkram.txt
##
## Project: AutoFPGA, a utility for composing FPGA designs from peripherals
##
## Purpose: To define the interface to a generic block RAM device for the
## purposes of autofpga.
##
## Creator: Dan Gisselquist, Ph.D.
## Gisselquist Technology, LLC
##
################################################################################
##
## Copyright (C) 2017, Gisselquist Technology, LLC
##
## This program is free software (firmware): you can redistribute it and/or
## modify it under the terms of the GNU General Public License as published
## by the Free Software Foundation, either version 3 of the License, or (at
## your option) any later version.
##
## This program is distributed in the hope that it will be useful, but WITHOUT
## ANY WARRANTY; without even the implied warranty of MERCHANTIBILITY or
## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
## for more details.
##
## You should have received a copy of the GNU General Public License along
## with this program. (It's in the $(ROOT)/doc directory. Run make with no
## target there if the PDF file isn't present.) If not, see
## <http://www.gnu.org/licenses/> for a copy.
##
## License: GPL, v3, as defined and found on www.gnu.org,
## http://www.gnu.org/licenses/gpl.html
##
##
################################################################################
##
##
@PREFIX=bkram
@DEVID=BKRAM
@$LGMEMSZ=20
@LGMEMSZ.FORMAT=%d
@$NADDR=(1<<(@$THIS.LGMEMSZ-2))
@$NBYTES=(1<<(@$THIS.LGMEMSZ))
@NBYTES.FORMAT=0x%08x
@ACCESS=@$(DEVID)_ACCESS
@SLAVE.TYPE=MEMORY
@SLAVE.BUS=wb
@LD.PERM=wx
@MAIN.INSERT=
memdev #(.LGMEMSZ(@$THIS.LGMEMSZ), .EXTRACLOCK(1))
@$(PREFIX)i(i_clk, i_reset,
(wb_cyc), (wb_stb)&&(@$(PREFIX)_sel), wb_we,
wb_addr[(@$THIS.LGMEMSZ-3):0], wb_data, wb_sel,
@$(PREFIX)_ack, @$(PREFIX)_stall, @$(PREFIX)_data);
@REGS.N=1
@REGS.0= 0 R_@$(DEVID) RAM
@REGDEFS.H.DEFNS=
#define @$(DEVID)BASE @$[0x%08x](REGBASE)
#define @$(DEVID)LEN @$NBYTES
@BDEF.OSDEF=_BOARD_HAS_@$(DEVID)
@MEM.NAME= @$(PREFIX)
@BDEF.OSVAL=extern char _@$(MEM.NAME)[@$NBYTES];
@LDSCRIPT.PSTR= wx
@LDSCRIPT.PTR= @$(MEM.NAME)
@LDSCRIPT.DEF=
_@$(MEM.NAME) = ORIGIN(@$(MEM.NAME))
@RTL.MAKE.GROUP= @$(DEVID)
@RTL.MAKE.FILES= memdev.v
@$NADDRHX = @$NADDR
@NADDRHX.FORMAT= 0x%x
@SIM.INCLUDE=
#include "byteswap.h"
@SIM.DEFINES=
#ifndef VVAR
#ifdef NEW_VERILATOR
#define VVAR(A) main__DOT_ ## A
#else
#define VVAR(A) v__DOT_ ## A
#endif
#endif
#define block_ram VVAR(_@$(PREFIX)i__DOT__mem)
@SIM.LOAD=
start = start & (-4);
wlen = (wlen+3)&(-4);
// Need to byte swap data to get it into the memory
char *bswapd = new char[len+8];
memcpy(bswapd, &buf[offset], wlen);
byteswapbuf(len>>2, (uint32_t *)bswapd);
memcpy(&m_core->block_ram[start], bswapd, wlen);
delete bswapd;