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

Adding Future Avalanche Board design files #109

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions Makefile.u500polarfireavalanchekit
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/u500polarfireavalanchekit
FPGA_DIR := $(base_dir)/fpga-shells/microsemi
MODEL := U500PolarFireAvalancheKitFPGAChip
PROJECT := sifive.freedom.unleashed.u500polarfireavalanchekit
CONFIG_PROJECT := sifive.freedom.unleashed.u500polarfireavalanchekit
export CONFIG := U500PolarFireAvalancheKitConfig
export BOARD := polarfireavalancheboard
export BOOTROM_DIR := $(base_dir)/bootrom/sdboot

rocketchip_dir := $(base_dir)/rocket-chip
sifiveblocks_dir := $(base_dir)/sifive-blocks
VSRCS := \
$(rocketchip_dir)/src/main/resources/vsrc/AsyncResetReg.v \
$(rocketchip_dir)/src/main/resources/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/vc707reset.v \
$(BUILD_DIR)/$(CONFIG_PROJECT).$(CONFIG).rom.v \
$(BUILD_DIR)/$(CONFIG_PROJECT).$(CONFIG).v

include common.mk
51 changes: 51 additions & 0 deletions src/main/scala/unleashed/u500polarfireavalanchekit/Config.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
// See LICENSE for license details.
package sifive.freedom.unleashed.u500polarfireavalanchekit

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.microsemi.polarfireddr3.{MemoryMicrosemiAvalancheBoardDDR3Key, PolarFireAvalancheBoardDDR3Params}


// Default FreedomU PolarFire Avalanche Kit Config
class FreedomUPolarFireAvalancheKitConfig extends Config(
new WithJtagDTM ++
new WithNMemoryChannels(1) ++
new WithNBigCores(1) ++
new BaseConfig
)

// Freedom U500 PolarFire Eval Kit Peripherals
class U500PolarFireAvalancheKitPeripherals 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))
})

// Freedom U500 PolarFire Avalanche Kit
class U500PolarFireAvalancheKitConfig extends Config(
new WithNExtTopInterrupts(0) ++
new U500PolarFireAvalancheKitPeripherals ++
new FreedomUPolarFireAvalancheKitConfig ().alter((site,here,up) => {
case PeripheryBusKey => up(PeripheryBusKey, site).copy(frequency = 50000000) // 50 MHz hperiphery
case MemoryMicrosemiAvalancheBoardDDR3Key => PolarFireAvalancheBoardDDR3Params(address = Seq(AddressSet(0x80000000L,0x40000000L-1))) //1GB
case DTSTimebase => BigInt(1000000)
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
})
)
69 changes: 69 additions & 0 deletions src/main/scala/unleashed/u500polarfireavalanchekit/FPGAChip.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
// See LICENSE for license details.
package sifive.freedom.unleashed.u500polarfireavalanchekit

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.devices.microsemi.polarfireddr3._
import sifive.fpgashells.shell.microsemi.polarfireavalanchekitshell._

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

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

//-------------------------------------------------------------------------
// U500VC707DevKitFPGAChip
//-------------------------------------------------------------------------


class U500PolarFireAvalancheKitFPGAChip(implicit override val p: Parameters)
extends PolarFireAvalancheKitShell
with HasDDR3 {

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

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

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

connectDebugJTAG(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/u500polarfireavalanchekit/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.u500polarfireavalanchekit

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.uart._

import sifive.fpgashells.devices.microsemi.polarfireddr3._


//-------------------------------------------------------------------------
// U500PolarFireEvalKitSystem
//-------------------------------------------------------------------------

//class U500PolarFireAvalancheKitSystem(implicit p: Parameters) extends RocketCoreplex
class U500PolarFireAvalancheKitSystem(implicit p: Parameters) extends RocketSubsystem
with HasPeripheryDebug
with HasPeripheryUART
with HasPeripheryGPIO
with HasMemoryPolarFireAvalancheBoardDDR3{
override lazy val module = new U500PolarFireAvalancheKitSystemModule(this)
}

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