-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[rtl] add token manager for top & add v0 write token.
- Loading branch information
Showing
2 changed files
with
47 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// SPDX-FileCopyrightText: 2022 Jiuyang Liu <[email protected]> | ||
|
||
package org.chipsalliance.t1.rtl | ||
|
||
import chisel3._ | ||
import chisel3.experimental.hierarchy.{instantiable, public} | ||
import chisel3.util._ | ||
|
||
@instantiable | ||
class T1TokenManager(parameter: T1Parameter) extends Module { | ||
@public | ||
val writeV0 = IO(Vec(parameter.laneNumber, Flipped(Valid(UInt(parameter.instructionIndexBits.W))))) | ||
|
||
@public | ||
val instructionFinish: Vec[UInt] = IO(Vec(parameter.laneNumber, Input(UInt(parameter.chainingSize.W)))) | ||
|
||
@public | ||
val v0WriteValid = IO(Output(UInt(parameter.chainingSize.W))) | ||
|
||
// v0 write token | ||
val v0WriteValidVec: Seq[UInt] = Seq.tabulate(parameter.laneNumber) { laneIndex => | ||
val update: ValidIO[UInt] = writeV0(laneIndex) | ||
val clear: UInt = instructionFinish(laneIndex) | ||
val updateOH = maskAnd(update.valid, indexToOH(update.bits, parameter.chainingSize)).asUInt | ||
VecInit(Seq.tabulate(parameter.chainingSize) { chainingIndex => | ||
val res = RegInit(false.B) | ||
when(updateOH(chainingIndex) || clear(chainingIndex)) { | ||
res := updateOH(chainingIndex) | ||
} | ||
res | ||
}).asUInt | ||
} | ||
|
||
v0WriteValid := v0WriteValidVec.reduce(_ | _) | ||
} |