1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
|
package vexriscv.experimental
import spinal.core._
import spinal.lib.eda.bench.{AlteraStdTargets, Bench, Rtl, XilinxStdTargets}
import spinal.lib.eda.icestorm.IcestormStdTargets
import vexriscv.demo.{GenSmallestNoCsr, Murax, MuraxConfig}
import vexriscv.plugin._
import vexriscv.{VexRiscv, VexRiscvConfig, plugin}
/**
* Created by spinalvm on 15.06.17.
*/
object GenMicro extends App{
def cpu() = {
val removeOneFetchStage = true
val pessimisticHazard = true
val writeBackOpt = true
val rspHoldValue = true
val withCompliantCsr = true
val withCompliantCsrPlusEmulation = true
val earlyBranch = false
val noShifter = false
val onlyLoadWords = false
new VexRiscv(
config = VexRiscvConfig(
plugins = List(
// new PcManagerSimplePlugin(
// resetVector = 0x00000000l,
// relaxedPcCalculation = false
// ),
new IBusSimplePlugin(
resetVector = 0x80000000l,
cmdForkOnSecondStage = false,
cmdForkPersistence = false,
prediction = NONE,
catchAccessFault = false,
compressedGen = false,
injectorStage = !removeOneFetchStage,
rspHoldValue = rspHoldValue
),
new DBusSimplePlugin(
catchAddressMisaligned = withCompliantCsr,
catchAccessFault = false,
earlyInjection = writeBackOpt,
onlyLoadWords = onlyLoadWords
),
new DecoderSimplePlugin(
catchIllegalInstruction = withCompliantCsrPlusEmulation
),
new RegFilePlugin(
regFileReadyKind = plugin.SYNC,
zeroBoot = false,
readInExecute = removeOneFetchStage,
writeRfInMemoryStage = writeBackOpt
),
new IntAluPlugin,
new SrcPlugin(
separatedAddSub = false,
executeInsertion = removeOneFetchStage
),
if(!pessimisticHazard)
new HazardSimplePlugin(
bypassExecute = false,
bypassMemory = false,
bypassWriteBack = false,
bypassWriteBackBuffer = false,
pessimisticUseSrc = false,
pessimisticWriteRegFile = false,
pessimisticAddressMatch = false
)
else
new HazardPessimisticPlugin(),
new BranchPlugin(
earlyBranch = earlyBranch,
catchAddressMisaligned = withCompliantCsr,
fenceiGenAsAJump = withCompliantCsr
),
new YamlPlugin("cpu0.yaml")
) ++ (if(noShifter) Nil else List(new LightShifterPlugin))
++ (if(!withCompliantCsr) Nil else List(new CsrPlugin(
config = if(withCompliantCsrPlusEmulation)CsrPluginConfig(
catchIllegalAccess = true,
mvendorid = null,
marchid = null,
mimpid = null,
mhartid = null,
misaExtensionsInit = 0,
misaAccess = CsrAccess.NONE,
mtvecAccess = CsrAccess.NONE,
mtvecInit = 0x80000020l,
mepcAccess = CsrAccess.NONE,
mscratchGen = false,
mcauseAccess = CsrAccess.READ_ONLY,
mbadaddrAccess = CsrAccess.NONE,
mcycleAccess = CsrAccess.NONE,
minstretAccess = CsrAccess.NONE,
ecallGen = false,
ebreakGen = false,
wfiGenAsWait = false,
wfiGenAsNop = false,
ucycleAccess = CsrAccess.NONE,
noCsrAlu = true
) else CsrPluginConfig(
catchIllegalAccess = false,
mvendorid = null,
marchid = null,
mimpid = null,
mhartid = null,
misaExtensionsInit = 0,
misaAccess = CsrAccess.READ_ONLY,
mtvecAccess = CsrAccess.WRITE_ONLY,
mtvecInit = 0x80000020l,
mepcAccess = CsrAccess.READ_WRITE,
mscratchGen = true,
mcauseAccess = CsrAccess.READ_ONLY,
mbadaddrAccess = CsrAccess.READ_ONLY,
mcycleAccess = CsrAccess.NONE,
minstretAccess = CsrAccess.NONE,
ecallGen = true,
ebreakGen = true,
wfiGenAsWait = false,
wfiGenAsNop = true,
ucycleAccess = CsrAccess.NONE
)
)))
)
)
}
SpinalConfig(mergeAsyncProcess = false).generateVerilog(cpu())
}
object GenMicroSynthesis {
def main(args: Array[String]) {
val microNoCsr = new Rtl {
override def getName(): String = "MicroNoCsr"
override def getRtlPath(): String = "MicroNoCsr.v"
SpinalVerilog(GenMicro.cpu().setDefinitionName(getRtlPath().split("\\.").head))
}
val smallestNoCsr = new Rtl {
override def getName(): String = "SmallestNoCsr"
override def getRtlPath(): String = "SmallestNoCsr.v"
SpinalVerilog(GenSmallestNoCsr.cpu().setDefinitionName(getRtlPath().split("\\.").head))
}
val rtls = List(microNoCsr)
// val rtls = List(smallestNoCsr)
val targets = IcestormStdTargets().take(1) ++ XilinxStdTargets(
vivadoArtix7Path = "/eda/Xilinx/Vivado/2017.2/bin"
) ++ AlteraStdTargets(
quartusCycloneIVPath = "/eda/intelFPGA_lite/17.0/quartus/bin/",
quartusCycloneVPath = "/eda/intelFPGA_lite/17.0/quartus/bin/"
)
Bench(rtls, targets, "/eda/tmp/")
}
}
|