forked from pretis/flexpret
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLICENSE.txt
169 lines (144 loc) · 6.14 KB
/
LICENSE.txt
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
163
164
165
166
167
168
169
/*
Copyright (c) 2013, The Regents of the University of California.
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the <organization> nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/******************************************************************************
flexpret.scala:
Configurable precision-timed (PRET) 5-stage RISC-V processor.
- Single-thread
- Multi-threaded (4-8) with fixed round-robin thread scheduling
- Multi-threaded (2-8) with flexible round-robin thread scheduling
Authors:
Michael Zimmer (mzimmer@eecs.berkeley.edu)
Chris Shaver (shaver@eecs.berkeley.edu)
Hokeun Kim (hokeunkim@eecs.berkeley.edu)
Acknowledgement:
Based on Sodor single-thread 5-stage RISC-V processor by Christopher Celio.
******************************************************************************/
package Core
{
import Chisel._
import Node._
import Common._
import CoreConstants._
import collection.mutable.{ArrayBuffer}
// TODO cleaner
case class CoreConfig(threads: Int, flex: Boolean,
iSpmKBytes: Int, dSpmKBytes: Int, mulStages: Int,
stats: Boolean, exceptions: Boolean,
getTime: Boolean, delayUntil: Boolean,
exceptionOnExpire: Boolean)
{
val threadBits = log2Up(threads)
val iSpmAddrBits = log2Up(1024/4*iSpmKBytes)
val dSpmAddrBits = log2Up(1024/4*dSpmKBytes)
val dSpmPageIndex = 10
val dSpmPageBits = dSpmAddrBits-dSpmPageIndex
// Use require() to dependencies between configurations.
require(mulStages >= 1 && mulStages <= 2)
// If excectionOnExpire, then exceptions and getTime
require(!exceptionOnExpire || (exceptions && getTime))
// If delayUntil, then getTime
require(!delayUntil || getTime)
}
// TODO: add mechanism to write to I-SPM.
class CoreIo(iSpmAddrBits: Int) extends Bundle
{
//val ispm_write = Bool(INPUT)
//val ispm_waddr = UInt(INPUT, iSpmAddrBits)
//val ispm_wdata = Bits(INPUT, XPRLEN)
val host = new HostIo()
val bus = new MemIo(32).flip
val exe_ns_clock = Bits(OUTPUT, 64)
}
class Core(conf: CoreConfig) extends Module
{
val io = new CoreIo(conf.iSpmAddrBits)
val c = Module(new Control(conf))
val d = Module(new Datapath(conf))
val ispm = Module(new ISpm(conf))
val dspm = Module(new DSpm(conf))
// Connect datapath and control unit.
c.io.ctl <> d.io.ctl
c.io.dat <> d.io.dat
// Connect datapath to scratchpad memories.
d.io.ispm <> ispm.io
d.io.dspm <> dspm.io
// Connect datapath to external IO
d.io.top <> io
}
object CoreMain {
def main(args: Array[String]): Unit = {
// Processor configuration is passed in using args from sbt.
val confString = args(0)
val chiselArgs = args.slice(1, args.length)
var threads = 4
var flex = true
var iSpmKBytes = 8
var dSpmKBytes = 8
var mulStages = 2
"""(\d+)t(.*)-(\d+)i-(\d+)d-(\d+)smul""".r.findAllIn(confString).matchData foreach {
m =>
threads = m.group(1).toInt
flex = m.group(2) contains "f"
iSpmKBytes = m.group(3).toInt
dSpmKBytes = m.group(4).toInt
mulStages = m.group(5).toInt
}
val stats = confString contains "stats"
val exceptions = confString contains "exc"
val getTime = confString contains "gt"
val delayUntil = confString contains "du"
val exceptionOnExpire = confString contains "ee"
val coreConfig = CoreConfig(threads, flex, iSpmKBytes, dSpmKBytes,
mulStages, stats, exceptions, getTime, delayUntil, exceptionOnExpire)
//val coreConfig = CoreConfig(4, true, 8, 8, 1, true, true, true, true, false)
//val coreConfig = CoreConfig(args(0).toInt,
// args(1).toBoolean,
// args(2).toInt,
// args(3).toInt,
// args(4).toInt,
// args(5).toBoolean,
// false,
// false,
// false,
// false)
//true,
//true,
//true,
//true)
//// Pass configuration to FlexPRET processor.
chiselMain( chiselArgs, () => Module(new Core(coreConfig)) )
// Processor configuration is passed in using args from sbt.
//val chiselArgs = args.slice(6, args.length)
//val coreConfig = CoreConfig(args(0).toInt,
// args(1).toBoolean,
// args(2).toInt,
// args(3).toInt,
// args(4).toInt,
// args(5).toBoolean)
//// Pass configuration to FlexPRET processor.
//chiselMain( chiselArgs, () => new Core(coreConfig) )
}
}
}