Skip to content

Commit

Permalink
optimize logic
Browse files Browse the repository at this point in the history
  • Loading branch information
LoveLonelyTime committed Jan 27, 2024
1 parent 801883b commit 347fff7
Show file tree
Hide file tree
Showing 20 changed files with 631 additions and 704 deletions.
24 changes: 24 additions & 0 deletions riscv-tests/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
Copyright (c) 2012-2015, The Regents of the University of California (Regents).
All Rights Reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. 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.
3. Neither the name of the Regents nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.

IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT,
SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING
OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF REGENTS HAS
BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED
HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION TO PROVIDE
MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
4 changes: 2 additions & 2 deletions src/main/scala/lltriscv/core/Core.scala
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ class CoreFrontend(config: CoreConfig) extends Module {
// Decode
decode.io.mapping <> registerMappingTable.io.mapping
decode.io.broadcast <> io.broadcast
decode.io.tableWrite <> io.tableWrite
decode.io.robTableWrite <> io.tableWrite
decode.io.recover := io.recover
decode.io.enqs <> io.enqs

Expand Down Expand Up @@ -370,7 +370,7 @@ class CoreBackend(config: CoreConfig) extends Module {
// Broadcaster
broadcaster.io.queues <> io.deqs
broadcaster.io.broadcast <> io.broadcast
broadcaster.io.tableCommit <> rob.io.tableCommit
broadcaster.io.robTableCommit <> rob.io.tableCommit

// InstructionRetire
instructionRetire.io.retired <> rob.io.retired
Expand Down
3 changes: 3 additions & 0 deletions src/main/scala/lltriscv/core/DataType.scala
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ object DataType {
def strobe = UInt(4.W) // 4-bits for 32-bits(4-lanes) strobe
def asid = UInt(9.W) // 9-bits address space ID
def aByte = UInt(8.W) // A Byte
def vpn = UInt(20.W) // Virtual page number
def ppn20 = UInt(20.W) // 20-bits physical page number
def half = UInt(16.W) // half word
}

object CoreConstant {
Expand Down
21 changes: 12 additions & 9 deletions src/main/scala/lltriscv/core/broadcast/BroadcastEntry.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ import chisel3.util._

import lltriscv.core._

import lltriscv.utils.CoreUtils._
import lltriscv.utils.ChiselUtils._

/*
* Broadcast entry
*
Expand All @@ -27,28 +30,28 @@ class DataBroadcastSlotEntry extends Bundle {
* A data broadcasts
*/
class DataBroadcastEntry extends Bundle {
val valid = Bool()
// Broadcast receipt
val receipt = DataType.receipt
// Data
val data = DataType.operation
val valid = Bool()

// Helper functions
/** Cast a broadcast
*
* @param receipt
* Data receipt
* @param data
* Data
*/
def castBroadcast(receipt: UInt, data: UInt) = {
valid := true.B
this.receipt := receipt
this.data := data
}

def noBroadcast() = {
valid := false.B
this.receipt := 0.U
this.data := 0.U
}
}

/** Data broadcast interface
*/
class DataBroadcastIO extends Bundle {
val entries = Output(Vec(2, new DataBroadcastEntry()))
val entries = Output(Vec2(new DataBroadcastEntry()))
}
23 changes: 12 additions & 11 deletions src/main/scala/lltriscv/core/broadcast/Broadcaster.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ import chisel3._
import chisel3.util._

import lltriscv.core._
import lltriscv.core.execute._
import lltriscv.core.record._
import lltriscv.utils.CoreUtils
import lltriscv.core.record.ROBTableCommitIO
import lltriscv.core.execute.ExecuteResultEntry

import lltriscv.utils.CoreUtils._
import lltriscv.utils.ChiselUtils._

/*
* Broadcaster
Expand All @@ -32,7 +34,7 @@ abstract class Broadcaster(executeQueueWidth: Int) extends Module {
// Broadcast interface
val broadcast = new DataBroadcastIO()
// ROB table commit interface
val tableCommit = new ROBTableCommitIO()
val robTableCommit = new ROBTableCommitIO()
})
}

Expand All @@ -45,20 +47,19 @@ abstract class Broadcaster(executeQueueWidth: Int) extends Module {
*/
class RoundRobinBroadcaster(executeQueueWidth: Int) extends Broadcaster(executeQueueWidth) {
// Single cycle auto increasing loop pointer
private val (pointer, nextVal) = CoreUtils.pointer(executeQueueWidth, true.B)
private val (focusPointer, nextFocusPointer) = pointer(executeQueueWidth, true.B)

/** Commit queue to entry
*
* @param queuePtr
* Pointer of queue
* @param entryPtr
* Pointer of entry
* @return
*/
def commit(queuePtr: UInt, entryPtr: Int) = {
when(io.queues(queuePtr).valid) {
io.queues(queuePtr).ready := true.B
io.tableCommit.entries(entryPtr) <> io.queues(queuePtr).bits
io.robTableCommit.entries(entryPtr) <> io.queues(queuePtr).bits
when(io.queues(queuePtr).bits.valid) {
io.broadcast.entries(entryPtr).castBroadcast(io.queues(queuePtr).bits.rd, io.queues(queuePtr).bits.result)
}
Expand All @@ -67,9 +68,9 @@ class RoundRobinBroadcaster(executeQueueWidth: Int) extends Broadcaster(executeQ

// Commit logic
io.queues.foreach(_.ready := false.B)
io.broadcast.entries.foreach(_.noBroadcast())
io.tableCommit.entries.foreach(_.noResult())
io.broadcast <> new DataBroadcastIO().zero
io.robTableCommit <> new ROBTableCommitIO().zero

commit(pointer, 0)
commit(nextVal, 1)
commit(focusPointer, 0)
commit(nextFocusPointer, 1)
}
Loading

0 comments on commit 347fff7

Please sign in to comment.