Livt packages

Eccelerators.RiscV

Version 0.3.0

Composable RV32I and Zmmul processors, machine-mode support, and reusable FPGA system components written in Livt.

Published files (120)

src/System/RvMemorySystem.lvt

namespace Eccelerators.RiscV.System

using Eccelerators.RiscV.Sequential
using Eccelerators.RiscV.Storage

/**
 * Turnkey core with independent 4 KiB fetch ROM and byte-enabled data RAM.
 * Provision only while idle with execution paused. Execution controls are driven exclusively through this wrapper.
 * Use RvSystem with explicit devices for a custom address map.
 */
component RvMemorySystem<TCORE : IRv32ControlPort & new(flip IRv32FetchPort, flip IRv32LoadStorePort)> : IRv32ControlPort
{
	// Host provisioning of the owned default devices.
	public fetchProgramWrite: in logic
	public fetchProgramIndex: in logic[10]
	public fetchProgramData: in logic[32]
	public dataProgramWrite: in logic
	public dataProgramIndex: in logic[10]
	public dataProgramData: in logic[32]

	// System-owned default devices.
	fetchDevice: RvFetchRom
	dataDevice: RvLoadStoreRam
	core: TCORE

	/**
	 * Creates both default devices, then the core borrowing them exclusively.
	 */
	new()
	{
		fetchDevice = new RvFetchRom()
		dataDevice = new RvLoadStoreRam()
		core = new TCORE(fetchDevice, dataDevice)
	}

	/**
	 * Pure wiring preserves the core's edge-level control and retirement contract.
	 */
	process Connect[]()
	{
		core.run = run
		core.stepRequest = stepRequest
		core.restartRequest = restartRequest
		stepAck = core.stepAck
		restartAck = core.restartAck
		idle = core.idle
		halted = core.halted
		pc = core.pc
		faultCause = core.faultCause
		faultValue = core.faultValue
		trapped = core.trapped
		trapPc = core.trapPc
		trapCause = core.trapCause
		trapValue = core.trapValue
		retired = core.retired
		retiredPc = core.retiredPc
		retiredInstruction = core.retiredInstruction
		retiredRd = core.retiredRd
		retiredValue = core.retiredValue
		fetchDevice.programWrite = fetchProgramWrite
		fetchDevice.programIndex = fetchProgramIndex
		fetchDevice.programData = fetchProgramData
		dataDevice.programWrite = dataProgramWrite
		dataDevice.programIndex = dataProgramIndex
		dataDevice.programData = dataProgramData
	}
}