Skip to content
This repository has been archived by the owner on Mar 2, 2021. It is now read-only.

Commit

Permalink
Adds support for VCU118
Browse files Browse the repository at this point in the history
  • Loading branch information
Farzad Farshchi committed Jun 5, 2018
1 parent 4a8ec54 commit fdc03bc
Show file tree
Hide file tree
Showing 6 changed files with 195 additions and 2 deletions.
24 changes: 24 additions & 0 deletions Makefile.u500vcu118devkit
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# See LICENSE for license details.
base_dir := $(patsubst %/,%,$(dir $(abspath $(lastword $(MAKEFILE_LIST)))))
BUILD_DIR := $(base_dir)/builds/u500vcu118devkit
FPGA_DIR := $(base_dir)/fpga-shells/xilinx
MODEL := U500VCU118DevKitFPGAChip
PROJECT := sifive.freedom.unleashed.u500vcu118devkit
export CONFIG_PROJECT := sifive.freedom.unleashed.u500vcu118devkit
export CONFIG := U500VCU118DevKitConfig
export BOARD := vcu118
export BOOTROM_DIR := $(base_dir)/bootrom/sdboot

rocketchip_dir := $(base_dir)/rocket-chip
sifiveblocks_dir := $(base_dir)/sifive-blocks
VSRCS := \
$(rocketchip_dir)/vsrc/AsyncResetReg.v \
$(rocketchip_dir)/vsrc/plusarg_reader.v \
$(sifiveblocks_dir)/vsrc/SRLatch.v \
$(FPGA_DIR)/common/vsrc/PowerOnResetFPGAOnly.v \
$(FPGA_DIR)/$(BOARD)/vsrc/sdio.v \
$(FPGA_DIR)/$(BOARD)/vsrc/vcu118reset.v \
$(BUILD_DIR)/$(CONFIG_PROJECT).$(CONFIG).rom.v \
$(BUILD_DIR)/$(CONFIG_PROJECT).$(CONFIG).v

include common.mk
2 changes: 1 addition & 1 deletion bootrom/sdboot/sd.c
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ static int copy(void)
dputs("CMD18");
kprintf("LOADING ");

REG32(spi, SPI_REG_SCKDIV) = (F_CLK / 20000000UL);
REG32(spi, SPI_REG_SCKDIV) = (F_CLK / 16666666UL);
if (sd_cmd(0x52, 0, 0xE1) != 0x00) {
sd_cmd_end();
return 1;
Expand Down
54 changes: 54 additions & 0 deletions src/main/scala/unleashed/u500vcu118devkit/Config.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
// See LICENSE for license details.
package sifive.freedom.unleashed.u500vcu118devkit

import freechips.rocketchip.config._
import freechips.rocketchip.subsystem._
import freechips.rocketchip.devices.debug._
import freechips.rocketchip.devices.tilelink._
import freechips.rocketchip.diplomacy._
import freechips.rocketchip.system._
import freechips.rocketchip.tile._

import sifive.blocks.devices.gpio._
import sifive.blocks.devices.spi._
import sifive.blocks.devices.uart._

import sifive.fpgashells.devices.xilinx.xilinxvcu118mig.{MemoryXilinxDDRKey,XilinxVCU118MIGParams}

// Default FreedomUVCU118Config
class FreedomUVCU118Config extends Config(
new WithJtagDTM ++
new WithNMemoryChannels(1) ++
new WithNBigCores(4) ++
new BaseConfig
)

// Freedom U500 VCU118 Dev Kit Peripherals
class U500VCU118DevKitPeripherals extends Config((site, here, up) => {
case PeripheryUARTKey => List(
UARTParams(address = BigInt(0x64000000L)))
case PeripherySPIKey => List(
SPIParams(rAddress = BigInt(0x64001000L)))
case PeripheryGPIOKey => List(
GPIOParams(address = BigInt(0x64002000L), width = 4))
case PeripheryMaskROMKey => List(
MaskROMParams(address = 0x10000, name = "BootROM"))
})

// Freedom U500 VCU118 Dev Kit
class U500VCU118DevKitConfig extends Config(
new WithNExtTopInterrupts(0) ++
new U500VCU118DevKitPeripherals ++
new FreedomUVCU118Config().alter((site,here,up) => {
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 MemoryXilinxDDRKey => XilinxVCU118MIGParams(address = Seq(AddressSet(0x80000000L,0x80000000L-1))) //2GB
case DTSTimebase => BigInt(1000000)
case ExtMem => up(ExtMem).copy(size = 0x80000000L)
case JtagDTMKey => new JtagDTMConfig (
idcodeVersion = 2, // 1 was legacy (FE310-G000, Acai).
idcodePartNum = 0x000, // Decided to simplify.
idcodeManufId = 0x489, // As Assigned by JEDEC to SiFive. Only used in wrappers / test harnesses.
debugIdleCycles = 5) // Reasonable guess for synchronization
})
)
70 changes: 70 additions & 0 deletions src/main/scala/unleashed/u500vcu118devkit/FPGAChip.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
// See LICENSE for license details.
package sifive.freedom.unleashed.u500vcu118devkit

import Chisel._
import chisel3.experimental.{withClockAndReset}

import freechips.rocketchip.config._
import freechips.rocketchip.diplomacy._

import sifive.blocks.devices.gpio._
import sifive.blocks.devices.pinctrl.{BasePin}

import sifive.fpgashells.shell.xilinx.vcu118shell._
import sifive.fpgashells.ip.xilinx.{IOBUF}

//-------------------------------------------------------------------------
// PinGen
//-------------------------------------------------------------------------

object PinGen {
def apply(): BasePin = {
new BasePin()
}
}

//-------------------------------------------------------------------------
// U500VCU118DevKitFPGAChip
//-------------------------------------------------------------------------

class U500VCU118DevKitFPGAChip(implicit override val p: Parameters)
extends VCU118Shell
with HasDDR3 {

//-----------------------------------------------------------------------
// DUT
//-----------------------------------------------------------------------

// Connect the clock to the 50 Mhz output from the PLL
dut_clock := clk50
withClockAndReset(dut_clock, dut_reset) {
val dut = Module(LazyModule(new U500VCU118DevKitSystem).module)

//---------------------------------------------------------------------
// Connect peripherals
//---------------------------------------------------------------------

connectDebugJTAG(dut)
connectSPI (dut)
connectUART (dut)
connectMIG (dut)

//---------------------------------------------------------------------
// GPIO
//---------------------------------------------------------------------

val gpioParams = p(PeripheryGPIOKey)
val gpio_pins = Wire(new GPIOPins(() => PinGen(), gpioParams(0)))

GPIOPinsFromPort(gpio_pins, dut.gpio(0))

gpio_pins.pins.foreach { _.i.ival := Bool(false) }
//gpio_pins.pins.zipWithIndex.foreach {
// case(pin, idx) => led(idx) := pin.o.oval
//}

// tie to zero
//for( idx <- 7 to 4 ) { led(idx) := false.B }
}

}
45 changes: 45 additions & 0 deletions src/main/scala/unleashed/u500vcu118devkit/System.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// See LICENSE for license details.
package sifive.freedom.unleashed.u500vcu118devkit

import Chisel._

import freechips.rocketchip.config._
import freechips.rocketchip.subsystem._
import freechips.rocketchip.devices.debug._
import freechips.rocketchip.devices.tilelink._
import freechips.rocketchip.diplomacy._
import freechips.rocketchip.system._

import sifive.blocks.devices.gpio._
import sifive.blocks.devices.spi._
import sifive.blocks.devices.uart._

import sifive.fpgashells.devices.xilinx.xilinxvcu118mig._

//-------------------------------------------------------------------------
// U500VCU118DevKitSystem
//-------------------------------------------------------------------------

class U500VCU118DevKitSystem(implicit p: Parameters) extends RocketSubsystem
with HasPeripheryMaskROMSlave
with HasPeripheryDebug
with HasSystemErrorSlave
with HasPeripheryUART
with HasPeripherySPI
with HasPeripheryGPIO
with HasMemoryXilinxVCU118MIG {
override lazy val module = new U500VCU118DevKitSystemModule(this)
}

class U500VCU118DevKitSystemModule[+L <: U500VCU118DevKitSystem](_outer: L)
extends RocketSubsystemModuleImp(_outer)
with HasRTCModuleImp
with HasPeripheryDebugModuleImp
with HasPeripheryUARTModuleImp
with HasPeripherySPIModuleImp
with HasPeripheryGPIOModuleImp
with HasMemoryXilinxVCU118MIGModuleImp {
// Reset vector is set to the location of the mask rom
val maskROMParams = p(PeripheryMaskROMKey)
global_reset_vector := maskROMParams(0).address.U
}

0 comments on commit fdc03bc

Please sign in to comment.