Compare commits
7 Commits
0cb89fd675
...
boot-test
Author | SHA1 | Date | |
---|---|---|---|
5ed6fb3d37 | |||
10c26c0f7b | |||
87bb3a5f24 | |||
a3f166d5a2 | |||
175ed051d3 | |||
291a765b8d | |||
7b46ed6b7c |
@ -8,7 +8,7 @@
|
|||||||
.globl _prog_start
|
.globl _prog_start
|
||||||
_prog_start:
|
_prog_start:
|
||||||
smp_pause(s1, s2)
|
smp_pause(s1, s2)
|
||||||
li sp, (PAYLOAD_DEST + 0x7fff000)
|
li sp, (PAYLOAD_DEST + 0xffff000)
|
||||||
call main
|
call main
|
||||||
smp_resume(s1, s2)
|
smp_resume(s1, s2)
|
||||||
csrr a0, mhartid
|
csrr a0, mhartid
|
||||||
|
@ -20,7 +20,8 @@ static volatile uint32_t * const uart = (void *)(UART_CTRL_ADDR);
|
|||||||
|
|
||||||
static inline void kputc(char c)
|
static inline void kputc(char c)
|
||||||
{
|
{
|
||||||
volatile uint32_t *tx = ®32(uart, UART_REG_TXFIFO);
|
//volatile uint32_t *tx = ®32(uart, UART_REG_TXFIFO);
|
||||||
|
volatile uint32_t *tx = (void *) 0x64003000; // Terminal (32 bit)
|
||||||
#ifdef __riscv_atomic
|
#ifdef __riscv_atomic
|
||||||
int32_t r;
|
int32_t r;
|
||||||
do {
|
do {
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
|
|
||||||
#define PAYLOAD_SIZE (16 << 11)
|
#define PAYLOAD_SIZE (16 << 11)
|
||||||
|
|
||||||
#define F_CLK 50000000UL
|
#define F_CLK 60000000UL
|
||||||
|
|
||||||
static volatile uint32_t * const spi = (void *)(SPI_CTRL_ADDR);
|
static volatile uint32_t * const spi = (void *)(SPI_CTRL_ADDR);
|
||||||
|
|
||||||
@ -160,7 +160,8 @@ static int copy(void)
|
|||||||
int rc = 0;
|
int rc = 0;
|
||||||
|
|
||||||
dputs("CMD18");
|
dputs("CMD18");
|
||||||
kprintf("LOADING ");
|
//~ kprintf("LOADING ");
|
||||||
|
kprintf("READ: ");
|
||||||
|
|
||||||
REG32(spi, SPI_REG_SCKDIV) = (F_CLK / 20000000UL);
|
REG32(spi, SPI_REG_SCKDIV) = (F_CLK / 20000000UL);
|
||||||
if (sd_cmd(0x52, 0, 0xE1) != 0x00) {
|
if (sd_cmd(0x52, 0, 0xE1) != 0x00) {
|
||||||
@ -172,14 +173,18 @@ static int copy(void)
|
|||||||
long n;
|
long n;
|
||||||
|
|
||||||
crc = 0;
|
crc = 0;
|
||||||
n = 512;
|
//~ n = 512;
|
||||||
|
n = 50;
|
||||||
while (sd_dummy() != 0xFE);
|
while (sd_dummy() != 0xFE);
|
||||||
do {
|
do {
|
||||||
uint8_t x = sd_dummy();
|
uint8_t x = sd_dummy();
|
||||||
*p++ = x;
|
kputc(x);
|
||||||
crc = crc16_round(crc, x);
|
//~ *p++ = x;
|
||||||
|
//~ crc = crc16_round(crc, x);
|
||||||
} while (--n > 0);
|
} while (--n > 0);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
|
||||||
crc_exp = ((uint16_t)sd_dummy() << 8);
|
crc_exp = ((uint16_t)sd_dummy() << 8);
|
||||||
crc_exp |= sd_dummy();
|
crc_exp |= sd_dummy();
|
||||||
|
|
||||||
@ -202,10 +207,60 @@ static int copy(void)
|
|||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// leave room for 2 MiB stack (SP = 8FFFF000)
|
||||||
|
#define RAMTEST_START (uint32_t*)(0x80000000)
|
||||||
|
#define RAMTEST_END (uint32_t*)(0x8FDFF000)
|
||||||
|
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
REG32(uart, UART_REG_TXCTRL) = UART_TXEN;
|
//REG32(uart, UART_REG_TXCTRL) = UART_TXEN;
|
||||||
|
|
||||||
|
//GPIO_REG(GPIO_INPUT_EN) = 0xFF;
|
||||||
|
GPIO_REG(GPIO_OUTPUT_EN) = 0xFF;
|
||||||
|
GPIO_REG(GPIO_OUTPUT_VAL) = 0xFF;
|
||||||
|
|
||||||
|
kprintf("\nFilling RAM from %lx to %lx...\n", RAMTEST_START, RAMTEST_END);
|
||||||
|
|
||||||
|
uint32_t counter = 0;
|
||||||
|
for(uint32_t* ram = RAMTEST_START; ram < RAMTEST_END; ++ram) {
|
||||||
|
*ram = counter++;
|
||||||
|
}
|
||||||
|
|
||||||
|
kprintf("\rChecking RAM...\n");
|
||||||
|
|
||||||
|
counter = 0;
|
||||||
|
uint32_t correct = 0;
|
||||||
|
uint32_t wrong = 0;
|
||||||
|
for(uint32_t* ram = RAMTEST_START; ram < RAMTEST_END; ++ram) {
|
||||||
|
if(*ram != counter) {
|
||||||
|
kprintf("\rMismatch at %lx: read %x, expected %x\n", ram, *ram, counter);
|
||||||
|
++wrong;
|
||||||
|
} else {
|
||||||
|
++correct;
|
||||||
|
}
|
||||||
|
++counter;
|
||||||
|
}
|
||||||
|
kprintf("\rSummary: %x matches, %x mismatches.\n", correct, wrong);
|
||||||
|
|
||||||
|
kprintf("\nTrying to read from SD card...\n");
|
||||||
|
|
||||||
|
kputs("POWERON");
|
||||||
|
sd_poweron();
|
||||||
|
kprintf("sd_cmd0: %hx\n", sd_cmd0());
|
||||||
|
kprintf("sd_cmd8: %hx\n", sd_cmd8());
|
||||||
|
kprintf("sd_acmd41: %hx\n", sd_acmd41());
|
||||||
|
kprintf("sd_cmd58: %hx\n", sd_cmd58());
|
||||||
|
kprintf("sd_cmd16: %hx\n", sd_cmd16());
|
||||||
|
kprintf("\ncopy: %hx\n", copy());
|
||||||
|
|
||||||
|
while(1) {
|
||||||
|
//uint8_t dip_value = GPIO_REG(GPIO_INPUT_VAL) & 0b01111111;
|
||||||
|
//kprintf("dip value: %hx, ram value: %c\n", dip_value, ram[dip_value]);
|
||||||
|
|
||||||
|
GPIO_REG(GPIO_OUTPUT_VAL) ^= 0xFF;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
/*
|
||||||
kputs("INIT");
|
kputs("INIT");
|
||||||
sd_poweron();
|
sd_poweron();
|
||||||
if (sd_cmd0() ||
|
if (sd_cmd0() ||
|
||||||
@ -221,5 +276,5 @@ int main(void)
|
|||||||
kputs("BOOT");
|
kputs("BOOT");
|
||||||
|
|
||||||
__asm__ __volatile__ ("fence.i" : : : "memory");
|
__asm__ __volatile__ ("fence.i" : : : "memory");
|
||||||
return 0;
|
return 0;*/
|
||||||
}
|
}
|
||||||
|
Submodule fpga-shells updated: 79b53cf2ae...b49f5cfa78
Submodule sifive-blocks updated: 48d8524c4a...88f1cbe420
@ -14,7 +14,7 @@ import sifive.blocks.devices.spi._
|
|||||||
import sifive.blocks.devices.uart._
|
import sifive.blocks.devices.uart._
|
||||||
import sifive.blocks.devices.terminal._
|
import sifive.blocks.devices.terminal._
|
||||||
|
|
||||||
import sifive.freedom.unleashed.u500ml507devkit.fpga._
|
import sifive.fpgashells.devices.xilinx.xilinxml507mig._
|
||||||
|
|
||||||
// Default FreedomUML507Config
|
// Default FreedomUML507Config
|
||||||
class FreedomUML507Config extends Config(
|
class FreedomUML507Config extends Config(
|
||||||
@ -45,10 +45,10 @@ class U500ML507DevKitConfig extends Config(
|
|||||||
new U500ML507DevKitPeripherals ++
|
new U500ML507DevKitPeripherals ++
|
||||||
new FreedomUML507Config().alter((site,here,up) => {
|
new FreedomUML507Config().alter((site,here,up) => {
|
||||||
case ErrorParams => ErrorParams(Seq(AddressSet(0x3000, 0xfff)), maxAtomic=site(XLen)/8, maxTransfer=128)
|
case ErrorParams => ErrorParams(Seq(AddressSet(0x3000, 0xfff)), maxAtomic=site(XLen)/8, maxTransfer=128)
|
||||||
case PeripheryBusKey => up(PeripheryBusKey, site).copy(frequency = 50000000) // 50 MHz hperiphery
|
case PeripheryBusKey => up(PeripheryBusKey, site).copy(frequency = 60000000) // 60 MHz clock
|
||||||
case MemoryML507Key => MemoryML507Params(address = Seq(AddressSet(0x80000000L,0x10000000L-1))) // 256 MiB
|
case MemoryML507Key => XilinxML507MIGParams(address = Seq(AddressSet(0x80000000L,0x10000000L-1))) // 256 MiB
|
||||||
case DTSTimebase => BigInt(1000000)
|
case DTSTimebase => BigInt(1000000)
|
||||||
case ExtMem => up(ExtMem).copy(size = 0x40000000L)
|
case ExtMem => up(ExtMem).copy(size = 0x10000000L)
|
||||||
case JtagDTMKey => new JtagDTMConfig (
|
case JtagDTMKey => new JtagDTMConfig (
|
||||||
idcodeVersion = 2, // 1 was legacy (FE310-G000, Acai).
|
idcodeVersion = 2, // 1 was legacy (FE310-G000, Acai).
|
||||||
idcodePartNum = 0x000, // Decided to simplify.
|
idcodePartNum = 0x000, // Decided to simplify.
|
||||||
|
@ -42,6 +42,7 @@ class U500ML507DevKitFPGAChip(implicit override val p: Parameters)
|
|||||||
//---------------------------------------------------------------------
|
//---------------------------------------------------------------------
|
||||||
|
|
||||||
connectTerminal (dut)
|
connectTerminal (dut)
|
||||||
|
connectDDRMemory(dut)
|
||||||
connectDebugJTAG(dut)
|
connectDebugJTAG(dut)
|
||||||
connectSPI (dut)
|
connectSPI (dut)
|
||||||
connectUART (dut)
|
connectUART (dut)
|
||||||
|
@ -15,7 +15,7 @@ import sifive.blocks.devices.spi._
|
|||||||
import sifive.blocks.devices.uart._
|
import sifive.blocks.devices.uart._
|
||||||
import sifive.blocks.devices.terminal._
|
import sifive.blocks.devices.terminal._
|
||||||
|
|
||||||
import sifive.freedom.unleashed.u500ml507devkit.fpga._
|
import sifive.fpgashells.devices.xilinx.xilinxml507mig._
|
||||||
|
|
||||||
//-------------------------------------------------------------------------
|
//-------------------------------------------------------------------------
|
||||||
// U500ML507DevKitSystem
|
// U500ML507DevKitSystem
|
||||||
@ -40,7 +40,8 @@ class U500ML507DevKitSystemModule[+L <: U500ML507DevKitSystem](_outer: L)
|
|||||||
with HasPeripheryUARTModuleImp
|
with HasPeripheryUARTModuleImp
|
||||||
with HasPeripheryTerminalModuleImp
|
with HasPeripheryTerminalModuleImp
|
||||||
with HasPeripherySPIModuleImp
|
with HasPeripherySPIModuleImp
|
||||||
with HasPeripheryGPIOModuleImp {
|
with HasPeripheryGPIOModuleImp
|
||||||
|
with HasMemoryML507ModuleImp {
|
||||||
// Reset vector is set to the location of the mask rom
|
// Reset vector is set to the location of the mask rom
|
||||||
val maskROMParams = p(PeripheryMaskROMKey)
|
val maskROMParams = p(PeripheryMaskROMKey)
|
||||||
global_reset_vector := maskROMParams(0).address.U
|
global_reset_vector := maskROMParams(0).address.U
|
||||||
|
@ -1,104 +0,0 @@
|
|||||||
// See LICENSE.SiFive for license details.
|
|
||||||
|
|
||||||
package sifive.freedom.unleashed.u500ml507devkit.fpga
|
|
||||||
|
|
||||||
import Chisel._
|
|
||||||
import freechips.rocketchip.config.{Field, Parameters}
|
|
||||||
import freechips.rocketchip.diplomacy._
|
|
||||||
import freechips.rocketchip.subsystem.BaseSubsystem
|
|
||||||
import freechips.rocketchip.tilelink._
|
|
||||||
import freechips.rocketchip.util._
|
|
||||||
|
|
||||||
case class MemoryML507Params(
|
|
||||||
address: Seq[AddressSet]
|
|
||||||
)
|
|
||||||
|
|
||||||
case object MemoryML507Key extends Field[MemoryML507Params]
|
|
||||||
|
|
||||||
trait HasMemoryML507 { this: BaseSubsystem =>
|
|
||||||
val memory = LazyModule(new TLMemoryML507(p(MemoryML507Key)))
|
|
||||||
|
|
||||||
// The Fragmenter will not fragment messages <= 32 bytes, so all
|
|
||||||
// slaves have to support this size. 64 byte specifies the maximum
|
|
||||||
// supported transfer size that the slave side of the fragmenter supports
|
|
||||||
// against the master (here the main memory bus). Specifying alwaysMin as
|
|
||||||
// true results in all messages being fragmented to the minimal size
|
|
||||||
// (32 byte). In TL1 terms, slaves
|
|
||||||
// correspond roughly to managers and masters to clients (confusingly…).
|
|
||||||
val fragmenter = TLFragmenter(32, 64, alwaysMin=true)
|
|
||||||
|
|
||||||
// TODO: right TL/memory node chain?
|
|
||||||
memory.node := fragmenter := memBuses.head.toDRAMController(Some("ml507mig"))()
|
|
||||||
}
|
|
||||||
|
|
||||||
class TLMemoryML507(c: MemoryML507Params)(implicit p: Parameters) extends LazyModule {
|
|
||||||
// Corresponds to MIG interface with 64 bit width and a burst length of 4
|
|
||||||
val width = 256
|
|
||||||
val beatBytes = width/8 // 32 byte (half a cache-line, fragmented)
|
|
||||||
|
|
||||||
val device = new MemoryDevice
|
|
||||||
val node = TLManagerNode(
|
|
||||||
Seq(TLManagerPortParameters(
|
|
||||||
Seq(TLManagerParameters(
|
|
||||||
address = c.address,
|
|
||||||
resources = device.reg,
|
|
||||||
regionType = RegionType.UNCACHED,
|
|
||||||
executable = true,
|
|
||||||
supportsGet = TransferSizes(1, beatBytes),
|
|
||||||
supportsPutFull = TransferSizes(1, beatBytes),
|
|
||||||
fifoId = Some(0) // in-order
|
|
||||||
)),
|
|
||||||
beatBytes = beatBytes
|
|
||||||
))
|
|
||||||
)
|
|
||||||
// We could possibly also support supportsPutPartial, as we need support
|
|
||||||
// for masks anyway because of the possibility of transfers smaller that
|
|
||||||
// the data width (size signal, see below).
|
|
||||||
|
|
||||||
lazy val module = new LazyModuleImp(this) {
|
|
||||||
// in: TLBundle, edge: TLEdgeIn
|
|
||||||
val (in, edge) = node.in(0)
|
|
||||||
|
|
||||||
// Due to the Fragmenter defined above, all messages are 32 bytes or
|
|
||||||
// smaller. The data signal of the TL channels is also 32 bytes, so
|
|
||||||
// all messages will be transfered in a single beat.
|
|
||||||
// Also, TL guarantees (see TL$4.6) that the payload of a data message
|
|
||||||
// is always aligned to the width of the beat, e.g. in case of a 32
|
|
||||||
// byte data signal, data[7:0] will always have address 0x***00000 and
|
|
||||||
// data[255:247] address 0x***11111. It is also guaranteed that the
|
|
||||||
// mask bits always correctly reflect the active bytes inside the beat
|
|
||||||
// with respect to the size and address.
|
|
||||||
// So we can directly forward the mask, (relative) address and possibly
|
|
||||||
// data to the MIG interface.
|
|
||||||
// Put requests can be acknowledged as soon as they are latched into
|
|
||||||
// the write fifo of the MIG (possibly combinatorily).
|
|
||||||
// For read requests, we have to store the source id and size in a
|
|
||||||
// queue for later acknowledgment.
|
|
||||||
// We are ready if both the MIG and the response data queue are not
|
|
||||||
// full.
|
|
||||||
|
|
||||||
// Widths of the A channel:
|
|
||||||
// addressBits: 32
|
|
||||||
// dataBits: 256
|
|
||||||
// sourceBits: 6
|
|
||||||
// sinkBits: 1
|
|
||||||
// sizeBits: 3
|
|
||||||
|
|
||||||
// source (from): in.a.bits.source
|
|
||||||
// adresse (to): edgeIn.address(in.a.bits)
|
|
||||||
// size: edgeIn.size(in.a.bits)
|
|
||||||
// isPut: edgeIn.hasData(in.a.bits)
|
|
||||||
|
|
||||||
// bits kommt von Decoupled: ready, valid + bits
|
|
||||||
|
|
||||||
println("a parameters: " + in.a.bits.params)
|
|
||||||
|
|
||||||
in.a.ready := Bool(false)
|
|
||||||
in.d.valid := Bool(false)
|
|
||||||
|
|
||||||
// Tie off unused channels
|
|
||||||
in.b.valid := Bool(false)
|
|
||||||
in.c.ready := Bool(true)
|
|
||||||
in.e.ready := Bool(true)
|
|
||||||
}
|
|
||||||
}
|
|
Reference in New Issue
Block a user