-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from Nancy-Chauhan/yosys-command
Add commands for Yosys Synthesis and FusesocJob
- Loading branch information
Showing
10 changed files
with
238 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package org.librecores.fusesoc | ||
|
||
class FuseSocJobSpec { | ||
private String image = '' | ||
private Map<String, String> libraries = [:] | ||
private List<FuseSocRunSpec> runTargets = [] | ||
private List<String> shellCommands = [] | ||
|
||
def image(String value) { | ||
this.image = value | ||
} | ||
|
||
def library(String name, String path) { | ||
libraries[name] = path | ||
} | ||
|
||
def run(system, @DelegatesTo(strategy = Closure.DELEGATE_ONLY, value = FuseSocRunSpec) Closure cl) { | ||
FuseSocRunSpec frs = new FuseSocRunSpec(system) | ||
cl.delegate = frs | ||
cl() | ||
runTargets << frs | ||
} | ||
|
||
def shell(command) { | ||
shellCommands << command | ||
} | ||
|
||
def build() { | ||
return (prepareLibraryCommands() + prepareRunCommands() + shellCommands).join(" && ") | ||
} | ||
|
||
private List<String> prepareRunCommands() { | ||
runTargets.collect { entry -> | ||
entry.build() | ||
} | ||
} | ||
|
||
private List<String> prepareLibraryCommands() { | ||
libraries.collect { entry -> | ||
"fusesoc library add ${entry.key} ${entry.value}".toString() | ||
} | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package org.librecores.fusesoc | ||
|
||
class FuseSocRunSpec { | ||
private String system | ||
private String target | ||
private String tool | ||
private String backendArgs = '' | ||
|
||
FuseSocRunSpec(String system) { | ||
this.system = system | ||
} | ||
|
||
def target(value) { | ||
this.target = value | ||
} | ||
|
||
def tool(value) { | ||
this.tool = value | ||
} | ||
|
||
def backendArgs(value) { | ||
this.backendArgs = value | ||
} | ||
|
||
def build() { | ||
def fusesocArgs = [] | ||
|
||
if (target != null) { | ||
fusesocArgs << "--target=${target}" | ||
} | ||
|
||
if (tool != null) { | ||
fusesocArgs << "--tool=${tool}" | ||
} | ||
|
||
return "fusesoc run ${fusesocArgs.join(' ')} ${system} ${backendArgs}".toString() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package org.librecores.fusesoc | ||
|
||
class YosysJobSpec { | ||
String core | ||
String logPath | ||
String target | ||
|
||
def core(String value) { | ||
this.core = value | ||
} | ||
|
||
def logPath(String value) { | ||
this.logPath = value | ||
} | ||
|
||
def target(String value) { | ||
this.target = value | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import org.librecores.fusesoc.FuseSocJobSpec | ||
|
||
def call(@DelegatesTo(strategy = Closure.DELEGATE_ONLY, value = FuseSocJobSpec) Closure<Void> cl) { | ||
FuseSocJobSpec fjs = new FuseSocJobSpec() | ||
cl.delegate = fjs | ||
cl() | ||
|
||
command = fjs.build() | ||
|
||
sh "docker run --rm -v \$(pwd):/src -w /src ${fjs.image} /bin/bash -c \"${command}\"" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<p> | ||
Executes a FuseSoC job | ||
</p> | ||
|
||
<!-- | ||
vim: ft=html | ||
--> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#!/usr/bin/env groovy | ||
|
||
import org.librecores.fusesoc.YosysJobSpec | ||
|
||
def call(@DelegatesTo(strategy = Closure.DELEGATE_ONLY, value = YosysJobSpec) Closure cl) { | ||
|
||
YosysJobSpec jobSpec = new YosysJobSpec() | ||
cl.delegate = jobSpec | ||
cl() | ||
|
||
fusesoc { | ||
image 'librecores/librecores-ci:0.5.0' | ||
library jobSpec.core, '/src' | ||
|
||
run(jobSpec.core) { | ||
target jobSpec.target | ||
} | ||
|
||
shell "/test-scripts/extract-yosys-stats.py < \"${jobSpec.logPath}\"" | ||
|
||
} | ||
|
||
plotGraph 'yosys-stats.csv', 'Resource Usage' | ||
plotGraph 'yosys-cell-stats.csv', 'Cell Count' | ||
} | ||
|
||
def plotGraph(csvSource, title) { | ||
plot csvFileName: "plot-${csvSource}", csvSeries: [[file: csvSource, url: '']], | ||
exclZero: true, | ||
group: title, | ||
numBuilds: '15', | ||
style: 'line', | ||
title: title, | ||
useDescr: true, | ||
yaxis: 'Values' | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<p> | ||
Executes Yosys synthesis and generates resource usage reports | ||
</p> | ||
|
||
<!-- | ||
vim: ft=html | ||
--> |