task_id stringclasses 24
values | path stringlengths 30 94 | left_context stringlengths 13 172k | right_context stringlengths 0 96.2k | groundtruth stringlengths 10 665 | crossfile_context stringclasses 1
value |
|---|---|---|---|---|---|
Quasar | Quasar/design/src/main/scala/lsu/lsu_clkdomain.scala | package lsu
import chisel3._
import chisel3.experimental.chiselName
import chisel3.util._
import lib._
import include._
@chiselName
class lsu_clkdomain extends Module with RequireAsyncReset with lib{
val io = IO (new Bundle {
val active_clk = Input(Clock()) // clock
// Inputs
val c... | lsu_c1_r_clken_q := withClock(io.lsu_free_c2_clk) {RegNext(lsu_c1_r_clken, 0.U)}
io.lsu_c1_m_clk := rvoclkhdr(clock,lsu_c1_m_clken.asBool,io.scan_mode)
io.lsu_c1_r_clk := rvoclkhdr(clock,lsu_c1_r_clken.asBool,io.scan_mode)
io.lsu_c2_m_clk := rvoclkhdr(clock,lsu_c2_m_clken.asBool,io.s... | lsu_c1_m_clken_q := withClock(io.lsu_free_c2_clk) {RegNext(lsu_c1_m_clken, 0.U)}
| |
Quasar | Quasar/design/src/main/scala/lsu/lsu_dccm_ctl.scala | package lsu
import include._
import lib._
import chisel3._
import chisel3.util._
import mem._
import chisel3.experimental.chiselName
@chiselName
class lsu_dccm_ctl extends Module with RequireAsyncReset with lib
{
val io = IO(new Bundle{
val clk_override = Input(Bool())
val lsu_c2_m_clk = Inpu... | io.lsu_dccm_rden_r := withClock(io.lsu_c2_r_clk){RegNext(io.lsu_dccm_rden_m,0.U)}
lsu_double_ecc_error_r_ff := withClock(io.lsu_free_c2_clk){RegNext(io.lsu_double_ecc_error_r,0.U)}
ld_single_ecc_error_hi_r_ff := withClock(io.lsu_free_c2_clk){RegNext(ld_single_ecc_error_hi_r_ns,0.U)}
ld_single_ecc_erro... | io.lsu_dccm_rden_m := withClock(io.lsu_c2_m_clk){RegNext(lsu_dccm_rden_d,0.U)}
| |
Quasar | Quasar/design/src/main/scala/lsu/lsu_ecc.scala | package lsu
import chisel3._
import chisel3.util._
import chisel3.experimental.chiselName
import include._
import lib._
@chiselName
class lsu_ecc extends Module with lib with RequireAsyncReset {
val io = IO(new Bundle{
val lsu_c2_r_clk = Input(Clock())
val clk_override = Input(Boo... |
when (LOAD_TO_USE_PLUS1.B) {
ldst_dual_r := io.lsu_addr_r(2) =/= io.end_addr_r(2)
is_ldst_r := io.lsu_pkt_r.valid & (io.lsu_pkt_r.bits.load | io.lsu_pkt_r.bits.store) & io.addr_in_dccm_r & io.lsu_dccm_rden_r
is_ldst_lo_r := is_ldst_r & !io.dec_tlu_core_ecc_disable
is_ldst_hi_r := is_ldst_r & ldst_dua... | val dccm_wdata_ecc_hi_any = if(DCCM_ENABLE) rvecc_encode(dccm_wdata_hi_any) else (0.U)
| |
Quasar | Quasar/design/src/main/scala/lsu/lsu_lsc_ctl.scala | package lsu
import include.{lsu_error_pkt_t, _}
import lib._
import chisel3._
import chisel3.util._
import chisel3.experimental.chiselName
@chiselName
class lsu_lsc_ctl extends Module with RequireAsyncReset with lib
{
val io = IO(new Bundle{
val clk_override = Input(Bool())
val lsu_c1_m_clk = Input(Clock())
... | val bus_read_data_r = rvdffe(io.bus_read_data_m,io.addr_external_m | io.clk_override,clock,io.scan_mode)
// Fast interrupt address
io.lsu_fir_addr := io.lsu_ld_data_corr_r(31,1) //original (31,1) TBD
// absence load/store all 0's
io.lsu_addr_d := full_addr_d
// Interrupt as a fl... | val addr_external_r = withClock(io.lsu_c1_r_clk){RegNext(io.addr_external_m,0.U)}
| |
Quasar | Quasar/design/src/main/scala/lsu/lsu_stbuf.scala | package lsu
import lib._
import chisel3._
import chisel3.experimental.chiselName
import chisel3.util._
import include._
@chiselName
class lsu_stbuf extends Module with lib with RequireAsyncReset {
val io = IO (new Bundle {
val lsu_stbuf_c1_clk = Input(Clock())
val lsu_free_c2_clk = Input(C... |
val stbuf_numvld_any = VecInit.tabulate(LSU_STBUF_DEPTH)(i=>Cat(0.U(3.W), stbuf_vld(i))).reduce (_+_)
val isdccmst_m = io.lsu_pkt_m.valid & io.lsu_pkt_m.bits.store & io.addr_in_dccm_m & !io.lsu_pkt_m.bits.dma
val isdccmst_r = io.lsu_pkt_r.valid & io.lsu_pkt_r.bits.store & io.addr_in_dccm_r & !io.lsu_pkt_r.bits.d... | withClock(io.lsu_stbuf_c1_clk){ RdPtr := RegEnable(NxtRdPtr, 0.U, RdPtrEn)}
| |
Quasar | Quasar/design/src/main/scala/lsu/lsu_trigger.scala | package lsu
import chisel3._
import lib._
import chisel3.util._
import include._
class lsu_trigger extends Module with RequireAsyncReset with lib {
val io = IO(new Bundle{
val trigger_pkt_any = Input(Vec (4,(new trigger_pkt_t)))
val lsu_pkt_m = Flipped(Valid(new lsu_pkt_t))
val lsu_add... | rvmaskandmatch(io.trigger_pkt_any(i).tdata2, lsu_match_data(i), io.trigger_pkt_any(i).match_pkt.asBool())).reverse.reduce(Cat(_,_))
}
| val store_data_trigger_m= Cat((Fill(16,io.lsu_pkt_m.bits.word) & io.store_data_m(31,16)),(Fill(8,(io.lsu_pkt_m.bits.half | io.lsu_pkt_m.bits.word)) & io.store_data_m(15,8)), io.store_data_m(7,0))
val ldst_addr_trigger_m = io.lsu_addr_m & Fill(32, trigger_enable)
val lsu_match_data = (0 until 4).map(i=>Mux1H(Seq(!... | |
Quasar | Quasar/design/src/main/scala/mem.scala | package mem
import chisel3._
import chisel3.util.HasBlackBoxResource
import lib._
import include._
class mem_lsu extends Bundle with lib{
val wren = Input(Bool())
val rden = Input(Bool())
val wr_addr_lo = Input(UInt(DCCM_BITS.W))
| }
class Mem_bundle extends Bundle with lib {
val clk = Input(Clock())
val rst_l = Input(AsyncReset())
val dccm_clk_override = Input(Bool())
val icm_clk_override = Input(Bool())
val dec_tlu_core_ecc_disable = Input(Bool())
val dccm = new mem_lsu()
val dccm_ext_in_pkt = Input(new ext_in_pkt_t(DCCM_NUM_BAN... | val wr_addr_hi = Input(UInt(DCCM_BITS.W))
val rd_addr_lo = Input(UInt(DCCM_BITS.W))
val rd_addr_hi = Input(UInt(DCCM_BITS.W))
val wr_data_lo = Input(UInt(DCCM_FDATA_WIDTH.W))
| |
Quasar | Quasar/design/src/main/scala/pic_ctrl.scala | import chisel3._
import chisel3.util._
import include._
import lib._
import chisel3.experimental.chiselName
@chiselName
class pic_ctrl extends Module with RequireAsyncReset with lib {
val io = IO (new Bundle {
val scan_mode = Input(Bool())
val free_clk = Input(Clock () )
val cl... | is ("b100000000011000".U(15.W)) {mask := "b1000".U(4.W)}
is ("b100000000011100".U(15.W)) {mask := "b1000".U(4.W)}
is ("b100000000100000".U(15.W)) {mask := "b1000".U(4.W)}
is ("b100000000100100".U(15.W)) {mask := "b1000".U(4.W)}
is ("b100000000101000".U(15.W)) {mask := "b1000".U(4.W)}
is ("b... | is ("b100000000010100".U(15.W)) {mask := "b1000".U(4.W)}
| |
Quasar | Quasar/design/src/main/scala/quasar.scala | import chisel3._
import chisel3.util._
import ifu._
import dec._
import exu._
import lsu._
import lib._
import include._
import dbg._
import mem.mem_lsu
class quasar_bundle extends Bundle with lib{
val lsu_axi = new axi_channels(LSU_BUS_TAG)
val ifu_axi = new axi_channels(IFU_BUS_TAG)
val sb_axi = new axi_chann... | val hreadyin = Input(Bool())}
val active_l2clk = Output(Clock())
val free_l2clk = Output(Clock())
val dbg_rst_l = Input(AsyncReset())
val rst_vec = Input(UInt(31.W))
val nmi_int = Input(Bool())
val nmi_vec = Input(UInt(31.W))
val core_rst_l = Output(AsyncReset())
val rv_trace_pkt = new trace_pkt_t()
... |
val lsu_ahb = new ahb_channel
val ifu_ahb = new ahb_channel
val sb_ahb = new ahb_channel
| |
Quasar | Quasar/design/src/main/scala/quasar_wrapper.scala | import chisel3._
import mem._
import chisel3.util._
import dmi._
import include._
import lib._
class quasar_wrapper extends Module with lib with RequireAsyncReset {
val io = IO(new Bundle{
val dbg_rst_l = Input(AsyncReset())
val rst_vec = Input(UInt(31.W))
val nmi_int = Input(Bool())
val nmi_vec = Inp... | core.io.dma_axi <> io.dma_brg
}
else {
core.io.ifu_ahb <> io.ifu_brg
core.io.lsu_ahb <> io.lsu_brg
core.io.sb_ahb <> io.sb_brg
core.io.dma_ahb <> io.dma_brg
core.io.lsu_axi <> 0.U.asTypeOf(core.io.lsu_axi)
core.io.ifu_axi <> 0.U.asTypeOf(core.io.ifu_axi)
core.io.sb_axi <> 0.U.asTy... | if(BUILD_AXI4) {
core.io.ifu_ahb <> 0.U.asTypeOf(core.io.ifu_ahb)
core.io.lsu_ahb <> 0.U.asTypeOf(core.io.lsu_ahb)
core.io.sb_ahb <> 0.U.asTypeOf(core.io.sb_ahb)
core.io.dma_ahb <> 0.U.asTypeOf(core.io.dma_ahb)
| |
NagiCore | NagiCore/src/main/scala/nagicore/Main.scala | package nagicore
import chisel3._
import chisel3.util._
import _root_.circt.stage._
object Main extends App {
val target = args(0)
val build_dir = "./build"
println(target)
def exportVerilog(core: () => chisel3.RawModule): Unit = {
println("Export Verilog Started")
val chiselStageOpti... |
object GlobalConfg{
var SIM = true
} | case _ => {
exportVerilog(() => new nagicore.loongarch.nscscc2024.Core)
}
| |
NagiCore | NagiCore/src/main/scala/nagicore/bus/AXI4.scala | package nagicore.bus
import chisel3._
import chisel3.util._
class AXI4AIO(addrBits: Int, idBits: Int=8) extends Bundle{
val id = Output(UInt(idBits.W))
val addr = Output(UInt(addrBits.W))
val len = Output(UInt(8.W))
val size = Output(UInt(3.W))
val burst = Output(UInt(2.W))
// val valid = Out... | }
}
is(s_writeResp) {
when(io.out.b.fire) { w_state := s_idle }
}
}
}
| when(thisReq_w.valid) { w_state := s_writeResp }
| |
NagiCore | NagiCore/src/main/scala/nagicore/bus/RAM.scala | package nagicore.bus
import chisel3._
import chisel3.util._
import nagicore.unit.cache.CacheMemType.{RAM_2cyc, Value}
import nagicore.GlobalConfg
object RamType extends Enumeration {
type RamType = Value
val RAM_2CYC, RAM_1CYC, BRAM_1CYC, DPIC_2CYC, DPIC_1CYC = Value
}
class RamIO(width: Int, depth: Long) ex... | class BlockRAMIP extends BlackBox{
override val desiredName = s"blk_mem_${width}_${depth}"
val io = IO(new Bundle {
val addra = Input(UInt(addrBits.W))
val clka = Input(Clock())
val dina ... | Predef.println(s"Xilinx BlockRAM IP blk_mem_${width}_${depth} needed")
| |
NagiCore | NagiCore/src/main/scala/nagicore/loongarch/ISA.scala | package nagicore.loongarch
/**
* Ref to https://github.com/MaZirui2001/LA32R-pipeline-scala
*/
import chisel3._
import chisel3.util._
/* Loongarch 32R */
object Instructions {
// rdcnt
def RDCNTIDW = BitPat("b0000000000000000011000?????00000")
def RDCNTVLW = BitPat("b000000000000000001100000000... | def BGE = BitPat("b011001??????????????????????????")
def BLTU = BitPat("b011010??????????????????????????")
def BGEU = BitPat("b011011??????????????????????????")
}
/* CSR */
object CSR {
val CSR_CRMD = 0x0.U(14.W)
val CSR_PRMD = 0x1.U(14.W)
val CSR_EUEN ... | def BLT = BitPat("b011000??????????????????????????")
| |
NagiCore | NagiCore/src/main/scala/nagicore/loongarch/nscscc2024/Config.scala | package nagicore.loongarch.nscscc2024
import chisel3._
import chisel3.util._
trait Config{
def XLEN = 32
def GPR_NUM = 32
def GPR_LEN = log2Up(GPR_NUM)
def PC_START = "h80000000".U(XLEN.W)
def ICACHE_WAYS = 2
| def ICACHE_WORDS = 4
def WBUFF_LEN = 4
def BTB_ENTRYS = 8
def AXI4IDBITS = 4
} | def ICACHE_LINES = 128
| |
NagiCore | NagiCore/src/main/scala/nagicore/loongarch/nscscc2024/Core.scala | package nagicore.loongarch.nscscc2024
import chisel3._
import chisel3.util._
import nagicore.bus.{AXI4SRAM, AXI4IO, Ram, RamType, RamIO}
import nagicore.bus.{AXI4XBar1toN, AXI4XBarNto1, AXI4SRAM_MultiCycs}
import nagicore.unit.MIAU
class Core extends Module with Config{
val io = IO(new Bundle{})
val preif_pa... | val mia = Module(new MIAU(XLEN, XLEN, AXI4IDBITS))
if_part.io.isram <> isram_axi4_wrapper.io.axi
val xbar_imem = Module(new AXI4XBarNto1(2, XLEN, XLEN, AXI4IDBITS))
xbar_imem.io.in(0) <> if_part.io.isram
xbar_imem.io.out <> isram_axi4_wrapper.io.axi
val xbar_dmem = Module(new AXI4XBarNto1(2, ... | mem_part.io.mem2id <> id_part.io.mem2id
mem_part.io.stall_all := false.B
| |
NagiCore | NagiCore/src/main/scala/nagicore/loongarch/nscscc2024/CtrlFlags.scala | package nagicore.loongarch.nscscc2024
import chisel3._
import chisel3.util._
object CtrlFlags{
// trait FlagsEnum {
// def value: String
// }
// object aluASel{
// sealed trait T extends FlagsEnum
// case object ra extends T{
// def value = "01"
// }
// ... | }
object aluBSel{
val rb = "001"
val imm = "010"
val num4 = "100"
def apply() = UInt(3.W)
}
object brpcAddSel{
val pc = "01"
val ra_val = "10"
def apply() = UInt(2.W)
}
object ldType{
val x = "000001"
... | def apply() = UInt(2.W)
| |
NagiCore | NagiCore/src/main/scala/nagicore/loongarch/nscscc2024/Decoder.scala | package nagicore.loongarch.nscscc2024
import chisel3._
import chisel3.util._
import chisel3.util.experimental.decode._
import nagicore.unit.ALU
import nagicore.unit.ALU_OP
import nagicore.unit.BR_TYPE
import nagicore.utils.Flags
import nagicore.loongarch.Instructions._
object DecoderMap{
object ImmType{
... | }
object regType{
val rj = "000"
val rk = "001"
val rd = "010"
// can be used as GPR_WB=false
val x = "011"
// for inst: BL
val num1 = "100"
def apply() = UInt(3.W)
}
def make_instr_list(
regB_sel: String = r... | def apply() = UInt(4.W)
| |
NagiCore | NagiCore/src/main/scala/nagicore/loongarch/nscscc2024/stages/EX.scala | package nagicore.loongarch.nscscc2024.stages
import chisel3._
import chisel3.util._
import nagicore.utils.Flags
import nagicore.unit.ALU
import nagicore.unit.BRU_SINGLE
import nagicore.GlobalConfg
import nagicore.unit.BTBUpdateIO
import nagicore.loongarch.nscscc2024.{Config, CtrlFlags}
import nagicore.unit.BR_TYPE
imp... | kill_nxt := Mux(!stall_nxt && !busy && (kill_nxt === 0.U || io.id2ex.bits.valid),
/* 当分支预测失败时,应该无视接下来3条有效指令(PREIF,IF,ID) */
Mux(br_pred_fail, 3.U,
// Mux(is_ld, 1.U,
Mux(kill_nxt===0.U, 0.U,
k... | dpic_perf_bru.io.rst := reset
dpic_perf_bru.io.valid := !Flags.OHis(preg.br_type, BR_TYPE.NEVER) && valid_instr
dpic_perf_bru.io.fail := br_pred_fail
}
| |
NagiCore | NagiCore/src/main/scala/nagicore/loongarch/nscscc2024/stages/ID.scala | package nagicore.loongarch.nscscc2024.stages
import chisel3._
import chisel3.util._
import nagicore.unit.GPR
import nagicore.unit.ALU_OP
import nagicore.unit.BR_TYPE
import nagicore.unit.BTBPredOutIO
import nagicore.loongarch.nscscc2024.{Config, CtrlFlags, Decoder}
import nagicore.GlobalConfg
class id2exBits extends... | def bypass_unit(rx: UInt, gpr_rdata: UInt):UInt = {
Mux(rx === 0.U, 0.U,
Mux(io.ex2id.bypass_rc === rx && io.ex2id.bypass_en, io.ex2id.bypass_val,
Mux(io.mem2id.bypass_rc === rx && io.mem2id.bypass_en, io.mem2id.bypass_val,
gpr_rdata
)
... | dpic_update_gpr.io.id := gpr.io.waddr(0)
dpic_update_gpr.io.wen := gpr.io.wen(0)
dpic_update_gpr.io.wdata := gpr.io.wdata(0)
| |
NagiCore | NagiCore/src/main/scala/nagicore/loongarch/nscscc2024/stages/IF.scala | package nagicore.loongarch.nscscc2024.stages
import chisel3._
import chisel3.util._
import nagicore.bus.AXI4IO
//import nagicore.unit.{InstrsBuff, InstrsBuffCacheBundle}
import nagicore.unit.cache.Cache
import nagicore.GlobalConfg
import nagicore.unit.cache.CacheReplaceType
import nagicore.unit.BTBPredOutIO
import nag... | } | if(GlobalConfg.SIM){
import nagicore.unit.DPIC_PERF_PIPE
val perf_pipe_if = Module(new DPIC_PERF_PIPE())
perf_pipe_if.io.clk := clock
perf_pipe_if.io.rst := reset
| |
NagiCore | NagiCore/src/main/scala/nagicore/loongarch/nscscc2024/stages/MEM.scala | package nagicore.loongarch.nscscc2024.stages
import chisel3._
import chisel3.util._
import nagicore.bus.AXI4IO
import nagicore.unit.cache.CacheMini
import nagicore.utils.Flags
import nagicore.GlobalConfg
import nagicore.unit.cache.CacheReplaceType
import nagicore.loongarch.nscscc2024.{Config, CtrlFlags}
import nagicor... | val byteData = Mux(addr(0), halfData(15, 8), halfData(7, 0))
val rdata_mem = Flags.onehotMux(preg.ld_type, Seq(
CtrlFlags.ldType.x -> (0.U).zext,
CtrlFlags.ldType.b -> byteData.asSInt,
CtrlFlags.ldType.bu -> byteData.zext,
CtrlFlags.ldType.h -> halfData.asSInt,
CtrlFl... | val wordData = if(XLEN == 64) Mux(addr(2), rdata_raw(63, 32), rdata_raw(31, 0))
else rdata_raw(31, 0)
| |
NagiCore | NagiCore/src/main/scala/nagicore/loongarch/nscscc2024/stages/PREIF.scala | package nagicore.loongarch.nscscc2024.stages
import chisel3._
import chisel3.util._
import nagicore.unit.BTB
import nagicore.unit.BTBPredOutIO
import nagicore.loongarch.nscscc2024.{Config, CtrlFlags}
import nagicore.GlobalConfg
class preif2ifBits extends Bundle with Config{
val pc = UInt(XLEN.W)
| class preif2ifIO extends Bundle{
val bits = Output(new preif2ifBits)
val stall = Input(Bool())
}
class PREIF extends Module with Config{
val io = IO(new Bundle {
val preif2if = new preif2ifIO
val ex2preif = Flipped(new ex2preifIO)
})
val nxt_pc = Wire(UInt(XLEN.W))
if(GlobalCon... | val bpu_out = new BTBPredOutIO(BTB_ENTRYS, XLEN)
val valid = Bool()
| |
NagiCore | NagiCore/src/main/scala/nagicore/loongarch/nscscc2024Dual/Config.scala | package nagicore.loongarch.nscscc2024Dual
import chisel3._
import chisel3.util._
trait Config{
def XLEN = 32
def GPR_NUM = 32
def GPR_LEN = log2Up(GPR_NUM)
def PC_START = "h80000000".U(XLEN.W)
def ICACHE_WAYS = 2
| def ICACHE_WORDS = 4
def WBUFF_LEN = 8
def BTB_ENTRYS = 8
def AXI4IDBITS = 4
} | def ICACHE_LINES = 128
| |
NagiCore | NagiCore/src/main/scala/nagicore/loongarch/nscscc2024Dual/Core.scala | package nagicore.loongarch.nscscc2024Dual
import chisel3._
import chisel3.util._
import nagicore.bus.{AXI4SRAM, AXI4IO, Ram, RamType, RamIO}
import nagicore.bus.{AXI4XBar1toN, AXI4XBarNto1, AXI4SRAM_MultiCycs}
class Core extends Module with Config{
val io = IO(new Bundle{})
val preif_stage = Module(new stage... | xbar_dmem.io.out(1) <> dsram_ctrl.io.axi
xbar_dmem.io.out(2) <> uart_axi4.io.axi
val isram = Module(new Ram(XLEN, 1.toLong<<XLEN, RamType.DPIC_2CYC))
val dsram = Module(new Ram(XLEN, 1.toLong<<XLEN, RamType.DPIC_2CYC))
val uart = Module(new Ram(XLEN, 1.toLong<<XLEN, RamType.DPIC_2CYC))
isram_ct... | (0x80000000L, 0x400000L, false),
(0x80400000L, 0x400000L, false),
(0xbfd00000L, 0x400000L, false),
)))
| |
NagiCore | NagiCore/src/main/scala/nagicore/loongarch/nscscc2024Dual/CtrlFlags.scala | package nagicore.loongarch.nscscc2024Dual
import chisel3._
import chisel3.util._
object CtrlFlags{
// trait FlagsEnum {
// def value: String
// }
// object aluASel{
// sealed trait T extends FlagsEnum
// case object ra extends T{
// def value = "01"
// }
//... | }
object aluBSel{
val rb = "001"
val imm = "010"
val num4 = "100"
def apply() = UInt(3.W)
}
object brpcAddSel{
val pc = "01"
val ra_val = "10"
def apply() = UInt(2.W)
}
object ldType{
val x = "000001"
... | def apply() = UInt(2.W)
| |
NagiCore | NagiCore/src/main/scala/nagicore/loongarch/nscscc2024Dual/Decoder.scala | package nagicore.loongarch.nscscc2024Dual
import chisel3._
import chisel3.util._
import chisel3.util.experimental.decode._
import nagicore.unit.ALU
import nagicore.unit.ALU_OP
import nagicore.unit.BR_TYPE
import nagicore.utils.Flags
import nagicore.loongarch.Instructions._
object DecoderMap{
object ImmType{
... | }
def make_instr_list(
regB_sel: String = regType.rk,
regC_sel: String = regType.rd,
imm_type: String = ImmType.si12,
aluA_sel: String = CtrlFlags.aluASel.ra,
aluB_sel: String = CtrlFlags.aluBSel.rb,
alu_op: String = ALU_OP.X,
brpcAdd... | def apply() = UInt(rj.length.W)
| |
NagiCore | NagiCore/src/main/scala/nagicore/loongarch/nscscc2024Dual/stages/EX.scala | package nagicore.loongarch.nscscc2024Dual.stages
import chisel3._
import chisel3.util._
import nagicore.utils.Flags
import nagicore.unit.ALU
import nagicore.unit.BRU_SINGLE
import nagicore.GlobalConfg
import nagicore.unit.BTBUpdateIO
import nagicore.loongarch.nscscc2024Dual.{Config, CtrlFlags}
import nagicore.unit.BR_... | dpic_perf_bru.io.clk := clock
dpic_perf_bru.io.rst := reset
dpic_perf_bru.io.valid := !Flags.OHis(preg.br_type, BR_TYPE.NEVER) && valid_instr1
dpic_perf_bru.io.fail := br_pred_fail
}
io.ex2mem.bits.valid1 := valid_instr1
io.ex2mem.bits.valid2 := valid_instr2
io.ex2mem.b... | val dpic_perf_bru = Module(new DPIC_PERF_BRU)
| |
NagiCore | NagiCore/src/main/scala/nagicore/loongarch/nscscc2024Dual/stages/ID.scala | package nagicore.loongarch.nscscc2024Dual.stages
import chisel3._
import chisel3.util._
import nagicore.unit.GPR
import nagicore.unit.ALU_OP
import nagicore.unit.BR_TYPE
import nagicore.unit.BTBPredOutIO
import nagicore.loongarch.nscscc2024Dual.{Config, CtrlFlags, Decoder}
import nagicore.GlobalConfg
class id2isBits... | io.id2is.bits.instr_type := decoder.io.instr_type
io.id2is.bits.bpu_out := preg.bpu_out
io.id2is.bits.pc_refill := preg.pc_refill
| ||
NagiCore | NagiCore/src/main/scala/nagicore/loongarch/nscscc2024Dual/stages/IF.scala | package nagicore.loongarch.nscscc2024Dual.stages
import chisel3._
import chisel3.util._
import nagicore.bus.AXI4IO
//import nagicore.unit.{InstrsBuff, InstrsBuffCacheBundle}
import nagicore.unit.cache.Cache
import nagicore.GlobalConfg
import nagicore.unit.cache.CacheReplaceType
import nagicore.unit.BTBPredOutIO
import... | perf_pipe_if.io.rst := reset
perf_pipe_if.io.id := 0.U
perf_pipe_if.io.invalid := !io.if2id.bits.valid
perf_pipe_if.io.stall := io.preif2if.stall
}
} | perf_pipe_if.io.clk := clock
| |
NagiCore | NagiCore/src/main/scala/nagicore/loongarch/nscscc2024Dual/stages/IS.scala | package nagicore.loongarch.nscscc2024Dual.stages
import chisel3._
import chisel3.util._
import nagicore.unit.GPR
import nagicore.unit.ALU_OP
import nagicore.unit.BR_TYPE
import nagicore.unit.BTBPredOutIO
import nagicore.loongarch.nscscc2024Dual.{Config, CtrlFlags, Decoder}
import nagicore.GlobalConfg
import nagicore.u... | issue_buffer.io.popN := issue_double
// io.id2is.stall := io.is2ex.stall
io.id2is.stall := issue_buffer.io.full
val gpr = Module(new GPR(XLEN, GPR_NUM, 4, 2))
gpr.io.wen(0) := io.mem2is.gpr_wen1 && (!io.mem2is.gpr_wen2 || io.mem2is.gpr_wid2 =/= io.mem2is.gpr_wid1)
gpr.io.waddr(0) := io.mem2... | val is2 = issue_buffer.io.rdatas(1)
val data_hazard = (is1.rc === is2.ra || is1.rc === is2.rb) && is1.rc =/= 0.U
// 只双发is2是ALU类,且无数据冒险的指令
val issue_double =
Flags.is(is2.instr_type, CtrlFlags.InstrType.alu) &&
| |
NagiCore | NagiCore/src/main/scala/nagicore/loongarch/nscscc2024Dual/stages/MEM.scala | package nagicore.loongarch.nscscc2024Dual.stages
import chisel3._
import chisel3.util._
import nagicore.bus.AXI4IO
import nagicore.unit.cache.CacheMini
import nagicore.utils.Flags
import nagicore.GlobalConfg
import nagicore.unit.cache.CacheReplaceType
import nagicore.loongarch.nscscc2024Dual.{Config, CtrlFlags}
import... | val dcache = Module(new UnCache(XLEN, XLEN, WBUFF_LEN, 1))
// pipeline registers
val preg = RegEnable(io.ex2mem.bits, !dcache.io.out.busy && !io.stall_all)
io.ex2mem.stall := dcache.io.out.busy || io.stall_all
dcache.io.axi <> io.dmem
val addr = preg.alu1_out
dcache.io.in.bits.addr := ad... | val pc = UInt(XLEN.W)
val no_ldst = Bool()
val valid = Bool()
| |
NagiCore | NagiCore/src/main/scala/nagicore/loongarch/nscscc2024Dual/stages/PREIF.scala | package nagicore.loongarch.nscscc2024Dual.stages
import chisel3._
import chisel3.util._
import nagicore.unit.BTB
import nagicore.unit.BTBPredOutIO
import nagicore.loongarch.nscscc2024Dual.{Config, CtrlFlags}
import nagicore.GlobalConfg
class preif2ifBits extends Bundle with Config{
val pc = UInt(XLEN.W)... |
val bpu = Module(new BTB(BTB_ENTRYS, XLEN, XLEN/2))
bpu.io.pred.in.pc := pc
bpu.io.update := io.ex2preif.bpu_update
nxt_pc := Mux(io.ex2preif.bpu_fail, io.ex2preif.br_real_pc,
Mux(bpu.io.pred.out.taken, bpu.io.pred.out.target,
pc4
)
)
io.preif2if.bits.pc := pc
i... | if(GlobalConfg.SIM){
dontTouch(nxt_pc)
}
| |
NagiCore | NagiCore/src/main/scala/nagicore/unit/ALU.scala | package nagicore.unit
import chisel3._
import chisel3.util._
import nagicore.utils.Flags
import nagicore.GlobalConfg
object ALU_OP{
// val X = Value(0.U)
// val ADD = Value(1.U)
// val SUB = Value(2.U)
// val AND = Value(4.U)
// val OR = Value(8.U)
// val XOR = Valu... | }
class ALUIO(dataBits: Int) extends Bundle{
val a = Input(UInt(dataBits.W))
val b = Input(UInt(dataBits.W))
val op = Input(ALU_OP())
val sum = Output(UInt(dataBits.W))
val out = Output(UInt(dataBits.W))
val valid = Input(Bool())
val busy = Output(Bool())
}
cl... | def apply() = UInt(X.length().W)
| |
NagiCore | NagiCore/src/main/scala/nagicore/unit/BPU.scala | package nagicore.unit
import chisel3._
import chisel3.util._
import nagicore.utils.Flags
import nagicore.utils.isPowerOf2
object BP_TYPE{
val dontcare = "??"
val jump = "01" // unconditional jump
val cond = "10" // conditional jump
| }
class BTBPredInIO(pcBits: Int) extends Bundle {
val pc = UInt(pcBits.W)
}
class BTBPredOutIO(entryNum: Int, pcBits: Int) extends Bundle {
val taken = Bool()
val target = UInt(pcBits.W)
val hit = Bool()
val index = UInt(log2Ceil(entryNum).W)
}
class BTBUpdateIO(entryNum: Int, pcBits: Int) extend... | def apply() = UInt(2.W)
| |
NagiCore | NagiCore/src/main/scala/nagicore/unit/BRU.scala | package nagicore.unit
import chisel3._
import chisel3.util._
import nagicore.utils.Flags
object BR_TYPE{
val NEVER = "00000001"
val EQ = "00000010"
val NE = "00000100"
val LT = "00001000"
val LTU = "00010000"
val GE = "00100000"
val GEU = "01000000"
val A... | }
class BRU_WITH_ALU_IO(dataBits: Int) extends Bundle{
val alu_out = Input(UInt(dataBits.W))
val br_type = Input(BR_TYPE())
val br_take = Output(Bool())
}
class BRU_WITH_ALU(dataBits: Int) extends Module{
val io = IO(new BRU_WITH_ALU_IO(dataBits))
val eq = io.alu_out === 0.U
import BR_TYPE._... | def apply() = UInt(NEVER.length.W)
| |
NagiCore | NagiCore/src/main/scala/nagicore/unit/DIVU.scala | package nagicore.unit
import chisel3._
import chisel3.util._
import nagicore.utils.Flags
object DIVU_IMP extends Enumeration {
type DIVU_IMP = Value
val none, radix2 = Value
}
class DIVU(dataBits: Int, imp_way: DIVU_IMP.DIVU_IMP = DIVU_IMP.radix2) extends Module{
val io = IO(new Bundle{
val a ... | val sign_r = Mux(io.signed, io.a(dataBits-1), false.B)
val src1 = Mux(io.signed && io.a(dataBits-1), ~io.a + 1.U, io.a)
val src2 = Mux(io.signed && io.b(dataBits-1), ~io.b + 1.U, io.b)
// get highest 1 in src1
// TODO use log2
val high_rev = Prior... | case DIVU_IMP.radix2 => {
/* ref: https://github.com/MaZirui2001/LAdataBitsR-pipeline-scala */
| |
NagiCore | NagiCore/src/main/scala/nagicore/unit/DPIC.scala | package nagicore.unit
import chisel3._
import chisel3.util._
import nagicore.bus.RamIO
class DPIC_RAM_1CYC(addr_width: Int, data_width: Int) extends BlackBox(Map("ADDR_WIDTH" -> addr_width, "DATA_WIDTH" -> data_width)) with HasBlackBoxResource{
val io = IO(new Bundle {
val clk = Input(Clock())
... | addResource("/sv/DPIC_TYPES_DEFINE.sv")
addResource("/sv/DPIC_PERF_BRU.sv")
}
class DPIC_PERF_PIPE extends BlackBox with HasBlackBoxResource{
val io = IO(new Bundle{
val clk = Input(Clock())
val rst = Input(Bool())
val id = Input(UInt(8.W))
// 对下一流水级的有效指令计数
... | class DPIC_PERF_BRU extends BlackBox with HasBlackBoxResource{
val io = IO(new Bundle{
val clk = Input(Clock())
val rst = Input(Bool())
| |
NagiCore | NagiCore/src/main/scala/nagicore/unit/GPR.scala | package nagicore.unit
import chisel3._
import chisel3.util._
class GPRIO(dataBits: Int, addrBits: Int, rchannel: Int, wchannel: Int) extends Bundle {
val raddr = Input(Vec(rchannel, UInt(addrBits.W)))
val rdata = Output(Vec(rchannel, UInt(dataBits.W)))
| }
class GPR(dataBits: Int, regNum: Int, rchannel: Int, wchannel: Int) extends Module {
val io = IO(new GPRIO(dataBits, log2Up(regNum), rchannel, wchannel))
val regs = Reg(Vec(regNum, UInt(dataBits.W)))
// val regs = Reg(VecInit.fill(regNum)(0.U(dataBits.W)))
// val regs = Mem(regNum, UInt(dataBits.W))
... | val wen = Input(Vec(wchannel, Bool()))
val waddr = Input(Vec(wchannel, UInt(addrBits.W)))
| |
NagiCore | NagiCore/src/main/scala/nagicore/unit/InstrsBuff.scala | package nagicore.unit
import chisel3._
import chisel3.util._
import nagicore.loongarch.nscscc2024.CtrlFlags.ldType.bu
import nagicore.GlobalConfg
import cache.CachePipedIO
class InstrsBuffCacheBundle extends Bundle{
val new_trans = Bool()
}
class InstrsBuffIO(addrBits:Int, dataBits: Int, cacheBlockWords: Int) ex... | }
when(io.in.fetch && !io.out.busy){
buff_head := buff_head + 1.U
buff_valid(buff_head) := false.B
}
}
}
}
io.cache.front.bits.size := log2Up(dataBits/8).U
io.cache.front.bits.uncache := false.B
... | for(i <- 0 until cacheBlockWords){
buff(buff_tail+i.U) := io.cache.back.bits.rline(i)
buff_valid(buff_tail+i.U) := (i.U >= new_trans_offset)
}
| |
NagiCore | NagiCore/src/main/scala/nagicore/unit/MIAU.scala | package nagicore.unit
import chisel3._
import chisel3.util._
import nagicore.bus._
/**
* Max In Array Unit
* 求数组中的最大值,为龙芯杯个人赛决赛设计
*
* @param addrBits
* @param dataBits
*/
class MIAU(addrBits:Int, dataBits: Int, idBits: Int) extends Module{
val io = IO(new Bundle{
val cmd = Flipped(new AXI4IO(a... | io.cmd.r.valid := rs === rs_r
io.cmd.r.bits.id := rid
io.cmd.r.bits.last := rlen === 0.U
io.cmd.r.bits.resp := 0.U
io.cmd.r.bits.data := FIR
io.cmd.aw <> DontCare
io.cmd.w <> DontCare
io.cmd.b <> DontCare
val axi_w_agent = Module(new AXI4WriteAgent(addrBits, dataBits, 1))
axi_w... | }otherwise{
rlen := rlen - 1.U
}
| |
NagiCore | NagiCore/src/main/scala/nagicore/unit/MULU.scala | package nagicore.unit
import chisel3._
import chisel3.util._
import nagicore.utils._
import nagicore.GlobalConfg
object MULU_IMP extends Enumeration {
type MULU_IMP = Value
val none, synthesizer_1cyc, oneBitShift, xsArrayMul, MultiplierIP, synthesizer_DSP = Value
}
object MULU_OP{
val MUL = ALU_OP.MU... | class MultiplierIP extends BlackBox{
override val desiredName = s"mult_${dataBits+1}_unsigned_2stages"
val io = IO(new Bundle {
val CLK = Input(Clock())
val A = Input(UInt((dataBits+1).W))
... | Predef.println(s"Xilinx Multiplier IP mult_${dataBits+1}_unsigned_2stages needed")
| |
NagiCore | NagiCore/src/main/scala/nagicore/unit/RingBuff.scala | package nagicore.unit
import chisel3._
import chisel3.util._
import nagicore.GlobalConfg
class RingBuffIO[T <: Bundle](dataT: ()=> T, rchannel: Int) extends Bundle{
val full = Output(Bool())
val empty = Output(Bool())
val push = Input(Bool())
val wdata = Input(dataT())
val pop = Inp... | }
| dpic_perf_instrs_buff.io.tail := buff_tail
dpic_perf_instrs_buff.io.full := full
dpic_perf_instrs_buff.io.reload := io.clear
| |
NagiCore | NagiCore/src/main/scala/nagicore/unit/cache/Cache.scala | package nagicore.unit.cache
import chisel3.VecInit._
import chisel3._
import chisel3.util._
import nagicore.bus._
import chisel3.util.random.LFSR
import nagicore.utils.isPowerOf2
import nagicore.GlobalConfg
class CacheIOFrontBits[T <: Bundle](addrBits: Int, dataBits: Int, pipedataT: () => T) extends Bundle{
val v... | wait_uncache_ready()
}
is(StageState.uncacheRead){
// 等待代理空闲
when(axi_r_agent.io.cmd.out.ready){
rdata_uncache := axi_r_agent.io.cmd.out.rdata
state := StageState.uncacheEnd
}
}
is(StageState.uncacheEnd){
... | state := StageState.lookup
for(i <- 0 until blockWords){
bypass_valid(i) := true.B
}
| |
NagiCore | NagiCore/src/main/scala/nagicore/unit/cache/CacheMini.scala | package nagicore.unit.cache
import chisel3._
import chisel3.util._
import nagicore.bus._
import chisel3.util.random.LFSR
import nagicore.utils.isPowerOf2
import nagicore.GlobalConfg
import nagicore.unit.RingBuff
/**
* 有个写缓存队列(write buffer),每次写的时候,直接一拍写到缓存队列里面,不阻塞前面的流水线,后台调AXI4自己慢慢写去
*
* @note busy拉高表示请求阻塞前级流水
... | if(GlobalConfg.SIM){
import nagicore.unit.DPIC_PERF_CACHE
val dpic_perf_cache = Module(new DPIC_PERF_CACHE)
dpic_perf_cache.io.clk := clock
dpic_perf_cache.io.rst := reset
dpic_perf_cache.io.valid := io.in.req
dpic_perf_cache.io.id := debug_id.U
dpic_perf_cac... | L0(0).addr := addr
L0(0).data := data
L0(0).valid := true.B
}
| |
NagiCore | NagiCore/src/main/scala/nagicore/unit/cache/CachePiped.scala | package nagicore.unit.cache
import chisel3._
import chisel3.util._
import nagicore.bus._
import chisel3.util.random.LFSR
import nagicore.utils.isPowerOf2
import nagicore.GlobalConfg
class CachePipedIOFrontBits[T <: Bundle](addrBits: Int, dataBits: Int, pipedataT: () => T) extends Bundle{
val valid = Bool()
... | tag_v_io(i).dout(0).asBool
}, pipego_reg)
val rdirty = RegEnable(VecInit.tabulate(ways){ i =>
dirty_io(i).dout.asBool
}, pipego_reg)
pipego :=
(
// 连续命中
(state_s2 === Stage2State.lookup && hit) ||
// 无效命令
!preg2.valid ||
//... | val rdatas = RegEnable(VecInit.tabulate(ways){ i =>
VecInit.tabulate(num_word){ j =>
data_bank_io(i)(j).dout
}
}, pipego_reg)
| |
NagiCore | NagiCore/src/main/scala/nagicore/unit/cache/CacheType.scala | package nagicore.unit.cache
import chisel3._
import chisel3.util._
import nagicore.bus.{Ram, RamIO}
object CacheMemType extends Enumeration {
type CacheMemType = Value
val RAM_2cyc, BRAM_1cyc, RAM_1cyc = Value
}
object CacheReplaceType extends Enumeration {
type CacheReplaceType = Value
val Random, ... | case _ => {
val sram = Module(new Ram(width, depth))
sram.io <> io
}
| ||
NagiCore | NagiCore/src/main/scala/nagicore/unit/cache/CacheWT.scala | package nagicore.unit.cache
import chisel3.VecInit._
import chisel3._
import chisel3.util._
import nagicore.bus._
import chisel3.util.random.LFSR
import nagicore.utils.isPowerOf2
import nagicore.GlobalConfg
import nagicore.unit.RingBuff
class CacheWTIOFrontBits[T <: Bundle](addrBits: Int, dataBits: Int, pipedataT: ()... |
val rdatas_hit = WireDefault(fill(blockWords)(0.U(dataBits.W)))
val rdatas_replace = RegInit(fill(blockWords)(0.U(dataBits.W)))
val rdata_uncache = RegInit(0.U(dataBits.W))
io.cmd.front.stall := !pipego
io.cmd.back.bits.valid := data_ok && preg.valid
// io.master.back.bits.rdata := Mux(state_s2... | val addr_word_reg = if(len_word!=0) addr_reg(len_word+len_byte-1, len_byte) else 0.U
| |
NagiCore | NagiCore/src/main/scala/nagicore/unit/cache/UnCache.scala | package nagicore.unit.cache
import chisel3._
import chisel3.util._
import nagicore.bus._
import chisel3.util.random.LFSR
import nagicore.utils.isPowerOf2
import nagicore.GlobalConfg
import nagicore.unit.RingBuff
/**
* 为uncache设计的cache(x),读写均直达
* 有个写缓存队列(write buffer),每次写的时候,直接一拍写到缓存队列里面,不阻塞前面的流水线,后台调AXI4自己慢慢写去
... | io.out.busy := state =/= State.idle // ...
val ready_read = axi_r_agent.io.cmd.out.ready&&write_buff.io.empty&&axi_w_agent.io.cmd.out.ready
switch(state){
is(State.idle){
when(io.in.req){
when(io.in.bits.we){
// Write
when(write_b... | val waitReadReady = Value(4.U)
val waitRead = Value(8.U)
}
| |
NagiCore | NagiCore/src/main/scala/nagicore/unit/ip/Xiangshan/ArrayMulDataModule.scala | /***************************************************************************************
* Copyright (c) 2020-2021 Institute of Computing Technology, Chinese Academy of Sciences
* Copyright (c) 2020-2021 Peng Cheng Laboratory
*
* XiangShan is licensed under Mulan PSL v2.
* You can use this software according to the ter... | val (s_1, c_1_1, c_1_2) = addOneColumn(col take 4, cin_1)
val (s_2, c_2_1, c_2_2) = addOneColumn(col drop 4, cin_2)
sum = s_1 ++ s_2
cout1 = c_1_1 ++ c_2_1
cout2 = c_1_2 ++ c_2_2
}
(sum, cout1, cout2)
}
def max(in: Iterable[Int]): Int = in.reduce((a, b) => if(a>b) a ... | val cin_2 = if(cin.nonEmpty) cin.drop(1) else Nil
| |
NagiCore | NagiCore/src/main/scala/nagicore/unit/ip/Xiangshan/CSA.scala | /***************************************************************************************
* Copyright (c) 2020-2021 Institute of Computing Technology, Chinese Academy of Sciences
* Copyright (c) 2020-2021 Peng Cheng Laboratory
*
* XiangShan is licensed under Mulan PSL v2.
* You can use this software according to the ter... | class C53 extends CSA5_3(1)
| ||
NagiCore | NagiCore/src/main/scala/nagicore/utils/Flags.scala | package nagicore.utils
import chisel3._
import chisel3.util._
import chisel3.util.experimental.decode._
object Flags{
def bp(x : String) : BitPat = BitPat(s"b${x}")
def U(x: String):UInt = s"b$x".U
| def onehotMux[T <: Data](input: UInt, cases: Iterable[(String, T)]) = {
// check one-hot
assert(cases.map(x => x._1.count(_ == '1')==1).reduce(_ && _))
// check no duplicate
assert(cases.map(x=>x._1).toSet.size == cases.size)
chisel3.util.Mux1H(cases.map(x => input(x._1.lengt... | def castFlags2Bitpat(x : Iterable[String]) : BitPat = BitPat(s"b${x.reduce(_ ++ _)}")
| |
NagiCore | NagiCore/src/main/scala/nagicore/utils/utils.scala | package nagicore.utils
import chisel3._
import chisel3.util._
object SignExt {
def apply(a: UInt, len: Int): UInt = {
val aLen = a.getWidth
val signBit = a(aLen-1)
| }
}
object isPowerOf2{
def apply(x: Int): Boolean = {
x > 0 && (x & (x-1)) == 0
}
}
| if (aLen >= len) a(len-1,0) else Cat(Fill(len - aLen, signBit), a)
| |
constellation | constellation/src/main/scala/channel/Buffer.scala | package constellation.channel
import chisel3._
import chisel3.util._
import org.chipsalliance.cde.config.{Field, Parameters}
import freechips.rocketchip.diplomacy.{LazyModule, LazyModuleImp}
object ChannelBuffer {
def apply(depth: Int)(implicit p: Parameters) = {
val buffer = LazyModule(new ChannelBuffer(depth... | out.flit.foreach(_.valid := false.B)
out.flit.foreach(_.bits := DontCare)
in.credit_return := 0.U
in.vc_free := 0.U
}
}
}
| if (cParam.traversable) {
(out.flit zip in.flit).map(t => t._1 := Pipe(t._2))
in.credit_return := ShiftRegister(out.credit_return, depth)
| |
constellation | constellation/src/main/scala/channel/Channel.scala | package constellation.channel
import chisel3._
import chisel3.util._
import org.chipsalliance.cde.config.{Field, Parameters}
import freechips.rocketchip.prci.{ClockCrossingType, NoCrossing}
import constellation.routing.{ChannelRoutingInfo}
import constellation.noc.{HasNoCParams}
class Channel(val cParam: ChannelPara... | val flit = Irrevocable(new EgressFlit(cParam.payloadBits))
}
| class IngressChannel(val cParam: BaseChannelParams)(implicit val p: Parameters) extends Bundle {
val payloadBits = cParam.payloadBits
require(cParam.isInstanceOf[IngressChannelParams])
val flit = Irrevocable(new IngressFlit(cParam.payloadBits))
}
| |
constellation | constellation/src/main/scala/channel/Flit.scala | package constellation.channel
import chisel3._
import chisel3.util._
import org.chipsalliance.cde.config.{Field, Parameters}
import constellation.routing.{FlowRoutingBundle}
import constellation.noc.{HasNoCParams}
|
class EgressFlit(payloadBits: Int)(implicit p: Parameters) extends BaseFlit(payloadBits)(p) {
val ingress_id = UInt()
}
class Flit(payloadBits: Int)(implicit p: Parameters) extends BaseFlit(payloadBits)(p) with HasNoCParams {
val flow = new FlowRoutingBundle
val virt_channel_id = UInt(virtualChannelBits.W)
}
| class BaseFlit(val payloadBits: Int)(implicit val p: Parameters) extends Bundle {
val head = Bool()
val tail = Bool()
val payload = UInt(payloadBits.W)
}
| |
constellation | constellation/src/main/scala/channel/Monitor.scala | package constellation.channel
import chisel3._
import chisel3.util._
import freechips.rocketchip.diplomacy._
import org.chipsalliance.cde.config.{Parameters}
import freechips.rocketchip.util._
import constellation.noc.{HasNoCParams}
class NoCMonitor(val cParam: ChannelParams)(implicit val p: Parameters) extends Modu... | for (i <- 0 until cParam.srcSpeedup) {
val flit = io.in.flit(i)
when (flit.valid) {
when (flit.bits.head) {
in_flight(flit.bits.virt_channel_id) := true.B
assert (!in_flight(flit.bits.virt_channel_id), "Flit head/tail sequencing is broken")
}
when (flit.bits.tail) {
i... | val in_flight = RegInit(VecInit(Seq.fill(cParam.nVirtualChannels) { false.B }))
| |
constellation | constellation/src/main/scala/channel/Nodes.scala | package constellation.channel
import chisel3._
import chisel3.experimental.SourceInfo
import org.chipsalliance.cde.config.{Parameters, Field}
import freechips.rocketchip.diplomacy._
|
case class ChannelEdgeParams(cp: ChannelParams, p: Parameters)
object ChannelImp extends SimpleNodeImp[EmptyParams, ChannelParams, ChannelEdgeParams, Channel] {
def edge(pd: EmptyParams, pu: ChannelParams, p: Parameters, sourceInfo: SourceInfo) = {
ChannelEdgeParams(pu, p)
}
def bundle(e: ChannelEdgeParams)... | case class EmptyParams()
| |
constellation | constellation/src/main/scala/channel/Parameters.scala | package constellation.channel
import chisel3._
import chisel3.util._
import org.chipsalliance.cde.config.{Field, Parameters}
import freechips.rocketchip.prci.{ClockCrossingType, NoCrossing}
import constellation.routing.{ChannelRoutingInfo, FlowRoutingInfo}
import constellation.noc.{HasNoCParams}
// BEGIN: FlowParams... | def srcSpeedup = 1
def destSpeedup = 1
}
case class ChannelParams(
srcId: Int,
destId: Int,
payloadBits: Int,
virtualChannelParams: Seq[VirtualChannelParams],
srcSpeedup: Int,
destSpeedup: Int,
channelGen: Parameters => ChannelOutwardNode => ChannelOutwardNode = { p => u => u },
useOutputQueues: B... | def nVirtualChannels = 1
| |
constellation | constellation/src/main/scala/channel/WidthWidget.scala | package constellation.channel
import chisel3._
import chisel3.util._
import freechips.rocketchip.diplomacy._
import org.chipsalliance.cde.config.{Parameters}
import freechips.rocketchip.util._
object WidthWidget {
def split[T <: BaseFlit](in: IrrevocableIO[T], out: IrrevocableIO[T]) = {
val inBits = in.bits.pay... | )
lazy val module = new LazyModuleImp(this) {
(node.in zip node.out) foreach { case ((in, edgeIn), (out, edgeOut)) =>
WidthWidget(in.flit, out.flit)
}
}
}
object EgressWidthWidget {
def apply(destBits: Int, srcBits: Int)(implicit p: Parameters) = {
if (destBits == srcBits) {
val node = ... | slaveFn = { s => s.copy(payloadBits=srcBits) }
| |
constellation | constellation/src/main/scala/noc/NoC.scala | package constellation.noc
import chisel3._
import chisel3.util._
import org.chipsalliance.cde.config.{Field, Parameters}
import freechips.rocketchip.diplomacy.{LazyModule, LazyModuleImp, BundleBridgeSink, InModuleBody}
import freechips.rocketchip.util.ElaborationArtefacts
import freechips.rocketchip.prci._
import co... | }.mkString("\n")
ElaborationArtefacts.add(prepend("noc.adjlist"), adjList)
val xys = routers.map(r => {
val n = r.nodeId
val ids = (Seq(r.nodeId.toString)
++ r.egressParams.map(e => s"e${e.egressId}")
++ r.ingressParams.map(i => s"i${i.ingressId}")
)
val plotter = no... | (Seq(s"${r.nodeId} $outs $egresses") ++ ingresses).mkString("\n")
| |
constellation | constellation/src/main/scala/noc/Parameters.scala | package constellation.noc
import chisel3._
import chisel3.util._
import org.chipsalliance.cde.config.{Field, Parameters}
import freechips.rocketchip.diplomacy.{LazyModule, LazyModuleImp, BundleBridgeSink, InModuleBody}
import constellation.router._
import constellation.channel._
import constellation.routing._
import... | )
neighbors.foreach { nI =>
if (!visited.contains(nI)) {
if (!checkAcyclicUtil(nI)) return false
} else if (stack.contains(nI)) {
stack = stack ++ Seq(nI)
return false
}
}
stack = stack.dropRight(1)
return true
... | .foldLeft(false) { (b, pI) => b || routingRel(cI, nI, pI) }
| |
constellation | constellation/src/main/scala/protocol/AXI4.scala | package constellation.protocol
import chisel3._
import chisel3.util._
import constellation.channel._
import constellation.noc._
import org.chipsalliance.cde.config._
import freechips.rocketchip.diplomacy._
import freechips.rocketchip.util._
import freechips.rocketchip.amba.axi4._
trait AXI4FieldHelper {
val wideB... | val awFIFOMap = WireInit(VecInit(Seq.fill(endId) { true.B }))
val arSel = UIntToOH(io.axi4.ar.bits.id, endId)
val awSel = UIntToOH(io.axi4.aw.bits.id, endId)
val rSel = UIntToOH(io.axi4.r .bits.id, endId)
val bSel = UIntToOH(io.axi4.b .bits.id, endId)
val arTag = OHToUInt(requestARIO.asUInt, edgesOut.size... | val arFIFOMap = WireInit(VecInit(Seq.fill(endId) { true.B }))
| |
constellation | constellation/src/main/scala/protocol/Protocol.scala | package constellation.protocol
import chisel3._
import chisel3.util._
import constellation.channel._
import constellation.noc._
import constellation.router.{RouterCtrlBundle}
import org.chipsalliance.cde.config._
import freechips.rocketchip.diplomacy._
import freechips.rocketchip.subsystem._
import scala.collection... | }
// BEGIN: ProtocolParams
trait ProtocolParams {
val minPayloadWidth: Int
val ingressNodes: Seq[Int]
val egressNodes: Seq[Int]
val nVirtualNetworks: Int
val vNetBlocking: (Int, Int) => Boolean
val flows: Seq[FlowParams]
def genIO()(implicit p: Parameters): Data
def interface(
terminals: NoCTermina... | def getNodesOut(ls: Seq[String]): Seq[Option[Int]] = getNodes(ls, outNodeMapping)
| |
constellation | constellation/src/main/scala/protocol/Tilelink.scala | package constellation.protocol
import chisel3._
import chisel3.util._
import constellation.channel._
import constellation.noc._
import constellation.soc.{CanAttachToGlobalNoC}
import org.chipsalliance.cde.config._
import freechips.rocketchip.diplomacy._
import freechips.rocketchip.util._
import freechips.rocketchip.... | }
trait TileLinkProtocolParams extends ProtocolParams with TLFieldHelper {
def edgesIn: Seq[TLEdge]
def edgesOut: Seq[TLEdge]
def edgeInNodes: Seq[Int]
def edgeOutNodes: Seq[Int]
require(edgesIn.size == edgeInNodes.size && edgesOut.size == edgeOutNodes.size)
def wideBundle = TLBundleParameters.union(edgesI... | val out = MixedVec(edgesOut.map { e => new TLBundle(e.bundle) })
| |
constellation | constellation/src/main/scala/protocol/TilelinkAdapters.scala | package constellation.protocol
import chisel3._
import chisel3.util._
import constellation.channel._
import constellation.noc._
import constellation.soc.{CanAttachToGlobalNoC}
import org.chipsalliance.cde.config._
import freechips.rocketchip.diplomacy._
import freechips.rocketchip.util._
import freechips.rocketchip.... |
val protocol = Wire(Decoupled(gen))
val body_fields = getBodyFields(protocol.bits)
val const_fields = getConstFields(protocol.bits)
val is_const = RegInit(true.B)
val const_reg = Reg(UInt(const_fields.map(_.getWidth).sum.W))
val const = Mux(io.flit.bits.head, io.flit.bits.payload, const_reg)
io.flit.rea... | def trim(id: UInt, size: Int): UInt = if (size <= 1) 0.U else id(log2Ceil(size)-1, 0)
| |
constellation | constellation/src/main/scala/router/ControlUnit.scala | package constellation.router
import chisel3._
import chisel3.util._
import org.chipsalliance.cde.config.{Parameters}
import constellation.channel.{ChannelParams, IngressChannelParams, EgressChannelParams}
trait HasRouterCtrlConsts {
val CTRL_ADDR_SZ = 8
val CTRL_WORD_SZ = 32
val CTRL_MAX_ADDR = (1 << CTRL_ADDR... | io.in_block(i) := epoch_cycles =/= 0.U && rate < epoch_cycles && fire_ctr >= rate && enable_ratelimiter
}
}
| when (reset_epoch) { last_fire_ctr := next_fire_ctr }
| |
constellation | constellation/src/main/scala/router/EgressUnit.scala | package constellation.router
import chisel3._
import chisel3.util._
import org.chipsalliance.cde.config.{Field, Parameters}
import freechips.rocketchip.util._
import constellation.channel._
import constellation.routing.{FlowRoutingBundle}
class EgressUnit(coupleSAVA: Boolean, combineSAST: Boolean, inParams: Seq[Cha... | q.io.enq.valid := io.in(0).valid
q.io.enq.bits.head := io.in(0).bits.head
q.io.enq.bits.tail := io.in(0).bits.tail
val flows = cParam.possibleFlows.toSeq
if (flows.size == 0) {
q.io.enq.bits.ingress_id := 0.U(1.W)
} else {
q.io.enq.bits.ingress_id := Mux1H(
flows.map(f => (f.ingressNode.U === ... | val q = Module(new Queue(new EgressFlit(cParam.payloadBits), 3 - (if (combineSAST) 1 else 0), flow=true))
| |
constellation | constellation/src/main/scala/router/IngressUnit.scala | package constellation.router
import chisel3._
import chisel3.util._
import org.chipsalliance.cde.config.{Field, Parameters}
import freechips.rocketchip.util._
import constellation.channel._
class IngressUnit(
ingressNodeId: Int,
cParam: IngressChannelParams,
outParams: Seq[ChannelParams],
egressParams: Seq[... | io.router_req.valid := false.B
io.router_req.bits := DontCare
io.vcalloc_req.valid := false.B
io.vcalloc_req.bits := DontCare
io.salloc_req.foreach(_.valid := false.B)
io.salloc_req.foreach(_.bits := DontCare)
io.out.foreach(_.valid := false.B)
io.out.foreach(_.bits := DontCare)
}
}
| io.in.ready := false.B
| |
constellation | constellation/src/main/scala/router/InputUnit.scala | package constellation.router
import chisel3._
import chisel3.util._
import org.chipsalliance.cde.config.{Field, Parameters}
import freechips.rocketchip.util._
import constellation.channel._
import constellation.routing.{FlowRoutingBundle}
import constellation.noc.{HasNoCParams}
class AbstractInputUnitIO(
val cPar... | qs.foreach(_.io.enq.valid := false.B)
qs.foreach(_.io.enq.bits := DontCare)
val vc_sel = UIntToOH(io.enq(0).bits.virt_channel_id)
val flit = Wire(new BaseFlit(cParam.payloadBits))
val direct_to_q = (Mux1H(vc_sel, qs.map(_.io.enq.ready)) && Mux1H(vc_sel, empty)) && useOutputQueues.B
flit.head :=... | val qs = Seq.fill(nVirtualChannels) { Module(new Queue(new BaseFlit(cParam.payloadBits), 1, pipe=true)) }
| |
constellation | constellation/src/main/scala/router/OutputUnit.scala | package constellation.router
import chisel3._
import chisel3.util._
import org.chipsalliance.cde.config.{Field, Parameters}
import constellation.channel._
import constellation.routing.{FlowRoutingBundle}
import constellation.noc.{HasNoCParams}
class OutputCreditAlloc extends Bundle {
val alloc = Bool()
val tail ... | (states zip io.channel_status).map { case (s,a) =>
a.occupied := s.occupied
a.flow := s.flow
}
io.out.flit := io.in
states.zipWithIndex.map { case (s,i) => if (cParam.virtualChannelParams(i).traversable) {
when (io.out.vc_free(i)) {
assert(s.occupied)
s.occupied := false.B
}
} }
... | val states = Reg(MixedVec(cParam.virtualChannelParams.map { u => new OutputState(u.bufferSize) }))
| |
constellation | constellation/src/main/scala/router/RouteComputer.scala | package constellation.router
import chisel3._
import chisel3.util._
import chisel3.util.experimental.decode.{TruthTable, decoder}
import org.chipsalliance.cde.config.{Field, Parameters}
import freechips.rocketchip.util._
import freechips.rocketchip.rocket.DecodeLogic
import constellation.channel._
import constellati... | })
(io.req zip io.resp).zipWithIndex.map { case ((req, resp), i) =>
req.ready := true.B
if (outParams.size == 0) {
assert(!req.valid)
resp.vc_sel := DontCare
} else {
def toUInt(t: (Int, FlowRoutingInfo)): UInt = {
val l2 = (BigInt(t._1) << req.bits.flow.vnet_id .getWi... | val resp = MixedVec(allInParams.map { u => Output(new RouteComputerResp(outParams, egressParams)) })
| |
constellation | constellation/src/main/scala/router/Router.scala | package constellation.router
import chisel3._
import chisel3.util._
import org.chipsalliance.cde.config.{Field, Parameters}
import freechips.rocketchip.diplomacy._
import freechips.rocketchip.util._
import constellation.channel._
import constellation.routing.{RoutingRelation}
import constellation.noc.{HasNoCParams}
... |
def nInputs = inParams.size
def nIngress = ingressParams.size
def nAllInputs = allInParams.size
}
trait HasRouterParams
{
def routerParams: RouterParams
def nodeId = routerParams.nodeId
def payloadBits = routerParams.user.payloadBits
}
class DebugBundle(val nIn: Int) extends Bundle {
val va_stall = Vec... | def allInParams = inParams ++ ingressParams
| |
constellation | constellation/src/main/scala/router/Switch.scala | package constellation.router
import chisel3._
import chisel3.util._
import org.chipsalliance.cde.config.{Field, Parameters}
import freechips.rocketchip.util._
import constellation.channel.{ChannelParams, IngressChannelParams, EgressChannelParams, Flit}
class SwitchBundle(val outParams: Seq[ChannelParams], val egres... | })
val in_flat = Wire(Vec(allInParams.map(_.destSpeedup).reduce(_+_),
Valid(new SwitchBundle(outParams, egressParams))))
var idx = 0
io.in.foreach(_.foreach { i =>
in_flat(idx) := i
idx += 1
})
for (i <- 0 until nAllOutputs) {
for (j <- 0 until allOutParams(i).srcSpeedup) {
val sel_f... | MixedVec(allInParams.map { i => Vec(i.destSpeedup, Input(Bool())) })) })
| |
constellation | constellation/src/main/scala/router/SwitchAllocator.scala | package constellation.router
import chisel3._
import chisel3.util._
import org.chipsalliance.cde.config.{Field, Parameters}
import freechips.rocketchip.util._
import constellation.channel._
class SwitchAllocReq(val outParams: Seq[ChannelParams], val egressParams: Seq[EgressChannelParams])
(implicit val p: Paramet... | val unassigned = Cat(io.in.map(_.valid).reverse) & ~(lock.reduce(_|_))
val mask = RegInit(0.U(inN.W))
val choices = Wire(Vec(outN, UInt(inN.W)))
var sel = PriorityEncoderOH(Cat(unassigned, unassigned & ~mask))
for (i <- 0 until outN) {
choices(i) := sel | (sel >> inN)
sel = PriorityEncoderOH(unassig... | val lock = Seq.fill(outN) { RegInit(0.U(inN.W)) }
| |
constellation | constellation/src/main/scala/router/vcalloc/ISLIP.scala | package constellation.router
import chisel3._
import chisel3.util._
import chisel3.util.random.{LFSR}
import org.chipsalliance.cde.config.{Field, Parameters}
import freechips.rocketchip.util._
import constellation.channel._
import constellation.routing.{ChannelRoutingInfo, FlowRoutingBundle}
trait ISLIP { this: VCA... | with ISLIP
| class RotatingSingleVCAllocator(vP: VCAllocatorParams)(implicit p: Parameters) extends SingleVCAllocator(vP)(p)
| |
constellation | constellation/src/main/scala/router/vcalloc/MultiVCAllocator.scala | package constellation.router
import chisel3._
import chisel3.util._
import chisel3.util.random.{LFSR}
import org.chipsalliance.cde.config.{Field, Parameters}
import freechips.rocketchip.util._
import constellation.channel._
import constellation.routing.{ChannelRoutingInfo, FlowRoutingBundle}
// Performs batch alloc... | a := Mux(io.req(i).valid,
inputAllocPolicy(io.req(i).bits.flow, io.req(i).bits.vc_sel, i.U, io.req(i).bits.in_vc, io.req(i).fire),
0.U.asTypeOf(a))
a
}
// output arbitration
val out_allocs = allOutParams.zipWithIndex.map { case (oP,i) =>
(0 until oP.nVirtualChannels).map { j =>
Mux(... | val a = Wire(MixedVec(allOutParams.map { u => Vec(u.nVirtualChannels, Bool()) }))
| |
constellation | constellation/src/main/scala/router/vcalloc/PIM.scala | package constellation.router
import chisel3._
import chisel3.util._
import chisel3.util.random.{LFSR}
import org.chipsalliance.cde.config.{Field, Parameters}
import freechips.rocketchip.util._
import constellation.channel._
import constellation.routing.{ChannelRoutingInfo, FlowRoutingBundle}
trait PIM { this: VCAll... | }
def outputAllocPolicy(channel: ChannelRoutingInfo, flows: Seq[FlowRoutingBundle], reqs: Seq[Bool], fire: Bool) = {
randOH(VecInit(reqs).asUInt).asTypeOf(Vec(allInParams.size, Bool()))
}
}
class PIMMultiVCAllocator(vP: VCAllocatorParams)(implicit p: Parameters) extends MultiVCAllocator(vP)(p)
with PIM
| randOH(vc_sel.asUInt).asTypeOf(MixedVec(allOutParams.map { u => Vec(u.nVirtualChannels, Bool())}))
| |
constellation | constellation/src/main/scala/router/vcalloc/Prioritizing.scala | package constellation.router
import chisel3._
import chisel3.util._
import chisel3.util.random.{LFSR}
import org.chipsalliance.cde.config.{Field, Parameters}
import freechips.rocketchip.rocket.{DecodeLogic}
import freechips.rocketchip.util._
import constellation.channel._
import constellation.routing._
trait Priori... | } else {
in
}
}
def inputAllocPolicy(flow: FlowRoutingBundle, vc_sel: MixedVec[Vec[Bool]], inId: UInt, inVId: UInt, fire: Bool) = {
prioritizing(
vc_sel,
inId,
inVId,
allOutParams.map(_.channelRoutingInfos).flatten,
flow,
fire)
}
def outputAllocPolicy(chan... | sel.asTypeOf(MixedVec(allOutParams.map { u => Vec(u.nVirtualChannels, Bool()) }))
| |
constellation | constellation/src/main/scala/router/vcalloc/SingleVCAllocator.scala | package constellation.router
import chisel3._
import chisel3.util._
import chisel3.util.random.{LFSR}
import org.chipsalliance.cde.config.{Field, Parameters}
import freechips.rocketchip.util._
import constellation.channel._
import constellation.routing.{ChannelRoutingInfo, FlowRoutingBundle}
// Allocates 1 VC per c... | val in_flow = Mux1H(in_arb_sel, io.req.map(_.bits.flow).toSeq)
val in_vc = Mux1H(in_arb_sel, io.req.map(_.bits.in_vc).toSeq)
val in_vc_sel = Mux1H(in_arb_sel, in_arb_reqs)
in_alloc := Mux(in_arb_vals.orR,
inputAllocPolicy(in_flow, in_vc_sel, OHToUInt(in_arb_sel), in_vc, io.req.map(_.fire).toSeq.orR),
0.... | val in_alloc = Wire(MixedVec(allOutParams.map { u => Vec(u.nVirtualChannels, Bool()) }))
| |
constellation | constellation/src/main/scala/router/vcalloc/VCAllocator.scala | package constellation.router
import chisel3._
import chisel3.util._
import org.chipsalliance.cde.config.{Field, Parameters}
import freechips.rocketchip.util._
import freechips.rocketchip.rocket.{DecodeLogic}
import constellation.channel._
import constellation.noc.{HasNoCParams}
import constellation.routing.{FlowRout... | }
case class VCAllocatorParams(
routerParams: RouterParams,
inParams: Seq[ChannelParams],
outParams: Seq[ChannelParams],
ingressParams: Seq[IngressChannelParams],
egressParams: Seq[EgressChannelParams])
abstract class VCAllocator(val vP: VCAllocatorParams)(implicit val p: Parameters) extends Module
with... | val vc_sel = MixedVec(allOutParams.map { u => Vec(u.nVirtualChannels, Bool()) })
| |
constellation | constellation/src/main/scala/routing/RoutingHelpers.scala | package constellation.routing
import constellation.topology._
import scala.collection.mutable
import scala.collection.mutable.{HashMap, HashSet, Queue}
import scala.collection.mutable.{Set => MSet, Map => MMap}
import org.chipsalliance.cde.config.Parameters
import scala.util.control.Breaks._
/**
* CustomGraph: A ut... | }
return false
}
true
}
def removeEdges(layer: Int, path: List[(Int, Int)]): Unit = {
val g = dagGraphs(layer)
val edgeCount = dags(layer)
for ((u, v) <- path) {
edgeCount((u, v)) -= 1
if (edgeCount((u, v)) == 0) {
edgeCount.remove((u, v... | if (edgeCount((u, v)) == 0) edgeCount.remove((u, v))
| |
constellation | constellation/src/main/scala/routing/RoutingRelations.scala | package constellation.routing
import scala.math.{min, max, pow}
import scala.collection.mutable.HashMap
import org.chipsalliance.cde.config.{Parameters}
import scala.collection.immutable.ListMap
import constellation.topology.{PhysicalTopology, Mesh2DLikePhysicalTopology, HierarchicalTopology, CustomTopology}
import s... |
override def getPrio(srcC: ChannelRoutingInfo, nxtC: ChannelRoutingInfo, flow: FlowRoutingInfo): Int = {
(flow.ingressNode * 31 + flow.egressNode) % maxVCs
}
override def isEscape(c: ChannelRoutingInfo, vNetId: Int): Boolean = c.isIngress || c.isEgress
println(s"[ShortestPathRouting] Initialize... | override def getNPrios(src: ChannelRoutingInfo): Int = maxVCs
| |
constellation | constellation/src/main/scala/routing/Types.scala | package constellation.routing
import chisel3._
import chisel3.util._
import org.chipsalliance.cde.config.{Parameters}
import constellation.noc.{HasNoCParams}
import constellation.channel.{Flit}
/** A representation for 1 specific virtual channel in wormhole routing
*
* @param src the source node
* @param vc ID fo... | (egressNode , b.egress_node),
(egressNodeId , b.egress_node_id)
).foldLeft(0)((l, t) => {
(l << t._2.getWidth) | t._1
})
}
}
class FlowRoutingBundle(implicit val p: Parameters) extends Bundle with HasNoCParams {
// Instead of tracking ingress/egress ID, track the physical destination ... | (vNetId , b.vnet_id),
(ingressNode , b.ingress_node),
| |
constellation | constellation/src/main/scala/soc/Buses.scala | package constellation.soc
import chisel3._
import chisel3.util._
import org.chipsalliance.cde.config._
import freechips.rocketchip.diplomacy._
import freechips.rocketchip.devices.tilelink._
import freechips.rocketchip.tilelink._
import freechips.rocketchip.subsystem._
import freechips.rocketchip.util._
import conste... | :*= in_xbar.node)
} .getOrElse {
val noc = genNoC()
noc.node :*= fixer.node
}
def inwardNode: TLInwardNode = node
def outwardNode: TLOutwardNode = node
def busView: TLEdge = fixer.node.edges.in.head
val builtInDevices: BuiltInDevices = BuiltInDevices.attach(pbus_params, outwardNode)
}
| } .getOrElse { TLAtomicAutomata(arithmetic = pa.arithmetic) })
| |
constellation | constellation/src/main/scala/soc/Configs.scala | package constellation.soc
import chisel3._
import chisel3.util._
import org.chipsalliance.cde.config._
import freechips.rocketchip.diplomacy._
import freechips.rocketchip.tilelink._
import freechips.rocketchip.subsystem._
import freechips.rocketchip.util._
import constellation.noc.NoCParams
import constellation.prot... | case x => x
}
})
}
})
class WithGlobalNoC(params: GlobalNoCParams) extends Config((site, here, up) => {
case GlobalNoCKey => params
})
| case j: TLBusWrapperTopology => {
new TLBusWrapperTopology(j.instantiations.map(inst => inst match {
case (PBUS, pbus_params: PeripheryBusParams) =>
(PBUS, ConstellationPeripheryBusParams(pbus_params, tlnocParams, inlineNoC))
| |
constellation | constellation/src/main/scala/soc/GlobalNoC.scala | package constellation.soc
import chisel3._
import chisel3.util._
import constellation.channel._
import constellation.noc._
import constellation.protocol._
import org.chipsalliance.cde.config._
import freechips.rocketchip.diplomacy._
import freechips.rocketchip.subsystem._
import freechips.rocketchip.prci._
case cla... |
class GlobalNoCDomain(implicit p: Parameters) extends ClockSinkDomain()(p) {
InModuleBody {
val interfaces = getChildren.map(_.module).collect {
case a: CanAttachToGlobalNoC => a
}.toSeq
if (interfaces.size > 0) {
val noc = Module(new ProtocolNoC(ProtocolNoCParams(
p(GlobalNoCKey).noc... | case object GlobalNoCKey extends Field[GlobalNoCParams](GlobalNoCParams())
| |
constellation | constellation/src/main/scala/test/AXI4TestHarness.scala | package constellation.test
import chisel3._
import chisel3.util._
import freechips.rocketchip.diplomacy._
import org.chipsalliance.cde.config.{Field, Parameters, Config}
import freechips.rocketchip.tilelink._
import freechips.rocketchip.util._
import freechips.rocketchip.amba.axi4._
import scala.collection.immutable... |
class WithAXI4NoCTesterParams(p: AXI4NoCTesterParams) extends Config((site, here, up) => {
case AXI4NoCTesterKey => p
})
class AXI4NoCTester(implicit p: Parameters) extends LazyModule {
val tParams = p(AXI4NoCTesterKey)
val txns = tParams.txns
val inNodeMapping = ListMap(tParams.inNodeMapping.zipWithIndex.m... | case object AXI4NoCTesterKey extends Field[AXI4NoCTesterParams](AXI4NoCTesterParams())
| |
constellation | constellation/src/main/scala/test/Configs.scala | package constellation.test
import org.chipsalliance.cde.config.{Field, Parameters, Config}
import constellation.routing._
import constellation.topology._
import constellation.noc.{NoCParams}
import constellation.channel._
import constellation.router._
import scala.collection.immutable.ListMap
import scala.math.{floor,... | routingRelation = BidirectionalTorus1DShortestRouting()
)))
class TestConfig19 extends NoCTesterConfig(NoCTesterParams(NoCParams(
topology = BidirectionalTorus1D(10),
channelParamGen = (a, b) => UserChannelParams(Seq.fill(4) { UserVirtualChannelParams(5) }),
ingresses = (0 until 10).map { i => User... | flows = Seq.tabulate(2, 2) { (s, d) => FlowParams(s, d, 0) }.flatten,
| |
constellation | constellation/src/main/scala/test/CustomConfigs.scala | package constellation.test
import constellation.noc._
import constellation.routing._
import constellation.topology._
import constellation.channel._
import org.chipsalliance.cde.config.Config
class CustomTestConfigBase(
topology: PhysicalTopology,
routingFn: PhysicalTopology => RoutingRelation,
name: String,
n... | ingresses = (0 until topology.nNodes).map(UserIngressParams(_)),
egresses = (0 until topology.nNodes).map(UserEgressParams(_)),
flows = Seq.tabulate(topology.nNodes, topology.nNodes) { (s, d) => FlowParams(s, d, 0) }.flatten,
routingRelation = NonblockingVirtualSubnetworksRouting(routingFn, nSub... | channelParamGen = (a, b) => UserChannelParams(Seq.fill(nSubnets*nDedicated) { UserVirtualChannelParams(4) }),
| |
constellation | constellation/src/main/scala/test/TLTestHarness.scala | package constellation.test
import chisel3._
import chisel3.util._
import chisel3.util.random.LFSR
import freechips.rocketchip.diplomacy._
import org.chipsalliance.cde.config.{Field, Parameters, Config}
import freechips.rocketchip.tilelink._
import freechips.rocketchip.util._
import constellation.noc.{NoCParams, HasN... | }
lazy val module = new Impl
class Impl extends LazyModuleImp(this) {
val io = IO(new Bundle {
val finished = Output(Bool())
})
io.finished := fuzzers.map(_.module.io.finished).reduce(_&&_)
}
}
class TLTestHarness(implicit val p: Parameters) extends Module with HasSuccessIO {
val tester = ... | DisableMonitors { implicit p => ram.node := TLFragmenter(4, 256) } := TLDelayer(tParams.delay) := noc.node
| |
constellation | constellation/src/main/scala/test/TestHarness.scala | package constellation.test
import chisel3._
import chisel3.util._
import chisel3.util.random.LFSR
import freechips.rocketchip.diplomacy._
import org.chipsalliance.cde.config.{Field, Parameters, Config}
import freechips.rocketchip.tilelink._
import freechips.rocketchip.util._
import constellation.noc.{NoCParams, HasN... | assert(o.flit.bits.ingress_id === rob_ingress_id(rob_idx), cf"out[${i.toString}] incorrect source")
assert(i.U === rob_egress_id(rob_idx), cf"out[${i.toString}] incorrect destination")
assert(rob_flits_returned(rob_idx) < rob_n_flits(rob_idx), cf"out[${i.toString}] too many flits returned")
asse... | assert(rob_payload(rob_idx).asUInt === o.flit.bits.payload.asUInt, cf"out[${i.toString}] incorrect payload");
| |
constellation | constellation/src/main/scala/test/TrafficEvalHarness.scala | package constellation.test
import chisel3._
import chisel3.experimental.IntParam
import chisel3.util._
import chisel3.util.random.LFSR
import freechips.rocketchip.diplomacy._
import org.chipsalliance.cde.config.{Field, Parameters, Config}
import freechips.rocketchip.tilelink._
import freechips.rocketchip.util._
impo... |
class EvalHarness(implicit val p: Parameters) extends Module with HasSuccessIO {
val lazyNoC = LazyModule(new NoC(p(NoCEvalKey).nocParams))
val noc = Module(lazyNoC.module)
noc.io.router_clocks.foreach(_.clock := clock)
noc.io.router_clocks.foreach(_.reset := reset)
noc.io.router_ctrl.foreach{ ctrl =>
c... | case object NoCEvalKey extends Field[NoCEvalParams](NoCEvalParams())
| |
constellation | constellation/src/main/scala/topology/Topologies.scala | package constellation.topology
import scala.math.{pow, cos, sin, Pi}
import scala.collection.immutable.ListMap
// BEGIN: PhysicalTopology
trait PhysicalTopology {
// Number of nodes in this physical topology
val nNodes: Int
/** Method that describes the particular topology represented by the concrete
* cla... | def toChildNode(node: Int): Int = node - offsets(childId(node))
def isBase(n: Int) = n < base.nNodes
def topo(src: Int, dst: Int) = {
(isBase(src), isBase(dst)) match {
case (true , true ) => base.topo(src, dst)
case (true , false) => {
val sub = children(childId(dst))
sub.src == s... | def childId(node: Int): Int = offsets.drop(1).indexWhere(_ > node)
| |
constellation | constellation/src/main/scala/topology/TopologyPlotters.scala | package constellation.topology
import scala.math.{pow, cos, sin, Pi, atan2, floor}
abstract class PhysicalTopologyPlotter {
/* Given a node ID, returns x, y position of a node. */
def node(nodeId: Int): (Double, Double)
/* iID: index of ingress within number of ingresses for that node
nI: number of ingresses... | }
class Torus1DPlotter(topo: Torus1DLikeTopology) extends PhysicalTopologyPlotter {
def node(n: Int) = {
val rad = n * 2 * Pi / topo.nNodes
(cos(rad), sin(rad))
}
def ingress(t: Int, nT: Int, n: Int) = {
val arc = 2 * Pi / topo.nNodes
val rad = arc * (n - 0.5 + (t + 1).toDouble / (nT + 1).toDoubl... | def egress (t: Int, nT: Int, n: Int) = (n - 0.5 + (t + 1).toDouble / (nT + 1).toDouble, -0.5)
| |
constellation | constellation/src/main/scala/util/Utils.scala | package constellation.util
import chisel3._
import chisel3.util._
object WrapInc {
// "n" is the number of increments, so we wrap at n-1.
def apply(value: UInt, n: Int): UInt = {
if (n == 1) {
0.U
} else if (isPow2(n)) {
(value + 1.U)(log2Ceil(n)-1,0)
} else {
| def apply(value: UInt, n: UInt): UInt = {
val wrap = value === n - 1.U
Mux(wrap, 0.U, value + 1.U)
}
}
| val wrap = (value === (n-1).U)
Mux(wrap, 0.U, value + 1.U)
}
| |
constellation | constellation/src/test/scala/constellation/NocTests.scala | package constellation
import org.chipsalliance.cde.config.{Config, Parameters}
import chiseltest._
import chiseltest.simulator.{VerilatorFlags, VerilatorCFlags, SimulatorDebugAnnotation, VerilatorLinkFlags}
import org.scalatest.flatspec.AnyFlatSpec
import chisel3._
import constellation.test._
class NoCChiselTester(im... | class NoCTest02 extends NoCTest(Seq(new TestConfig02))
class NoCTest03 extends NoCTest(Seq(new TestConfig03))
class NoCTest04 extends NoCTest(Seq(new TestConfig04))
class NoCTest05 extends NoCTest(Seq(new TestConfig05))
class NoCTest06 extends NoCTest(Seq(new TestConfig06))
class NoCTest07 extends NoCTest(Seq(new TestC... | class NoCTest01 extends NoCTest(Seq(new TestConfig01))
| |
essent | essent/src/main/scala/ActivityTracker.scala | package essent
import essent.Emitter._
import essent.Extract._
import essent.ir._
import essent.Util._
import firrtl.ir._
import java.io.Writer
class ActivityTracker(w: Writer, opt: OptFlags) {
val actVarName = "ACTcounts"
val sigTrackName = "SIGcounts"
val sigActName = "SIGact"
val sigExtName = "SIGext"
v... | w.writeLines(2, s"""sig_acts[i] = JSON({"id", i, "acts", $sigTrackName[i]});""")
w.writeLines(1, "}")
w.writeLines(1, "all_data[\"signal-activities\"] = sig_acts;")
}
if (opt.trackParts) {
w.writeLines(1, "JSON part_acts;")
w.writeLines(1, s"for (int i=0; i<$numParts; i++) {")
... | w.writeLines(1, s"for (int i=0; i<${sigNameToID.size}; i++) {")
| |
essent | essent/src/main/scala/AcyclicPart.scala | package essent
import essent.Graph.NodeID
import logger._
import collection.mutable.{ArrayBuffer, HashSet}
class AcyclicPart(val mg: MergeGraph, excludeSet: Set[NodeID]) extends LazyLogging {
def partsRemaining() = (mg.mergeIDToMembers.keys.toSet - excludeSet).size
def findSmallParts(smallPartCutoff: Int) = m... | )
toApply foreach { case (label, func) => {
val startTime = System.currentTimeMillis()
func(this)
val stopTime = System.currentTimeMillis()
logger.info(s"[$label] took: ${stopTime - startTime}")
logger.info(s"Down to ${partsRemaining()} parts")
}}
assert(checkPartioning())
... | ("small2", {ap: AcyclicPart => ap.mergeSmallParts(2*smallPartCutoff, 0.25)}),
| |
essent | essent/src/main/scala/ArgsParser.scala | package essent
import java.io.File
import scopt.OptionParser
case class OptFlags(
firInputFile: File = null,
removeFlatConnects: Boolean = true,
regUpdates: Boolean = true,
conditionalMuxes: Boolean = true,
useCondParts: Boolean = true,
writeHarness: Boolean = false,
dumpLoFirrtl: Boolea... | }
class ArgsParser {
val parser = new OptionParser[OptFlags]("essent") {
arg[File]("<file>").required().unbounded().action( (x, c) =>
c.copy(firInputFile = x) ).text(".fir input file")
opt[Unit]("O0").abbr("O0").action( (_, c) => c.copy(
removeFlatConnects = false,
regUpdates = false,
... | def outputDir() = if (inputFileDir() == null) "" else inputFileDir()
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.