Freedom E300 Hardware Accelerator

Hi, I am trying to use the hardware acclerator in Freedom e300. As per my understanding I am doing this

  1. By looking at class WithRoccExample in coreplex/Config.scala adding following code in it
    class WithAccumRocc extends Config((site, here, up) => {
    case RocketTilesKey => up(RocketTilesKey, site) map { r =>
    r.copy(rocc =
    Seq(
    RoCCParams(
    opcodes = OpcodeSet.custom0,
    generator = (p: Parameters) => LazyModule(new AccumulatorExample()§))
    ))
    }
    })
  2. In system/Config.scala updating class TinyConfig as following:
    class TinyConfig extends Config(
    new WithNMemoryChannels(0) ++
    new WithStatelessBridge ++
    new WithNTinyCores(1) ++
    //add by me
    new WithAccumRocc ++
    new BaseConfig)
    Am I doing it right? What am I missing? because when I compare the generated verilog code with the one without Accelerator there is no difference. Could you please guide me how to add hardware accelerator? Thank you

Hey Nauman,

You are very close. The issue is that WithAccumRocc only modifies the existing cores in the configuration. In this case that means because WithAccumRocc is appended after WitNTinyCores(1) the Tiny cores will not be modified. Switching the order of those statements should produce your expected output.

Colin

Hi Colin, Thank you for the reply. I moved new WithAccumRocc ++ before new WithNTinyCores(1) ++ instructions and now I am getting following error.
mkdir -p /home/anbuntu/freedom/builds/e300artydevkit/
java -jar /home/anbuntu/freedom/rocket-chip/sbt-launch.jar “run-main freechips.rocketchip.system.Generator /home/anbuntu/freedom/builds/e300artydevkit sifive.freedom.everywhere.e300artydevkit E300ArtyDevKitFPGAChip sifive.freedom.everywhere.e300artydevkit E300ArtyDevKitConfig”
[info] Loading project definition from /home/anbuntu/freedom/rocket-chip/project
Using addons:
[info] Set current project to freedom (in build file:/home/anbuntu/freedom/)
[info] Compiling 1 Scala source to /home/anbuntu/freedom/rocket-chip/chisel3/target/scala-2.11/classes…
[info] Packaging /home/anbuntu/freedom/rocket-chip/chisel3/target/scala-2.11/chisel3_2.11-3.1-SNAPSHOT.jar …
[info] Done packaging.
[info] Compiling 1 Scala source to /home/anbuntu/freedom/rocket-chip/target/scala-2.11/classes…
[info] Running freechips.rocketchip.system.Generator /home/anbuntu/freedom/builds/e300artydevkit sifive.freedom.everywhere.e300artydevkit E300ArtyDevKitFPGAChip sifive.freedom.everywhere.e300artydevkit E300ArtyDevKitConfig
[info] [0.003] Elaborating design…
Interrupt map (1 harts 52 interrupts):
[1, 2] => aon
[3, 3] => uarts_0
[4, 4] => uarts_1
[5, 5] => qspis_0
[6, 6] => spis_0
[7, 7] => spis_1
[8, 39] => gpios_0
[40, 43] => pwms_0
[44, 47] => pwms_1
[48, 51] => pwms_2
[52, 52] => i2c_0

[error] (run-main-0) java.lang.reflect.InvocationTargetException
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at freechips.rocketchip.util.HasGeneratorUtilities$$anonfun$2.apply(GeneratorUtils.scala:50)
at freechips.rocketchip.util.HasGeneratorUtilities$$anonfun$2.apply(GeneratorUtils.scala:47)
at chisel3.core.Module$.do_apply(Module.scala:42)
at chisel3.Driver$$anonfun$elaborate$1.apply(Driver.scala:92)
at chisel3.Driver$$anonfun$elaborate$1.apply(Driver.scala:92)
at chisel3.internal.Builder$$anonfun$build$1.apply(Builder.scala:240)
at chisel3.internal.Builder$$anonfun$build$1.apply(Builder.scala:238)
at scala.util.DynamicVariable.withValue(DynamicVariable.scala:58)
at chisel3.internal.Builder$.build(Builder.scala:238)
at chisel3.Driver$.elaborate(Driver.scala:92)
at freechips.rocketchip.util.HasGeneratorUtilities$class.elaborate(GeneratorUtils.scala:53)
at freechips.rocketchip.system.Generator$.elaborate(Generator.scala:12)
at freechips.rocketchip.util.GeneratorApp$class.circuit(GeneratorUtils.scala:100)
at freechips.rocketchip.system.Generator$.circuit$lzycompute(Generator.scala:12)
at freechips.rocketchip.system.Generator$.circuit(Generator.scala:12)
at freechips.rocketchip.util.GeneratorApp$class.generateFirrtl(GeneratorUtils.scala:106)
at freechips.rocketchip.system.Generator$.generateFirrtl(Generator.scala:12)
at freechips.rocketchip.system.Generator$.delayedEndpoint$freechips$rocketchip$system$Generator$1(Generator.scala:89)
at freechips.rocketchip.system.Generator$delayedInit$body.apply(Generator.scala:12)
at scala.Function0$class.apply$mcV$sp(Function0.scala:34)
at scala.runtime.AbstractFunction0.apply$mcV$sp(AbstractFunction0.scala:12)
at scala.App$$anonfun$main$1.apply(App.scala:76)
at scala.App$$anonfun$main$1.apply(App.scala:76)
at scala.collection.immutable.List.foreach(List.scala:381)
at scala.collection.generic.TraversableForwarder$class.foreach(TraversableForwarder.scala:35)
at scala.App$class.main(App.scala:76)
at freechips.rocketchip.system.Generator$.main(Generator.scala:12)
at freechips.rocketchip.system.Generator.main(Generator.scala)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
Caused by: scala.MatchError: null
at chisel3.core.Binding$.chisel3$core$Binding$$walkToBinding(Binding.scala:62)
at chisel3.core.Binding$.bind(Binding.scala:88)
at chisel3.core.BaseModule.IO(Module.scala:220)
at Chisel.package$CompatibilityModule.autoWrapPorts(compatibility.scala:186)
at chisel3.core.Binding$$anonfun$checkSynthesizable$1.apply(Binding.scala:125)
at chisel3.core.Binding$$anonfun$checkSynthesizable$1.apply(Binding.scala:121)
at chisel3.core.Binding$.chisel3$core$Binding$$walkToBinding(Binding.scala:63)
at chisel3.core.Binding$.checkSynthesizable(Binding.scala:119)
at chisel3.core.Bits.compop(Bits.scala:167)
at chisel3.core.UInt.do
$eq$eq$eq(Bits.scala:482)
at freechips.rocketchip.tile.OpcodeSet$$anonfun$matches$1.apply(LazyRoCC.scala:363)
at freechips.rocketchip.tile.OpcodeSet$$anonfun$matches$1.apply(LazyRoCC.scala:363)
at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:245)
at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:245)
at scala.collection.immutable.List.foreach(List.scala:381)
at scala.collection.TraversableLike$class.map(TraversableLike.scala:245)
at scala.collection.immutable.List.map(List.scala:285)
at freechips.rocketchip.tile.OpcodeSet.matches(LazyRoCC.scala:363)
at freechips.rocketchip.tile.RoccCommandRouter$$anonfun$41.apply(LazyRoCC.scala:384)
at freechips.rocketchip.tile.RoccCommandRouter$$anonfun$41.apply(LazyRoCC.scala:383)
at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:245)
at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:245)
at scala.collection.Iterator$class.foreach(Iterator.scala:742)
at scala.collection.AbstractIterator.foreach(Iterator.scala:1194)
at scala.collection.IterableLike$class.foreach(IterableLike.scala:72)
at scala.collection.AbstractIterable.foreach(Iterable.scala:54)
at scala.collection.TraversableLike$class.map(TraversableLike.scala:245)
at scala.collection.AbstractTraversable.map(Traversable.scala:104)
at freechips.rocketchip.tile.RoccCommandRouter.(LazyRoCC.scala:383)
at freechips.rocketchip.tile.HasLazyRoCCModule$$anonfun$23.apply(LazyRoCC.scala:114)
at freechips.rocketchip.tile.HasLazyRoCCModule$$anonfun$23.apply(LazyRoCC.scala:114)
at chisel3.core.Module$.do_apply(Module.scala:42)
at freechips.rocketchip.tile.HasLazyRoCCModule$class.$init$(LazyRoCC.scala:114)
at freechips.rocketchip.tile.RocketTileModule.(RocketTile.scala:131)
at freechips.rocketchip.tile.RocketTile.module$lzycompute(RocketTile.scala:124)
at freechips.rocketchip.tile.RocketTile.module(RocketTile.scala:124)
at freechips.rocketchip.tile.RocketTile.module(RocketTile.scala:26)
at freechips.rocketchip.diplomacy.LazyModule$$anonfun$instantiate$1$$anonfun$apply$5.apply(LazyModule.scala:61)
at freechips.rocketchip.diplomacy.LazyModule$$anonfun$instantiate$1$$anonfun$apply$5.apply(LazyModule.scala:61)
at chisel3.core.Module$.do_apply(Module.scala:42)
at freechips.rocketchip.diplomacy.LazyModule$$anonfun$instantiate$1.apply(LazyModule.scala:61)
at freechips.rocketchip.diplomacy.LazyModule$$anonfun$instantiate$1.apply(LazyModule.scala:58)
at scala.collection.immutable.List.foreach(List.scala:381)
at freechips.rocketchip.diplomacy.LazyModule.instantiate(LazyModule.scala:58)
at freechips.rocketchip.diplomacy.LazyModuleImp.(LazyModule.scala:158)
at freechips.rocketchip.tile.RocketTileWrapper$$anon$5.(RocketTile.scala:198)
at freechips.rocketchip.tile.RocketTileWrapper.module$lzycompute(RocketTile.scala:198)
at freechips.rocketchip.tile.RocketTileWrapper.module(RocketTile.scala:198)
at freechips.rocketchip.tile.RocketTileWrapper.module(RocketTile.scala:167)
at freechips.rocketchip.diplomacy.LazyModule$$anonfun$instantiate$1$$anonfun$apply$5.apply(LazyModule.scala:61)
at freechips.rocketchip.diplomacy.LazyModule$$anonfun$instantiate$1$$anonfun$apply$5.apply(LazyModule.scala:61)
at chisel3.core.Module$.do_apply(Module.scala:42)
at freechips.rocketchip.diplomacy.LazyModule$$anonfun$instantiate$1.apply(LazyModule.scala:61)
at freechips.rocketchip.diplomacy.LazyModule$$anonfun$instantiate$1.apply(LazyModule.scala:58)
at scala.collection.immutable.List.foreach(List.scala:381)
at freechips.rocketchip.diplomacy.LazyModule.instantiate(LazyModule.scala:58)
at freechips.rocketchip.diplomacy.LazyMultiIOModuleImp.(LazyModule.scala:162)
at freechips.rocketchip.coreplex.BareCoreplexModule.(BaseCoreplex.scala:25)
at freechips.rocketchip.coreplex.BaseCoreplexModule.(BaseCoreplex.scala:91)
at freechips.rocketchip.coreplex.RocketCoreplexModule.(RocketCoreplex.scala:128)
at sifive.freedom.everywhere.e300artydevkit.E300ArtyDevKitSystemModule.(System.scala:38)
at sifive.freedom.everywhere.e300artydevkit.E300ArtyDevKitSystem.module$lzycompute(System.scala:34)
at sifive.freedom.everywhere.e300artydevkit.E300ArtyDevKitSystem.module(System.scala:34)
at sifive.freedom.everywhere.e300artydevkit.E300ArtyDevKitPlatform$$anonfun$4.apply(Platform.scala:54)
at sifive.freedom.everywhere.e300artydevkit.E300ArtyDevKitPlatform$$anonfun$4.apply(Platform.scala:54)
at chisel3.core.Module$.do_apply(Module.scala:42)
at sifive.freedom.everywhere.e300artydevkit.E300ArtyDevKitPlatform.(Platform.scala:54)
at sifive.freedom.everywhere.e300artydevkit.E300ArtyDevKitFPGAChip$$anonfun$2$$anonfun$3.apply(FPGAChip.scala:41)
at sifive.freedom.everywhere.e300artydevkit.E300ArtyDevKitFPGAChip$$anonfun$2$$anonfun$3.apply(FPGAChip.scala:41)
at chisel3.core.Module$.do_apply(Module.scala:42)
at sifive.freedom.everywhere.e300artydevkit.E300ArtyDevKitFPGAChip$$anonfun$2.apply$mcV$sp(FPGAChip.scala:41)
at sifive.freedom.everywhere.e300artydevkit.E300ArtyDevKitFPGAChip$$anonfun$2.apply(FPGAChip.scala:40)
at sifive.freedom.everywhere.e300artydevkit.E300ArtyDevKitFPGAChip$$anonfun$2.apply(FPGAChip.scala:40)
at chisel3.core.withClockAndReset$.apply(MultiClock.scala:26)
at sifive.freedom.everywhere.e300artydevkit.E300ArtyDevKitFPGAChip.(FPGAChip.scala:40)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at freechips.rocketchip.util.HasGeneratorUtilities$$anonfun$2.apply(GeneratorUtils.scala:50)
at freechips.rocketchip.util.HasGeneratorUtilities$$anonfun$2.apply(GeneratorUtils.scala:47)
at chisel3.core.Module$.do_apply(Module.scala:42)
at chisel3.Driver$$anonfun$elaborate$1.apply(Driver.scala:92)
at chisel3.Driver$$anonfun$elaborate$1.apply(Driver.scala:92)
at chisel3.internal.Builder$$anonfun$build$1.apply(Builder.scala:240)
at chisel3.internal.Builder$$anonfun$build$1.apply(Builder.scala:238)
at scala.util.DynamicVariable.withValue(DynamicVariable.scala:58)
at chisel3.internal.Builder$.build(Builder.scala:238)
at chisel3.Driver$.elaborate(Driver.scala:92)
at freechips.rocketchip.util.HasGeneratorUtilities$class.elaborate(GeneratorUtils.scala:53)
at freechips.rocketchip.system.Generator$.elaborate(Generator.scala:12)
at freechips.rocketchip.util.GeneratorApp$class.circuit(GeneratorUtils.scala:100)
at freechips.rocketchip.system.Generator$.circuit$lzycompute(Generator.scala:12)
at freechips.rocketchip.system.Generator$.circuit(Generator.scala:12)
at freechips.rocketchip.util.GeneratorApp$class.generateFirrtl(GeneratorUtils.scala:106)
at freechips.rocketchip.system.Generator$.generateFirrtl(Generator.scala:12)
at freechips.rocketchip.system.Generator$.delayedEndpoint$freechips$rocketchip$system$Generator$1(Generator.scala:89)
at freechips.rocketchip.system.Generator$delayedInit$body.apply(Generator.scala:12)
at scala.Function0$class.apply$mcV$sp(Function0.scala:34)
at scala.runtime.AbstractFunction0.apply$mcV$sp(AbstractFunction0.scala:12)
at scala.App$$anonfun$main$1.apply(App.scala:76)
at scala.App$$anonfun$main$1.apply(App.scala:76)
at scala.collection.immutable.List.foreach(List.scala:381)
at scala.collection.generic.TraversableForwarder$class.foreach(TraversableForwarder.scala:35)
at scala.App$class.main(App.scala:76)
at freechips.rocketchip.system.Generator$.main(Generator.scala:12)
at freechips.rocketchip.system.Generator.main(Generator.scala)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
[trace] Stack trace suppressed: run last freedomPlatforms/compile:runMain for the full output.
java.lang.RuntimeException: Nonzero exit code: 1
at scala.sys.package$.error(package.scala:27)
[trace] Stack trace suppressed: run last freedomPlatforms/compile:runMain for the full output.
[error] (freedomPlatforms/compile:runMain) Nonzero exit code: 1
[error] Total time: 11 s, completed 21 Sep, 2017 10:27:52 AM
common.mk:48: recipe for target ‘/home/anbuntu/freedom/builds/e300artydevkit/sifive.freedom.everywhere.e300artydevkit.E300ArtyDevKitConfig.fir’ failed
make: *** [/home/anbuntu/freedom/builds/e300artydevkit/sifive.freedom.everywhere.e300artydevkit.E300ArtyDevKitConfig.fir] Error 1
Any suggestion?

Hi. As an update if I generate verilog file in rocketchip/vsim using make verilog CONFIG = TinyConfig. where TinyConfig is the one I mention above. I get the .v file and on inspection I could see that the Hardware accelerator is in generated.

Just to clarify you can build the TinyConfig by it self but when you build the E300ArtyDevKitConfig which builds on top of TinyConfig it fails?

Assuming that is the case the error message you are getting is a strange Chisel error I haven’t seen before. I’ll try to reproduce this locally to understand whats going on.

Hi Colins, This is exactly the case. After updating TinyConfig as per our discussion I can built it in freedom/rocketchip/vsim folder using make verilog CONFIG = TinyConfig command which give me freechips.rocketchip.system.TinyConfig.v and other related file in freedom/rocket-chip/vsim/generated-src folder. But I get the above mention error when I run make -f Makefile.e300artydevkit verilog in the freedom folder.

Hey guys.
I am trying to build my own hardware accelerators and as a first step I am trying to run the Accumulator example in the LazyRoCC-file. When I tried to add Nauman’s changes to my copy of freedom, I could not find any of the two Config.scala files only Configs.scala. Furthermore, the first set of changes was (as far as I could tell) already included in the respective Configs-file. Does this mean that more current versions of the E-300-arty include the example Accumulator RoCC by default? And if this is true, is there any assembly example code to access the accelerator?
Thanks in advance
Lukas