Skip to content

Commit

Permalink
Merge pull request #6 from Nancy-Chauhan/yosys-command
Browse files Browse the repository at this point in the history
Add commands for Yosys Synthesis and FusesocJob
  • Loading branch information
oleg-nenashev authored Aug 26, 2019
2 parents 9163a3a + 4478e3f commit 10e61b9
Show file tree
Hide file tree
Showing 10 changed files with 238 additions and 0 deletions.
60 changes: 60 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,63 @@ openriscPipeline {
}
}
```
### fusesoc

Builds a step for a generic FuseSoC invocation.

- Chooses a base docker image with FuseSoC
- Adds library to FuseSoC
- Runs FuseSoC step
- Runs arbitrary shell commands in this step

#### Example

```groovy
@Library('librecoresci') _
pipeline {
stages {
stage('example-fusesoc-step') {
fusesoc {
image 'librecores/librecores-ci:0.5.0'
library 'some_core', '/src'
run('some_core') {
target 'fusesoc_target'
}
shell "echo 'Additional steps on shell'"
}
}
}
}
```
### yosysSynthesisReport

Build a step for [Yosys Synthesis](http://www.clifford.at/yosys/) for monitoring resource usage statistics and publish on Jenkins.

- Generalised Yosys Synthesis
- Can be configured for various hardware projects
- Simple declarative call which requires parameters `core`, `target`, `logpath`
- Can be modified and extend to include more paramaters in future.

#### Example

```groovy
@Library('librecoresci') _
pipeline {
agent any
stages{
stage('yosys') {
steps {
yosysSynthesisReport {
core 'mor1kx'
target 'synth'
logPath 'build/mor1kx_5.0-r3/synth-icestorm/yosys.log'
}
}
}
}
}
```
44 changes: 44 additions & 0 deletions src/org/librecores/fusesoc/FuseSocJobSpec.groovy
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()
}
}
}

38 changes: 38 additions & 0 deletions src/org/librecores/fusesoc/FuseSocRunSpec.groovy
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()
}
}
19 changes: 19 additions & 0 deletions src/org/librecores/fusesoc/YosysJobSpec.groovy
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
}
}
5 changes: 5 additions & 0 deletions src/org/openrisc/ci/PipelineSpec.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ package org.openrisc.ci
class PipelineSpec {
def jobConfigs = []
def image = 'librecores/librecores-ci-openrisc'
def yosysJobSpec

def image(value) {
this.image = value
Expand All @@ -18,4 +19,8 @@ class PipelineSpec {
closure()
jobConfigs << jobSpec.jobConfig
}

def yosysReport(Closure cl) {
yosysJobSpec = cl
}
}
11 changes: 11 additions & 0 deletions vars/fusesoc.groovy
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}\""
}
7 changes: 7 additions & 0 deletions vars/fusesoc.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<p>
Executes a FuseSoC job
</p>

<!--
vim: ft=html
-->
11 changes: 11 additions & 0 deletions vars/openriscPipeline.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,17 @@ def call(@DelegatesTo(strategy = Closure.DELEGATE_ONLY, value = PipelineSpec) Cl
}
}
}

stage("Yosys Synthesis resource usage statistics parsing and publishing ") {
when {
expression {
pipelineSpec.yosysJobSpec != null
}
}
steps {
yosysSynthesisReport pipelineSpec.yosysJobSpec
}
}
}
}
}
36 changes: 36 additions & 0 deletions vars/yosysSynthesisReport.groovy
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'
}
7 changes: 7 additions & 0 deletions vars/yosysSynthesisReport.txt
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
-->

0 comments on commit 10e61b9

Please sign in to comment.