Commit f07fe80a by Luis Vega Committed by Thierry Moreau

[VTA][Chisel] add ISA BitPat generation (#3891)

parent 0d4870cc
...@@ -21,6 +21,7 @@ package vta.core ...@@ -21,6 +21,7 @@ package vta.core
import chisel3._ import chisel3._
import chisel3.util._ import chisel3.util._
import scala.collection.mutable.HashMap
/** ISAConstants. /** ISAConstants.
* *
...@@ -70,45 +71,78 @@ trait ISAConstants { ...@@ -70,45 +71,78 @@ trait ISAConstants {
/** ISA. /** ISA.
* *
* This is the VTA ISA, here we specify the cares and dont-cares that makes * This is the VTA task ISA
* decoding easier. Since instructions are quite long 128-bit, we could generate
* these based on ISAConstants.
* *
* FIXME: VSHX should be replaced by VSHR and VSHL once we modify the compiler
* TODO: Add VXOR to clear accumulator * TODO: Add VXOR to clear accumulator
* TODO: Use ISA object for decoding as well
* TODO: Eventually deprecate ISAConstants
*/ */
object ISA { object ISA {
def LUOP = private val xLen = 128
BitPat( private val depBits = 4
"b_????????_????????_????????_????????_????????_????????_????????_????????_????????_????????_????????_????????_????????_????????_???????0_0????000")
def LWGT = private val idBits: HashMap[String, Int] =
BitPat( HashMap(("task", 3), ("mem", 2), ("alu", 2))
"b_????????_????????_????????_????????_????????_????????_????????_????????_????????_????????_????????_????????_????????_????????_???????0_1????000")
def LINP = private val taskId: HashMap[String, String] =
BitPat( HashMap(("load", "000"),
"b_????????_????????_????????_????????_????????_????????_????????_????????_????????_????????_????????_????????_????????_????????_???????1_0????000") ("store", "001"),
def LACC = ("gemm", "010"),
BitPat( ("finish", "011"),
"b_????????_????????_????????_????????_????????_????????_????????_????????_????????_????????_????????_????????_????????_????????_???????1_1????000") ("alu", "100"))
def SOUT =
BitPat( private val memId: HashMap[String, String] =
"b_????????_????????_????????_????????_????????_????????_????????_????????_????????_????????_????????_????????_????????_????????_????????_?????001") HashMap(("uop", "00"), ("wgt", "01"), ("inp", "10"), ("acc", "11"))
def GEMM =
BitPat( private val aluId: HashMap[String, String] =
"b_????????_????????_????????_????????_????????_????????_????????_????????_????????_????????_????????_????????_????????_????????_????????_?????010") HashMap(("minpool", "00"),
def VMIN = ("maxpool", "01"),
BitPat( ("add", "10"),
"b_????????_????????_??00????_????????_????????_????????_????????_????????_????????_????????_????????_????????_????????_????????_????????_?????100") ("shift", "11"))
def VMAX =
BitPat( private def dontCare(bits: Int): String = "?" * bits
"b_????????_????????_??01????_????????_????????_????????_????????_????????_????????_????????_????????_????????_????????_????????_????????_?????100")
def VADD = private def instPat(bin: String): BitPat = BitPat("b" + bin)
BitPat(
"b_????????_????????_??10????_????????_????????_????????_????????_????????_????????_????????_????????_????????_????????_????????_????????_?????100") private def load(id: String): BitPat = {
def VSHX = val rem = xLen - idBits("mem") - depBits - idBits("task")
BitPat( val inst = dontCare(rem) + memId(id) + dontCare(depBits) + taskId("load")
"b_????????_????????_??11????_????????_????????_????????_????????_????????_????????_????????_????????_????????_????????_????????_????????_?????100") instPat(inst)
def FNSH = }
BitPat(
"b_????????_????????_????????_????????_????????_????????_????????_????????_????????_????????_????????_????????_????????_????????_????????_?????011") private def store: BitPat = {
val rem = xLen - idBits("task")
val inst = dontCare(rem) + taskId("store")
instPat(inst)
}
private def gemm: BitPat = {
val rem = xLen - idBits("task")
val inst = dontCare(rem) + taskId("gemm")
instPat(inst)
}
private def alu(id: String): BitPat = {
// TODO: move alu id next to task id
val inst = dontCare(18) + aluId(id) + dontCare(105) + taskId("alu")
instPat(inst)
}
private def finish: BitPat = {
val rem = xLen - idBits("task")
val inst = dontCare(rem) + taskId("finish")
instPat(inst)
}
def LUOP = load("uop")
def LWGT = load("wgt")
def LINP = load("inp")
def LACC = load("acc")
def SOUT = store
def GEMM = gemm
def VMIN = alu("minpool")
def VMAX = alu("maxpool")
def VADD = alu("add")
def VSHX = alu("shift")
def FNSH = finish
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment