Skip to content

Commit 10e61b9

Browse files
Merge pull request #6 from Nancy-Chauhan/yosys-command
Add commands for Yosys Synthesis and FusesocJob
2 parents 9163a3a + 4478e3f commit 10e61b9

File tree

10 files changed

+238
-0
lines changed

10 files changed

+238
-0
lines changed

README.md

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,3 +72,63 @@ openriscPipeline {
7272
}
7373
}
7474
```
75+
### fusesoc
76+
77+
Builds a step for a generic FuseSoC invocation.
78+
79+
- Chooses a base docker image with FuseSoC
80+
- Adds library to FuseSoC
81+
- Runs FuseSoC step
82+
- Runs arbitrary shell commands in this step
83+
84+
#### Example
85+
86+
```groovy
87+
@Library('librecoresci') _
88+
89+
pipeline {
90+
stages {
91+
stage('example-fusesoc-step') {
92+
fusesoc {
93+
image 'librecores/librecores-ci:0.5.0'
94+
library 'some_core', '/src'
95+
96+
run('some_core') {
97+
target 'fusesoc_target'
98+
}
99+
100+
shell "echo 'Additional steps on shell'"
101+
}
102+
}
103+
}
104+
}
105+
```
106+
### yosysSynthesisReport
107+
108+
Build a step for [Yosys Synthesis](http://www.clifford.at/yosys/) for monitoring resource usage statistics and publish on Jenkins.
109+
110+
- Generalised Yosys Synthesis
111+
- Can be configured for various hardware projects
112+
- Simple declarative call which requires parameters `core`, `target`, `logpath`
113+
- Can be modified and extend to include more paramaters in future.
114+
115+
#### Example
116+
117+
```groovy
118+
@Library('librecoresci') _
119+
120+
pipeline {
121+
agent any
122+
stages{
123+
stage('yosys') {
124+
steps {
125+
yosysSynthesisReport {
126+
core 'mor1kx'
127+
target 'synth'
128+
logPath 'build/mor1kx_5.0-r3/synth-icestorm/yosys.log'
129+
}
130+
}
131+
}
132+
}
133+
}
134+
```
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
package org.librecores.fusesoc
2+
3+
class FuseSocJobSpec {
4+
private String image = ''
5+
private Map<String, String> libraries = [:]
6+
private List<FuseSocRunSpec> runTargets = []
7+
private List<String> shellCommands = []
8+
9+
def image(String value) {
10+
this.image = value
11+
}
12+
13+
def library(String name, String path) {
14+
libraries[name] = path
15+
}
16+
17+
def run(system, @DelegatesTo(strategy = Closure.DELEGATE_ONLY, value = FuseSocRunSpec) Closure cl) {
18+
FuseSocRunSpec frs = new FuseSocRunSpec(system)
19+
cl.delegate = frs
20+
cl()
21+
runTargets << frs
22+
}
23+
24+
def shell(command) {
25+
shellCommands << command
26+
}
27+
28+
def build() {
29+
return (prepareLibraryCommands() + prepareRunCommands() + shellCommands).join(" && ")
30+
}
31+
32+
private List<String> prepareRunCommands() {
33+
runTargets.collect { entry ->
34+
entry.build()
35+
}
36+
}
37+
38+
private List<String> prepareLibraryCommands() {
39+
libraries.collect { entry ->
40+
"fusesoc library add ${entry.key} ${entry.value}".toString()
41+
}
42+
}
43+
}
44+
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
package org.librecores.fusesoc
2+
3+
class FuseSocRunSpec {
4+
private String system
5+
private String target
6+
private String tool
7+
private String backendArgs = ''
8+
9+
FuseSocRunSpec(String system) {
10+
this.system = system
11+
}
12+
13+
def target(value) {
14+
this.target = value
15+
}
16+
17+
def tool(value) {
18+
this.tool = value
19+
}
20+
21+
def backendArgs(value) {
22+
this.backendArgs = value
23+
}
24+
25+
def build() {
26+
def fusesocArgs = []
27+
28+
if (target != null) {
29+
fusesocArgs << "--target=${target}"
30+
}
31+
32+
if (tool != null) {
33+
fusesocArgs << "--tool=${tool}"
34+
}
35+
36+
return "fusesoc run ${fusesocArgs.join(' ')} ${system} ${backendArgs}".toString()
37+
}
38+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package org.librecores.fusesoc
2+
3+
class YosysJobSpec {
4+
String core
5+
String logPath
6+
String target
7+
8+
def core(String value) {
9+
this.core = value
10+
}
11+
12+
def logPath(String value) {
13+
this.logPath = value
14+
}
15+
16+
def target(String value) {
17+
this.target = value
18+
}
19+
}

src/org/openrisc/ci/PipelineSpec.groovy

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ package org.openrisc.ci
66
class PipelineSpec {
77
def jobConfigs = []
88
def image = 'librecores/librecores-ci-openrisc'
9+
def yosysJobSpec
910

1011
def image(value) {
1112
this.image = value
@@ -18,4 +19,8 @@ class PipelineSpec {
1819
closure()
1920
jobConfigs << jobSpec.jobConfig
2021
}
22+
23+
def yosysReport(Closure cl) {
24+
yosysJobSpec = cl
25+
}
2126
}

vars/fusesoc.groovy

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import org.librecores.fusesoc.FuseSocJobSpec
2+
3+
def call(@DelegatesTo(strategy = Closure.DELEGATE_ONLY, value = FuseSocJobSpec) Closure<Void> cl) {
4+
FuseSocJobSpec fjs = new FuseSocJobSpec()
5+
cl.delegate = fjs
6+
cl()
7+
8+
command = fjs.build()
9+
10+
sh "docker run --rm -v \$(pwd):/src -w /src ${fjs.image} /bin/bash -c \"${command}\""
11+
}

vars/fusesoc.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<p>
2+
Executes a FuseSoC job
3+
</p>
4+
5+
<!--
6+
vim: ft=html
7+
-->

vars/openriscPipeline.groovy

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,17 @@ def call(@DelegatesTo(strategy = Closure.DELEGATE_ONLY, value = PipelineSpec) Cl
6363
}
6464
}
6565
}
66+
67+
stage("Yosys Synthesis resource usage statistics parsing and publishing ") {
68+
when {
69+
expression {
70+
pipelineSpec.yosysJobSpec != null
71+
}
72+
}
73+
steps {
74+
yosysSynthesisReport pipelineSpec.yosysJobSpec
75+
}
76+
}
6677
}
6778
}
6879
}

vars/yosysSynthesisReport.groovy

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#!/usr/bin/env groovy
2+
3+
import org.librecores.fusesoc.YosysJobSpec
4+
5+
def call(@DelegatesTo(strategy = Closure.DELEGATE_ONLY, value = YosysJobSpec) Closure cl) {
6+
7+
YosysJobSpec jobSpec = new YosysJobSpec()
8+
cl.delegate = jobSpec
9+
cl()
10+
11+
fusesoc {
12+
image 'librecores/librecores-ci:0.5.0'
13+
library jobSpec.core, '/src'
14+
15+
run(jobSpec.core) {
16+
target jobSpec.target
17+
}
18+
19+
shell "/test-scripts/extract-yosys-stats.py < \"${jobSpec.logPath}\""
20+
21+
}
22+
23+
plotGraph 'yosys-stats.csv', 'Resource Usage'
24+
plotGraph 'yosys-cell-stats.csv', 'Cell Count'
25+
}
26+
27+
def plotGraph(csvSource, title) {
28+
plot csvFileName: "plot-${csvSource}", csvSeries: [[file: csvSource, url: '']],
29+
exclZero: true,
30+
group: title,
31+
numBuilds: '15',
32+
style: 'line',
33+
title: title,
34+
useDescr: true,
35+
yaxis: 'Values'
36+
}

vars/yosysSynthesisReport.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<p>
2+
Executes Yosys synthesis and generates resource usage reports
3+
</p>
4+
5+
<!--
6+
vim: ft=html
7+
-->

0 commit comments

Comments
 (0)