Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Midas integration #6

Merged
merged 52 commits into from
Oct 3, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
ec78da8
Moved files from firrtl repo to new midas repo
jackkoenig Dec 8, 2015
20467fc
Added HostDecoupledIO Type
jackkoenig Dec 10, 2015
a9a03b7
Added .gitignore, minor documentation change to Fame, changed old Hos…
jackkoenig Dec 11, 2015
fe59210
Update to new FIRRTL spec, add tests, add submodules for testing.
jackkoenig Mar 23, 2016
f1da21e
Just fame-1 xform the top module
davidbiancolin Apr 30, 2016
0d74609
A bunch of demo related hacks to get the pointer chaser working
davidbiancolin May 9, 2016
2eb058b
mask memory enables
donggyukim May 12, 2016
a426fa1
whens should go at the end of the body... why?
donggyukim May 12, 2016
8fd841f
WIP - Midas configuration file, ripped from uncore, speaks NASTI
davidbiancolin May 13, 2016
e60bf88
WIP - MCR file integration. Change build to depend on junctions, para…
davidbiancolin May 14, 2016
760edfc
WIP - Add an MCR driven simulation controller
davidbiancolin May 15, 2016
c4d55fc
Make sim controller take its base address from params
davidbiancolin May 16, 2016
3b95e16
Properly return the channel ID on writes to MCRFiles
davidbiancolin May 18, 2016
6eb4030
Merge branch 'transform_top' of github.com:jackkoenig/midas into risc…
donggyukim May 18, 2016
6a1544e
Align mcrs to appropriate word boundaries
davidbiancolin May 19, 2016
da21cc1
Merge branch 'transform_top' of github.com:jackkoenig/midas into risc…
donggyukim May 19, 2016
be01c8b
Enable write strobe
davidbiancolin May 20, 2016
e86bc40
Hack: Add flipToken as a parameter to HostPort
davidbiancolin Jun 2, 2016
9e7a609
Remove firrtlutils
davidbiancolin Jun 5, 2016
98f796b
Add a scan register to help measure FPGA QoR on single module
davidbiancolin Jun 15, 2016
deb49b4
Implement a SeqMem based MultiFifo
davidbiancolin Jun 17, 2016
4186563
Minor style changes
davidbiancolin Jun 17, 2016
33387ed
Merge remote-tracking branch 'origin/transform_top'
davidbiancolin Jun 18, 2016
f2cdcc1
Add a saturating up/down counter
davidbiancolin Jun 28, 2016
ff21cb8
Remove fame1 pass, defunct firrtl utils
davidbiancolin Sep 6, 2016
c16238b
turn off AddDaisyChains for a while
donggyukim Sep 10, 2016
5c169a4
First pass at factoring out widgets in Zynq shim
davidbiancolin Sep 22, 2016
c148ead
Simplify MCR file for the time being until we move to TL
davidbiancolin Sep 22, 2016
afbab99
Use midas host_port and fix memory model
davidbiancolin Sep 23, 2016
06c3ad1
Merge remote-tracking branch 'origin/chisel3' into midas_integration
davidbiancolin Sep 23, 2016
ebb4972
[WIP] Memory model functions for ISA tests
davidbiancolin Sep 24, 2016
8ebe543
Remove unused modules, change hostOut hostIn to toHost and fromHost
davidbiancolin Sep 26, 2016
5aa2a95
Remove errant println
davidbiancolin Sep 26, 2016
67896d6
Add support for externally defined memory model
davidbiancolin Sep 26, 2016
73e425c
Merge branch 'chisel3' of github.com:ucb-bar/strober into midas_integ…
davidbiancolin Sep 26, 2016
23eb7a1
[WIP] Use correct address offset
davidbiancolin Sep 27, 2016
67405d1
Ensure last is asserted in w xactions, reduce reset length
davidbiancolin Sep 27, 2016
1821e6e
Merge branch 'chisel3' of github.com:ucb-bar/strober into midas_integ…
davidbiancolin Sep 27, 2016
7561474
Prepare to push into strober
davidbiancolin Sep 27, 2016
14f763f
Merge branch 'strober_integration' of ../../midas_merge into midas_in…
davidbiancolin Sep 27, 2016
274a434
Remove defunct midas dependency
davidbiancolin Sep 27, 2016
a3a0bce
Pass correct NastiKey to the McrFile
davidbiancolin Sep 29, 2016
72dc51c
Merge branch 'master' of https://github.com/ucb-bar/strober into mida…
donggyukim Oct 1, 2016
e3a8c76
Merge branch 'midas_integration' of https://github.com/ucb-bar/strobe…
donggyukim Oct 1, 2016
dbcf38c
gsdt fix
donggyukim Oct 1, 2016
99ea200
catch up lastest junctions
donggyukim Oct 2, 2016
8d3917b
truncate adresses according to platform MMIO size
donggyukim Oct 2, 2016
feeb287
remove set_latency
donggyukim Oct 3, 2016
eb4166e
fix widget addresses
donggyukim Oct 3, 2016
76d9fa6
poke correct write data strb
donggyukim Oct 3, 2016
9f35369
fix width of latency
donggyukim Oct 3, 2016
1f2262e
avoid weird bulk connection behavior
donggyukim Oct 3, 2016
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
3 changes: 0 additions & 3 deletions csrc/simif.h
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,6 @@ class simif_t
void init();
void finish();
inline uint64_t cycles() { return t; }
inline void set_latency(size_t cycles) {
poke_channel(LATENCY_ADDR, cycles);
}
inline void set_tracelen(size_t len) {
assert(len > 2);
trace_len = len;
Expand Down
38 changes: 19 additions & 19 deletions src/main/scala/compiler.scala
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ private class StroberCompilerContext {
val shims = ArrayBuffer[ZynqShim[_]]()
// Todo: Should be handled in the backend
val memPorts = ArrayBuffer[junctions.NastiIO]()
val memWires = HashSet[Chisel.Bits]()
val memWires = HashSet[chisel3.Bits]()
}

private class StroberCompiler extends firrtl.Compiler {
Expand Down Expand Up @@ -75,30 +75,30 @@ object StroberCompiler {
implicit val channelWidth = sim.channelWidth
def dump(arg: (String, Int)) = s"#define ${arg._1} ${arg._2}\n"
val consts = List(
"HOST_RESET_ADDR" -> ZynqCtrlSignals.HOST_RESET.id,
"SIM_RESET_ADDR" -> ZynqCtrlSignals.SIM_RESET.id,
"STEP_ADDR" -> ZynqCtrlSignals.STEP.id,
"DONE_ADDR" -> ZynqCtrlSignals.DONE.id,
"TRACELEN_ADDR" -> ZynqCtrlSignals.TRACELEN.id,
"LATENCY_ADDR" -> ZynqCtrlSignals.LATENCY.id,
"MEM_AR_ADDR" -> c.AR_ADDR,
"MEM_AW_ADDR" -> c.AW_ADDR,
"MEM_W_ADDR" -> c.W_ADDR,
"MEM_R_ADDR" -> c.R_ADDR,
"CTRL_NUM" -> c.CTRL_NUM,
"CTRL_NUM" -> c.CTRL_NUM,
"DAISY_WIDTH" -> (c.sim match { case sim: SimWrapper[_] => sim.daisyWidth }),
"POKE_SIZE" -> c.ins.size,
"PEEK_SIZE" -> c.outs.size,
"MEM_DATA_BITS" -> c.arb.nastiXDataBits,
"TRACE_MAX_LEN" -> sim.traceMaxLen,
"MEM_DATA_CHUNK" -> SimUtils.getChunks(c.io.slave.w.bits.data),

"HOST_RESET_ADDR" -> ZynqCtrlSignals.HOST_RESET.id,
"SIM_RESET_ADDR" -> ZynqCtrlSignals.SIM_RESET.id,
"STEP_ADDR" -> ZynqCtrlSignals.STEP.id,
"DONE_ADDR" -> ZynqCtrlSignals.DONE.id,
"TRACELEN_ADDR" -> ZynqCtrlSignals.TRACELEN.id,
"SRAM_RESTART_ADDR" -> c.SRAM_RESTART_ADDR,
"DAISY_WIDTH" -> (c.sim match { case sim: SimWrapper[_] => sim.daisyWidth }),
"POKE_SIZE" -> c.ins.size,
"PEEK_SIZE" -> c.outs.size,
"MEM_DATA_BITS" -> c.arb.nastiXDataBits,
"TRACE_MAX_LEN" -> sim.traceMaxLen,
"MEM_DATA_CHUNK" -> SimUtils.getChunks(c.io.slave.w.bits.data)
"MEM_AR_ADDR" -> c.AR_ADDR,
"MEM_AW_ADDR" -> c.AW_ADDR,
"MEM_W_ADDR" -> c.W_ADDR,
"MEM_R_ADDR" -> c.R_ADDR
)
val sb = new StringBuilder
sb append "#ifndef __%s_H\n".format(targetName.toUpperCase)
sb append "#define __%s_H\n".format(targetName.toUpperCase)
consts foreach (sb append dump(_))
val chainTypes =
c.genHeader(sb)
sb append "enum CHAIN_TYPE {%s,CHAIN_NUM};\n".format(
ChainType.values.toList map (t => s"${t.toString.toUpperCase}_CHAIN") mkString ",")
sb append "const unsigned CHAIN_SIZE[CHAIN_NUM] = {%s};\n".format(
Expand Down
3 changes: 2 additions & 1 deletion src/main/scala/daisy.scala
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package strober

import Chisel._
import chisel3._
import chisel3.util._
import cde.{Parameters, Field}
import scala.collection.mutable.HashMap

Expand Down
97 changes: 0 additions & 97 deletions src/main/scala/mem.scala

This file was deleted.

17 changes: 12 additions & 5 deletions src/main/scala/testers/ZynqShimTester.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package strober
package testers

import junctions._
import midas_widgets._
import scala.collection.mutable.{HashMap, ArrayBuffer, Queue => ScalaQueue}
import java.io.{File, InputStream}

Expand All @@ -26,7 +27,7 @@ abstract class ZynqShimTester[+T <: SimNetwork](
private val MAXI_aw = new ChannelSource(c.io.master.aw, (aw: NastiWriteAddressChannel, in: NastiWriteAddr) =>
{ _poke(aw.id, in.id) ; _poke(aw.addr, in.addr) })
private val MAXI_w = new ChannelSource(c.io.master.w, (w: NastiWriteDataChannel, in: NastiWriteData) =>
{ _poke(w.data, in.data) })
{ _poke(w.data, in.data) ; _poke(w.last, in.last) ; _poke(w.strb, (BigInt(1) << w.nastiWStrobeBits) - 1) })
private val MAXI_b = new ChannelSink(c.io.master.b, (b: NastiWriteResponseChannel) =>
new NastiWriteResp(_peek(b.id), _peek(b.resp)))
private val MAXI_ar = new ChannelSource(c.io.master.ar, (ar: NastiReadAddressChannel, in: NastiReadAddr) =>
Expand Down Expand Up @@ -54,15 +55,21 @@ abstract class ZynqShimTester[+T <: SimNetwork](
pokeChannel(ZynqCtrlSignals.TRACELEN.id, len)
}

def setMemLatency(cycles: Int) {
pokeChannel(ZynqCtrlSignals.LATENCY.id, cycles)
def writeCR(w: Widget, crName: String, value: BigInt){
val addr = c.getCRAddr(w, crName)
pokeChannel(addr, value)
}

def readCR(w: Widget, crName: String) = {
val addr = c.getCRAddr(w, crName)
peekChannel(addr)
}

override def reset(n: Int) {
for (_ <- 0 until n) {
pokeChannel(ZynqCtrlSignals.HOST_RESET.id, 0)
pokeChannel(ZynqCtrlSignals.SIM_RESET.id, 0)
Predef.assert(_eventually(peekChannel(ZynqCtrlSignals.DONE.id)),
Predef.assert(_eventually(peekChannel(ZynqCtrlSignals.DONE.id) == BigInt(1)),
"simulation is not done in time")
_peekMap.clear
// flush junk output tokens
Expand All @@ -79,7 +86,7 @@ abstract class ZynqShimTester[+T <: SimNetwork](
c.IN_ADDRS foreach {case (in, addr) =>
pokeChunks(addr, SimUtils.getChunks(in), _pokeMap getOrElse (in, BigInt(rnd.nextInt)))
}
Predef.assert(_eventually(peekChannel(ZynqCtrlSignals.DONE.id)),
Predef.assert(_eventually(peekChannel(ZynqCtrlSignals.DONE.id) == BigInt(1)),
"simulation is not done in time")
c.OUT_ADDRS foreach {case (out, addr) =>
_peekMap(out) = peekChunks(addr, SimUtils.getChunks(out))
Expand Down
20 changes: 18 additions & 2 deletions src/main/scala/util.scala
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package strober

import Chisel._
import chisel3._
import chisel3.util._
import junctions.NastiIO
import scala.collection.immutable.ListMap
import scala.collection.mutable.ArrayBuffer
Expand Down Expand Up @@ -55,7 +56,7 @@ object SimUtils {
val channels = inChannels slice (off, off + getChunks(wire))
val channelOuts = wire match {
case _: Bool => channels.head.io.out.bits.toBool
case _ => Vec(channels map (_.io.out.bits)).toBits
case _ => Cat(channels map (_.io.out.bits))
}
val buffer = RegEnable(channelOuts, fire)
buffer suggestName (name + "_buffer")
Expand All @@ -72,3 +73,18 @@ object SimUtils {
off + getChunks(wire)
}
}

object SimMemIO {
def add(mem: NastiIO) {
val (ins, outs) = SimUtils.parsePorts(mem)
StroberCompiler.context.memWires ++= ins.unzip._1
StroberCompiler.context.memWires ++= outs.unzip._1
StroberCompiler.context.memPorts += mem
}
def apply(i: Int): NastiIO = StroberCompiler.context.memPorts(i)
def apply(wire: Bits) = StroberCompiler.context.memWires(wire)
def apply(mem: NastiIO) = StroberCompiler.context.memPorts contains mem
def zipWithIndex = StroberCompiler.context.memPorts.toList.zipWithIndex
def size = StroberCompiler.context.memPorts.size
}

79 changes: 79 additions & 0 deletions src/main/scala/widgets/Interfaces.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
package midas_widgets

import chisel3._

// Adapted from DecoupledIO in Chisel3
class HostDecoupledIO[+T <: Data](gen: T) extends Bundle
{
val hReady = Bool(INPUT)
val hValid = Bool(OUTPUT)
val hBits = gen.cloneType
def fire(dummy: Int = 0): Bool = hReady && hValid
override def cloneType: this.type =
new HostDecoupledIO(gen).asInstanceOf[this.type]
}

/** Adds a ready-valid handshaking protocol to any interface.
* The standard used is that the consumer uses the flipped interface.
*/
object HostDecoupled {
def apply[T <: Data](gen: T): HostDecoupledIO[T] = new HostDecoupledIO(gen)
}


class HostReadyValid extends Bundle {
val hReady= Bool(INPUT)
val hValid = Bool(OUTPUT)
def fire(dummy: Int = 0): Bool = hReady && hValid
}

/**
* Hack: A note on tokenFlip:
* Previously we had difficulties generating hostPortIOs with flipped
* aggregates of aggregates. We thus had to manually flip the subfields of the
* aggregate in a new class (ex. the FlipNastiIO). tokenFlip captures
* whether hBits should be flipped when it is cloned.
*
* thus what would ideally be expressed as HostPort(Flipped(new NastiIO)) must
* be expressed as HostPort((new NastiIO), tokenFlip = true)
*/

class HostPortIO[+T <: Data](gen: T, tokenFlip: Boolean) extends Bundle
{
val fromHost = Flipped(new HostReadyValid)
val toHost = new HostReadyValid
val hBits = if (tokenFlip) Flipped(gen.cloneType) else gen cloneType
override def cloneType: this.type =
new HostPortIO(gen, tokenFlip).asInstanceOf[this.type]
}

object HostPort {
def apply[T <: Data](gen: T, tokenFlip : Boolean = false): HostPortIO[T] = new HostPortIO(gen, tokenFlip)
}


// The below is currently used to generate FIRRTL code for buildSimQueue
// TODO
// - Actually use this code in buildSimQueue instead of one off FIRRTL
// - This requires either a change to Bundle API (and possible others)
// or using Scala macros (see quasiquotes)

/** An I/O Bundle with simple handshaking using valid and ready signals for
* data 'bits'
*/
class MidasDecoupledIO[+T <: Data](gen: T) extends Bundle
{
val hReady = Bool(INPUT)
val hValid = Bool(OUTPUT)
val hBits = gen.cloneType.asOutput
def fire(dummy: Int = 0): Bool = hReady && hValid
override def cloneType: this.type =
new MidasDecoupledIO(gen).asInstanceOf[this.type]
}

/** Adds a hReady-hValid handshaking protocol to any interface.
* The standard used is that the consumer uses the flipped interface.
*/
object MidasDecoupled {
def apply[T <: Data](gen: T): MidasDecoupledIO[T] = new MidasDecoupledIO(gen)
}
Loading