From 589d416104f8f214da78c636aa6d64b2493f39b4 Mon Sep 17 00:00:00 2001 From: Prateek Mahajan Date: Wed, 22 Nov 2023 12:45:13 -0800 Subject: [PATCH 1/9] Second Round of ISA Agnostic Changes --- v/vanilla_bean/alu.v | 56 ++-- v/vanilla_bean/bsg_manycore_proc_vanilla.v | 2 +- v/vanilla_bean/bsg_riscv_defines.vh | 223 +++++++++++++ v/vanilla_bean/bsg_vanilla_defines.vh | 314 +++++++----------- v/vanilla_bean/bsg_vanilla_pkg.v | 71 ++-- v/vanilla_bean/fcsr.v | 30 +- v/vanilla_bean/fpu_fdiv_fsqrt.v | 2 +- v/vanilla_bean/fpu_float.v | 6 +- v/vanilla_bean/fpu_float_aux.v | 4 +- v/vanilla_bean/fpu_float_fma.v | 2 +- v/vanilla_bean/fpu_int.v | 4 +- v/vanilla_bean/icache.v | 36 +- v/vanilla_bean/idiv.v | 6 +- v/vanilla_bean/load_packer.v | 4 +- v/vanilla_bean/lsu.v | 6 +- v/vanilla_bean/mcsr.v | 110 +++--- v/vanilla_bean/network_tx.v | 2 +- .../{cl_decode.v => riscv_decode.v} | 5 +- v/vanilla_bean/scoreboard.v | 4 +- v/vanilla_bean/vanilla_core.v | 22 +- 20 files changed, 523 insertions(+), 386 deletions(-) create mode 100644 v/vanilla_bean/bsg_riscv_defines.vh rename v/vanilla_bean/{cl_decode.v => riscv_decode.v} (99%) diff --git a/v/vanilla_bean/alu.v b/v/vanilla_bean/alu.v index 5c1848f26..fc656faaa 100644 --- a/v/vanilla_bean/alu.v +++ b/v/vanilla_bean/alu.v @@ -4,11 +4,11 @@ module alu import bsg_vanilla_pkg::*; #(`BSG_INV_PARAM(pc_width_p )) - ( input [RV32_reg_data_width_gp-1:0] rs1_i - ,input [RV32_reg_data_width_gp-1:0] rs2_i - ,input [RV32_reg_data_width_gp-1:0] pc_plus4_i + ( input [reg_data_width_gp-1:0] rs1_i + ,input [reg_data_width_gp-1:0] rs2_i + ,input [reg_data_width_gp-1:0] pc_plus4_i ,input instruction_s op_i - ,output logic [RV32_reg_data_width_gp-1:0] result_o + ,output logic [reg_data_width_gp-1:0] result_o ,output logic [pc_width_p-1:0] jalr_addr_o ,output logic jump_now_o ); @@ -23,10 +23,10 @@ logic [32:0] shr_out; logic [31:0] shl_out, xor_out, and_out, or_out; ///////////////////////////////////////////////////////// -assign is_imm_op = (op_i.op ==? `RV32_OP_IMM) | (op_i.op ==? `RV32_JALR_OP); +assign is_imm_op = (op_i.op ==? `VANILLA_OP_IMM) | (op_i.op ==? `VANILLA_JALR_OP); ///////////////////////////////////////////////////////// -assign op2 = is_imm_op ? `RV32_signext_Iimm(op_i) : rs2_i; +assign op2 = is_imm_op ? `Vanilla_signext_Iimm(op_i) : rs2_i; /////////////////////////////////////////////////////////// @@ -49,61 +49,61 @@ always_comb sign_ex_or_zero = 1'b0; unique casez (op_i) - `RV32_LUI: - result_o = `RV32_signext_Uimm(op_i); + `VANILLA_LUI: + result_o = `Vanilla_signext_Uimm(op_i); - `RV32_AUIPC: - result_o = `RV32_signext_Uimm(op_i) + pc_plus4_i - 3'b100; + `VANILLA_AUIPC: + result_o = `Vanilla_signext_Uimm(op_i) + pc_plus4_i - 3'b100; - `RV32_ADDI, `RV32_ADD: + `VANILLA_ADDI, `VANILLA_ADD: begin result_o = sum[31:0]; sub_not_add = 1'b0; end - `RV32_SLTI, `RV32_SLT: + `VANILLA_SLTI, `VANILLA_SLT: begin sub_not_add = 1'b1; result_o = {{31{1'b0}},sum[32]}; end - `RV32_SLTIU, `RV32_SLTU: + `VANILLA_SLTIU, `VANILLA_SLTU: begin sub_not_add = 1'b1; result_o = {{31{1'b0}},~carry}; end - `RV32_XORI, `RV32_XOR: + `VANILLA_XORI, `VANILLA_XOR: result_o = xor_out; - `RV32_ORI, `RV32_OR: + `VANILLA_ORI, `VANILLA_OR: result_o = or_out; - `RV32_ANDI, `RV32_AND: + `VANILLA_ANDI, `VANILLA_AND: result_o = and_out; - `RV32_SLLI, `RV32_SLL: + `VANILLA_SLLI, `VANILLA_SLL: result_o = shl_out; - `RV32_SRLI, `RV32_SRL: + `VANILLA_SRLI, `VANILLA_SRL: begin result_o = shr_out[31:0]; sign_ex_or_zero = 1'b0; end - `RV32_SRAI, `RV32_SRA: + `VANILLA_SRAI, `VANILLA_SRA: begin result_o = shr_out[31:0]; sign_ex_or_zero = rs1_i[31]; end - `RV32_SUB: + `VANILLA_SUB: begin result_o = sum[31:0]; sub_not_add = 1'b1; end - `RV32_JALR: + `VANILLA_JALR: begin sub_not_add = 1'b0; // jalr_addr_o = sum[31:0] & 32'hfffe; @@ -111,7 +111,7 @@ always_comb result_o = pc_plus4_i; end - `RV32_JAL: + `VANILLA_JAL: begin result_o =pc_plus4_i; end @@ -129,12 +129,12 @@ wire rs1_lt_rs2_signed = ( $signed(rs1_i) < $signed( rs2_i ) ); always_comb begin unique casez(op_i ) - `RV32_BEQ: jump_now_o = rs1_eq_rs2; - `RV32_BNE: jump_now_o = ~rs1_eq_rs2; - `RV32_BLT: jump_now_o = rs1_lt_rs2_signed; - `RV32_BGE: jump_now_o = ~rs1_lt_rs2_signed; - `RV32_BLTU: jump_now_o = rs1_lt_rs2_unsigned; - `RV32_BGEU: jump_now_o = ~rs1_lt_rs2_unsigned; + `VANILLA_BEQ: jump_now_o = rs1_eq_rs2; + `VANILLA_BNE: jump_now_o = ~rs1_eq_rs2; + `VANILLA_BLT: jump_now_o = rs1_lt_rs2_signed; + `VANILLA_BGE: jump_now_o = ~rs1_lt_rs2_signed; + `VANILLA_BLTU: jump_now_o = rs1_lt_rs2_unsigned; + `VANILLA_BGEU: jump_now_o = ~rs1_lt_rs2_unsigned; default: jump_now_o = 1'b0; endcase end diff --git a/v/vanilla_bean/bsg_manycore_proc_vanilla.v b/v/vanilla_bean/bsg_manycore_proc_vanilla.v index 7aa076990..162251c33 100644 --- a/v/vanilla_bean/bsg_manycore_proc_vanilla.v +++ b/v/vanilla_bean/bsg_manycore_proc_vanilla.v @@ -43,7 +43,7 @@ module bsg_manycore_proc_vanilla , dmem_addr_width_lp = `BSG_SAFE_CLOG2(dmem_size_p) , pc_width_lp=(icache_addr_width_lp+icache_tag_width_p) , data_mask_width_lp=(data_width_p>>3) - , reg_addr_width_lp=RV32_reg_addr_width_gp + , reg_addr_width_lp=VANILLA_reg_addr_width_gp , parameter `BSG_INV_PARAM(barrier_dirs_p) , localparam barrier_lg_dirs_lp=`BSG_SAFE_CLOG2(barrier_dirs_p+1) diff --git a/v/vanilla_bean/bsg_riscv_defines.vh b/v/vanilla_bean/bsg_riscv_defines.vh new file mode 100644 index 000000000..a97dc7f79 --- /dev/null +++ b/v/vanilla_bean/bsg_riscv_defines.vh @@ -0,0 +1,223 @@ +`ifndef BSG_RISCV_DEFINES_VH +`define BSG_RISCV_DEFINES_VH + +/** + * bsg_riscv_defines.vh + * + * This file defines the macros + * used for riscv operations throughout the vanilla core. + * + */ + +`include "bsg_vanilla_defines.v" + +`define RV32_MSTATUS_MIE_BIT_IDX 3 +`define RV32_MSTATUS_MPIE_BIT_IDX 7 + +// RV32 Opcodes +`define RV32_LOAD 7'b0000011 +`define RV32_STORE 7'b0100011 + +// we have branch instructions ignore the low bit so that we can place the prediction bit there. +// RISC-V by default has the low bits set to 11 in the icache, so we can use those creatively. +// note this relies on all code using ==? and casez. +`define RV32_BRANCH 7'b110001? + +`define RV32_JALR_OP 7'b1100111 +`define RV32_MISC_MEM 7'b0001111 +`define RV32_AMO_OP 7'b0101111 +`define RV32_JAL_OP 7'b1101111 +`define RV32_OP_IMM 7'b0010011 +`define RV32_OP 7'b0110011 +`define RV32_SYSTEM 7'b1110011 +`define RV32_AUIPC_OP 7'b0010111 +`define RV32_LUI_OP 7'b0110111 + + +// Some useful RV32 instruction macros +`define RV32_Rtype(op, funct3, funct7) {``funct7``, {5{1'b?}}, {5{1'b?}},``funct3``, {5{1'b?}},``op``} +`define RV32_Itype(op, funct3) {{12{1'b?}},{5{1'b?}},``funct3``,{5{1'b?}},``op``} +`define RV32_Stype(op, funct3) {{7{1'b?}},{5{1'b?}},{5{1'b?}},``funct3``,{5{1'b?}},``op``} +`define RV32_Utype(op) {{20{1'b?}},{5{1'b?}},``op``} + +// RV32 Immediate sign extension macros +`define RV32_signext_Iimm(instr) {{21{``instr``[31]}},``instr``[30:20]} +`define RV32_signext_Simm(instr) {{21{``instr``[31]}},``instr[30:25],``instr``[11:7]} +`define RV32_signext_Bimm(instr) {{20{``instr``[31]}},``instr``[7],``instr``[30:25],``instr``[11:8], {1'b0}} +`define RV32_signext_Uimm(instr) {``instr``[31:12], {12{1'b0}}} +`define RV32_signext_Jimm(instr) {{12{``instr``[31]}},``instr``[19:12],``instr``[20],``instr``[30:21], {1'b0}} + +`define RV32_Bimm_12inject1(instr,value) {``value``[12], ``value``[10:5], ``instr``[24:12],\ + ``value``[4:1],``value``[11],``instr``[6:0]} +`define RV32_Jimm_20inject1(instr,value) {``value``[20], ``value``[10:1], ``value``[11],``value``[19:12], ``instr``[11:0]} + +// Both JAL and BRANCH use 2-byte address, we need to pad 1'b0 at MSB to get +// the real byte address +`define RV32_Bimm_13extract(instr) {``instr``[31], ``instr``[7], ``instr``[30:25], ``instr``[11:8], 1'b0} +`define RV32_Jimm_21extract(instr) {``instr``[31], ``instr``[19:12],``instr``[20],``instr``[30:21], 1'b0} + +`define RV32_Iimm_12extract(instr) {``instr``[31:20]} +`define RV32_Simm_12extract(instr) {``instr[31:25],``instr``[11:7]} + +// RV32I Instruction encodings +// We have to delete the white space in macro definition, +// otherwise Design Compiler would issue warings. +`define RV32_LUI `RV32_Utype(`RV32_LUI_OP) +`define RV32_AUIPC `RV32_Utype(`RV32_AUIPC_OP) +`define RV32_JAL `RV32_Utype(`RV32_JAL_OP) +`define RV32_JALR `RV32_Itype(`RV32_JALR_OP, 3'b000) +`define RV32_BEQ `RV32_Stype(`RV32_BRANCH, 3'b000) +`define RV32_BNE `RV32_Stype(`RV32_BRANCH, 3'b001) +`define RV32_BLT `RV32_Stype(`RV32_BRANCH, 3'b100) +`define RV32_BGE `RV32_Stype(`RV32_BRANCH, 3'b101) +`define RV32_BLTU `RV32_Stype(`RV32_BRANCH, 3'b110) +`define RV32_BGEU `RV32_Stype(`RV32_BRANCH, 3'b111) +`define RV32_LB `RV32_Itype(`RV32_LOAD, 3'b000) +`define RV32_LH `RV32_Itype(`RV32_LOAD, 3'b001) +`define RV32_LW `RV32_Itype(`RV32_LOAD, 3'b010) +`define RV32_LBU `RV32_Itype(`RV32_LOAD, 3'b100) +`define RV32_LHU `RV32_Itype(`RV32_LOAD, 3'b101) +`define RV32_SB `RV32_Stype(`RV32_STORE, 3'b000) +`define RV32_SH `RV32_Stype(`RV32_STORE, 3'b001) +`define RV32_SW `RV32_Stype(`RV32_STORE, 3'b010) +`define RV32_ADDI `RV32_Itype(`RV32_OP_IMM,3'b000) +`define RV32_SLTI `RV32_Itype(`RV32_OP_IMM, 3'b010) +`define RV32_SLTIU `RV32_Itype(`RV32_OP_IMM, 3'b011) +`define RV32_XORI `RV32_Itype(`RV32_OP_IMM, 3'b100) +`define RV32_ORI `RV32_Itype(`RV32_OP_IMM, 3'b110) +`define RV32_ANDI `RV32_Itype(`RV32_OP_IMM, 3'b111) +`define RV32_SLLI `RV32_Rtype(`RV32_OP_IMM, 3'b001, 7'b0000000) +`define RV32_SRLI `RV32_Rtype(`RV32_OP_IMM, 3'b101, 7'b0000000) +`define RV32_SRAI `RV32_Rtype(`RV32_OP_IMM, 3'b101, 7'b0100000) +`define RV32_ADD `RV32_Rtype(`RV32_OP,3'b000,7'b0000000) +`define RV32_SUB `RV32_Rtype(`RV32_OP, 3'b000, 7'b0100000) +`define RV32_SLL `RV32_Rtype(`RV32_OP, 3'b001, 7'b0000000) +`define RV32_SLT `RV32_Rtype(`RV32_OP, 3'b010, 7'b0000000) +`define RV32_SLTU `RV32_Rtype(`RV32_OP, 3'b011, 7'b0000000) +`define RV32_XOR `RV32_Rtype(`RV32_OP, 3'b100, 7'b0000000) +`define RV32_SRL `RV32_Rtype(`RV32_OP, 3'b101, 7'b0000000) +`define RV32_SRA `RV32_Rtype(`RV32_OP, 3'b101, 7'b0100000) +`define RV32_OR `RV32_Rtype(`RV32_OP, 3'b110, 7'b0000000) +`define RV32_AND `RV32_Rtype(`RV32_OP, 3'b111, 7'b0000000) + +// FENCE defines +`define RV32_FENCE_FUN3 3'b000 +`define RV32_FENCE_OP {4'b????,4'b????,4'b????,5'b00000,`RV32_FENCE_FUN3,5'b00000,`RV32_MISC_MEM} +`define RV32_FENCE_FM 4'b0000 +`define RV32_BARSEND_FM 4'b0001 +`define RV32_BARRECV_FM 4'b0010 + +//TRIGGER SAIF DUMP defines +`define SAIF_TRIGGER_START {12'b000000000001,5'b00000,3'b000,5'b00000,`RV32_OP_IMM} +`define SAIF_TRIGGER_END {12'b000000000010,5'b00000,3'b000,5'b00000,`RV32_OP_IMM} + +// CSR encoding +`define RV32_CSRRW_FUN3 3'b001 +`define RV32_CSRRS_FUN3 3'b010 +`define RV32_CSRRC_FUN3 3'b011 +`define RV32_CSRRWI_FUN3 3'b101 +`define RV32_CSRRSI_FUN3 3'b110 +`define RV32_CSRRCI_FUN3 3'b111 + +`define RV32_CSRRW `RV32_Itype(`RV32_SYSTEM, `RV32_CSRRW_FUN3) +`define RV32_CSRRS `RV32_Itype(`RV32_SYSTEM, `RV32_CSRRS_FUN3) +`define RV32_CSRRC `RV32_Itype(`RV32_SYSTEM, `RV32_CSRRC_FUN3) +`define RV32_CSRRWI `RV32_Itype(`RV32_SYSTEM, `RV32_CSRRWI_FUN3) +`define RV32_CSRRSI `RV32_Itype(`RV32_SYSTEM, `RV32_CSRRSI_FUN3) +`define RV32_CSRRCI `RV32_Itype(`RV32_SYSTEM, `RV32_CSRRCI_FUN3) + +// fcsr CSR addr +`define RV32_CSR_FFLAGS_ADDR 12'h001 +`define RV32_CSR_FRM_ADDR 12'h002 +`define RV32_CSR_FCSR_ADDR 12'h003 +// machine CSR addr +`define RV32_CSR_MSTATUS_ADDR 12'h300 +`define RV32_CSR_MTVEC_ADDR 12'h305 +`define RV32_CSR_MIE_ADDR 12'h304 +`define RV32_CSR_MIP_ADDR 12'h344 +`define RV32_CSR_MEPC_ADDR 12'h341 +`define RV32_CSR_CFG_POD_ADDR 12'h360 + +// machine custom CSR addr +`define RV32_CSR_CREDIT_LIMIT_ADDR 12'hfc0 +`define RV32_CSR_BARCFG_ADDR 12'hfc1 +`define RV32_CSR_BAR_PI_ADDR 12'hfc2 +`define RV32_CSR_BAR_PO_ADDR 12'hfc3 + +// mret +// used for returning from the interrupt +`define RV32_MRET {7'b0011000, 5'b00010, 5'b00000, 3'b000, 5'b00000, `RV32_SYSTEM} + +// RV32M Instruction Encodings +`define RV32_MUL `RV32_Rtype(`RV32_OP, `MD_MUL_FUN3 , 7'b0000001) +`define RV32_MULH `RV32_Rtype(`RV32_OP, `MD_MULH_FUN3 , 7'b0000001) +`define RV32_MULHSU `RV32_Rtype(`RV32_OP, `MD_MULHSU_FUN3, 7'b0000001) +`define RV32_MULHU `RV32_Rtype(`RV32_OP, `MD_MULHU_FUN3 , 7'b0000001) +`define RV32_DIV `RV32_Rtype(`RV32_OP, `MD_DIV_FUN3 , 7'b0000001) +`define RV32_DIVU `RV32_Rtype(`RV32_OP, `MD_DIVU_FUN3 , 7'b0000001) +`define RV32_REM `RV32_Rtype(`RV32_OP, `MD_REM_FUN3 , 7'b0000001) +`define RV32_REMU `RV32_Rtype(`RV32_OP, `MD_REMU_FUN3 , 7'b0000001) + +// RV32A Instruction Encodings +`define RV32_LR_W {5'b00010,2'b00,5'b00000,5'b?????,3'b010,5'b?????,`RV32_AMO_OP} +`define RV32_LR_W_AQ {5'b00010,2'b10,5'b00000,5'b?????,3'b010,5'b?????,`RV32_AMO_OP} +`define RV32_AMOSWAP_W {5'b00001,2'b??,5'b?????,5'b?????,3'b010,5'b?????,`RV32_AMO_OP} +`define RV32_AMOOR_W {5'b01000,2'b??,5'b?????,5'b?????,3'b010,5'b?????,`RV32_AMO_OP} +`define RV32_AMOADD_W {5'b00000,2'b??,5'b?????,5'b?????,3'b010,5'b?????,`RV32_AMO_OP} + +// RV32F Instruction Encodings +`define RV32_OP_FP 7'b1010011 +`define RV32_LOAD_FP 7'b0000111 +`define RV32_STORE_FP 7'b0100111 + +`define RV32_FCMP_S_FUN7 7'b1010000 +`define RV32_FCLASS_S_FUN7 7'b1110000 +`define RV32_FCVT_S_F2I_FUN7 7'b1100000 +`define RV32_FCVT_S_I2F_FUN7 7'b1101000 +`define RV32_FMV_W_X_FUN7 7'b1111000 +`define RV32_FMV_X_W_FUN7 7'b1110000 + +`define RV32_FADD_S `RV32_Rtype(`RV32_OP_FP, 3'b???, 7'b0000000) +`define RV32_FSUB_S `RV32_Rtype(`RV32_OP_FP, 3'b???, 7'b0000100) +`define RV32_FMUL_S `RV32_Rtype(`RV32_OP_FP, 3'b???, 7'b0001000) + +`define RV32_FSGNJ_S `RV32_Rtype(`RV32_OP_FP, 3'b000, 7'b0010000) +`define RV32_FSGNJN_S `RV32_Rtype(`RV32_OP_FP, 3'b001, 7'b0010000) +`define RV32_FSGNJX_S `RV32_Rtype(`RV32_OP_FP, 3'b010, 7'b0010000) + +`define RV32_FMIN_S `RV32_Rtype(`RV32_OP_FP, 3'b000, 7'b0010100) +`define RV32_FMAX_S `RV32_Rtype(`RV32_OP_FP, 3'b001, 7'b0010100) + +`define RV32_FEQ_S `RV32_Rtype(`RV32_OP_FP, 3'b010, `RV32_FCMP_S_FUN7) +`define RV32_FLT_S `RV32_Rtype(`RV32_OP_FP, 3'b001, `RV32_FCMP_S_FUN7) +`define RV32_FLE_S `RV32_Rtype(`RV32_OP_FP, 3'b000, `RV32_FCMP_S_FUN7) + +`define RV32_FCLASS_S {`RV32_FCLASS_S_FUN7, 5'b00000, 5'b?????, 3'b001, 5'b?????, `RV32_OP_FP} + +// i2f +`define RV32_FCVT_S_W {`RV32_FCVT_S_I2F_FUN7, 5'b00000, 5'b?????, 3'b???, 5'b?????, `RV32_OP_FP} +`define RV32_FCVT_S_WU {`RV32_FCVT_S_I2F_FUN7, 5'b00001, 5'b?????, 3'b???, 5'b?????, `RV32_OP_FP} + +// f2i +`define RV32_FCVT_W_S {`RV32_FCVT_S_F2I_FUN7, 5'b00000, 5'b?????, 3'b???, 5'b?????, `RV32_OP_FP} +`define RV32_FCVT_WU_S {`RV32_FCVT_S_F2I_FUN7, 5'b00001, 5'b?????, 3'b???, 5'b?????, `RV32_OP_FP} + +// move (i->f) +`define RV32_FMV_W_X {`RV32_FMV_W_X_FUN7, 5'b0000, 5'b?????, 3'b000, 5'b?????, `RV32_OP_FP} + +// move (f->i) +`define RV32_FMV_X_W {`RV32_FMV_X_W_FUN7, 5'b0000, 5'b?????, 3'b000, 5'b?????, `RV32_OP_FP} + +`define RV32_FLW_S `RV32_Itype(`RV32_LOAD_FP, 3'b010) +`define RV32_FSW_S `RV32_Stype(`RV32_STORE_FP, 3'b010) + +`define RV32_FMADD_S {5'b?????, 2'b00, 5'b?????, 5'b?????, 3'b???, 5'b?????, 7'b1000011} +`define RV32_FMSUB_S {5'b?????, 2'b00, 5'b?????, 5'b?????, 3'b???, 5'b?????, 7'b1000111} +`define RV32_FNMSUB_S {5'b?????, 2'b00, 5'b?????, 5'b?????, 3'b???, 5'b?????, 7'b1001011} +`define RV32_FNMADD_S {5'b?????, 2'b00, 5'b?????, 5'b?????, 3'b???, 5'b?????, 7'b1001111} + +`define RV32_FDIV_S `RV32_Rtype(`RV32_OP_FP, 3'b???, 7'b0001100) +`define RV32_FSQRT_S {7'b0101100, 5'b00000, 5'b?????, 3'b???, 5'b?????, 7'b1010011} + +`endif + diff --git a/v/vanilla_bean/bsg_vanilla_defines.vh b/v/vanilla_bean/bsg_vanilla_defines.vh index fe8f0e413..4d08c20b7 100644 --- a/v/vanilla_bean/bsg_vanilla_defines.vh +++ b/v/vanilla_bean/bsg_vanilla_defines.vh @@ -9,7 +9,7 @@ * */ -`include "bsg_defines.sv" +`include "bsg_defines.v" `define declare_icache_format_s(tag_width_mp, block_size_in_words_mp) \ typedef struct packed { \ @@ -27,224 +27,136 @@ `define FPU_RECODED_ZERO 33'h0 `define FPU_RECODED_CANONICAL_NAN 33'h0e0400000 -`define RV32_MSTATUS_MIE_BIT_IDX 3 -`define RV32_MSTATUS_MPIE_BIT_IDX 7 - `define REMOTE_INTERRUPT_JUMP_ADDR 0 // remote interrupt jump addr (word addr) `define TRACE_INTERRUPT_JUMP_ADDR 1 // trace interrupt jump addr (word addr) -// RV32 Opcodes -`define RV32_LOAD 7'b0000011 -`define RV32_STORE 7'b0100011 - -// we have branch instructions ignore the low bit so that we can place the prediction bit there. -// RISC-V by default has the low bits set to 11 in the icache, so we can use those creatively. -// note this relies on all code using ==? and casez. -`define RV32_BRANCH 7'b110001? - -`define RV32_JALR_OP 7'b1100111 -`define RV32_MISC_MEM 7'b0001111 -`define RV32_AMO_OP 7'b0101111 -`define RV32_JAL_OP 7'b1101111 -`define RV32_OP_IMM 7'b0010011 -`define RV32_OP 7'b0110011 -`define RV32_SYSTEM 7'b1110011 -`define RV32_AUIPC_OP 7'b0010111 -`define RV32_LUI_OP 7'b0110111 - - -// Some useful RV32 instruction macros -`define RV32_Rtype(op, funct3, funct7) {``funct7``, {5{1'b?}}, {5{1'b?}},``funct3``, {5{1'b?}},``op``} -`define RV32_Itype(op, funct3) {{12{1'b?}},{5{1'b?}},``funct3``,{5{1'b?}},``op``} -`define RV32_Stype(op, funct3) {{7{1'b?}},{5{1'b?}},{5{1'b?}},``funct3``,{5{1'b?}},``op``} -`define RV32_Utype(op) {{20{1'b?}},{5{1'b?}},``op``} - -// RV32 Immediate sign extension macros -`define RV32_signext_Iimm(instr) {{21{``instr``[31]}},``instr``[30:20]} -`define RV32_signext_Simm(instr) {{21{``instr``[31]}},``instr[30:25],``instr``[11:7]} -`define RV32_signext_Bimm(instr) {{20{``instr``[31]}},``instr``[7],``instr``[30:25],``instr``[11:8], {1'b0}} -`define RV32_signext_Uimm(instr) {``instr``[31:12], {12{1'b0}}} -`define RV32_signext_Jimm(instr) {{12{``instr``[31]}},``instr``[19:12],``instr``[20],``instr``[30:21], {1'b0}} - -`define RV32_Bimm_12inject1(instr,value) {``value``[12], ``value``[10:5], ``instr``[24:12],\ +// 32M Instruction Encodings +`define MD_MUL_FUN3 3'b000 +`define MD_MULH_FUN3 3'b001 +`define MD_MULHSU_FUN3 3'b010 +`define MD_MULHU_FUN3 3'b011 +`define MD_DIV_FUN3 3'b100 +`define MD_DIVU_FUN3 3'b101 +`define MD_REM_FUN3 3'b110 +`define MD_REMU_FUN3 3'b111 + +`define VANILLA_MSTATUS_MIE_BIT_IDX 3 +`define VANILLA_MSTATUS_MPIE_BIT_IDX 7 + +// Vanilla Core Opcodes +`define VANILLA_LOAD 7'b0000011 +`define VANILLA_STORE 7'b0100011 + +`define VANILLA_BRANCH 7'b110001? + +`define VANILLA_JALR_OP 7'b1100111 +`define VANILLA_MISC_MEM 7'b0001111 +`define VANILLA_AMO_OP 7'b0101111 +`define VANILLA_JAL_OP 7'b1101111 +`define VANILLA_OP_IMM 7'b0010011 +`define VANILLA_OP 7'b0110011 +`define VANILLA_SYSTEM 7'b1110011 +`define VANILLA_AUIPC_OP 7'b0010111 +`define VANILLA_LUI_OP 7'b0110111 + +// Some useful Vanilla instruction macros +`define Vanilla_Rtype(op, funct3, funct7) {``funct7``, {5{1'b?}}, {5{1'b?}},``funct3``, {5{1'b?}},``op``} +`define Vanilla_Itype(op, funct3) {{12{1'b?}},{5{1'b?}},``funct3``,{5{1'b?}},``op``} +`define Vanilla_Stype(op, funct3) {{7{1'b?}},{5{1'b?}},{5{1'b?}},``funct3``,{5{1'b?}},``op``} +`define Vanilla_Utype(op) {{20{1'b?}},{5{1'b?}},``op``} + +// Vanilla Immediate sign extension macros +`define Vanilla_signext_Iimm(instr) {{21{``instr``[31]}},``instr``[30:20]} +`define Vanilla_signext_Simm(instr) {{21{``instr``[31]}},``instr[30:25],``instr``[11:7]} +`define Vanilla_signext_Bimm(instr) {{20{``instr``[31]}},``instr``[7],``instr``[30:25],``instr``[11:8], {1'b0}} +`define Vanilla_signext_Uimm(instr) {``instr``[31:12], {12{1'b0}}} +`define Vanilla_signext_Jimm(instr) {{12{``instr``[31]}},``instr``[19:12],``instr``[20],``instr``[30:21], {1'b0}} + +`define Vanilla_Bimm_12inject1(instr,value) {``value``[12], ``value``[10:5], ``instr``[24:12],\ ``value``[4:1],``value``[11],``instr``[6:0]} -`define RV32_Jimm_20inject1(instr,value) {``value``[20], ``value``[10:1], ``value``[11],``value``[19:12], ``instr``[11:0]} +`define Vanilla_Jimm_20inject1(instr,value) {``value``[20], ``value``[10:1], ``value``[11],``value``[19:12], ``instr``[11:0]} // Both JAL and BRANCH use 2-byte address, we need to pad 1'b0 at MSB to get // the real byte address -`define RV32_Bimm_13extract(instr) {``instr``[31], ``instr``[7], ``instr``[30:25], ``instr``[11:8], 1'b0} -`define RV32_Jimm_21extract(instr) {``instr``[31], ``instr``[19:12],``instr``[20],``instr``[30:21], 1'b0} +`define Vanilla_Bimm_13extract(instr) {``instr``[31], ``instr``[7], ``instr``[30:25], ``instr``[11:8], 1'b0} +`define Vanilla_Jimm_21extract(instr) {``instr``[31], ``instr``[19:12],``instr``[20],``instr``[30:21], 1'b0} -`define RV32_Iimm_12extract(instr) {``instr``[31:20]} -`define RV32_Simm_12extract(instr) {``instr[31:25],``instr``[11:7]} +`define Vanilla_Iimm_12extract(instr) {``instr``[31:20]} +`define Vanilla_Simm_12extract(instr) {``instr[31:25],``instr``[11:7]} -// RV32I Instruction encodings +// Vanilla Instruction encodings // We have to delete the white space in macro definition, // otherwise Design Compiler would issue warings. -`define RV32_LUI `RV32_Utype(`RV32_LUI_OP) -`define RV32_AUIPC `RV32_Utype(`RV32_AUIPC_OP) -`define RV32_JAL `RV32_Utype(`RV32_JAL_OP) -`define RV32_JALR `RV32_Itype(`RV32_JALR_OP, 3'b000) -`define RV32_BEQ `RV32_Stype(`RV32_BRANCH, 3'b000) -`define RV32_BNE `RV32_Stype(`RV32_BRANCH, 3'b001) -`define RV32_BLT `RV32_Stype(`RV32_BRANCH, 3'b100) -`define RV32_BGE `RV32_Stype(`RV32_BRANCH, 3'b101) -`define RV32_BLTU `RV32_Stype(`RV32_BRANCH, 3'b110) -`define RV32_BGEU `RV32_Stype(`RV32_BRANCH, 3'b111) -`define RV32_LB `RV32_Itype(`RV32_LOAD, 3'b000) -`define RV32_LH `RV32_Itype(`RV32_LOAD, 3'b001) -`define RV32_LW `RV32_Itype(`RV32_LOAD, 3'b010) -`define RV32_LBU `RV32_Itype(`RV32_LOAD, 3'b100) -`define RV32_LHU `RV32_Itype(`RV32_LOAD, 3'b101) -`define RV32_SB `RV32_Stype(`RV32_STORE, 3'b000) -`define RV32_SH `RV32_Stype(`RV32_STORE, 3'b001) -`define RV32_SW `RV32_Stype(`RV32_STORE, 3'b010) -`define RV32_ADDI `RV32_Itype(`RV32_OP_IMM,3'b000) -`define RV32_SLTI `RV32_Itype(`RV32_OP_IMM, 3'b010) -`define RV32_SLTIU `RV32_Itype(`RV32_OP_IMM, 3'b011) -`define RV32_XORI `RV32_Itype(`RV32_OP_IMM, 3'b100) -`define RV32_ORI `RV32_Itype(`RV32_OP_IMM, 3'b110) -`define RV32_ANDI `RV32_Itype(`RV32_OP_IMM, 3'b111) -`define RV32_SLLI `RV32_Rtype(`RV32_OP_IMM, 3'b001, 7'b0000000) -`define RV32_SRLI `RV32_Rtype(`RV32_OP_IMM, 3'b101, 7'b0000000) -`define RV32_SRAI `RV32_Rtype(`RV32_OP_IMM, 3'b101, 7'b0100000) -`define RV32_ADD `RV32_Rtype(`RV32_OP,3'b000,7'b0000000) -`define RV32_SUB `RV32_Rtype(`RV32_OP, 3'b000, 7'b0100000) -`define RV32_SLL `RV32_Rtype(`RV32_OP, 3'b001, 7'b0000000) -`define RV32_SLT `RV32_Rtype(`RV32_OP, 3'b010, 7'b0000000) -`define RV32_SLTU `RV32_Rtype(`RV32_OP, 3'b011, 7'b0000000) -`define RV32_XOR `RV32_Rtype(`RV32_OP, 3'b100, 7'b0000000) -`define RV32_SRL `RV32_Rtype(`RV32_OP, 3'b101, 7'b0000000) -`define RV32_SRA `RV32_Rtype(`RV32_OP, 3'b101, 7'b0100000) -`define RV32_OR `RV32_Rtype(`RV32_OP, 3'b110, 7'b0000000) -`define RV32_AND `RV32_Rtype(`RV32_OP, 3'b111, 7'b0000000) - -// FENCE defines -`define RV32_FENCE_FUN3 3'b000 -`define RV32_FENCE_OP {4'b????,4'b????,4'b????,5'b00000,`RV32_FENCE_FUN3,5'b00000,`RV32_MISC_MEM} -`define RV32_FENCE_FM 4'b0000 -`define RV32_BARSEND_FM 4'b0001 -`define RV32_BARRECV_FM 4'b0010 - -//TRIGGER SAIF DUMP defines -`define SAIF_TRIGGER_START {12'b000000000001,5'b00000,3'b000,5'b00000,`RV32_OP_IMM} -`define SAIF_TRIGGER_END {12'b000000000010,5'b00000,3'b000,5'b00000,`RV32_OP_IMM} +`define VANILLA_LUI `Vanilla_Utype(`VANILLA_LUI_OP) +`define VANILLA_AUIPC `Vanilla_Utype(`VANILLA_AUIPC_OP) +`define VANILLA_JAL `Vanilla_Utype(`VANILLA_JAL_OP) +`define VANILLA_JALR `Vanilla_Itype(`VANILLA_JALR_OP, 3'b000) +`define VANILLA_BEQ `Vanilla_Stype(`VANILLA_BRANCH, 3'b000) +`define VANILLA_BNE `Vanilla_Stype(`VANILLA_BRANCH, 3'b001) +`define VANILLA_BLT `Vanilla_Stype(`VANILLA_BRANCH, 3'b100) +`define VANILLA_BGE `Vanilla_Stype(`VANILLA_BRANCH, 3'b101) +`define VANILLA_BLTU `Vanilla_Stype(`VANILLA_BRANCH, 3'b110) +`define VANILLA_BGEU `Vanilla_Stype(`VANILLA_BRANCH, 3'b111) +`define VANILLA_LB `Vanilla_Itype(`VANILLA_LOAD, 3'b000) +`define VANILLA_LH `Vanilla_Itype(`VANILLA_LOAD, 3'b001) +`define VANILLA_LW `Vanilla_Itype(`VANILLA_LOAD, 3'b010) +`define VANILLA_LBU `Vanilla_Itype(`VANILLA_LOAD, 3'b100) +`define VANILLA_LHU `Vanilla_Itype(`VANILLA_LOAD, 3'b101) +`define VANILLA_SB `Vanilla_Stype(`VANILLA_STORE, 3'b000) +`define VANILLA_SH `Vanilla_Stype(`VANILLA_STORE, 3'b001) +`define VANILLA_SW `Vanilla_Stype(`VANILLA_STORE, 3'b010) +`define VANILLA_ADDI `Vanilla_Itype(`VANILLA_OP_IMM,3'b000) +`define VANILLA_SLTI `Vanilla_Itype(`VANILLA_OP_IMM, 3'b010) +`define VANILLA_SLTIU `Vanilla_Itype(`VANILLA_OP_IMM, 3'b011) +`define VANILLA_XORI `Vanilla_Itype(`VANILLA_OP_IMM, 3'b100) +`define VANILLA_ORI `Vanilla_Itype(`VANILLA_OP_IMM, 3'b110) +`define VANILLA_ANDI `Vanilla_Itype(`VANILLA_OP_IMM, 3'b111) +`define VANILLA_SLLI `Vanilla_Rtype(`VANILLA_OP_IMM, 3'b001, 7'b0000000) +`define VANILLA_SRLI `Vanilla_Rtype(`VANILLA_OP_IMM, 3'b101, 7'b0000000) +`define VANILLA_SRAI `Vanilla_Rtype(`VANILLA_OP_IMM, 3'b101, 7'b0100000) +`define VANILLA_ADD `Vanilla_Rtype(`VANILLA_OP,3'b000,7'b0000000) +`define VANILLA_SUB `Vanilla_Rtype(`VANILLA_OP, 3'b000, 7'b0100000) +`define VANILLA_SLL `Vanilla_Rtype(`VANILLA_OP, 3'b001, 7'b0000000) +`define VANILLA_SLT `Vanilla_Rtype(`VANILLA_OP, 3'b010, 7'b0000000) +`define VANILLA_SLTU `Vanilla_Rtype(`VANILLA_OP, 3'b011, 7'b0000000) +`define VANILLA_XOR `Vanilla_Rtype(`VANILLA_OP, 3'b100, 7'b0000000) +`define VANILLA_SRL `Vanilla_Rtype(`VANILLA_OP, 3'b101, 7'b0000000) +`define VANILLA_SRA `Vanilla_Rtype(`VANILLA_OP, 3'b101, 7'b0100000) +`define VANILLA_OR `Vanilla_Rtype(`VANILLA_OP, 3'b110, 7'b0000000) +`define VANILLA_AND `Vanilla_Rtype(`VANILLA_OP, 3'b111, 7'b0000000) // CSR encoding -`define RV32_CSRRW_FUN3 3'b001 -`define RV32_CSRRS_FUN3 3'b010 -`define RV32_CSRRC_FUN3 3'b011 -`define RV32_CSRRWI_FUN3 3'b101 -`define RV32_CSRRSI_FUN3 3'b110 -`define RV32_CSRRCI_FUN3 3'b111 - -`define RV32_CSRRW `RV32_Itype(`RV32_SYSTEM, `RV32_CSRRW_FUN3) -`define RV32_CSRRS `RV32_Itype(`RV32_SYSTEM, `RV32_CSRRS_FUN3) -`define RV32_CSRRC `RV32_Itype(`RV32_SYSTEM, `RV32_CSRRC_FUN3) -`define RV32_CSRRWI `RV32_Itype(`RV32_SYSTEM, `RV32_CSRRWI_FUN3) -`define RV32_CSRRSI `RV32_Itype(`RV32_SYSTEM, `RV32_CSRRSI_FUN3) -`define RV32_CSRRCI `RV32_Itype(`RV32_SYSTEM, `RV32_CSRRCI_FUN3) +`define VANILLA_CSRRW_FUN3 3'b001 +`define VANILLA_CSRRS_FUN3 3'b010 +`define VANILLA_CSRRC_FUN3 3'b011 +`define VANILLA_CSRRWI_FUN3 3'b101 +`define VANILLA_CSRRSI_FUN3 3'b110 +`define VANILLA_CSRRCI_FUN3 3'b111 + +`define VANILLA_CSRRW `Vanilla_Itype(`VANILLA_SYSTEM, `VANILLA_CSRRW_FUN3) +`define VANILLA_CSRRS `Vanilla_Itype(`VANILLA_SYSTEM, `VANILLA_CSRRS_FUN3) +`define VANILLA_CSRRC `Vanilla_Itype(`VANILLA_SYSTEM, `VANILLA_CSRRC_FUN3) +`define VANILLA_CSRRWI `Vanilla_Itype(`VANILLA_SYSTEM, `VANILLA_CSRRWI_FUN3) +`define VANILLA_CSRRSI `Vanilla_Itype(`VANILLA_SYSTEM, `VANILLA_CSRRSI_FUN3) +`define VANILLA_CSRRCI `Vanilla_Itype(`VANILLA_SYSTEM, `VANILLA_CSRRCI_FUN3) // fcsr CSR addr -`define RV32_CSR_FFLAGS_ADDR 12'h001 -`define RV32_CSR_FRM_ADDR 12'h002 -`define RV32_CSR_FCSR_ADDR 12'h003 +`define VANILLA_CSR_FFLAGS_ADDR 12'h001 +`define VANILLA_CSR_FRM_ADDR 12'h002 +`define VANILLA_CSR_FCSR_ADDR 12'h003 // machine CSR addr -`define RV32_CSR_MSTATUS_ADDR 12'h300 -`define RV32_CSR_MTVEC_ADDR 12'h305 -`define RV32_CSR_MIE_ADDR 12'h304 -`define RV32_CSR_MIP_ADDR 12'h344 -`define RV32_CSR_MEPC_ADDR 12'h341 -`define RV32_CSR_CFG_POD_ADDR 12'h360 +`define VANILLA_CSR_MSTATUS_ADDR 12'h300 +`define VANILLA_CSR_MTVEC_ADDR 12'h305 +`define VANILLA_CSR_MIE_ADDR 12'h304 +`define VANILLA_CSR_MIP_ADDR 12'h344 +`define VANILLA_CSR_MEPC_ADDR 12'h341 +`define VANILLA_CSR_CFG_POD_ADDR 12'h360 // machine custom CSR addr -`define RV32_CSR_CREDIT_LIMIT_ADDR 12'hfc0 -`define RV32_CSR_BARCFG_ADDR 12'hfc1 -`define RV32_CSR_BAR_PI_ADDR 12'hfc2 -`define RV32_CSR_BAR_PO_ADDR 12'hfc3 - -// mret -// used for returning from the interrupt -`define RV32_MRET {7'b0011000, 5'b00010, 5'b00000, 3'b000, 5'b00000, `RV32_SYSTEM} - -// RV32M Instruction Encodings -`define MD_MUL_FUN3 3'b000 -`define MD_MULH_FUN3 3'b001 -`define MD_MULHSU_FUN3 3'b010 -`define MD_MULHU_FUN3 3'b011 -`define MD_DIV_FUN3 3'b100 -`define MD_DIVU_FUN3 3'b101 -`define MD_REM_FUN3 3'b110 -`define MD_REMU_FUN3 3'b111 -`define RV32_MUL `RV32_Rtype(`RV32_OP, `MD_MUL_FUN3 , 7'b0000001) -`define RV32_MULH `RV32_Rtype(`RV32_OP, `MD_MULH_FUN3 , 7'b0000001) -`define RV32_MULHSU `RV32_Rtype(`RV32_OP, `MD_MULHSU_FUN3, 7'b0000001) -`define RV32_MULHU `RV32_Rtype(`RV32_OP, `MD_MULHU_FUN3 , 7'b0000001) -`define RV32_DIV `RV32_Rtype(`RV32_OP, `MD_DIV_FUN3 , 7'b0000001) -`define RV32_DIVU `RV32_Rtype(`RV32_OP, `MD_DIVU_FUN3 , 7'b0000001) -`define RV32_REM `RV32_Rtype(`RV32_OP, `MD_REM_FUN3 , 7'b0000001) -`define RV32_REMU `RV32_Rtype(`RV32_OP, `MD_REMU_FUN3 , 7'b0000001) - -// RV32A Instruction Encodings -`define RV32_LR_W {5'b00010,2'b00,5'b00000,5'b?????,3'b010,5'b?????,`RV32_AMO_OP} -`define RV32_LR_W_AQ {5'b00010,2'b10,5'b00000,5'b?????,3'b010,5'b?????,`RV32_AMO_OP} -`define RV32_AMOSWAP_W {5'b00001,2'b??,5'b?????,5'b?????,3'b010,5'b?????,`RV32_AMO_OP} -`define RV32_AMOOR_W {5'b01000,2'b??,5'b?????,5'b?????,3'b010,5'b?????,`RV32_AMO_OP} -`define RV32_AMOADD_W {5'b00000,2'b??,5'b?????,5'b?????,3'b010,5'b?????,`RV32_AMO_OP} - -// RV32F Instruction Encodings -`define RV32_OP_FP 7'b1010011 -`define RV32_LOAD_FP 7'b0000111 -`define RV32_STORE_FP 7'b0100111 - -`define RV32_FCMP_S_FUN7 7'b1010000 -`define RV32_FCLASS_S_FUN7 7'b1110000 -`define RV32_FCVT_S_F2I_FUN7 7'b1100000 -`define RV32_FCVT_S_I2F_FUN7 7'b1101000 -`define RV32_FMV_W_X_FUN7 7'b1111000 -`define RV32_FMV_X_W_FUN7 7'b1110000 - -`define RV32_FADD_S `RV32_Rtype(`RV32_OP_FP, 3'b???, 7'b0000000) -`define RV32_FSUB_S `RV32_Rtype(`RV32_OP_FP, 3'b???, 7'b0000100) -`define RV32_FMUL_S `RV32_Rtype(`RV32_OP_FP, 3'b???, 7'b0001000) - -`define RV32_FSGNJ_S `RV32_Rtype(`RV32_OP_FP, 3'b000, 7'b0010000) -`define RV32_FSGNJN_S `RV32_Rtype(`RV32_OP_FP, 3'b001, 7'b0010000) -`define RV32_FSGNJX_S `RV32_Rtype(`RV32_OP_FP, 3'b010, 7'b0010000) - -`define RV32_FMIN_S `RV32_Rtype(`RV32_OP_FP, 3'b000, 7'b0010100) -`define RV32_FMAX_S `RV32_Rtype(`RV32_OP_FP, 3'b001, 7'b0010100) - -`define RV32_FEQ_S `RV32_Rtype(`RV32_OP_FP, 3'b010, `RV32_FCMP_S_FUN7) -`define RV32_FLT_S `RV32_Rtype(`RV32_OP_FP, 3'b001, `RV32_FCMP_S_FUN7) -`define RV32_FLE_S `RV32_Rtype(`RV32_OP_FP, 3'b000, `RV32_FCMP_S_FUN7) - -`define RV32_FCLASS_S {`RV32_FCLASS_S_FUN7, 5'b00000, 5'b?????, 3'b001, 5'b?????, `RV32_OP_FP} - -// i2f -`define RV32_FCVT_S_W {`RV32_FCVT_S_I2F_FUN7, 5'b00000, 5'b?????, 3'b???, 5'b?????, `RV32_OP_FP} -`define RV32_FCVT_S_WU {`RV32_FCVT_S_I2F_FUN7, 5'b00001, 5'b?????, 3'b???, 5'b?????, `RV32_OP_FP} - -// f2i -`define RV32_FCVT_W_S {`RV32_FCVT_S_F2I_FUN7, 5'b00000, 5'b?????, 3'b???, 5'b?????, `RV32_OP_FP} -`define RV32_FCVT_WU_S {`RV32_FCVT_S_F2I_FUN7, 5'b00001, 5'b?????, 3'b???, 5'b?????, `RV32_OP_FP} - -// move (i->f) -`define RV32_FMV_W_X {`RV32_FMV_W_X_FUN7, 5'b0000, 5'b?????, 3'b000, 5'b?????, `RV32_OP_FP} - -// move (f->i) -`define RV32_FMV_X_W {`RV32_FMV_X_W_FUN7, 5'b0000, 5'b?????, 3'b000, 5'b?????, `RV32_OP_FP} - -`define RV32_FLW_S `RV32_Itype(`RV32_LOAD_FP, 3'b010) -`define RV32_FSW_S `RV32_Stype(`RV32_STORE_FP, 3'b010) - -`define RV32_FMADD_S {5'b?????, 2'b00, 5'b?????, 5'b?????, 3'b???, 5'b?????, 7'b1000011} -`define RV32_FMSUB_S {5'b?????, 2'b00, 5'b?????, 5'b?????, 3'b???, 5'b?????, 7'b1000111} -`define RV32_FNMSUB_S {5'b?????, 2'b00, 5'b?????, 5'b?????, 3'b???, 5'b?????, 7'b1001011} -`define RV32_FNMADD_S {5'b?????, 2'b00, 5'b?????, 5'b?????, 3'b???, 5'b?????, 7'b1001111} - -`define RV32_FDIV_S `RV32_Rtype(`RV32_OP_FP, 3'b???, 7'b0001100) -`define RV32_FSQRT_S {7'b0101100, 5'b00000, 5'b?????, 3'b???, 5'b?????, 7'b1010011} +`define VANILLA_CSR_CREDIT_LIMIT_ADDR 12'hfc0 +`define VANILLA_CSR_BARCFG_ADDR 12'hfc1 +`define VANILLA_CSR_BAR_PI_ADDR 12'hfc2 +`define VANILLA_CSR_BAR_PO_ADDR 12'hfc3 `endif diff --git a/v/vanilla_bean/bsg_vanilla_pkg.v b/v/vanilla_bean/bsg_vanilla_pkg.v index 12147d102..062896a7f 100644 --- a/v/vanilla_bean/bsg_vanilla_pkg.v +++ b/v/vanilla_bean/bsg_vanilla_pkg.v @@ -12,18 +12,18 @@ package bsg_vanilla_pkg; import bsg_manycore_pkg::*; // vanilla_core global parameters -localparam RV32_reg_data_width_gp = 32; -localparam RV32_instr_width_gp = 32; -localparam RV32_reg_els_gp = 32; -localparam RV32_reg_addr_width_gp = 5; -localparam RV32_opcode_width_gp = 7; -localparam RV32_funct3_width_gp = 3; -localparam RV32_funct7_width_gp = 7; -localparam RV32_Iimm_width_gp = 12; -localparam RV32_Simm_width_gp = 12; -localparam RV32_Bimm_width_gp = 12; -localparam RV32_Uimm_width_gp = 20; -localparam RV32_Jimm_width_gp = 20; +localparam reg_data_width_gp = 32; +localparam instr_width_gp = 32; +localparam reg_els_gp = 32; +localparam reg_addr_width_gp = 5; +localparam opcode_width_gp = 7; +localparam funct3_width_gp = 3; +localparam funct7_width_gp = 7; +localparam Iimm_width_gp = 12; +localparam Simm_width_gp = 12; +localparam Bimm_width_gp = 12; +localparam Uimm_width_gp = 20; +localparam Jimm_width_gp = 20; localparam fpu_recoded_exp_width_gp = 8; localparam fpu_recoded_sig_width_gp = 24; @@ -33,16 +33,17 @@ localparam fpu_recoded_data_width_gp = (1+fpu_recoded_exp_width_gp+fpu_recoded localparam epa_word_addr_width_gp=16; -// RV32 Instruction structure +// Vanilla Core Instruction structure (Optimised towards RV32 format, may +// require changes while adding new formats) // Ideally represents a R-type instruction; these fields if // present in other types of instructions, appear at same positions typedef struct packed { - logic [RV32_funct7_width_gp-1:0] funct7; - logic [RV32_reg_addr_width_gp-1:0] rs2; - logic [RV32_reg_addr_width_gp-1:0] rs1; - logic [RV32_funct3_width_gp-1:0] funct3; - logic [RV32_reg_addr_width_gp-1:0] rd; - logic [RV32_opcode_width_gp-1:0] op; + logic [funct7_width_gp-1:0] funct7; + logic [reg_addr_width_gp-1:0] rs2; + logic [reg_addr_width_gp-1:0] rs1; + logic [funct3_width_gp-1:0] funct3; + logic [reg_addr_width_gp-1:0] rd; + logic [opcode_width_gp-1:0] op; } instruction_s; // remote request from vanilla core @@ -214,8 +215,8 @@ typedef struct packed { // Instruction decode stage signals typedef struct packed { - logic [RV32_reg_data_width_gp-1:0] pc_plus4; // PC + 4 - logic [RV32_reg_data_width_gp-1:0] pred_or_jump_addr; // Jump target PC + logic [reg_data_width_gp-1:0] pc_plus4; // PC + 4 + logic [reg_data_width_gp-1:0] pred_or_jump_addr; // Jump target PC instruction_s instruction; // Instruction being executed decode_s decode; // Decode signals fp_decode_s fp_decode; @@ -227,14 +228,14 @@ typedef struct packed // Execute stage signals typedef struct packed { - logic [RV32_reg_data_width_gp-1:0] pc_plus4; // PC + 4 - logic [RV32_reg_data_width_gp-1:0] pred_or_jump_addr; // Jump target PC + logic [reg_data_width_gp-1:0] pc_plus4; // PC + 4 + logic [reg_data_width_gp-1:0] pred_or_jump_addr; // Jump target PC instruction_s instruction; // Instruction being executed decode_s decode; // Decode signals - logic [RV32_reg_data_width_gp-1:0] rs1_val; // RF output data from RS1 address - logic [RV32_reg_data_width_gp-1:0] rs2_val; // RF output data from RS2 address + logic [reg_data_width_gp-1:0] rs1_val; // RF output data from RS1 address + logic [reg_data_width_gp-1:0] rs2_val; // RF output data from RS2 address // CSR instructions use this register for loading CSR vals - logic [RV32_Iimm_width_gp-1:0] mem_addr_op2; // the second operands to compute + logic [Iimm_width_gp-1:0] mem_addr_op2; // the second operands to compute // memory address logic icache_miss; logic valid; // valid instruction in EXE @@ -244,7 +245,7 @@ typedef struct packed // Memory stage signals typedef struct packed { - logic [RV32_reg_addr_width_gp-1:0] rd_addr; + logic [reg_addr_width_gp-1:0] rd_addr; logic write_rd; logic write_frd; logic is_byte_op; @@ -256,26 +257,26 @@ typedef struct packed { } mem_ctrl_signals_s; typedef struct packed { - logic [RV32_reg_data_width_gp-1:0] exe_result; + logic [reg_data_width_gp-1:0] exe_result; } mem_data_signals_s; // RF write back stage signals typedef struct packed { logic write_rd; - logic [RV32_reg_addr_width_gp-1:0] rd_addr; + logic [reg_addr_width_gp-1:0] rd_addr; logic icache_miss; logic clear_sb; } wb_ctrl_signals_s; typedef struct packed { - logic [RV32_reg_data_width_gp-1:0] rf_data; + logic [reg_data_width_gp-1:0] rf_data; } wb_data_signals_s; // FP Execute stage signals typedef struct packed { - logic [RV32_reg_addr_width_gp-1:0] rd; - fp_decode_s fp_decode; - frm_e rm; + logic [reg_addr_width_gp-1:0] rd; + fp_decode_s fp_decode; + frm_e rm; } fp_exe_ctrl_signals_s; typedef struct packed { @@ -287,11 +288,11 @@ typedef struct packed { // FLW write back stage signals typedef struct packed { logic valid; - logic [RV32_reg_addr_width_gp-1:0] rd_addr; + logic [reg_addr_width_gp-1:0] rd_addr; } flw_wb_ctrl_signals_s; typedef struct packed { - logic [RV32_reg_data_width_gp-1:0] rf_data; + logic [reg_data_width_gp-1:0] rf_data; } flw_wb_data_signals_s; diff --git a/v/vanilla_bean/fcsr.v b/v/vanilla_bean/fcsr.v index 728844dce..73ae57b64 100644 --- a/v/vanilla_bean/fcsr.v +++ b/v/vanilla_bean/fcsr.v @@ -9,7 +9,7 @@ module fcsr import bsg_vanilla_pkg::*; #(localparam fflags_width_lp=$bits(fflags_s) , frm_width_lp=$bits(frm_e) - , reg_addr_width_lp=RV32_reg_addr_width_gp + , reg_addr_width_lp=reg_addr_width_gp ) ( input clk_i @@ -41,27 +41,27 @@ module fcsr always_comb begin if (v_i) begin case (funct3_i) - `RV32_CSRRW_FUN3: begin + `VANILLA_CSRRW_FUN3: begin write_mask = {8{1'b1}}; write_data = data_i; end - `RV32_CSRRS_FUN3: begin + `VANILLA_CSRRS_FUN3: begin write_mask = data_i; write_data = data_i; end - `RV32_CSRRC_FUN3: begin + `VANILLA_CSRRC_FUN3: begin write_mask = data_i; write_data = ~data_i; end - `RV32_CSRRWI_FUN3: begin + `VANILLA_CSRRWI_FUN3: begin write_mask = {8{1'b1}}; write_data = {3'b000, rs1_i}; end - `RV32_CSRRSI_FUN3: begin + `VANILLA_CSRRSI_FUN3: begin write_mask = {3'b000, rs1_i}; write_data = {3'b000, rs1_i}; end - `RV32_CSRRCI_FUN3: begin + `VANILLA_CSRRCI_FUN3: begin write_mask = {3'b000, rs1_i}; write_data = {3'b000, ~rs1_i}; end @@ -87,12 +87,12 @@ module fcsr always_comb begin case (addr_i) // frm - `RV32_CSR_FRM_ADDR: begin + `VANILLA_CSR_FRM_ADDR: begin frm_write_mask = write_mask[0+:frm_width_lp]; frm_write_data = write_data[0+:frm_width_lp]; end // fcsr - `RV32_CSR_FCSR_ADDR: begin + `VANILLA_CSR_FCSR_ADDR: begin frm_write_mask = write_mask[fflags_width_lp+:frm_width_lp]; frm_write_data = write_data[fflags_width_lp+:frm_width_lp]; end @@ -120,8 +120,8 @@ module fcsr if (v_i) begin case (addr_i) // fflags, fcsr - `RV32_CSR_FFLAGS_ADDR, - `RV32_CSR_FCSR_ADDR: begin + `VANILLA_CSR_FFLAGS_ADDR, + `VANILLA_CSR_FCSR_ADDR: begin fflags_write_mask = write_mask[0+:fflags_width_lp]; fflags_write_data = write_data[0+:fflags_width_lp]; end @@ -158,15 +158,15 @@ module fcsr // output always_comb begin case (addr_i) - `RV32_CSR_FFLAGS_ADDR: begin + `VANILLA_CSR_FFLAGS_ADDR: begin data_o = {3'b0, fflags_r}; data_v_o = 1'b1; end - `RV32_CSR_FRM_ADDR: begin + `VANILLA_CSR_FRM_ADDR: begin data_o = {5'b0, frm_r}; data_v_o = 1'b1; end - `RV32_CSR_FCSR_ADDR: begin + `VANILLA_CSR_FCSR_ADDR: begin data_o = {frm_r, fflags_r}; data_v_o = 1'b1; end @@ -185,7 +185,7 @@ module fcsr if (~reset_i) begin // this assertion checks that there are no fflags exception being accrued // while fflags are being accessed by CSR instruction in ID. - if (v_i & ((addr_i == `RV32_CSR_FFLAGS_ADDR) || (addr_i == `RV32_CSR_FCSR_ADDR))) begin + if (v_i & ((addr_i == `VANILLA_CSR_FFLAGS_ADDR) || (addr_i == `VANILLA_CSR_FCSR_ADDR))) begin assert(~(|fflags_v_i)) else $error("[BSG_ERROR] Exception cannot be accrued while being written by fcsr op."); end end diff --git a/v/vanilla_bean/fpu_fdiv_fsqrt.v b/v/vanilla_bean/fpu_fdiv_fsqrt.v index fae1e0103..d47a633c9 100644 --- a/v/vanilla_bean/fpu_fdiv_fsqrt.v +++ b/v/vanilla_bean/fpu_fdiv_fsqrt.v @@ -12,7 +12,7 @@ module fpu_fdiv_fsqrt import bsg_vanilla_pkg::*; #( parameter exp_width_p=fpu_recoded_exp_width_gp ,parameter sig_width_p=fpu_recoded_sig_width_gp - ,parameter reg_addr_width_p=RV32_reg_addr_width_gp + ,parameter reg_addr_width_p=reg_addr_width_gp ,parameter bits_per_iter_p=2 ,localparam recoded_data_width_lp=(1+exp_width_p+sig_width_p) ) diff --git a/v/vanilla_bean/fpu_float.v b/v/vanilla_bean/fpu_float.v index 5a42d3056..94ab73f70 100644 --- a/v/vanilla_bean/fpu_float.v +++ b/v/vanilla_bean/fpu_float.v @@ -9,14 +9,14 @@ * Other float operations becomes available in the second stage. */ -`include "bsg_defines.sv" +`include "bsg_defines.v" module fpu_float import bsg_vanilla_pkg::*; #(parameter exp_width_p=fpu_recoded_exp_width_gp , sig_width_p=fpu_recoded_sig_width_gp - , data_width_p=RV32_reg_data_width_gp // integer width - , reg_addr_width_p=RV32_reg_addr_width_gp + , data_width_p=reg_data_width_gp // integer width + , reg_addr_width_p=reg_addr_width_gp , localparam recoded_data_width_lp=(1+exp_width_p+sig_width_p) ) ( diff --git a/v/vanilla_bean/fpu_float_aux.v b/v/vanilla_bean/fpu_float_aux.v index a9c95cdfe..50fecb17f 100644 --- a/v/vanilla_bean/fpu_float_aux.v +++ b/v/vanilla_bean/fpu_float_aux.v @@ -3,7 +3,7 @@ * */ -`include "bsg_defines.sv" +`include "bsg_defines.v" `include "HardFloat_consts.vi" `include "HardFloat_specialize.vi" @@ -11,7 +11,7 @@ module fpu_float_aux import bsg_vanilla_pkg::*; #(parameter sig_width_p=fpu_recoded_sig_width_gp , exp_width_p=fpu_recoded_exp_width_gp - , data_width_p=RV32_reg_data_width_gp + , data_width_p=reg_data_width_gp , localparam recoded_data_width_lp=(1+sig_width_p+exp_width_p) ) diff --git a/v/vanilla_bean/fpu_float_fma.v b/v/vanilla_bean/fpu_float_fma.v index f6f8d6278..55d9af624 100644 --- a/v/vanilla_bean/fpu_float_fma.v +++ b/v/vanilla_bean/fpu_float_fma.v @@ -13,7 +13,7 @@ module fpu_float_fma import bsg_hardfloat_pkg::*; #(parameter exp_width_p=fpu_recoded_exp_width_gp , sig_width_p=fpu_recoded_sig_width_gp - , data_width_p=RV32_reg_data_width_gp + , data_width_p=reg_data_width_gp , localparam recoded_data_width_lp=(1+exp_width_p+sig_width_p) ) ( diff --git a/v/vanilla_bean/fpu_int.v b/v/vanilla_bean/fpu_int.v index 18b28025d..6900343ef 100644 --- a/v/vanilla_bean/fpu_int.v +++ b/v/vanilla_bean/fpu_int.v @@ -8,7 +8,7 @@ * - F2I, FMV */ -`include "bsg_defines.sv" +`include "bsg_defines.v" `include "HardFloat_consts.vi" `include "HardFloat_specialize.vi" @@ -16,7 +16,7 @@ module fpu_int import bsg_vanilla_pkg::*; #(parameter exp_width_p=fpu_recoded_exp_width_gp , sig_width_p=fpu_recoded_sig_width_gp - , data_width_p=RV32_reg_data_width_gp // integer width + , data_width_p=reg_data_width_gp // integer width , localparam recoded_data_width_lp=(1+exp_width_p+sig_width_p) ) ( diff --git a/v/vanilla_bean/icache.v b/v/vanilla_bean/icache.v index d7fec193c..c59c8966e 100644 --- a/v/vanilla_bean/icache.v +++ b/v/vanilla_bean/icache.v @@ -33,12 +33,12 @@ module icache // icache write , input [pc_width_lp-1:0] w_pc_i - , input [RV32_instr_width_gp-1:0] w_instr_i + , input [instr_width_gp-1:0] w_instr_i // icache read (by processor) , input [pc_width_lp-1:0] pc_i , input [pc_width_lp-1:0] jalr_prediction_i - , output [RV32_instr_width_gp-1:0] instr_o + , output [instr_width_gp-1:0] instr_o , output [pc_width_lp-1:0] pred_or_jump_addr_o , output [pc_width_lp-1:0] pc_r_o , output icache_miss_o @@ -48,8 +48,8 @@ module icache // localparam // - localparam branch_pc_low_width_lp = (RV32_Bimm_width_gp+1); - localparam jal_pc_low_width_lp = (RV32_Jimm_width_gp+1); + localparam branch_pc_low_width_lp = (Bimm_width_gp+1); + localparam jal_pc_low_width_lp = (Jimm_width_gp+1); localparam branch_pc_high_width_lp = (pc_width_lp+2) - branch_pc_low_width_lp; localparam jal_pc_high_width_lp = (pc_width_lp+2) - jal_pc_low_width_lp; @@ -103,14 +103,14 @@ module icache // instruction_s w_instr; assign w_instr = w_instr_i; - wire write_branch_instr = w_instr.op ==? `RV32_BRANCH; - wire write_jal_instr = w_instr.op ==? `RV32_JAL_OP; + wire write_branch_instr = w_instr.op ==? `VANILLA_BRANCH; + wire write_jal_instr = w_instr.op ==? `VANILLA_JAL_OP; // BYTE address computation - wire [branch_pc_low_width_lp-1:0] branch_imm_val = `RV32_Bimm_13extract(w_instr); + wire [branch_pc_low_width_lp-1:0] branch_imm_val = `Vanilla_Bimm_13extract(w_instr); wire [branch_pc_low_width_lp-1:0] branch_pc_val = branch_pc_low_width_lp'({w_pc_i, 2'b0}); - wire [jal_pc_low_width_lp-1:0] jal_imm_val = `RV32_Jimm_21extract(w_instr); + wire [jal_pc_low_width_lp-1:0] jal_imm_val = `Vanilla_Jimm_21extract(w_instr); wire [jal_pc_low_width_lp-1:0] jal_pc_val = jal_pc_low_width_lp'({w_pc_i, 2'b0}); logic [branch_pc_low_width_lp-1:0] branch_pc_lower_res; @@ -123,15 +123,15 @@ module icache // Inject the 2-BYTE (half) address, the LSB is ignored. - wire [RV32_instr_width_gp-1:0] injected_instr = write_branch_instr - ? `RV32_Bimm_12inject1(w_instr, branch_pc_lower_res) + wire [instr_width_gp-1:0] injected_instr = write_branch_instr + ? `Vanilla_Bimm_12inject1(w_instr, branch_pc_lower_res) : (write_jal_instr - ? `RV32_Jimm_20inject1(w_instr, jal_pc_lower_res) + ? `Vanilla_Jimm_20inject1(w_instr, jal_pc_lower_res) : w_instr); wire imm_sign = write_branch_instr - ? branch_imm_val[RV32_Bimm_width_gp] - : jal_imm_val[RV32_Jimm_width_gp]; + ? branch_imm_val[Bimm_width_gp] + : jal_imm_val[Jimm_width_gp]; wire pc_lower_cout = write_branch_instr ? branch_pc_lower_cout @@ -141,7 +141,7 @@ module icache // buffered writes logic [icache_block_size_in_words_p-2:0] imm_sign_r; logic [icache_block_size_in_words_p-2:0] pc_lower_cout_r; - logic [icache_block_size_in_words_p-2:0][RV32_instr_width_gp-1:0] buffered_instr_r; + logic [icache_block_size_in_words_p-2:0][instr_width_gp-1:0] buffered_instr_r; assign icache_data_li = '{ lower_sign : {imm_sign, imm_sign_r}, @@ -275,15 +275,15 @@ module icache end end - wire is_jal_instr = instr_out.op == `RV32_JAL_OP; - wire is_jalr_instr = instr_out.op == `RV32_JALR_OP; + wire is_jal_instr = instr_out.op == `VANILLA_JAL_OP; + wire is_jalr_instr = instr_out.op == `VANILLA_JALR_OP; // these are bytes address logic [pc_width_lp+2-1:0] jal_pc; logic [pc_width_lp+2-1:0] branch_pc; - assign branch_pc = {branch_pc_high_out, `RV32_Bimm_13extract(instr_out)}; - assign jal_pc = {jal_pc_high_out, `RV32_Jimm_21extract(instr_out)}; + assign branch_pc = {branch_pc_high_out, `Vanilla_Bimm_13extract(instr_out)}; + assign jal_pc = {jal_pc_high_out, `Vanilla_Jimm_21extract(instr_out)}; // assign outputs. assign instr_o = instr_out; diff --git a/v/vanilla_bean/idiv.v b/v/vanilla_bean/idiv.v index 33c7930c7..6acef4569 100644 --- a/v/vanilla_bean/idiv.v +++ b/v/vanilla_bean/idiv.v @@ -5,12 +5,12 @@ * */ -`include "bsg_defines.sv" +`include "bsg_defines.v" module idiv import bsg_vanilla_pkg::*; - #(data_width_p=RV32_reg_data_width_gp - ,reg_addr_width_p=RV32_reg_addr_width_gp + #(data_width_p=reg_data_width_gp + ,reg_addr_width_p=reg_addr_width_gp ) ( input clk_i diff --git a/v/vanilla_bean/load_packer.v b/v/vanilla_bean/load_packer.v index f8fc8adc1..6a7c7829f 100644 --- a/v/vanilla_bean/load_packer.v +++ b/v/vanilla_bean/load_packer.v @@ -3,11 +3,11 @@ * */ -`include "bsg_defines.sv" +`include "bsg_defines.v" module load_packer import bsg_vanilla_pkg::*; - #(data_width_p = RV32_reg_data_width_gp) + #(data_width_p = reg_data_width_gp) ( input [data_width_p-1:0] mem_data_i diff --git a/v/vanilla_bean/lsu.v b/v/vanilla_bean/lsu.v index 0e8b99f83..508e253b1 100644 --- a/v/vanilla_bean/lsu.v +++ b/v/vanilla_bean/lsu.v @@ -8,7 +8,7 @@ * */ -`include "bsg_defines.sv" +`include "bsg_defines.v" module lsu @@ -23,7 +23,7 @@ module lsu , localparam dmem_addr_width_lp=`BSG_SAFE_CLOG2(dmem_size_p) , data_mask_width_lp=(data_width_p>>3) - , reg_addr_width_lp=RV32_reg_addr_width_gp + , reg_addr_width_lp=reg_addr_width_gp ) ( input clk_i @@ -34,7 +34,7 @@ module lsu , input [data_width_p-1:0] exe_rs1_i , input [data_width_p-1:0] exe_rs2_i , input [reg_addr_width_lp-1:0] exe_rd_i - , input [RV32_Iimm_width_gp-1:0] mem_offset_i + , input [Iimm_width_gp-1:0] mem_offset_i , input [data_width_p-1:0] pc_plus4_i , input icache_miss_i diff --git a/v/vanilla_bean/mcsr.v b/v/vanilla_bean/mcsr.v index 84a5e9ced..8bf56f1d1 100644 --- a/v/vanilla_bean/mcsr.v +++ b/v/vanilla_bean/mcsr.v @@ -13,8 +13,8 @@ module mcsr import bsg_vanilla_pkg::*; - #(localparam reg_addr_width_lp = RV32_reg_addr_width_gp - , reg_data_width_lp = RV32_reg_data_width_gp + #(localparam reg_addr_width_lp = reg_addr_width_gp + , reg_data_width_lp = reg_data_width_gp , parameter `BSG_INV_PARAM(pc_width_p) , `BSG_INV_PARAM(barrier_dirs_p) , localparam barrier_lg_dirs_lp=`BSG_SAFE_CLOG2(barrier_dirs_p+1) @@ -103,38 +103,38 @@ module mcsr mstatus_n.mie = 1'b0; mstatus_n.mpie = mstatus_r.mie; end - else if (we_i & (addr_i == `RV32_CSR_MSTATUS_ADDR)) begin + else if (we_i & (addr_i == `VANILLA_CSR_MSTATUS_ADDR)) begin case (funct3_i) - `RV32_CSRRW_FUN3: begin - mstatus_n.mpie = data_i[`RV32_MSTATUS_MPIE_BIT_IDX]; - mstatus_n.mie = data_i[`RV32_MSTATUS_MIE_BIT_IDX]; + `VANILLA_CSRRW_FUN3: begin + mstatus_n.mpie = data_i[`VANILLA_MSTATUS_MPIE_BIT_IDX]; + mstatus_n.mie = data_i[`VANILLA_MSTATUS_MIE_BIT_IDX]; end - `RV32_CSRRS_FUN3: begin - mstatus_n.mpie = data_i[`RV32_MSTATUS_MPIE_BIT_IDX] + `VANILLA_CSRRS_FUN3: begin + mstatus_n.mpie = data_i[`VANILLA_MSTATUS_MPIE_BIT_IDX] ? 1'b1 : mstatus_r.mpie; - mstatus_n.mie = data_i[`RV32_MSTATUS_MIE_BIT_IDX] + mstatus_n.mie = data_i[`VANILLA_MSTATUS_MIE_BIT_IDX] ? 1'b1 : mstatus_r.mie; end - `RV32_CSRRC_FUN3: begin - mstatus_n.mpie = data_i[`RV32_MSTATUS_MPIE_BIT_IDX] + `VANILLA_CSRRC_FUN3: begin + mstatus_n.mpie = data_i[`VANILLA_MSTATUS_MPIE_BIT_IDX] ? 1'b0 : mstatus_r.mpie; - mstatus_n.mie = data_i[`RV32_MSTATUS_MIE_BIT_IDX] + mstatus_n.mie = data_i[`VANILLA_MSTATUS_MIE_BIT_IDX] ? 1'b0 : mstatus_r.mie; end - `RV32_CSRRWI_FUN3: begin - mstatus_n.mie = rs1_i[`RV32_MSTATUS_MIE_BIT_IDX]; + `VANILLA_CSRRWI_FUN3: begin + mstatus_n.mie = rs1_i[`VANILLA_MSTATUS_MIE_BIT_IDX]; end - `RV32_CSRRSI_FUN3: begin - mstatus_n.mie = rs1_i[`RV32_MSTATUS_MIE_BIT_IDX] + `VANILLA_CSRRSI_FUN3: begin + mstatus_n.mie = rs1_i[`VANILLA_MSTATUS_MIE_BIT_IDX] ? 1'b1 : mstatus_r.mie; end - `RV32_CSRRCI_FUN3: begin - mstatus_n.mie = rs1_i[`RV32_MSTATUS_MIE_BIT_IDX] + `VANILLA_CSRRCI_FUN3: begin + mstatus_n.mie = rs1_i[`VANILLA_MSTATUS_MIE_BIT_IDX] ? 1'b0 : mstatus_r.mie; end @@ -150,12 +150,12 @@ module mcsr // this can be only modified by csr instr. always_comb begin mie_n = mie_r; - if (we_i & (addr_i == `RV32_CSR_MIE_ADDR)) begin + if (we_i & (addr_i == `VANILLA_CSR_MIE_ADDR)) begin case (funct3_i) - `RV32_CSRRW_FUN3: begin + `VANILLA_CSRRW_FUN3: begin mie_n = data_i[17:16]; end - `RV32_CSRRS_FUN3: begin + `VANILLA_CSRRS_FUN3: begin mie_n.trace = data_i[17] ? 1'b1 : mie_r.trace; @@ -163,7 +163,7 @@ module mcsr ? 1'b1 : mie_r.remote; end - `RV32_CSRRC_FUN3: begin + `VANILLA_CSRRC_FUN3: begin mie_n.trace = data_i[17] ? 1'b0 : mie_r.trace; @@ -189,17 +189,17 @@ module mcsr if (instr_executed_i & mie_r.trace) begin mip_n.trace = 1'b1; end - else if (we_i & (addr_i == `RV32_CSR_MIP_ADDR)) begin + else if (we_i & (addr_i == `VANILLA_CSR_MIP_ADDR)) begin case (funct3_i) - `RV32_CSRRW_FUN3: begin + `VANILLA_CSRRW_FUN3: begin mip_n.trace = data_i[17]; end - `RV32_CSRRS_FUN3: begin + `VANILLA_CSRRS_FUN3: begin mip_n.trace = data_i[17] ? 1'b1 : mip_r.trace; end - `RV32_CSRRC_FUN3: begin + `VANILLA_CSRRC_FUN3: begin mip_n.trace = data_i[17] ? 1'b0 : mip_r.trace; @@ -215,17 +215,17 @@ module mcsr else if (remote_interrupt_clear_i) begin mip_n.remote = 1'b0; end - else if (we_i & (addr_i == `RV32_CSR_MIP_ADDR)) begin + else if (we_i & (addr_i == `VANILLA_CSR_MIP_ADDR)) begin case (funct3_i) - `RV32_CSRRW_FUN3: begin + `VANILLA_CSRRW_FUN3: begin mip_n.remote = data_i[16]; end - `RV32_CSRRS_FUN3: begin + `VANILLA_CSRRS_FUN3: begin mip_n.remote = data_i[16] ? 1'b1 : mip_r.remote; end - `RV32_CSRRC_FUN3: begin + `VANILLA_CSRRC_FUN3: begin mip_n.remote = data_i[16] ? 1'b0 : mip_r.remote; @@ -245,19 +245,19 @@ module mcsr if (interrupt_entered_i) begin mepc_n = npc_r_i; end - else if (we_i & (addr_i == `RV32_CSR_MEPC_ADDR)) begin + else if (we_i & (addr_i == `VANILLA_CSR_MEPC_ADDR)) begin case (funct3_i) - `RV32_CSRRW_FUN3: begin + `VANILLA_CSRRW_FUN3: begin mepc_n = data_i[2+:pc_width_p]; end - `RV32_CSRRS_FUN3: begin + `VANILLA_CSRRS_FUN3: begin for (integer i = 0; i < pc_width_p; i++) begin mepc_n[i] = data_i[2+i] ? 1'b1 : mepc_r[i]; end end - `RV32_CSRRC_FUN3: begin + `VANILLA_CSRRC_FUN3: begin for (integer i = 0; i < pc_width_p; i++) begin mepc_n[i] = data_i[2+i] ? 1'b0 @@ -274,7 +274,7 @@ module mcsr always_comb begin credit_limit_n = credit_limit_r; - if (we_i & (addr_i == `RV32_CSR_CREDIT_LIMIT_ADDR) & (funct3_i == `RV32_CSRRW_FUN3)) begin + if (we_i & (addr_i == `VANILLA_CSR_CREDIT_LIMIT_ADDR) & (funct3_i == `VANILLA_CSRRW_FUN3)) begin credit_limit_n = data_i[0+:credit_counter_width_p]; end end @@ -286,7 +286,7 @@ module mcsr cfg_pod_r <= cfg_pod_reset_val_i; end else begin - if (we_i && (addr_i == `RV32_CSR_CFG_POD_ADDR) && (funct3_i == `RV32_CSRRW_FUN3)) begin + if (we_i && (addr_i == `VANILLA_CSR_CFG_POD_ADDR) && (funct3_i == `VANILLA_CSRRW_FUN3)) begin cfg_pod_r <= data_i[0+:cfg_pod_width_p]; end end @@ -300,7 +300,7 @@ module mcsr {barrier_src_r, barrier_dest_r} <= '0; end else begin - if (we_i && (addr_i == `RV32_CSR_BARCFG_ADDR) && (funct3_i == `RV32_CSRRW_FUN3)) begin + if (we_i && (addr_i == `VANILLA_CSR_BARCFG_ADDR) && (funct3_i == `VANILLA_CSRRW_FUN3)) begin barrier_src_r <= data_i[0+:barrier_dirs_p]; barrier_dest_r <= data_i[16+:barrier_lg_dirs_lp]; end @@ -317,14 +317,14 @@ module mcsr barrier_data_r <= 1'b0; end else begin - if (we_i && (addr_i == `RV32_CSR_BAR_PI_ADDR)) begin + if (we_i && (addr_i == `VANILLA_CSR_BAR_PI_ADDR)) begin case (funct3_i) - `RV32_CSRRW_FUN3: barrier_data_r <= data_i[0]; - `RV32_CSRRS_FUN3: barrier_data_r <= data_i[0] ? 1'b1 : barrier_data_r; - `RV32_CSRRC_FUN3: barrier_data_r <= data_i[0] ? 1'b0 : barrier_data_r; - `RV32_CSRRWI_FUN3: barrier_data_r <= rs1_i[0]; - `RV32_CSRRSI_FUN3: barrier_data_r <= rs1_i[0] ? 1'b1 : barrier_data_r; - `RV32_CSRRCI_FUN3: barrier_data_r <= rs1_i[0] ? 1'b0 : barrier_data_r; + `VANILLA_CSRRW_FUN3: barrier_data_r <= data_i[0]; + `VANILLA_CSRRS_FUN3: barrier_data_r <= data_i[0] ? 1'b1 : barrier_data_r; + `VANILLA_CSRRC_FUN3: barrier_data_r <= data_i[0] ? 1'b0 : barrier_data_r; + `VANILLA_CSRRWI_FUN3: barrier_data_r <= rs1_i[0]; + `VANILLA_CSRRSI_FUN3: barrier_data_r <= rs1_i[0] ? 1'b1 : barrier_data_r; + `VANILLA_CSRRCI_FUN3: barrier_data_r <= rs1_i[0] ? 1'b0 : barrier_data_r; endcase end else if (barsend_i) begin @@ -340,33 +340,33 @@ module mcsr always_comb begin data_o = '0; case (addr_i) - `RV32_CSR_MSTATUS_ADDR: begin - data_o[`RV32_MSTATUS_MPIE_BIT_IDX] = mstatus_r.mpie; - data_o[`RV32_MSTATUS_MIE_BIT_IDX] = mstatus_r.mie; + `VANILLA_CSR_MSTATUS_ADDR: begin + data_o[`VANILLA_MSTATUS_MPIE_BIT_IDX] = mstatus_r.mpie; + data_o[`VANILLA_MSTATUS_MIE_BIT_IDX] = mstatus_r.mie; end - `RV32_CSR_MIE_ADDR: begin + `VANILLA_CSR_MIE_ADDR: begin data_o[17:16] = mie_r; end - `RV32_CSR_MIP_ADDR: begin + `VANILLA_CSR_MIP_ADDR: begin data_o[17:16] = mip_r; end - `RV32_CSR_MEPC_ADDR: begin + `VANILLA_CSR_MEPC_ADDR: begin data_o[2+:pc_width_p] = mepc_r; end - `RV32_CSR_CREDIT_LIMIT_ADDR: begin + `VANILLA_CSR_CREDIT_LIMIT_ADDR: begin data_o[0+:credit_counter_width_p] = credit_limit_r; end - `RV32_CSR_CFG_POD_ADDR: begin + `VANILLA_CSR_CFG_POD_ADDR: begin data_o[0+:cfg_pod_width_p] = cfg_pod_r; end - `RV32_CSR_BARCFG_ADDR: begin + `VANILLA_CSR_BARCFG_ADDR: begin data_o[0+:barrier_dirs_p] = barrier_src_r; data_o[16+:barrier_lg_dirs_lp] = barrier_dest_r; end - `RV32_CSR_BAR_PO_ADDR: begin + `VANILLA_CSR_BAR_PO_ADDR: begin data_o[0] = barrier_data_i; end - `RV32_CSR_BAR_PI_ADDR: begin + `VANILLA_CSR_BAR_PI_ADDR: begin data_o[0] = barrier_data_r; end diff --git a/v/vanilla_bean/network_tx.v b/v/vanilla_bean/network_tx.v index 385f25f9c..da373dfe0 100644 --- a/v/vanilla_bean/network_tx.v +++ b/v/vanilla_bean/network_tx.v @@ -35,7 +35,7 @@ module network_tx , icache_addr_width_lp=`BSG_SAFE_CLOG2(icache_entries_p) , pc_width_lp=(icache_tag_width_p+icache_addr_width_lp) - , reg_addr_width_lp=RV32_reg_addr_width_gp + , reg_addr_width_lp=reg_addr_width_gp , packet_width_lp= `bsg_manycore_packet_width(addr_width_p,data_width_p,x_cord_width_p,y_cord_width_p) diff --git a/v/vanilla_bean/cl_decode.v b/v/vanilla_bean/riscv_decode.v similarity index 99% rename from v/vanilla_bean/cl_decode.v rename to v/vanilla_bean/riscv_decode.v index 5188edd18..f5f57c0b5 100644 --- a/v/vanilla_bean/cl_decode.v +++ b/v/vanilla_bean/riscv_decode.v @@ -1,6 +1,6 @@ /** * - * cl_decode.v + * riscv_decode.v * * instruction decoder. * @@ -12,8 +12,9 @@ */ `include "bsg_vanilla_defines.vh" +`include "bsg_riscv_defines.vh" -module cl_decode +module riscv_decode import bsg_vanilla_pkg::*; import bsg_manycore_pkg::*; ( diff --git a/v/vanilla_bean/scoreboard.v b/v/vanilla_bean/scoreboard.v index e2d3978a5..df4c2231c 100644 --- a/v/vanilla_bean/scoreboard.v +++ b/v/vanilla_bean/scoreboard.v @@ -5,11 +5,11 @@ * */ -`include "bsg_defines.sv" +`include "bsg_vanilla_defines.v" module scoreboard import bsg_vanilla_pkg::*; - #(els_p = RV32_reg_els_gp + #(els_p = reg_els_gp , `BSG_INV_PARAM(num_src_port_p) , num_clear_port_p=1 , x0_tied_to_zero_p = 0 diff --git a/v/vanilla_bean/vanilla_core.v b/v/vanilla_bean/vanilla_core.v index 6c857ccde..49cca0212 100644 --- a/v/vanilla_bean/vanilla_core.v +++ b/v/vanilla_bean/vanilla_core.v @@ -39,7 +39,7 @@ module vanilla_core , dmem_addr_width_lp=`BSG_SAFE_CLOG2(dmem_size_p) , pc_width_lp=(icache_tag_width_p+`BSG_SAFE_CLOG2(icache_entries_p)) - , reg_addr_width_lp = RV32_reg_addr_width_gp + , reg_addr_width_lp = reg_addr_width_gp , data_mask_width_lp=(data_width_p>>3) , parameter debug_p=0 @@ -217,7 +217,7 @@ module vanilla_core decode_s decode; fp_decode_s fp_decode; - cl_decode decode0 ( + riscv_decode decode0 ( .instruction_i(instruction) ,.decode_o(decode) ,.fp_decode_o(fp_decode) @@ -251,7 +251,7 @@ module vanilla_core regfile #( .width_p(data_width_p) - ,.els_p(RV32_reg_els_gp) + ,.els_p(reg_els_gp) ,.num_rs_p(2) ,.x0_tied_to_zero_p(1) ) int_rf ( @@ -277,7 +277,7 @@ module vanilla_core logic [reg_addr_width_lp-1:0] int_sb_clear_id; scoreboard #( - .els_p(RV32_reg_els_gp) + .els_p(reg_els_gp) ,.num_src_port_p(2) ,.num_clear_port_p(1) ,.x0_tied_to_zero_p(1) @@ -312,7 +312,7 @@ module vanilla_core regfile #( .width_p(fpu_recoded_data_width_gp) - ,.els_p(RV32_reg_els_gp) + ,.els_p(reg_els_gp) ,.num_rs_p(3) ,.x0_tied_to_zero_p(0) ) float_rf ( @@ -338,7 +338,7 @@ module vanilla_core logic [reg_addr_width_lp-1:0] float_sb_clear_id; scoreboard #( - .els_p(RV32_reg_els_gp) + .els_p(reg_els_gp) ,.x0_tied_to_zero_p(0) ,.num_src_port_p(3) ,.num_clear_port_p(1) @@ -480,10 +480,10 @@ module vanilla_core // calculate mem address offset // - wire [RV32_Iimm_width_gp-1:0] mem_addr_op2 = id_r.decode.is_store_op - ? `RV32_Simm_12extract(id_r.instruction) + wire [Iimm_width_gp-1:0] mem_addr_op2 = id_r.decode.is_store_op + ? `Vanilla_Simm_12extract(id_r.instruction) : (id_r.decode.is_load_op - ? `RV32_Iimm_12extract(id_r.instruction) + ? `Vanilla_Iimm_12extract(id_r.instruction) : '0); // 'aq' register @@ -1469,8 +1469,8 @@ module vanilla_core // stall_fcsr assign stall_fcsr = (id_r.decode.is_csr_op) - & ((id_r.instruction[31:20] == `RV32_CSR_FFLAGS_ADDR) - |(id_r.instruction[31:20] == `RV32_CSR_FCSR_ADDR)) + & ((id_r.instruction[31:20] == `VANILLA_CSR_FFLAGS_ADDR) + |(id_r.instruction[31:20] == `VANILLA_CSR_FCSR_ADDR)) & (fp_exe_ctrl_r.fp_decode.is_fpu_float_op |fp_exe_ctrl_r.fp_decode.is_fpu_int_op |fp_exe_ctrl_r.fp_decode.is_fdiv_op From 3a13c64a4722a6fbda17f2f558aabb9d9252e36b Mon Sep 17 00:00:00 2001 From: Prateek Mahajan Date: Thu, 23 Nov 2023 13:25:48 -0800 Subject: [PATCH 2/9] Building on Second Round of Changes Post Testing --- testbenches/common/v/nb_waw_detector.v | 6 +-- testbenches/common/v/remote_load_trace.v | 16 ++++---- .../common/v/vanilla_core_pc_histogram.v | 6 +-- testbenches/common/v/vanilla_core_profiler.v | 6 +-- testbenches/common/v/vanilla_core_trace.v | 40 +++++++++---------- .../common/v/vanilla_exe_bubble_classifier.v | 10 ++--- .../common/v/vanilla_scoreboard_tracker.v | 18 ++++----- .../fpu_fdiv_fsqrt/test_fpu_fdiv_fsqrt.v | 2 +- v/vanilla_bean/bsg_manycore_proc_vanilla.v | 2 +- v/vanilla_bean/bsg_riscv_defines.vh | 2 +- v/vanilla_bean/bsg_vanilla_defines.vh | 2 +- .../{riscv_decode.v => cl_decode.v} | 4 +- v/vanilla_bean/fpu_float.v | 2 +- v/vanilla_bean/fpu_float_aux.v | 2 +- v/vanilla_bean/fpu_int.v | 2 +- v/vanilla_bean/idiv.v | 2 +- v/vanilla_bean/load_packer.v | 2 +- v/vanilla_bean/lsu.v | 2 +- v/vanilla_bean/scoreboard.v | 2 +- v/vanilla_bean/vanilla_core.v | 2 +- 20 files changed, 65 insertions(+), 65 deletions(-) rename v/vanilla_bean/{riscv_decode.v => cl_decode.v} (99%) diff --git a/testbenches/common/v/nb_waw_detector.v b/testbenches/common/v/nb_waw_detector.v index 9f1c6ea67..bcf67c09d 100644 --- a/testbenches/common/v/nb_waw_detector.v +++ b/testbenches/common/v/nb_waw_detector.v @@ -4,8 +4,8 @@ module nb_waw_detector , parameter x_cord_width_p="inv" , parameter y_cord_width_p="inv" - , parameter reg_els_lp=RV32_reg_els_gp - , parameter instr_width_lp=RV32_instr_width_gp + , parameter reg_els_lp=reg_els_gp + , parameter instr_width_lp=instr_width_gp ) ( input clk_i @@ -18,7 +18,7 @@ module nb_waw_detector , input int_remote_load_resp_v_i , input int_remote_load_resp_force_i - , input [RV32_reg_addr_width_gp-1:0] int_remote_load_resp_rd_i + , input [reg_addr_width_gp-1:0] int_remote_load_resp_rd_i , input mem_signals_s mem_r , input wb_signals_s wb_r diff --git a/testbenches/common/v/remote_load_trace.v b/testbenches/common/v/remote_load_trace.v index 16de812a1..cd8e669b5 100644 --- a/testbenches/common/v/remote_load_trace.v +++ b/testbenches/common/v/remote_load_trace.v @@ -55,7 +55,7 @@ module remote_load_trace // Load response coming back , input returned_v_i - , input [RV32_reg_addr_width_gp-1:0] returned_reg_id_i + , input [reg_addr_width_gp-1:0] returned_reg_id_i , input bsg_manycore_return_packet_type_e returned_pkt_type_i , input returned_yumi_o @@ -95,8 +95,8 @@ module remote_load_trace } remote_load_status_s; - remote_load_status_s [RV32_reg_els_gp-1:0] int_rl_status_r; - remote_load_status_s [RV32_reg_els_gp-1:0] float_rl_status_r; + remote_load_status_s [reg_els_gp-1:0] int_rl_status_r; + remote_load_status_s [reg_els_gp-1:0] float_rl_status_r; remote_load_status_s icache_status_r; wire int_rl_v = out_v_o & ( @@ -112,11 +112,11 @@ module remote_load_trace wire icache_rl_v = out_v_o & ( (out_packet.op_v2 == e_remote_load) & load_info.icache_fetch); - logic [RV32_reg_els_gp-1:0] int_rl_we; - logic [RV32_reg_els_gp-1:0] float_rl_we; + logic [reg_els_gp-1:0] int_rl_we; + logic [reg_els_gp-1:0] float_rl_we; bsg_decode_with_v #( - .num_out_p(RV32_reg_els_gp) + .num_out_p(reg_els_gp) ) dv0 ( .i(out_packet.reg_id) ,.v_i(int_rl_v) @@ -124,7 +124,7 @@ module remote_load_trace ); bsg_decode_with_v #( - .num_out_p(RV32_reg_els_gp) + .num_out_p(reg_els_gp) ) dv1 ( .i(out_packet.reg_id) ,.v_i(float_rl_v) @@ -148,7 +148,7 @@ module remote_load_trace end else begin - for (integer i = 0 ; i < RV32_reg_els_gp; i++) begin + for (integer i = 0 ; i < reg_els_gp; i++) begin if (int_rl_we[i]) int_rl_status_r[i] <= next_rl; if (float_rl_we[i]) diff --git a/testbenches/common/v/vanilla_core_pc_histogram.v b/testbenches/common/v/vanilla_core_pc_histogram.v index 2c3269e6e..87447b65d 100644 --- a/testbenches/common/v/vanilla_core_pc_histogram.v +++ b/testbenches/common/v/vanilla_core_pc_histogram.v @@ -15,8 +15,8 @@ module vanilla_core_pc_histogram ,parameter `BSG_INV_PARAM(origin_y_cord_p) ,parameter icache_addr_width_lp=`BSG_SAFE_CLOG2(icache_entries_p) ,parameter pc_width_lp=(icache_tag_width_p+icache_addr_width_lp) - ,parameter reg_els_lp=RV32_reg_els_gp - ,parameter reg_addr_width_lp=RV32_reg_addr_width_gp + ,parameter reg_els_lp=reg_els_gp + ,parameter reg_addr_width_lp=reg_addr_width_gp ) ( input clk_i @@ -61,7 +61,7 @@ module vanilla_core_pc_histogram , input jalr_mispredict , input [data_width_p-1:0] rs1_val_to_exe - , input [RV32_Iimm_width_gp-1:0] mem_addr_op2 + , input [Iimm_width_gp-1:0] mem_addr_op2 , input int_sb_clear , input float_sb_clear diff --git a/testbenches/common/v/vanilla_core_profiler.v b/testbenches/common/v/vanilla_core_profiler.v index 2f3af3016..5129571e0 100644 --- a/testbenches/common/v/vanilla_core_profiler.v +++ b/testbenches/common/v/vanilla_core_profiler.v @@ -32,8 +32,8 @@ module vanilla_core_profiler , parameter icache_addr_width_lp=`BSG_SAFE_CLOG2(icache_entries_p) , parameter pc_width_lp=(icache_tag_width_p+icache_addr_width_lp) - , parameter reg_els_lp = RV32_reg_els_gp - , parameter reg_addr_width_lp = RV32_reg_addr_width_gp + , parameter reg_els_lp = reg_els_gp + , parameter reg_addr_width_lp = reg_addr_width_gp ) ( input clk_i @@ -79,7 +79,7 @@ module vanilla_core_profiler , input remote_req_s remote_req_o , input [data_width_p-1:0] rs1_val_to_exe - , input [RV32_Iimm_width_gp-1:0] mem_addr_op2 + , input [Iimm_width_gp-1:0] mem_addr_op2 , input int_sb_clear , input float_sb_clear diff --git a/testbenches/common/v/vanilla_core_trace.v b/testbenches/common/v/vanilla_core_trace.v index b6a4e0c89..6cc961784 100644 --- a/testbenches/common/v/vanilla_core_trace.v +++ b/testbenches/common/v/vanilla_core_trace.v @@ -13,7 +13,7 @@ module vanilla_core_trace , localparam icache_addr_width_lp=`BSG_SAFE_CLOG2(icache_entries_p) , localparam dmem_addr_width_lp=`BSG_SAFE_CLOG2(dmem_size_p) , localparam pc_width_lp=(icache_tag_width_p+icache_addr_width_lp) - , localparam reg_addr_width_lp=RV32_reg_addr_width_gp + , localparam reg_addr_width_lp=reg_addr_width_gp ) ( @@ -56,52 +56,52 @@ module vanilla_core_trace typedef struct packed { - logic [RV32_reg_data_width_gp-1:0] pc; - logic [RV32_instr_width_gp-1:0] instr; + logic [reg_data_width_gp-1:0] pc; + logic [instr_width_gp-1:0] instr; logic branch_or_jump; - logic [RV32_instr_width_gp-1:0] btarget; + logic [instr_width_gp-1:0] btarget; logic is_local_load; logic is_local_store; logic [dmem_addr_width_lp-1:0] local_dmem_addr; - logic [RV32_reg_data_width_gp-1:0] local_store_data; + logic [reg_data_width_gp-1:0] local_store_data; logic is_remote_load; logic is_remote_store; - logic [RV32_reg_data_width_gp-1:0] remote_addr; - logic [RV32_reg_data_width_gp-1:0] remote_store_data; + logic [reg_data_width_gp-1:0] remote_addr; + logic [reg_data_width_gp-1:0] remote_store_data; } exe_debug_s; typedef struct packed { - logic [RV32_reg_data_width_gp-1:0] pc; - logic [RV32_instr_width_gp-1:0] instr; + logic [reg_data_width_gp-1:0] pc; + logic [instr_width_gp-1:0] instr; logic branch_or_jump; - logic [RV32_instr_width_gp-1:0] btarget; + logic [instr_width_gp-1:0] btarget; logic is_local_load; logic is_local_store; logic [dmem_addr_width_lp-1:0] local_dmem_addr; - logic [RV32_reg_data_width_gp-1:0] local_store_data; + logic [reg_data_width_gp-1:0] local_store_data; logic is_remote_load; logic is_remote_store; - logic [RV32_reg_data_width_gp-1:0] remote_addr; - logic [RV32_reg_data_width_gp-1:0] remote_store_data; + logic [reg_data_width_gp-1:0] remote_addr; + logic [reg_data_width_gp-1:0] remote_store_data; } mem_debug_s; typedef struct packed { - logic [RV32_reg_data_width_gp-1:0] pc; - logic [RV32_instr_width_gp-1:0] instr; + logic [reg_data_width_gp-1:0] pc; + logic [instr_width_gp-1:0] instr; logic branch_or_jump; - logic [RV32_instr_width_gp-1:0] btarget; + logic [instr_width_gp-1:0] btarget; logic is_local_load; logic is_local_store; logic [dmem_addr_width_lp-1:0] local_dmem_addr; - logic [RV32_reg_data_width_gp-1:0] local_load_data; - logic [RV32_reg_data_width_gp-1:0] local_store_data; + logic [reg_data_width_gp-1:0] local_load_data; + logic [reg_data_width_gp-1:0] local_store_data; logic is_remote_load; logic is_remote_store; - logic [RV32_reg_data_width_gp-1:0] remote_addr; - logic [RV32_reg_data_width_gp-1:0] remote_store_data; + logic [reg_data_width_gp-1:0] remote_addr; + logic [reg_data_width_gp-1:0] remote_store_data; } wb_debug_s; exe_debug_s exe_debug; diff --git a/testbenches/common/v/vanilla_exe_bubble_classifier.v b/testbenches/common/v/vanilla_exe_bubble_classifier.v index e9a29344d..4fcba4f38 100644 --- a/testbenches/common/v/vanilla_exe_bubble_classifier.v +++ b/testbenches/common/v/vanilla_exe_bubble_classifier.v @@ -45,12 +45,12 @@ module vanilla_exe_bubble_classifier ,input jalr_mispredict ,input [data_width_p-1:0] rs1_val_to_exe - ,input [RV32_Iimm_width_gp-1:0] mem_addr_op2 + ,input [Iimm_width_gp-1:0] mem_addr_op2 ,input int_sb_clear ,input float_sb_clear - ,input [RV32_reg_addr_width_gp-1:0] int_sb_clear_id - ,input [RV32_reg_addr_width_gp-1:0] float_sb_clear_id + ,input [reg_addr_width_gp-1:0] int_sb_clear_id + ,input [reg_addr_width_gp-1:0] float_sb_clear_id ,input id_signals_s id_r ,input exe_signals_s exe_r @@ -122,8 +122,8 @@ module vanilla_exe_bubble_classifier exe_bubble_type_e exe_bubble_r; logic [data_width_p-1:0] exe_bubble_pc_r; - vanilla_isb_info_s [RV32_reg_els_gp-1:0] int_sb; - vanilla_fsb_info_s [RV32_reg_els_gp-1:0] float_sb; + vanilla_isb_info_s [reg_els_gp-1:0] int_sb; + vanilla_fsb_info_s [reg_els_gp-1:0] float_sb; logic is_id_seq_lw, is_id_seq_flw; vanilla_scoreboard_tracker diff --git a/testbenches/common/v/vanilla_scoreboard_tracker.v b/testbenches/common/v/vanilla_scoreboard_tracker.v index 366f0779e..fc5e623ff 100644 --- a/testbenches/common/v/vanilla_scoreboard_tracker.v +++ b/testbenches/common/v/vanilla_scoreboard_tracker.v @@ -5,7 +5,7 @@ module vanilla_scoreboard_tracker import bsg_vanilla_pkg::*; import vanilla_scoreboard_tracker_pkg::*; #(parameter `BSG_INV_PARAM(data_width_p) - ,parameter reg_addr_width_lp=RV32_reg_addr_width_gp + ,parameter reg_addr_width_lp=reg_addr_width_gp ) (input clk_i ,input reset_i @@ -15,7 +15,7 @@ module vanilla_scoreboard_tracker ,input stall_id ,input [data_width_p-1:0] rs1_val_to_exe - ,input [RV32_Iimm_width_gp-1:0] mem_addr_op2 + ,input [Iimm_width_gp-1:0] mem_addr_op2 ,input int_sb_clear ,input float_sb_clear @@ -29,8 +29,8 @@ module vanilla_scoreboard_tracker ,input instruction_s instruction ,input decode_s decode - ,output vanilla_isb_info_s [RV32_reg_els_gp-1:0] int_sb_o - ,output vanilla_fsb_info_s [RV32_reg_els_gp-1:0] float_sb_o + ,output vanilla_isb_info_s [reg_els_gp-1:0] int_sb_o + ,output vanilla_fsb_info_s [reg_els_gp-1:0] float_sb_o // is the load in ID sequential load? ,output logic is_id_seq_lw_o ,output logic is_id_seq_flw_o @@ -40,7 +40,7 @@ module vanilla_scoreboard_tracker wire [reg_addr_width_lp-1:0] id_rs1 = id_r.instruction.rs1; wire [reg_addr_width_lp-1:0] id_rd = id_r.instruction.rd; wire [9:0] id_imm_plus4 = 1'b1 + mem_addr_op2[11:2]; - wire [11:0] if_load_imm = `RV32_Iimm_12extract(instruction); + wire [11:0] if_load_imm = `Vanilla_Iimm_12extract(instruction); wire is_seq_lw = id_r.decode.is_load_op & decode.is_load_op & id_r.decode.write_rd & decode.write_rd @@ -71,8 +71,8 @@ module vanilla_scoreboard_tracker // remote/local scoreboard tracking - vanilla_isb_info_s [RV32_reg_els_gp-1:0] int_sb_r; - vanilla_fsb_info_s [RV32_reg_els_gp-1:0] float_sb_r; + vanilla_isb_info_s [reg_els_gp-1:0] int_sb_r; + vanilla_fsb_info_s [reg_els_gp-1:0] float_sb_r; always_ff @ (posedge clk_i) begin if (reset_i) begin @@ -82,7 +82,7 @@ module vanilla_scoreboard_tracker else begin // int sb - for (integer i = 0; i < RV32_reg_els_gp; i++) begin + for (integer i = 0; i < reg_els_gp; i++) begin // idiv if (~stall_id & ~stall_all & ~flush & id_r.decode.is_idiv_op & (id_rd == i)) begin int_sb_r[i].idiv <= 1'b1; @@ -128,7 +128,7 @@ module vanilla_scoreboard_tracker end // float sb - for (integer i = 0; i < RV32_reg_els_gp; i++) begin + for (integer i = 0; i < reg_els_gp; i++) begin // fdiv, fsqrt if (~stall_id & ~stall_all & ~flush & (id_r.decode.is_fp_op & (id_r.fp_decode.is_fdiv_op | id_r.fp_decode.is_fsqrt_op)) & (id_rd == i)) begin float_sb_r[i].fdiv_fsqrt <= 1'b1; diff --git a/testbenches/hardfloat/fpu_fdiv_fsqrt/test_fpu_fdiv_fsqrt.v b/testbenches/hardfloat/fpu_fdiv_fsqrt/test_fpu_fdiv_fsqrt.v index 366f27145..972a035a4 100644 --- a/testbenches/hardfloat/fpu_fdiv_fsqrt/test_fpu_fdiv_fsqrt.v +++ b/testbenches/hardfloat/fpu_fdiv_fsqrt/test_fpu_fdiv_fsqrt.v @@ -4,7 +4,7 @@ module test_fpu_fdiv_fsqrt import bsg_vanilla_pkg::*; - #(parameter expWidth = 8, parameter sigWidth = 24, parameter bits_per_iter_p = 1, parameter reg_addr_width_p = RV32_reg_addr_width_gp); + #(parameter expWidth = 8, parameter sigWidth = 24, parameter bits_per_iter_p = 1, parameter reg_addr_width_p = reg_addr_width_gp); parameter maxNumErrors = 20; diff --git a/v/vanilla_bean/bsg_manycore_proc_vanilla.v b/v/vanilla_bean/bsg_manycore_proc_vanilla.v index 162251c33..e9e259c5f 100644 --- a/v/vanilla_bean/bsg_manycore_proc_vanilla.v +++ b/v/vanilla_bean/bsg_manycore_proc_vanilla.v @@ -43,7 +43,7 @@ module bsg_manycore_proc_vanilla , dmem_addr_width_lp = `BSG_SAFE_CLOG2(dmem_size_p) , pc_width_lp=(icache_addr_width_lp+icache_tag_width_p) , data_mask_width_lp=(data_width_p>>3) - , reg_addr_width_lp=VANILLA_reg_addr_width_gp + , reg_addr_width_lp=reg_addr_width_gp , parameter `BSG_INV_PARAM(barrier_dirs_p) , localparam barrier_lg_dirs_lp=`BSG_SAFE_CLOG2(barrier_dirs_p+1) diff --git a/v/vanilla_bean/bsg_riscv_defines.vh b/v/vanilla_bean/bsg_riscv_defines.vh index a97dc7f79..85df2d073 100644 --- a/v/vanilla_bean/bsg_riscv_defines.vh +++ b/v/vanilla_bean/bsg_riscv_defines.vh @@ -9,7 +9,7 @@ * */ -`include "bsg_vanilla_defines.v" +`include "bsg_vanilla_defines.vh" `define RV32_MSTATUS_MIE_BIT_IDX 3 `define RV32_MSTATUS_MPIE_BIT_IDX 7 diff --git a/v/vanilla_bean/bsg_vanilla_defines.vh b/v/vanilla_bean/bsg_vanilla_defines.vh index 4d08c20b7..3b5525b15 100644 --- a/v/vanilla_bean/bsg_vanilla_defines.vh +++ b/v/vanilla_bean/bsg_vanilla_defines.vh @@ -9,7 +9,7 @@ * */ -`include "bsg_defines.v" +`include "bsg_defines.sv" `define declare_icache_format_s(tag_width_mp, block_size_in_words_mp) \ typedef struct packed { \ diff --git a/v/vanilla_bean/riscv_decode.v b/v/vanilla_bean/cl_decode.v similarity index 99% rename from v/vanilla_bean/riscv_decode.v rename to v/vanilla_bean/cl_decode.v index f5f57c0b5..7bf860c72 100644 --- a/v/vanilla_bean/riscv_decode.v +++ b/v/vanilla_bean/cl_decode.v @@ -1,6 +1,6 @@ /** * - * riscv_decode.v + * cl_decode.v * * instruction decoder. * @@ -14,7 +14,7 @@ `include "bsg_vanilla_defines.vh" `include "bsg_riscv_defines.vh" -module riscv_decode +module cl_decode import bsg_vanilla_pkg::*; import bsg_manycore_pkg::*; ( diff --git a/v/vanilla_bean/fpu_float.v b/v/vanilla_bean/fpu_float.v index 94ab73f70..96f0626b9 100644 --- a/v/vanilla_bean/fpu_float.v +++ b/v/vanilla_bean/fpu_float.v @@ -9,7 +9,7 @@ * Other float operations becomes available in the second stage. */ -`include "bsg_defines.v" +`include "bsg_defines.sv" module fpu_float import bsg_vanilla_pkg::*; diff --git a/v/vanilla_bean/fpu_float_aux.v b/v/vanilla_bean/fpu_float_aux.v index 50fecb17f..bb893adeb 100644 --- a/v/vanilla_bean/fpu_float_aux.v +++ b/v/vanilla_bean/fpu_float_aux.v @@ -3,7 +3,7 @@ * */ -`include "bsg_defines.v" +`include "bsg_defines.sv" `include "HardFloat_consts.vi" `include "HardFloat_specialize.vi" diff --git a/v/vanilla_bean/fpu_int.v b/v/vanilla_bean/fpu_int.v index 6900343ef..0ad5e9232 100644 --- a/v/vanilla_bean/fpu_int.v +++ b/v/vanilla_bean/fpu_int.v @@ -8,7 +8,7 @@ * - F2I, FMV */ -`include "bsg_defines.v" +`include "bsg_defines.sv" `include "HardFloat_consts.vi" `include "HardFloat_specialize.vi" diff --git a/v/vanilla_bean/idiv.v b/v/vanilla_bean/idiv.v index 6acef4569..1e9d6c45a 100644 --- a/v/vanilla_bean/idiv.v +++ b/v/vanilla_bean/idiv.v @@ -5,7 +5,7 @@ * */ -`include "bsg_defines.v" +`include "bsg_defines.sv" module idiv import bsg_vanilla_pkg::*; diff --git a/v/vanilla_bean/load_packer.v b/v/vanilla_bean/load_packer.v index 6a7c7829f..221f04dd6 100644 --- a/v/vanilla_bean/load_packer.v +++ b/v/vanilla_bean/load_packer.v @@ -3,7 +3,7 @@ * */ -`include "bsg_defines.v" +`include "bsg_defines.sv" module load_packer import bsg_vanilla_pkg::*; diff --git a/v/vanilla_bean/lsu.v b/v/vanilla_bean/lsu.v index 508e253b1..939dfc38c 100644 --- a/v/vanilla_bean/lsu.v +++ b/v/vanilla_bean/lsu.v @@ -8,7 +8,7 @@ * */ -`include "bsg_defines.v" +`include "bsg_defines.sv" module lsu diff --git a/v/vanilla_bean/scoreboard.v b/v/vanilla_bean/scoreboard.v index df4c2231c..e7aa0d0bb 100644 --- a/v/vanilla_bean/scoreboard.v +++ b/v/vanilla_bean/scoreboard.v @@ -5,7 +5,7 @@ * */ -`include "bsg_vanilla_defines.v" +`include "bsg_defines.sv" module scoreboard import bsg_vanilla_pkg::*; diff --git a/v/vanilla_bean/vanilla_core.v b/v/vanilla_bean/vanilla_core.v index 49cca0212..847921e82 100644 --- a/v/vanilla_bean/vanilla_core.v +++ b/v/vanilla_bean/vanilla_core.v @@ -217,7 +217,7 @@ module vanilla_core decode_s decode; fp_decode_s fp_decode; - riscv_decode decode0 ( + cl_decode decode0 ( .instruction_i(instruction) ,.decode_o(decode) ,.fp_decode_o(fp_decode) From 66a141d750a60bb6670c5a7ac02e87eaa53bc47d Mon Sep 17 00:00:00 2001 From: Prateek Mahajan Date: Fri, 8 Dec 2023 16:48:17 -0800 Subject: [PATCH 3/9] Adding Manycore defines and Makefile changes for different ISAs allowed : Testing still pending --- .../bsg_manycore_instruction_defines.vh | 154 ++++++++++++ v/vanilla_bean/bsg_riscv_defines.vh | 223 ------------------ 2 files changed, 154 insertions(+), 223 deletions(-) create mode 100644 v/vanilla_bean/bsg_manycore_instruction_defines.vh delete mode 100644 v/vanilla_bean/bsg_riscv_defines.vh diff --git a/v/vanilla_bean/bsg_manycore_instruction_defines.vh b/v/vanilla_bean/bsg_manycore_instruction_defines.vh new file mode 100644 index 000000000..848a753bf --- /dev/null +++ b/v/vanilla_bean/bsg_manycore_instruction_defines.vh @@ -0,0 +1,154 @@ +`ifndef BSG_VANILLA_DEFINES_VH +`define BSG_VANILLA_DEFINES_VH + +/** + * bsg_manycore_instructions_defines.vh + * + * This file defines the macros + * used throughout the vanilla core. (Outside the decoder) + * + */ + +`include "bsg_defines.sv" + +`define declare_icache_format_s(tag_width_mp, block_size_in_words_mp) \ + typedef struct packed { \ + logic [block_size_in_words_mp-1:0] lower_cout; \ + logic [block_size_in_words_mp-1:0] lower_sign; \ + logic [tag_width_mp-1:0] tag; \ + instruction_s [block_size_in_words_mp-1:0] instr; \ + } icache_format_s + +`define icache_format_width(tag_width_mp, block_size_in_words_mp) \ + ((2*block_size_in_words_mp)+tag_width_mp+(block_size_in_words_mp*$bits(instruction_s))) + +// FPU recoded Constants +`define FPU_RECODED_ONE 33'h080000000 +`define FPU_RECODED_ZERO 33'h0 +`define FPU_RECODED_CANONICAL_NAN 33'h0e0400000 + +`define REMOTE_INTERRUPT_JUMP_ADDR 0 // remote interrupt jump addr (word addr) +`define TRACE_INTERRUPT_JUMP_ADDR 1 // trace interrupt jump addr (word addr) + +// 32M Instruction Encodings +`define MD_MUL_FUN3 3'b000 +`define MD_MULH_FUN3 3'b001 +`define MD_MULHSU_FUN3 3'b010 +`define MD_MULHU_FUN3 3'b011 +`define MD_DIV_FUN3 3'b100 +`define MD_DIVU_FUN3 3'b101 +`define MD_REM_FUN3 3'b110 +`define MD_REMU_FUN3 3'b111 + +// Generic Many Core Opcodes +`define MANYCORE_LOAD 7'b1111100 +`define MANYCORE_STORE 7'b1011100 + +`define MANYCORE_BRANCH 7'b001110? + +`define MANYCORE_JALR_OP 7'b0011000 +`define MANYCORE_MISC_MEM 7'b1110000 +`define MANYCORE_AMO_OP 7'b1010000 +`define MANYCORE_JAL_OP 7'b0010000 +`define MANYCORE_OP_IMM 7'b1101100 +`define MANYCORE_OP 7'b1001100 +`define MANYCORE_SYSTEM 7'b0001100 +`define MANYCORE_AUIPC_OP 7'b1101000 +`define MANYCORE_LUI_OP 7'b1001000 + +// Some useful ManyCore instruction macros +`define MANYCORE_Rtype(op, funct3, funct7) {``funct7``, {5{1'b?}}, {5{1'b?}},``funct3``, {5{1'b?}},``op``} +`define MANYCORE_Itype(op, funct3) {{12{1'b?}},{5{1'b?}},``funct3``,{5{1'b?}},``op``} +`define MANYCORE_Stype(op, funct3) {{7{1'b?}},{5{1'b?}},{5{1'b?}},``funct3``,{5{1'b?}},``op``} +`define MANYCORE_Utype(op) {{20{1'b?}},{5{1'b?}},``op``} + +// ManyCore Immediate sign extension macros +`define MANYCORE_signext_Iimm(instr) {{21{``instr``[31]}},``instr``[30:20]} +`define MANYCORE_signext_Simm(instr) {{21{``instr``[31]}},``instr[30:25],``instr``[11:7]} +`define MANYCORE_signext_Bimm(instr) {{20{``instr``[31]}},``instr``[7],``instr``[30:25],``instr``[11:8], {1'b0}} +`define MANYCORE_signext_Uimm(instr) {``instr``[31:12], {12{1'b0}}} +`define MANYCORE_signext_Jimm(instr) {{12{``instr``[31]}},``instr``[19:12],``instr``[20],``instr``[30:21], {1'b0}} + +`define MANYCORE_Bimm_12inject1(instr,value) {``value``[12], ``value``[10:5], ``instr``[24:12],\ + ``value``[4:1],``value``[11],``instr``[6:0]} +`define MANYCORE_Jimm_20inject1(instr,value) {``value``[20], ``value``[10:1], ``value``[11],``value``[19:12], ``instr``[11:0]} + +// Both JAL and BRANCH use 2-byte address, we need to pad 1'b0 at MSB to get +// the real byte address +`define MANYCORE_Bimm_13extract(instr) {``instr``[31], ``instr``[7], ``instr``[30:25], ``instr``[11:8], 1'b0} +`define MANYCORE_Jimm_21extract(instr) {``instr``[31], ``instr``[19:12],``instr``[20],``instr``[30:21], 1'b0} + +`define MANYCORE_Iimm_12extract(instr) {``instr``[31:20]} +`define MANYCORE_Simm_12extract(instr) {``instr[31:25],``instr``[11:7]} + +// Manycore Instruction encodings +// We have to delete the white space in macro definition, +// otherwise Design Compiler would issue warings. +`define MANYCORE_LUI `MANYCORE_Utype(`MANYCORE_LUI_OP) +`define MANYCORE_AUIPC `MANYCORE_Utype(`MANYCORE_AUIPC_OP) +`define MANYCORE_JAL `MANYCORE_Utype(`MANYCORE_JAL_OP) +`define MANYCORE_JALR `MANYCORE_Itype(`MANYCORE_JALR_OP, 3'b000) +`define MANYCORE_BEQ `MANYCORE_Stype(`MANYCORE_BRANCH, 3'b000) +`define MANYCORE_BNE `MANYCORE_Stype(`MANYCORE_BRANCH, 3'b001) +`define MANYCORE_BLT `MANYCORE_Stype(`MANYCORE_BRANCH, 3'b100) +`define MANYCORE_BGE `MANYCORE_Stype(`MANYCORE_BRANCH, 3'b101) +`define MANYCORE_BLTU `MANYCORE_Stype(`MANYCORE_BRANCH, 3'b110) +`define MANYCORE_BGEU `MANYCORE_Stype(`MANYCORE_BRANCH, 3'b111) +`define MANYCORE_LB `MANYCORE_Itype(`MANYCORE_LOAD, 3'b000) +`define MANYCORE_LH `MANYCORE_Itype(`MANYCORE_LOAD, 3'b001) +`define MANYCORE_LW `MANYCORE_Itype(`MANYCORE_LOAD, 3'b010) +`define MANYCORE_LBU `MANYCORE_Itype(`MANYCORE_LOAD, 3'b100) +`define MANYCORE_LHU `MANYCORE_Itype(`MANYCORE_LOAD, 3'b101) +`define MANYCORE_SB `MANYCORE_Stype(`MANYCORE_STORE, 3'b000) +`define MANYCORE_SH `MANYCORE_Stype(`MANYCORE_STORE, 3'b001) +`define MANYCORE_SW `MANYCORE_Stype(`MANYCORE_STORE, 3'b010) +`define MANYCORE_ADDI `MANYCORE_Itype(`MANYCORE_OP_IMM,3'b000) +`define MANYCORE_SLTI `MANYCORE_Itype(`MANYCORE_OP_IMM, 3'b010) +`define MANYCORE_SLTIU `MANYCORE_Itype(`MANYCORE_OP_IMM, 3'b011) +`define MANYCORE_XORI `MANYCORE_Itype(`MANYCORE_OP_IMM, 3'b100) +`define MANYCORE_ORI `MANYCORE_Itype(`MANYCORE_OP_IMM, 3'b110) +`define MANYCORE_ANDI `MANYCORE_Itype(`MANYCORE_OP_IMM, 3'b111) +`define MANYCORE_SLLI `MANYCORE_Rtype(`MANYCORE_OP_IMM, 3'b001, 7'b0000000) +`define MANYCORE_SRLI `MANYCORE_Rtype(`MANYCORE_OP_IMM, 3'b101, 7'b0000000) +`define MANYCORE_SRAI `MANYCORE_Rtype(`MANYCORE_OP_IMM, 3'b101, 7'b0100000) +`define MANYCORE_ADD `MANYCORE_Rtype(`MANYCORE_OP,3'b000,7'b0000000) +`define MANYCORE_SUB `MANYCORE_Rtype(`MANYCORE_OP, 3'b000, 7'b0100000) +`define MANYCORE_SLL `MANYCORE_Rtype(`MANYCORE_OP, 3'b001, 7'b0000000) +`define MANYCORE_SLT `MANYCORE_Rtype(`MANYCORE_OP, 3'b010, 7'b0000000) +`define MANYCORE_SLTU `MANYCORE_Rtype(`MANYCORE_OP, 3'b011, 7'b0000000) +`define MANYCORE_XOR `MANYCORE_Rtype(`MANYCORE_OP, 3'b100, 7'b0000000) +`define MANYCORE_SRL `MANYCORE_Rtype(`MANYCORE_OP, 3'b101, 7'b0000000) +`define MANYCORE_SRA `MANYCORE_Rtype(`MANYCORE_OP, 3'b101, 7'b0100000) +`define MANYCORE_OR `MANYCORE_Rtype(`MANYCORE_OP, 3'b110, 7'b0000000) +`define MANYCORE_AND `MANYCORE_Rtype(`MANYCORE_OP, 3'b111, 7'b0000000) + +// CSR encoding +`define MANYCORE_CSRRW_FUN3 3'b001 +`define MANYCORE_CSRRS_FUN3 3'b010 +`define MANYCORE_CSRRC_FUN3 3'b011 +`define MANYCORE_CSRRWI_FUN3 3'b101 +`define MANYCORE_CSRRSI_FUN3 3'b110 +`define MANYCORE_CSRRCI_FUN3 3'b111 + +`define MANYCORE_CSRRW `MANYCORE_Itype(`MANYCORE_SYSTEM, `MANYCORE_CSRRW_FUN3) +`define MANYCORE_CSRRS `MANYCORE_Itype(`MANYCORE_SYSTEM, `MANYCORE_CSRRS_FUN3) +`define MANYCORE_CSRRC `MANYCORE_Itype(`MANYCORE_SYSTEM, `MANYCORE_CSRRC_FUN3) +`define MANYCORE_CSRRWI `MANYCORE_Itype(`MANYCORE_SYSTEM, `MANYCORE_CSRRWI_FUN3) +`define MANYCORE_CSRRSI `MANYCORE_Itype(`MANYCORE_SYSTEM, `MANYCORE_CSRRSI_FUN3) +`define MANYCORE_CSRRCI `MANYCORE_Itype(`MANYCORE_SYSTEM, `MANYCORE_CSRRCI_FUN3) + +// fcsr CSR addr +`define MANYCORE_CSR_FFLAGS_ADDR 12'h001 +`define MANYCORE_CSR_FRM_ADDR 12'h002 +`define MANYCORE_CSR_FCSR_ADDR 12'h003 +// machine CSR addr +`define VANILLA_CSR_CFG_POD_ADDR 12'h360 + +// machine custom CSR addr +`define MANYCORE_CSR_CREDIT_LIMIT_ADDR 12'hfc0 +`define MANYCORE_CSR_BARCFG_ADDR 12'hfc1 +`define MANYCORE_CSR_BAR_PI_ADDR 12'hfc2 +`define MANYCORE_CSR_BAR_PO_ADDR 12'hfc3 + +`endif + diff --git a/v/vanilla_bean/bsg_riscv_defines.vh b/v/vanilla_bean/bsg_riscv_defines.vh deleted file mode 100644 index 85df2d073..000000000 --- a/v/vanilla_bean/bsg_riscv_defines.vh +++ /dev/null @@ -1,223 +0,0 @@ -`ifndef BSG_RISCV_DEFINES_VH -`define BSG_RISCV_DEFINES_VH - -/** - * bsg_riscv_defines.vh - * - * This file defines the macros - * used for riscv operations throughout the vanilla core. - * - */ - -`include "bsg_vanilla_defines.vh" - -`define RV32_MSTATUS_MIE_BIT_IDX 3 -`define RV32_MSTATUS_MPIE_BIT_IDX 7 - -// RV32 Opcodes -`define RV32_LOAD 7'b0000011 -`define RV32_STORE 7'b0100011 - -// we have branch instructions ignore the low bit so that we can place the prediction bit there. -// RISC-V by default has the low bits set to 11 in the icache, so we can use those creatively. -// note this relies on all code using ==? and casez. -`define RV32_BRANCH 7'b110001? - -`define RV32_JALR_OP 7'b1100111 -`define RV32_MISC_MEM 7'b0001111 -`define RV32_AMO_OP 7'b0101111 -`define RV32_JAL_OP 7'b1101111 -`define RV32_OP_IMM 7'b0010011 -`define RV32_OP 7'b0110011 -`define RV32_SYSTEM 7'b1110011 -`define RV32_AUIPC_OP 7'b0010111 -`define RV32_LUI_OP 7'b0110111 - - -// Some useful RV32 instruction macros -`define RV32_Rtype(op, funct3, funct7) {``funct7``, {5{1'b?}}, {5{1'b?}},``funct3``, {5{1'b?}},``op``} -`define RV32_Itype(op, funct3) {{12{1'b?}},{5{1'b?}},``funct3``,{5{1'b?}},``op``} -`define RV32_Stype(op, funct3) {{7{1'b?}},{5{1'b?}},{5{1'b?}},``funct3``,{5{1'b?}},``op``} -`define RV32_Utype(op) {{20{1'b?}},{5{1'b?}},``op``} - -// RV32 Immediate sign extension macros -`define RV32_signext_Iimm(instr) {{21{``instr``[31]}},``instr``[30:20]} -`define RV32_signext_Simm(instr) {{21{``instr``[31]}},``instr[30:25],``instr``[11:7]} -`define RV32_signext_Bimm(instr) {{20{``instr``[31]}},``instr``[7],``instr``[30:25],``instr``[11:8], {1'b0}} -`define RV32_signext_Uimm(instr) {``instr``[31:12], {12{1'b0}}} -`define RV32_signext_Jimm(instr) {{12{``instr``[31]}},``instr``[19:12],``instr``[20],``instr``[30:21], {1'b0}} - -`define RV32_Bimm_12inject1(instr,value) {``value``[12], ``value``[10:5], ``instr``[24:12],\ - ``value``[4:1],``value``[11],``instr``[6:0]} -`define RV32_Jimm_20inject1(instr,value) {``value``[20], ``value``[10:1], ``value``[11],``value``[19:12], ``instr``[11:0]} - -// Both JAL and BRANCH use 2-byte address, we need to pad 1'b0 at MSB to get -// the real byte address -`define RV32_Bimm_13extract(instr) {``instr``[31], ``instr``[7], ``instr``[30:25], ``instr``[11:8], 1'b0} -`define RV32_Jimm_21extract(instr) {``instr``[31], ``instr``[19:12],``instr``[20],``instr``[30:21], 1'b0} - -`define RV32_Iimm_12extract(instr) {``instr``[31:20]} -`define RV32_Simm_12extract(instr) {``instr[31:25],``instr``[11:7]} - -// RV32I Instruction encodings -// We have to delete the white space in macro definition, -// otherwise Design Compiler would issue warings. -`define RV32_LUI `RV32_Utype(`RV32_LUI_OP) -`define RV32_AUIPC `RV32_Utype(`RV32_AUIPC_OP) -`define RV32_JAL `RV32_Utype(`RV32_JAL_OP) -`define RV32_JALR `RV32_Itype(`RV32_JALR_OP, 3'b000) -`define RV32_BEQ `RV32_Stype(`RV32_BRANCH, 3'b000) -`define RV32_BNE `RV32_Stype(`RV32_BRANCH, 3'b001) -`define RV32_BLT `RV32_Stype(`RV32_BRANCH, 3'b100) -`define RV32_BGE `RV32_Stype(`RV32_BRANCH, 3'b101) -`define RV32_BLTU `RV32_Stype(`RV32_BRANCH, 3'b110) -`define RV32_BGEU `RV32_Stype(`RV32_BRANCH, 3'b111) -`define RV32_LB `RV32_Itype(`RV32_LOAD, 3'b000) -`define RV32_LH `RV32_Itype(`RV32_LOAD, 3'b001) -`define RV32_LW `RV32_Itype(`RV32_LOAD, 3'b010) -`define RV32_LBU `RV32_Itype(`RV32_LOAD, 3'b100) -`define RV32_LHU `RV32_Itype(`RV32_LOAD, 3'b101) -`define RV32_SB `RV32_Stype(`RV32_STORE, 3'b000) -`define RV32_SH `RV32_Stype(`RV32_STORE, 3'b001) -`define RV32_SW `RV32_Stype(`RV32_STORE, 3'b010) -`define RV32_ADDI `RV32_Itype(`RV32_OP_IMM,3'b000) -`define RV32_SLTI `RV32_Itype(`RV32_OP_IMM, 3'b010) -`define RV32_SLTIU `RV32_Itype(`RV32_OP_IMM, 3'b011) -`define RV32_XORI `RV32_Itype(`RV32_OP_IMM, 3'b100) -`define RV32_ORI `RV32_Itype(`RV32_OP_IMM, 3'b110) -`define RV32_ANDI `RV32_Itype(`RV32_OP_IMM, 3'b111) -`define RV32_SLLI `RV32_Rtype(`RV32_OP_IMM, 3'b001, 7'b0000000) -`define RV32_SRLI `RV32_Rtype(`RV32_OP_IMM, 3'b101, 7'b0000000) -`define RV32_SRAI `RV32_Rtype(`RV32_OP_IMM, 3'b101, 7'b0100000) -`define RV32_ADD `RV32_Rtype(`RV32_OP,3'b000,7'b0000000) -`define RV32_SUB `RV32_Rtype(`RV32_OP, 3'b000, 7'b0100000) -`define RV32_SLL `RV32_Rtype(`RV32_OP, 3'b001, 7'b0000000) -`define RV32_SLT `RV32_Rtype(`RV32_OP, 3'b010, 7'b0000000) -`define RV32_SLTU `RV32_Rtype(`RV32_OP, 3'b011, 7'b0000000) -`define RV32_XOR `RV32_Rtype(`RV32_OP, 3'b100, 7'b0000000) -`define RV32_SRL `RV32_Rtype(`RV32_OP, 3'b101, 7'b0000000) -`define RV32_SRA `RV32_Rtype(`RV32_OP, 3'b101, 7'b0100000) -`define RV32_OR `RV32_Rtype(`RV32_OP, 3'b110, 7'b0000000) -`define RV32_AND `RV32_Rtype(`RV32_OP, 3'b111, 7'b0000000) - -// FENCE defines -`define RV32_FENCE_FUN3 3'b000 -`define RV32_FENCE_OP {4'b????,4'b????,4'b????,5'b00000,`RV32_FENCE_FUN3,5'b00000,`RV32_MISC_MEM} -`define RV32_FENCE_FM 4'b0000 -`define RV32_BARSEND_FM 4'b0001 -`define RV32_BARRECV_FM 4'b0010 - -//TRIGGER SAIF DUMP defines -`define SAIF_TRIGGER_START {12'b000000000001,5'b00000,3'b000,5'b00000,`RV32_OP_IMM} -`define SAIF_TRIGGER_END {12'b000000000010,5'b00000,3'b000,5'b00000,`RV32_OP_IMM} - -// CSR encoding -`define RV32_CSRRW_FUN3 3'b001 -`define RV32_CSRRS_FUN3 3'b010 -`define RV32_CSRRC_FUN3 3'b011 -`define RV32_CSRRWI_FUN3 3'b101 -`define RV32_CSRRSI_FUN3 3'b110 -`define RV32_CSRRCI_FUN3 3'b111 - -`define RV32_CSRRW `RV32_Itype(`RV32_SYSTEM, `RV32_CSRRW_FUN3) -`define RV32_CSRRS `RV32_Itype(`RV32_SYSTEM, `RV32_CSRRS_FUN3) -`define RV32_CSRRC `RV32_Itype(`RV32_SYSTEM, `RV32_CSRRC_FUN3) -`define RV32_CSRRWI `RV32_Itype(`RV32_SYSTEM, `RV32_CSRRWI_FUN3) -`define RV32_CSRRSI `RV32_Itype(`RV32_SYSTEM, `RV32_CSRRSI_FUN3) -`define RV32_CSRRCI `RV32_Itype(`RV32_SYSTEM, `RV32_CSRRCI_FUN3) - -// fcsr CSR addr -`define RV32_CSR_FFLAGS_ADDR 12'h001 -`define RV32_CSR_FRM_ADDR 12'h002 -`define RV32_CSR_FCSR_ADDR 12'h003 -// machine CSR addr -`define RV32_CSR_MSTATUS_ADDR 12'h300 -`define RV32_CSR_MTVEC_ADDR 12'h305 -`define RV32_CSR_MIE_ADDR 12'h304 -`define RV32_CSR_MIP_ADDR 12'h344 -`define RV32_CSR_MEPC_ADDR 12'h341 -`define RV32_CSR_CFG_POD_ADDR 12'h360 - -// machine custom CSR addr -`define RV32_CSR_CREDIT_LIMIT_ADDR 12'hfc0 -`define RV32_CSR_BARCFG_ADDR 12'hfc1 -`define RV32_CSR_BAR_PI_ADDR 12'hfc2 -`define RV32_CSR_BAR_PO_ADDR 12'hfc3 - -// mret -// used for returning from the interrupt -`define RV32_MRET {7'b0011000, 5'b00010, 5'b00000, 3'b000, 5'b00000, `RV32_SYSTEM} - -// RV32M Instruction Encodings -`define RV32_MUL `RV32_Rtype(`RV32_OP, `MD_MUL_FUN3 , 7'b0000001) -`define RV32_MULH `RV32_Rtype(`RV32_OP, `MD_MULH_FUN3 , 7'b0000001) -`define RV32_MULHSU `RV32_Rtype(`RV32_OP, `MD_MULHSU_FUN3, 7'b0000001) -`define RV32_MULHU `RV32_Rtype(`RV32_OP, `MD_MULHU_FUN3 , 7'b0000001) -`define RV32_DIV `RV32_Rtype(`RV32_OP, `MD_DIV_FUN3 , 7'b0000001) -`define RV32_DIVU `RV32_Rtype(`RV32_OP, `MD_DIVU_FUN3 , 7'b0000001) -`define RV32_REM `RV32_Rtype(`RV32_OP, `MD_REM_FUN3 , 7'b0000001) -`define RV32_REMU `RV32_Rtype(`RV32_OP, `MD_REMU_FUN3 , 7'b0000001) - -// RV32A Instruction Encodings -`define RV32_LR_W {5'b00010,2'b00,5'b00000,5'b?????,3'b010,5'b?????,`RV32_AMO_OP} -`define RV32_LR_W_AQ {5'b00010,2'b10,5'b00000,5'b?????,3'b010,5'b?????,`RV32_AMO_OP} -`define RV32_AMOSWAP_W {5'b00001,2'b??,5'b?????,5'b?????,3'b010,5'b?????,`RV32_AMO_OP} -`define RV32_AMOOR_W {5'b01000,2'b??,5'b?????,5'b?????,3'b010,5'b?????,`RV32_AMO_OP} -`define RV32_AMOADD_W {5'b00000,2'b??,5'b?????,5'b?????,3'b010,5'b?????,`RV32_AMO_OP} - -// RV32F Instruction Encodings -`define RV32_OP_FP 7'b1010011 -`define RV32_LOAD_FP 7'b0000111 -`define RV32_STORE_FP 7'b0100111 - -`define RV32_FCMP_S_FUN7 7'b1010000 -`define RV32_FCLASS_S_FUN7 7'b1110000 -`define RV32_FCVT_S_F2I_FUN7 7'b1100000 -`define RV32_FCVT_S_I2F_FUN7 7'b1101000 -`define RV32_FMV_W_X_FUN7 7'b1111000 -`define RV32_FMV_X_W_FUN7 7'b1110000 - -`define RV32_FADD_S `RV32_Rtype(`RV32_OP_FP, 3'b???, 7'b0000000) -`define RV32_FSUB_S `RV32_Rtype(`RV32_OP_FP, 3'b???, 7'b0000100) -`define RV32_FMUL_S `RV32_Rtype(`RV32_OP_FP, 3'b???, 7'b0001000) - -`define RV32_FSGNJ_S `RV32_Rtype(`RV32_OP_FP, 3'b000, 7'b0010000) -`define RV32_FSGNJN_S `RV32_Rtype(`RV32_OP_FP, 3'b001, 7'b0010000) -`define RV32_FSGNJX_S `RV32_Rtype(`RV32_OP_FP, 3'b010, 7'b0010000) - -`define RV32_FMIN_S `RV32_Rtype(`RV32_OP_FP, 3'b000, 7'b0010100) -`define RV32_FMAX_S `RV32_Rtype(`RV32_OP_FP, 3'b001, 7'b0010100) - -`define RV32_FEQ_S `RV32_Rtype(`RV32_OP_FP, 3'b010, `RV32_FCMP_S_FUN7) -`define RV32_FLT_S `RV32_Rtype(`RV32_OP_FP, 3'b001, `RV32_FCMP_S_FUN7) -`define RV32_FLE_S `RV32_Rtype(`RV32_OP_FP, 3'b000, `RV32_FCMP_S_FUN7) - -`define RV32_FCLASS_S {`RV32_FCLASS_S_FUN7, 5'b00000, 5'b?????, 3'b001, 5'b?????, `RV32_OP_FP} - -// i2f -`define RV32_FCVT_S_W {`RV32_FCVT_S_I2F_FUN7, 5'b00000, 5'b?????, 3'b???, 5'b?????, `RV32_OP_FP} -`define RV32_FCVT_S_WU {`RV32_FCVT_S_I2F_FUN7, 5'b00001, 5'b?????, 3'b???, 5'b?????, `RV32_OP_FP} - -// f2i -`define RV32_FCVT_W_S {`RV32_FCVT_S_F2I_FUN7, 5'b00000, 5'b?????, 3'b???, 5'b?????, `RV32_OP_FP} -`define RV32_FCVT_WU_S {`RV32_FCVT_S_F2I_FUN7, 5'b00001, 5'b?????, 3'b???, 5'b?????, `RV32_OP_FP} - -// move (i->f) -`define RV32_FMV_W_X {`RV32_FMV_W_X_FUN7, 5'b0000, 5'b?????, 3'b000, 5'b?????, `RV32_OP_FP} - -// move (f->i) -`define RV32_FMV_X_W {`RV32_FMV_X_W_FUN7, 5'b0000, 5'b?????, 3'b000, 5'b?????, `RV32_OP_FP} - -`define RV32_FLW_S `RV32_Itype(`RV32_LOAD_FP, 3'b010) -`define RV32_FSW_S `RV32_Stype(`RV32_STORE_FP, 3'b010) - -`define RV32_FMADD_S {5'b?????, 2'b00, 5'b?????, 5'b?????, 3'b???, 5'b?????, 7'b1000011} -`define RV32_FMSUB_S {5'b?????, 2'b00, 5'b?????, 5'b?????, 3'b???, 5'b?????, 7'b1000111} -`define RV32_FNMSUB_S {5'b?????, 2'b00, 5'b?????, 5'b?????, 3'b???, 5'b?????, 7'b1001011} -`define RV32_FNMADD_S {5'b?????, 2'b00, 5'b?????, 5'b?????, 3'b???, 5'b?????, 7'b1001111} - -`define RV32_FDIV_S `RV32_Rtype(`RV32_OP_FP, 3'b???, 7'b0001100) -`define RV32_FSQRT_S {7'b0101100, 5'b00000, 5'b?????, 3'b???, 5'b?????, 7'b1010011} - -`endif - From 24f5ab8febb558b01cf93ff1d75c0fcac6e5bac7 Mon Sep 17 00:00:00 2001 From: Prateek Mahajan Date: Fri, 8 Dec 2023 16:50:02 -0800 Subject: [PATCH 4/9] Adding Manycore defines and Makefile changes for different ISAs allowed : Testing still pending --- machines/Makefile | 13 +- v/vanilla_bean/alu.v | 50 +-- .../bsg_manycore_instruction_defines.vh | 6 +- v/vanilla_bean/bsg_vanilla_defines.vh | 289 +++++++++++------- v/vanilla_bean/cl_decode.v | 188 ++++++------ v/vanilla_bean/fcsr.v | 32 +- v/vanilla_bean/fpu_float_fma.v | 2 +- v/vanilla_bean/fpu_fmin_fmax.v | 2 +- v/vanilla_bean/icache.v | 22 +- v/vanilla_bean/mcsr.v | 186 +---------- v/vanilla_bean/vanilla_core.v | 10 +- 11 files changed, 346 insertions(+), 454 deletions(-) diff --git a/machines/Makefile b/machines/Makefile index 94f4d5d57..004d9e08b 100644 --- a/machines/Makefile +++ b/machines/Makefile @@ -3,6 +3,7 @@ BSG_MANYCORE_DIR := $(shell git rev-parse --show-toplevel) # By convention, basejump_stl is in the same directory as $(BSG_MANYCORE_DIR) BASEJUMP_STL_DIR := $(abspath $(BSG_MANYCORE_DIR)/../basejump_stl) +BSG_MANYCORE_ISA_DIR := $(abspath $(BSG_MANYCORE_DIR)/../bsg_manycore_ISA) ifeq ($(wildcard $(BASEJUMP_STL_DIR)/imports/DRAMSim3/Makefile),) $(error DRAMSim3 has not been submoduled in basejump_stl, see top-level README.md) @@ -16,11 +17,21 @@ DEFAULT_TARGETS = $(foreach machine, $(DEFAULT_MACHINES),$(machine)/$(BSG_SIM_BA DEFAULT_DEBUG_TARGETS = $(foreach machine, $(DEFAULT_MACHINES),$(machine)/$(BSG_SIM_BASE)-debug) DEFAULT_PROFILE_TARGETS = $(foreach machine, $(DEFAULT_MACHINES),$(machine)/$(BSG_SIM_BASE)-profile) +# Default Machine ISA is Vanilla. This can be modified to any of the supported ISA in the repository bsg_manycore_ISA +# Note that you would have to sync the above repository as well to use another ISA +BSG_MACHINE_ISA ?= VANILLA + # set_vcs_machine_variables includes the Makefile.machine.include file and sets the all: $(DEFAULT_TARGETS) $(DEFAULT_DEBUG_TARGETS) $(DEFAULT_PROFILE_TARGETS) # Include source lists -include arch_filelist.mk +# We include different source lists for different ISAs +ifeq ($(BSG_MANYCORE_ISA_DIR),VANILLA) +include $(BSG_MANYCORE_DIR)/machines/arch_filelist.mk +else ifeq ($(BSG_MANYCORE_ISA_DIR),RISCV) +include $(BSG_MANYCORE_ISA_DIR)/RISCV/arch_filelist.mk +endif + include sim_filelist.mk include Makefile.vcs diff --git a/v/vanilla_bean/alu.v b/v/vanilla_bean/alu.v index fc656faaa..e2cac09bc 100644 --- a/v/vanilla_bean/alu.v +++ b/v/vanilla_bean/alu.v @@ -1,5 +1,5 @@ -`include "bsg_vanilla_defines.vh" +`include "bsg_manycore_instruction_defines.vh" module alu import bsg_vanilla_pkg::*; @@ -23,10 +23,10 @@ logic [32:0] shr_out; logic [31:0] shl_out, xor_out, and_out, or_out; ///////////////////////////////////////////////////////// -assign is_imm_op = (op_i.op ==? `VANILLA_OP_IMM) | (op_i.op ==? `VANILLA_JALR_OP); +assign is_imm_op = (op_i.op ==? `MANYCORE_OP_IMM) | (op_i.op ==? `MANYCORE_JALR_OP); ///////////////////////////////////////////////////////// -assign op2 = is_imm_op ? `Vanilla_signext_Iimm(op_i) : rs2_i; +assign op2 = is_imm_op ? `MANYCORE_signext_Iimm(op_i) : rs2_i; /////////////////////////////////////////////////////////// @@ -49,61 +49,61 @@ always_comb sign_ex_or_zero = 1'b0; unique casez (op_i) - `VANILLA_LUI: - result_o = `Vanilla_signext_Uimm(op_i); + `MANYCORE_LUI: + result_o = `MANYCORE_signext_Uimm(op_i); - `VANILLA_AUIPC: - result_o = `Vanilla_signext_Uimm(op_i) + pc_plus4_i - 3'b100; + `MANYCORE_AUIPC: + result_o = `MANYCORE_signext_Uimm(op_i) + pc_plus4_i - 3'b100; - `VANILLA_ADDI, `VANILLA_ADD: + `MANYCORE_ADDI, `MANYCORE_ADD: begin result_o = sum[31:0]; sub_not_add = 1'b0; end - `VANILLA_SLTI, `VANILLA_SLT: + `MANYCORE_SLTI, `MANYCORE_SLT: begin sub_not_add = 1'b1; result_o = {{31{1'b0}},sum[32]}; end - `VANILLA_SLTIU, `VANILLA_SLTU: + `MANYCORE_SLTIU, `MANYCORE_SLTU: begin sub_not_add = 1'b1; result_o = {{31{1'b0}},~carry}; end - `VANILLA_XORI, `VANILLA_XOR: + `MANYCORE_XORI, `MANYCORE_XOR: result_o = xor_out; - `VANILLA_ORI, `VANILLA_OR: + `MANYCORE_ORI, `MANYCORE_OR: result_o = or_out; - `VANILLA_ANDI, `VANILLA_AND: + `MANYCORE_ANDI, `MANYCORE_AND: result_o = and_out; - `VANILLA_SLLI, `VANILLA_SLL: + `MANYCORE_SLLI, `MANYCORE_SLL: result_o = shl_out; - `VANILLA_SRLI, `VANILLA_SRL: + `MANYCORE_SRLI, `MANYCORE_SRL: begin result_o = shr_out[31:0]; sign_ex_or_zero = 1'b0; end - `VANILLA_SRAI, `VANILLA_SRA: + `MANYCORE_SRAI, `MANYCORE_SRA: begin result_o = shr_out[31:0]; sign_ex_or_zero = rs1_i[31]; end - `VANILLA_SUB: + `MANYCORE_SUB: begin result_o = sum[31:0]; sub_not_add = 1'b1; end - `VANILLA_JALR: + `MANYCORE_JALR: begin sub_not_add = 1'b0; // jalr_addr_o = sum[31:0] & 32'hfffe; @@ -111,7 +111,7 @@ always_comb result_o = pc_plus4_i; end - `VANILLA_JAL: + `MANYCORE_JAL: begin result_o =pc_plus4_i; end @@ -129,12 +129,12 @@ wire rs1_lt_rs2_signed = ( $signed(rs1_i) < $signed( rs2_i ) ); always_comb begin unique casez(op_i ) - `VANILLA_BEQ: jump_now_o = rs1_eq_rs2; - `VANILLA_BNE: jump_now_o = ~rs1_eq_rs2; - `VANILLA_BLT: jump_now_o = rs1_lt_rs2_signed; - `VANILLA_BGE: jump_now_o = ~rs1_lt_rs2_signed; - `VANILLA_BLTU: jump_now_o = rs1_lt_rs2_unsigned; - `VANILLA_BGEU: jump_now_o = ~rs1_lt_rs2_unsigned; + `MANYCORE_BEQ: jump_now_o = rs1_eq_rs2; + `MANYCORE_BNE: jump_now_o = ~rs1_eq_rs2; + `MANYCORE_BLT: jump_now_o = rs1_lt_rs2_signed; + `MANYCORE_BGE: jump_now_o = ~rs1_lt_rs2_signed; + `MANYCORE_BLTU: jump_now_o = rs1_lt_rs2_unsigned; + `MANYCORE_BGEU: jump_now_o = ~rs1_lt_rs2_unsigned; default: jump_now_o = 1'b0; endcase end diff --git a/v/vanilla_bean/bsg_manycore_instruction_defines.vh b/v/vanilla_bean/bsg_manycore_instruction_defines.vh index 848a753bf..b488d1175 100644 --- a/v/vanilla_bean/bsg_manycore_instruction_defines.vh +++ b/v/vanilla_bean/bsg_manycore_instruction_defines.vh @@ -1,5 +1,5 @@ -`ifndef BSG_VANILLA_DEFINES_VH -`define BSG_VANILLA_DEFINES_VH +`ifndef BSG_MANYCORE_INSTRUCTION_DEFINES_VH +`define BSG_MANYCORE_INSTRUCTION_DEFINES_VH /** * bsg_manycore_instructions_defines.vh @@ -142,7 +142,7 @@ `define MANYCORE_CSR_FRM_ADDR 12'h002 `define MANYCORE_CSR_FCSR_ADDR 12'h003 // machine CSR addr -`define VANILLA_CSR_CFG_POD_ADDR 12'h360 +`define MANYCORE_CSR_CFG_POD_ADDR 12'h360 // machine custom CSR addr `define MANYCORE_CSR_CREDIT_LIMIT_ADDR 12'hfc0 diff --git a/v/vanilla_bean/bsg_vanilla_defines.vh b/v/vanilla_bean/bsg_vanilla_defines.vh index 3b5525b15..8e8552e17 100644 --- a/v/vanilla_bean/bsg_vanilla_defines.vh +++ b/v/vanilla_bean/bsg_vanilla_defines.vh @@ -1,129 +1,112 @@ -`ifndef BSG_VANILLA_DEFINES_VH -`define BSG_VANILLA_DEFINES_VH +`ifndef BSG_RISCV_DEFINES_VH +`define BSG_RISCV_DEFINES_VH /** * bsg_vanilla_defines.vh * * This file defines the macros - * used throughout the vanilla core. + * used for Vanilla ISA operations throughout the vanilla core. * */ -`include "bsg_defines.sv" - -`define declare_icache_format_s(tag_width_mp, block_size_in_words_mp) \ - typedef struct packed { \ - logic [block_size_in_words_mp-1:0] lower_cout; \ - logic [block_size_in_words_mp-1:0] lower_sign; \ - logic [tag_width_mp-1:0] tag; \ - instruction_s [block_size_in_words_mp-1:0] instr; \ - } icache_format_s - -`define icache_format_width(tag_width_mp, block_size_in_words_mp) \ - ((2*block_size_in_words_mp)+tag_width_mp+(block_size_in_words_mp*$bits(instruction_s))) - -// FPU recoded Constants -`define FPU_RECODED_ONE 33'h080000000 -`define FPU_RECODED_ZERO 33'h0 -`define FPU_RECODED_CANONICAL_NAN 33'h0e0400000 - -`define REMOTE_INTERRUPT_JUMP_ADDR 0 // remote interrupt jump addr (word addr) -`define TRACE_INTERRUPT_JUMP_ADDR 1 // trace interrupt jump addr (word addr) - -// 32M Instruction Encodings -`define MD_MUL_FUN3 3'b000 -`define MD_MULH_FUN3 3'b001 -`define MD_MULHSU_FUN3 3'b010 -`define MD_MULHU_FUN3 3'b011 -`define MD_DIV_FUN3 3'b100 -`define MD_DIVU_FUN3 3'b101 -`define MD_REM_FUN3 3'b110 -`define MD_REMU_FUN3 3'b111 - -`define VANILLA_MSTATUS_MIE_BIT_IDX 3 -`define VANILLA_MSTATUS_MPIE_BIT_IDX 7 - -// Vanilla Core Opcodes -`define VANILLA_LOAD 7'b0000011 -`define VANILLA_STORE 7'b0100011 - -`define VANILLA_BRANCH 7'b110001? - -`define VANILLA_JALR_OP 7'b1100111 -`define VANILLA_MISC_MEM 7'b0001111 -`define VANILLA_AMO_OP 7'b0101111 -`define VANILLA_JAL_OP 7'b1101111 -`define VANILLA_OP_IMM 7'b0010011 -`define VANILLA_OP 7'b0110011 -`define VANILLA_SYSTEM 7'b1110011 -`define VANILLA_AUIPC_OP 7'b0010111 -`define VANILLA_LUI_OP 7'b0110111 +`include "bsg_manycore_instruction_defines.vh" + +// Vanilla Opcodes +`define VANILLA_LOAD `MANYCORE_LOAD +`define VANILLA_STORE `MANYCORE_STORE + +// we have branch instructions ignore the low bit so that we can place the prediction bit there. +// RISC-V by default has the low bits set to 11 in the icache, so we can use those creatively. +// note this relies on all code using ==? and casez. +`define VANILLA_BRANCH `MANYCORE_BRANCH + +`define VANILLA_JALR_OP `MANYCORE_JALR_OP +`define VANILLA_MISC_MEM `MANYCORE_MISC_MEM +`define VANILLA_AMO_OP `MANYCORE_AMO_OP +`define VANILLA_JAL_OP `MANYCORE_JAL_OP +`define VANILLA_OP_IMM `MANYCORE_OP_IMM +`define VANILLA_OP `MANYCORE_OP +`define VANILLA_SYSTEM `MANYCORE_SYSTEM +`define VANILLA_AUIPC_OP `MANYCORE_AUIPC_OP +`define VANILLA_LUI_OP `MANYCORE_LUI_OP + // Some useful Vanilla instruction macros -`define Vanilla_Rtype(op, funct3, funct7) {``funct7``, {5{1'b?}}, {5{1'b?}},``funct3``, {5{1'b?}},``op``} -`define Vanilla_Itype(op, funct3) {{12{1'b?}},{5{1'b?}},``funct3``,{5{1'b?}},``op``} -`define Vanilla_Stype(op, funct3) {{7{1'b?}},{5{1'b?}},{5{1'b?}},``funct3``,{5{1'b?}},``op``} -`define Vanilla_Utype(op) {{20{1'b?}},{5{1'b?}},``op``} +`define VANILLA_Rtype(op, funct3, funct7) {``funct7``, {5{1'b?}}, {5{1'b?}},``funct3``, {5{1'b?}},``op``} +`define VANILLA_Itype(op, funct3) {{12{1'b?}},{5{1'b?}},``funct3``,{5{1'b?}},``op``} +`define VANILLA_Stype(op, funct3) {{7{1'b?}},{5{1'b?}},{5{1'b?}},``funct3``,{5{1'b?}},``op``} +`define VANILLA_Utype(op) {{20{1'b?}},{5{1'b?}},``op``} // Vanilla Immediate sign extension macros -`define Vanilla_signext_Iimm(instr) {{21{``instr``[31]}},``instr``[30:20]} -`define Vanilla_signext_Simm(instr) {{21{``instr``[31]}},``instr[30:25],``instr``[11:7]} -`define Vanilla_signext_Bimm(instr) {{20{``instr``[31]}},``instr``[7],``instr``[30:25],``instr``[11:8], {1'b0}} -`define Vanilla_signext_Uimm(instr) {``instr``[31:12], {12{1'b0}}} -`define Vanilla_signext_Jimm(instr) {{12{``instr``[31]}},``instr``[19:12],``instr``[20],``instr``[30:21], {1'b0}} +`define VANILLA_signext_Iimm(instr) {{21{``instr``[31]}},``instr``[30:20]} +`define VANILLA_signext_Simm(instr) {{21{``instr``[31]}},``instr[30:25],``instr``[11:7]} +`define VANILLA_signext_Bimm(instr) {{20{``instr``[31]}},``instr``[7],``instr``[30:25],``instr``[11:8], {1'b0}} +`define VANILLA_signext_Uimm(instr) {``instr``[31:12], {12{1'b0}}} +`define VANILLA_signext_Jimm(instr) {{12{``instr``[31]}},``instr``[19:12],``instr``[20],``instr``[30:21], {1'b0}} -`define Vanilla_Bimm_12inject1(instr,value) {``value``[12], ``value``[10:5], ``instr``[24:12],\ +`define VANILLA_Bimm_12inject1(instr,value) {``value``[12], ``value``[10:5], ``instr``[24:12],\ ``value``[4:1],``value``[11],``instr``[6:0]} -`define Vanilla_Jimm_20inject1(instr,value) {``value``[20], ``value``[10:1], ``value``[11],``value``[19:12], ``instr``[11:0]} +`define VANILLA_Jimm_20inject1(instr,value) {``value``[20], ``value``[10:1], ``value``[11],``value``[19:12], ``instr``[11:0]} // Both JAL and BRANCH use 2-byte address, we need to pad 1'b0 at MSB to get // the real byte address -`define Vanilla_Bimm_13extract(instr) {``instr``[31], ``instr``[7], ``instr``[30:25], ``instr``[11:8], 1'b0} -`define Vanilla_Jimm_21extract(instr) {``instr``[31], ``instr``[19:12],``instr``[20],``instr``[30:21], 1'b0} +`define VANILLA_Bimm_13extract(instr) {``instr``[31], ``instr``[7], ``instr``[30:25], ``instr``[11:8], 1'b0} +`define VANILLA_Jimm_21extract(instr) {``instr``[31], ``instr``[19:12],``instr``[20],``instr``[30:21], 1'b0} -`define Vanilla_Iimm_12extract(instr) {``instr``[31:20]} -`define Vanilla_Simm_12extract(instr) {``instr[31:25],``instr``[11:7]} +`define VANILLA_Iimm_12extract(instr) {``instr``[31:20]} +`define VANILLA_Simm_12extract(instr) {``instr[31:25],``instr``[11:7]} -// Vanilla Instruction encodings +// VanillaI Instruction encodings // We have to delete the white space in macro definition, // otherwise Design Compiler would issue warings. -`define VANILLA_LUI `Vanilla_Utype(`VANILLA_LUI_OP) -`define VANILLA_AUIPC `Vanilla_Utype(`VANILLA_AUIPC_OP) -`define VANILLA_JAL `Vanilla_Utype(`VANILLA_JAL_OP) -`define VANILLA_JALR `Vanilla_Itype(`VANILLA_JALR_OP, 3'b000) -`define VANILLA_BEQ `Vanilla_Stype(`VANILLA_BRANCH, 3'b000) -`define VANILLA_BNE `Vanilla_Stype(`VANILLA_BRANCH, 3'b001) -`define VANILLA_BLT `Vanilla_Stype(`VANILLA_BRANCH, 3'b100) -`define VANILLA_BGE `Vanilla_Stype(`VANILLA_BRANCH, 3'b101) -`define VANILLA_BLTU `Vanilla_Stype(`VANILLA_BRANCH, 3'b110) -`define VANILLA_BGEU `Vanilla_Stype(`VANILLA_BRANCH, 3'b111) -`define VANILLA_LB `Vanilla_Itype(`VANILLA_LOAD, 3'b000) -`define VANILLA_LH `Vanilla_Itype(`VANILLA_LOAD, 3'b001) -`define VANILLA_LW `Vanilla_Itype(`VANILLA_LOAD, 3'b010) -`define VANILLA_LBU `Vanilla_Itype(`VANILLA_LOAD, 3'b100) -`define VANILLA_LHU `Vanilla_Itype(`VANILLA_LOAD, 3'b101) -`define VANILLA_SB `Vanilla_Stype(`VANILLA_STORE, 3'b000) -`define VANILLA_SH `Vanilla_Stype(`VANILLA_STORE, 3'b001) -`define VANILLA_SW `Vanilla_Stype(`VANILLA_STORE, 3'b010) -`define VANILLA_ADDI `Vanilla_Itype(`VANILLA_OP_IMM,3'b000) -`define VANILLA_SLTI `Vanilla_Itype(`VANILLA_OP_IMM, 3'b010) -`define VANILLA_SLTIU `Vanilla_Itype(`VANILLA_OP_IMM, 3'b011) -`define VANILLA_XORI `Vanilla_Itype(`VANILLA_OP_IMM, 3'b100) -`define VANILLA_ORI `Vanilla_Itype(`VANILLA_OP_IMM, 3'b110) -`define VANILLA_ANDI `Vanilla_Itype(`VANILLA_OP_IMM, 3'b111) -`define VANILLA_SLLI `Vanilla_Rtype(`VANILLA_OP_IMM, 3'b001, 7'b0000000) -`define VANILLA_SRLI `Vanilla_Rtype(`VANILLA_OP_IMM, 3'b101, 7'b0000000) -`define VANILLA_SRAI `Vanilla_Rtype(`VANILLA_OP_IMM, 3'b101, 7'b0100000) -`define VANILLA_ADD `Vanilla_Rtype(`VANILLA_OP,3'b000,7'b0000000) -`define VANILLA_SUB `Vanilla_Rtype(`VANILLA_OP, 3'b000, 7'b0100000) -`define VANILLA_SLL `Vanilla_Rtype(`VANILLA_OP, 3'b001, 7'b0000000) -`define VANILLA_SLT `Vanilla_Rtype(`VANILLA_OP, 3'b010, 7'b0000000) -`define VANILLA_SLTU `Vanilla_Rtype(`VANILLA_OP, 3'b011, 7'b0000000) -`define VANILLA_XOR `Vanilla_Rtype(`VANILLA_OP, 3'b100, 7'b0000000) -`define VANILLA_SRL `Vanilla_Rtype(`VANILLA_OP, 3'b101, 7'b0000000) -`define VANILLA_SRA `Vanilla_Rtype(`VANILLA_OP, 3'b101, 7'b0100000) -`define VANILLA_OR `Vanilla_Rtype(`VANILLA_OP, 3'b110, 7'b0000000) -`define VANILLA_AND `Vanilla_Rtype(`VANILLA_OP, 3'b111, 7'b0000000) +`define VANILLA_LUI `MANYCORE_LUI +`define VANILLA_AUIPC `MANYCORE_AUIPC +`define VANILLA_JAL `MANYCORE_JAL +`define VANILLA_JALR `MANYCORE_JALR +`define VANILLA_BEQ `MANYCORE_BEQ +`define VANILLA_BNE `MANYCORE_BNE +`define VANILLA_BLT `MANYCORE_BLT +`define VANILLA_BGE `MANYCORE_BGE +`define VANILLA_BLTU `MANYCORE_BLTU +`define VANILLA_BGEU `MANYCORE_BGEU +`define VANILLA_LB `MANYCORE_LB +`define VANILLA_LH `MANYCORE_LH +`define VANILLA_LW `MANYCORE_LW +`define VANILLA_LBU `MANYCORE_LBU +`define VANILLA_LHU `MANYCORE_LHU +`define VANILLA_SB `MANYCORE_SB +`define VANILLA_SH `MANYCORE_SH +`define VANILLA_SW `MANYCORE_SW +`define VANILLA_ADDI `MANYCORE_ADDI +`define VANILLA_SLTI `MANYCORE_SLTI +`define VANILLA_SLTIU `MANYCORE_SLTIU +`define VANILLA_XORI `MANYCORE_XORI +`define VANILLA_ORI `MANYCORE_ORI +`define VANILLA_ANDI `MANYCORE_ANDI +`define VANILLA_SLLI `MANYCORE_SLLI +`define VANILLA_SRLI `MANYCORE_SLRI +`define VANILLA_SRAI `MANYCORE_SRAI +`define VANILLA_ADD `MANYCORE_ADD +`define VANILLA_SUB `MANYCORE_SUB +`define VANILLA_SLL `MANYCORE_SLL +`define VANILLA_SLT `MANYCORE_SLT +`define VANILLA_SLTU `MANYCORE_SLTU +`define VANILLA_XOR `MANYCORE_XOR +`define VANILLA_SRL `MANYCORE_SRL +`define VANILLA_SRA `MANYCORE_SRA +`define VANILLA_OR `MANYCORE_OR +`define VANILLA_AND `MANYCORE_AND + +// FENCE defines +`define VANILLA_FENCE_FUN3 3'b000 +`define VANILLA_FENCE_OP {4'b????,4'b????,4'b????,5'b00000,`VANILLA_FENCE_FUN3,5'b00000,`VANILLA_MISC_MEM} +`define VANILLA_FENCE_FM 4'b0000 +`define VANILLA_BARSEND_FM 4'b0001 +`define VANILLA_BARRECV_FM 4'b0010 + +//TRIGGER SAIF DUMP defines +`define SAIF_TRIGGER_START {12'b000000000001,5'b00000,3'b000,5'b00000,`VANILLA_OP_IMM} +`define SAIF_TRIGGER_END {12'b000000000010,5'b00000,3'b000,5'b00000,`VANILLA_OP_IMM} // CSR encoding `define VANILLA_CSRRW_FUN3 3'b001 @@ -133,24 +116,19 @@ `define VANILLA_CSRRSI_FUN3 3'b110 `define VANILLA_CSRRCI_FUN3 3'b111 -`define VANILLA_CSRRW `Vanilla_Itype(`VANILLA_SYSTEM, `VANILLA_CSRRW_FUN3) -`define VANILLA_CSRRS `Vanilla_Itype(`VANILLA_SYSTEM, `VANILLA_CSRRS_FUN3) -`define VANILLA_CSRRC `Vanilla_Itype(`VANILLA_SYSTEM, `VANILLA_CSRRC_FUN3) -`define VANILLA_CSRRWI `Vanilla_Itype(`VANILLA_SYSTEM, `VANILLA_CSRRWI_FUN3) -`define VANILLA_CSRRSI `Vanilla_Itype(`VANILLA_SYSTEM, `VANILLA_CSRRSI_FUN3) -`define VANILLA_CSRRCI `Vanilla_Itype(`VANILLA_SYSTEM, `VANILLA_CSRRCI_FUN3) +`define VANILLA_CSRRW `VANILLA_Itype(`VANILLA_SYSTEM, `VANILLA_CSRRW_FUN3) +`define VANILLA_CSRRS `VANILLA_Itype(`VANILLA_SYSTEM, `VANILLA_CSRRS_FUN3) +`define VANILLA_CSRRC `VANILLA_Itype(`VANILLA_SYSTEM, `VANILLA_CSRRC_FUN3) +`define VANILLA_CSRRWI `VANILLA_Itype(`VANILLA_SYSTEM, `VANILLA_CSRRWI_FUN3) +`define VANILLA_CSRRSI `VANILLA_Itype(`VANILLA_SYSTEM, `VANILLA_CSRRSI_FUN3) +`define VANILLA_CSRRCI `VANILLA_Itype(`VANILLA_SYSTEM, `VANILLA_CSRRCI_FUN3) // fcsr CSR addr `define VANILLA_CSR_FFLAGS_ADDR 12'h001 -`define VANILLA_CSR_FRM_ADDR 12'h002 +`define VANILLA_CSR_FRM_ADDR 12'h002 `define VANILLA_CSR_FCSR_ADDR 12'h003 // machine CSR addr -`define VANILLA_CSR_MSTATUS_ADDR 12'h300 -`define VANILLA_CSR_MTVEC_ADDR 12'h305 -`define VANILLA_CSR_MIE_ADDR 12'h304 -`define VANILLA_CSR_MIP_ADDR 12'h344 -`define VANILLA_CSR_MEPC_ADDR 12'h341 -`define VANILLA_CSR_CFG_POD_ADDR 12'h360 +`define VANILLA_CSR_CFG_POD_ADDR 12'h360 // machine custom CSR addr `define VANILLA_CSR_CREDIT_LIMIT_ADDR 12'hfc0 @@ -158,5 +136,80 @@ `define VANILLA_CSR_BAR_PI_ADDR 12'hfc2 `define VANILLA_CSR_BAR_PO_ADDR 12'hfc3 +// mret +// used for returning from the interrupt +`define VANILLA_MRET {7'b0011000, 5'b00010, 5'b00000, 3'b000, 5'b00000, `VANILLA_SYSTEM} + +// VANILLA M Instruction Encodings +`define VANILLA_MUL `VANILLA_Rtype(`VANILLA_OP, `MD_MUL_FUN3 , 7'b0000001) +`define VANILLA_MULH `VANILLA_Rtype(`VANILLA_OP, `MD_MULH_FUN3 , 7'b0000001) +`define VANILLA_MULHSU `VANILLA_Rtype(`VANILLA_OP, `MD_MULHSU_FUN3, 7'b0000001) +`define VANILLA_MULHU `VANILLA_Rtype(`VANILLA_OP, `MD_MULHU_FUN3 , 7'b0000001) +`define VANILLA_DIV `VANILLA_Rtype(`VANILLA_OP, `MD_DIV_FUN3 , 7'b0000001) +`define VANILLA_DIVU `VANILLA_Rtype(`VANILLA_OP, `MD_DIVU_FUN3 , 7'b0000001) +`define VANILLA_REM `VANILLA_Rtype(`VANILLA_OP, `MD_REM_FUN3 , 7'b0000001) +`define VANILLA_REMU `VANILLA_Rtype(`VANILLA_OP, `MD_REMU_FUN3 , 7'b0000001) + +// VANILLA A Instruction Encodings +`define VANILLA_LR_W {5'b00010,2'b00,5'b00000,5'b?????,3'b010,5'b?????,`VANILLA_AMO_OP} +`define VANILLA_LR_W_AQ {5'b00010,2'b10,5'b00000,5'b?????,3'b010,5'b?????,`VANILLA_AMO_OP} +`define VANILLA_AMOSWAP_W {5'b00001,2'b??,5'b?????,5'b?????,3'b010,5'b?????,`VANILLA_AMO_OP} +`define VANILLA_AMOOR_W {5'b01000,2'b??,5'b?????,5'b?????,3'b010,5'b?????,`VANILLA_AMO_OP} +`define VANILLA_AMOADD_W {5'b00000,2'b??,5'b?????,5'b?????,3'b010,5'b?????,`VANILLA_AMO_OP} + +// VANILLA F Instruction Encodings +`define VANILLA_OP_FP 7'b0101100 +`define VANILLA_LOAD_FP 7'b1111000 +`define VANILLA_STORE_FP 7'b1011000 + +`define VANILLA_FCMP_S_FUN7 7'b1010000 +`define VANILLA_FCLASS_S_FUN7 7'b1110000 +`define VANILLA_FCVT_S_F2I_FUN7 7'b1100000 +`define VANILLA_FCVT_S_I2F_FUN7 7'b1101000 +`define VANILLA_FMV_W_X_FUN7 7'b1111000 +`define VANILLA_FMV_X_W_FUN7 7'b1110000 + +`define VANILLA_FADD_S `VANILLA_Rtype(`VANILLA_OP_FP, 3'b???, 7'b0000000) +`define VANILLA_FSUB_S `VANILLA_Rtype(`VANILLA_OP_FP, 3'b???, 7'b0000100) +`define VANILLA_FMUL_S `VANILLA_Rtype(`VANILLA_OP_FP, 3'b???, 7'b0001000) + +`define VANILLA_FSGNJ_S `VANILLA_Rtype(`VANILLA_OP_FP, 3'b000, 7'b0010000) +`define VANILLA_FSGNJN_S `VANILLA_Rtype(`VANILLA_OP_FP, 3'b001, 7'b0010000) +`define VANILLA_FSGNJX_S `VANILLA_Rtype(`VANILLA_OP_FP, 3'b010, 7'b0010000) + +`define VANILLA_FMIN_S `VANILLA_Rtype(`VANILLA_OP_FP, 3'b000, 7'b0010100) +`define VANILLA_FMAX_S `VANILLA_Rtype(`VANILLA_OP_FP, 3'b001, 7'b0010100) + +`define VANILLA_FEQ_S `VANILLA_Rtype(`VANILLA_OP_FP, 3'b010, `VANILLA_FCMP_S_FUN7) +`define VANILLA_FLT_S `VANILLA_Rtype(`VANILLA_OP_FP, 3'b001, `VANILLA_FCMP_S_FUN7) +`define VANILLA_FLE_S `VANILLA_Rtype(`VANILLA_OP_FP, 3'b000, `VANILLA_FCMP_S_FUN7) + +`define VANILLA_FCLASS_S {`VANILLA_FCLASS_S_FUN7, 5'b00000, 5'b?????, 3'b001, 5'b?????, `VANILLA_OP_FP} + +// i2f +`define VANILLA_FCVT_S_W {`VANILLA_FCVT_S_I2F_FUN7, 5'b00000, 5'b?????, 3'b???, 5'b?????, `VANILLA_OP_FP} +`define VANILLA_FCVT_S_WU {`VANILLA_FCVT_S_I2F_FUN7, 5'b00001, 5'b?????, 3'b???, 5'b?????, `VANILLA_OP_FP} + +// f2i +`define VANILLA_FCVT_W_S {`VANILLA_FCVT_S_F2I_FUN7, 5'b00000, 5'b?????, 3'b???, 5'b?????, `VANILLA_OP_FP} +`define VANILLA_FCVT_WU_S {`VANILLA_FCVT_S_F2I_FUN7, 5'b00001, 5'b?????, 3'b???, 5'b?????, `VANILLA_OP_FP} + +// move (i->f) +`define VANILLA_FMV_W_X {`VANILLA_FMV_W_X_FUN7, 5'b0000, 5'b?????, 3'b000, 5'b?????, `VANILLA_OP_FP} + +// move (f->i) +`define VANILLA_FMV_X_W {`VANILLA_FMV_X_W_FUN7, 5'b0000, 5'b?????, 3'b000, 5'b?????, `VANILLA_OP_FP} + +`define VANILLA_FLW_S `VANILLA_Itype(`VANILLA_LOAD_FP, 3'b010) +`define VANILLA_FSW_S `VANILLA_Stype(`VANILLA_STORE_FP, 3'b010) + +`define VANILLA_FMADD_S {5'b?????, 2'b00, 5'b?????, 5'b?????, 3'b???, 5'b?????, 7'b0111100} +`define VANILLA_FMSUB_S {5'b?????, 2'b00, 5'b?????, 5'b?????, 3'b???, 5'b?????, 7'b0111000} +`define VANILLA_FNMSUB_S {5'b?????, 2'b00, 5'b?????, 5'b?????, 3'b???, 5'b?????, 7'b0110100} +`define VANILLA_FNMADD_S {5'b?????, 2'b00, 5'b?????, 5'b?????, 3'b???, 5'b?????, 7'b0110000} + +`define VANILLA_FDIV_S `VANILLA_Rtype(`VANILLA_OP_FP, 3'b???, 7'b0001100) +`define VANILLA_FSQRT_S {7'b0101100, 5'b00000, 5'b?????, 3'b???, 5'b?????, 7'b0101100} + `endif diff --git a/v/vanilla_bean/cl_decode.v b/v/vanilla_bean/cl_decode.v index 7bf860c72..90463bb69 100644 --- a/v/vanilla_bean/cl_decode.v +++ b/v/vanilla_bean/cl_decode.v @@ -12,7 +12,6 @@ */ `include "bsg_vanilla_defines.vh" -`include "bsg_riscv_defines.vh" module cl_decode import bsg_vanilla_pkg::*; @@ -31,19 +30,19 @@ always_comb begin end else begin unique casez (instruction_i.op) - `RV32_LUI_OP, `RV32_AUIPC_OP, - `RV32_JAL_OP, `RV32_JALR_OP, - `RV32_LOAD, `RV32_OP, - `RV32_OP_IMM, `RV32_AMO_OP: begin + `VANILLA_LUI_OP, `VANILLA_AUIPC_OP, + `VANILLA_JAL_OP, `VANILLA_JALR_OP, + `VANILLA_LOAD, `VANILLA_OP, + `VANILLA_OP_IMM, `VANILLA_AMO_OP: begin decode_o.write_rd = 1'b1; end - `RV32_OP_FP: begin + `VANILLA_OP_FP: begin decode_o.write_rd = - (instruction_i.funct7 == `RV32_FCMP_S_FUN7) // FEQ, FLT, FLE - | ((instruction_i.funct7 == `RV32_FCLASS_S_FUN7) & (instruction_i.rs2 == 5'b00000)) // FCLASS, FMV.X.W - | ((instruction_i.funct7 == `RV32_FCVT_S_F2I_FUN7)); // FCVT.W.S, FCVT.WU.S + (instruction_i.funct7 == `VANILLA_FCMP_S_FUN7) // FEQ, FLT, FLE + | ((instruction_i.funct7 == `VANILLA_FCLASS_S_FUN7) & (instruction_i.rs2 == 5'b00000)) // FCLASS, FMV.X.W + | ((instruction_i.funct7 == `VANILLA_FCVT_S_F2I_FUN7)); // FCVT.W.S, FCVT.WU.S end - `RV32_SYSTEM: begin + `VANILLA_SYSTEM: begin decode_o.write_rd = 1'b1; // CSRRW, CSRRS end default: begin @@ -56,23 +55,23 @@ end // declares if OP reads from first port of register file always_comb begin unique casez (instruction_i.op) - `RV32_JALR_OP, `RV32_BRANCH, - `RV32_LOAD, `RV32_STORE, - `RV32_OP, `RV32_OP_IMM, - `RV32_AMO_OP: begin + `VANILLA_JALR_OP, `VANILLA_BRANCH, + `VANILLA_LOAD, `VANILLA_STORE, + `VANILLA_OP, `VANILLA_OP_IMM, + `VANILLA_AMO_OP: begin decode_o.read_rs1 = 1'b1; end - `RV32_OP_FP: begin + `VANILLA_OP_FP: begin decode_o.read_rs1 = - (instruction_i.funct7 == `RV32_FCVT_S_I2F_FUN7) // FCVT.S.W, FCVT.S.WU - | (instruction_i.funct7 == `RV32_FMV_W_X_FUN7); // FMV.W.X + (instruction_i.funct7 == `VANILLA_FCVT_S_I2F_FUN7) // FCVT.S.W, FCVT.S.WU + | (instruction_i.funct7 == `VANILLA_FMV_W_X_FUN7); // FMV.W.X end - `RV32_LOAD_FP, `RV32_STORE_FP: begin // FLW, FSW + `VANILLA_LOAD_FP, `VANILLA_STORE_FP: begin // FLW, FSW decode_o.read_rs1 = 1'b1; end - `RV32_SYSTEM: begin + `VANILLA_SYSTEM: begin case (instruction_i.funct3) - `RV32_CSRRW_FUN3, `RV32_CSRRS_FUN3, `RV32_CSRRC_FUN3: begin + `VANILLA_CSRRW_FUN3, `VANILLA_CSRRS_FUN3, `VANILLA_CSRRC_FUN3: begin decode_o.read_rs1 = 1'b1; end default: begin @@ -89,10 +88,10 @@ end // declares if Op reads from second port of register file always_comb begin unique casez (instruction_i.op) - `RV32_BRANCH, `RV32_STORE, `RV32_OP: begin + `VANILLA_BRANCH, `VANILLA_STORE, `VANILLA_OP: begin decode_o.read_rs2 = 1'b1; end - `RV32_AMO_OP: begin + `VANILLA_AMO_OP: begin // According the ISA, LR instruction don't read rs2 decode_o.read_rs2 = (instruction_i.funct7 ==? 7'b00001??) // amoswap | (instruction_i.funct7 ==? 7'b01000??) // amoor @@ -105,36 +104,36 @@ always_comb begin end // Load & Store -wire is_rv32_load = (instruction_i.op == `RV32_LOAD); -wire is_rv32_store = (instruction_i.op == `RV32_STORE); -assign decode_o.is_load_op = is_rv32_load | (instruction_i.op == `RV32_LOAD_FP); -assign decode_o.is_store_op = is_rv32_store | (instruction_i.op == `RV32_STORE_FP); +wire is_vanilla_load = (instruction_i.op == `VANILLA_LOAD); +wire is_vanilla_store = (instruction_i.op == `VANILLA_STORE); +assign decode_o.is_load_op = is_vanilla_load | (instruction_i.op == `VANILLA_LOAD_FP); +assign decode_o.is_store_op = is_vanilla_store | (instruction_i.op == `VANILLA_STORE_FP); assign decode_o.is_byte_op = - (is_rv32_load & (instruction_i.funct3 ==? 3'b?00)) | - (is_rv32_store & (instruction_i.funct3 == 3'b000)); + (is_vanilla_load & (instruction_i.funct3 ==? 3'b?00)) | + (is_vanilla_store & (instruction_i.funct3 == 3'b000)); assign decode_o.is_hex_op = - (is_rv32_load & (instruction_i.funct3 ==? 3'b?01)) | - (is_rv32_store & (instruction_i.funct3 == 3'b001)); + (is_vanilla_load & (instruction_i.funct3 ==? 3'b?01)) | + (is_vanilla_store & (instruction_i.funct3 == 3'b001)); assign decode_o.is_load_unsigned = - is_rv32_load & (instruction_i.funct3 ==? 3'b10?); + is_vanilla_load & (instruction_i.funct3 ==? 3'b10?); // Branch & Jump -assign decode_o.is_branch_op = instruction_i.op ==? `RV32_BRANCH; -assign decode_o.is_jal_op = instruction_i.op == `RV32_JAL_OP; -assign decode_o.is_jalr_op = instruction_i.op == `RV32_JALR_OP; +assign decode_o.is_branch_op = instruction_i.op ==? `VANILLA_BRANCH; +assign decode_o.is_jal_op = instruction_i.op == `VANILLA_JAL_OP; +assign decode_o.is_jalr_op = instruction_i.op == `VANILLA_JALR_OP; // MEMORY FENCE always_comb begin decode_o.is_fence_op = 1'b0; decode_o.is_barsend_op = 1'b0; decode_o.is_barrecv_op = 1'b0; - if (instruction_i ==? `RV32_FENCE_OP) begin + if (instruction_i ==? `VANILLA_FENCE_OP) begin // fence FM unique casez (instruction_i[31:28]) - `RV32_FENCE_FM: decode_o.is_fence_op = 1'b1; - `RV32_BARSEND_FM: decode_o.is_barsend_op = 1'b1; - `RV32_BARRECV_FM: decode_o.is_barrecv_op = 1'b1; + `VANILLA_FENCE_FM: decode_o.is_fence_op = 1'b1; + `VANILLA_BARSEND_FM: decode_o.is_barsend_op = 1'b1; + `VANILLA_BARRECV_FM: decode_o.is_barrecv_op = 1'b1; default: begin decode_o.is_fence_op = 1'b0; decode_o.is_barsend_op = 1'b0; @@ -146,14 +145,14 @@ end // CSR always_comb begin - if (instruction_i.op == `RV32_SYSTEM) begin + if (instruction_i.op == `VANILLA_SYSTEM) begin case (instruction_i.funct3) - `RV32_CSRRW_FUN3, - `RV32_CSRRS_FUN3, - `RV32_CSRRC_FUN3, - `RV32_CSRRWI_FUN3, - `RV32_CSRRSI_FUN3, - `RV32_CSRRCI_FUN3: begin + `VANILLA_CSRRW_FUN3, + `VANILLA_CSRRS_FUN3, + `VANILLA_CSRRC_FUN3, + `VANILLA_CSRRWI_FUN3, + `VANILLA_CSRRSI_FUN3, + `VANILLA_CSRRCI_FUN3: begin decode_o.is_csr_op = 1'b1; end default: begin @@ -167,7 +166,7 @@ always_comb begin end // MRET -assign decode_o.is_mret_op = (instruction_i == `RV32_MRET); +assign decode_o.is_mret_op = (instruction_i == `VANILLA_MRET); //+---------------------------------------------- @@ -176,23 +175,23 @@ assign decode_o.is_mret_op = (instruction_i == `RV32_MRET); //| //+---------------------------------------------- -assign decode_o.is_imul_op = (instruction_i ==? `RV32_MUL); +assign decode_o.is_imul_op = (instruction_i ==? `VANILLA_MUL); always_comb begin unique casez (instruction_i) - `RV32_DIV: begin + `VANILLA_DIV: begin decode_o.is_idiv_op = 1'b1; decode_o.idiv_op = eDIV; end - `RV32_DIVU: begin + `VANILLA_DIVU: begin decode_o.is_idiv_op = 1'b1; decode_o.idiv_op = eDIVU; end - `RV32_REM: begin + `VANILLA_REM: begin decode_o.is_idiv_op = 1'b1; decode_o.idiv_op = eREM; end - `RV32_REMU: begin + `VANILLA_REMU: begin decode_o.is_idiv_op = 1'b1; decode_o.idiv_op = eREMU; end @@ -211,21 +210,21 @@ end //+---------------------------------------------- // LOAD RESERVATION -assign decode_o.is_lr_op = (instruction_i ==? `RV32_LR_W); -assign decode_o.is_lr_aq_op = (instruction_i ==? `RV32_LR_W_AQ); +assign decode_o.is_lr_op = (instruction_i ==? `VANILLA_LR_W); +assign decode_o.is_lr_aq_op = (instruction_i ==? `VANILLA_LR_W_AQ); // ATOMICS always_comb begin unique casez (instruction_i) - `RV32_AMOSWAP_W: begin + `VANILLA_AMOSWAP_W: begin decode_o.is_amo_op = 1'b1; decode_o.amo_type = e_vanilla_amoswap; end - `RV32_AMOOR_W: begin + `VANILLA_AMOOR_W: begin decode_o.is_amo_op = 1'b1; decode_o.amo_type = e_vanilla_amoor; end - `RV32_AMOADD_W: begin + `VANILLA_AMOADD_W: begin decode_o.is_amo_op = 1'b1; decode_o.amo_type = e_vanilla_amoadd; end @@ -254,9 +253,9 @@ always_comb begin decode_o.is_fp_op = 1'b0; unique casez (instruction_i) // Rtype float instr - `RV32_FADD_S, `RV32_FSUB_S, `RV32_FMUL_S, - `RV32_FSGNJ_S, `RV32_FSGNJN_S, `RV32_FSGNJX_S, - `RV32_FMIN_S, `RV32_FMAX_S: begin + `VANILLA_FADD_S, `VANILLA_FSUB_S, `VANILLA_FMUL_S, + `VANILLA_FSGNJ_S, `VANILLA_FSGNJN_S, `VANILLA_FSGNJX_S, + `VANILLA_FMIN_S, `VANILLA_FMAX_S: begin decode_o.read_frs1 = 1'b1; decode_o.read_frs2 = 1'b1; decode_o.read_frs3 = 1'b0; @@ -264,7 +263,7 @@ always_comb begin decode_o.is_fp_op = 1'b1; end // compare - `RV32_FEQ_S, `RV32_FLT_S, `RV32_FLE_S: begin + `VANILLA_FEQ_S, `VANILLA_FLT_S, `VANILLA_FLE_S: begin decode_o.read_frs1 = 1'b1; decode_o.read_frs2 = 1'b1; decode_o.read_frs3 = 1'b0; @@ -272,7 +271,7 @@ always_comb begin decode_o.is_fp_op = 1'b1; end // classify - `RV32_FCLASS_S: begin + `VANILLA_FCLASS_S: begin decode_o.read_frs1 = 1'b1; decode_o.read_frs2 = 1'b0; decode_o.read_frs3 = 1'b0; @@ -280,7 +279,7 @@ always_comb begin decode_o.is_fp_op = 1'b1; end // i2f (signed int) - `RV32_FCVT_S_W, `RV32_FCVT_S_WU: begin + `VANILLA_FCVT_S_W, `VANILLA_FCVT_S_WU: begin decode_o.read_frs1 = 1'b0; decode_o.read_frs2 = 1'b0; decode_o.read_frs3 = 1'b0; @@ -288,7 +287,7 @@ always_comb begin decode_o.is_fp_op = 1'b1; end // f2i - `RV32_FCVT_W_S, `RV32_FCVT_WU_S: begin + `VANILLA_FCVT_W_S, `VANILLA_FCVT_WU_S: begin decode_o.read_frs1 = 1'b1; decode_o.read_frs2 = 1'b0; decode_o.read_frs3 = 1'b0; @@ -296,7 +295,7 @@ always_comb begin decode_o.is_fp_op = 1'b1; end // FMV (fp -> int) - `RV32_FMV_X_W: begin + `VANILLA_FMV_X_W: begin decode_o.read_frs1 = 1'b1; decode_o.read_frs2 = 1'b0; decode_o.read_frs3 = 1'b0; @@ -304,7 +303,7 @@ always_comb begin decode_o.is_fp_op = 1'b1; end // FMV (int -> fp) - `RV32_FMV_W_X: begin + `VANILLA_FMV_W_X: begin decode_o.read_frs1 = 1'b0; decode_o.read_frs2 = 1'b0; decode_o.read_frs3 = 1'b0; @@ -312,7 +311,7 @@ always_comb begin decode_o.is_fp_op = 1'b1; end // Float load - `RV32_FLW_S: begin + `VANILLA_FLW_S: begin decode_o.read_frs1 = 1'b0; decode_o.read_frs2 = 1'b0; decode_o.read_frs3 = 1'b0; @@ -320,7 +319,7 @@ always_comb begin decode_o.is_fp_op = 1'b0; end // Float store - `RV32_FSW_S: begin + `VANILLA_FSW_S: begin decode_o.read_frs1 = 1'b0; decode_o.read_frs2 = 1'b1; decode_o.read_frs3 = 1'b0; @@ -328,7 +327,7 @@ always_comb begin decode_o.is_fp_op = 1'b0; end // FMA - `RV32_FMADD_S, `RV32_FMSUB_S, `RV32_FNMSUB_S, `RV32_FNMADD_S: begin + `VANILLA_FMADD_S, `VANILLA_FMSUB_S, `VANILLA_FNMSUB_S, `VANILLA_FNMADD_S: begin decode_o.read_frs1 = 1'b1; decode_o.read_frs2 = 1'b1; decode_o.read_frs3 = 1'b1; @@ -336,7 +335,7 @@ always_comb begin decode_o.is_fp_op = 1'b1; end // FDIV, SQRT - `RV32_FDIV_S, `RV32_FSQRT_S: begin + `VANILLA_FDIV_S, `VANILLA_FSQRT_S: begin decode_o.read_frs1 = 1'b1; decode_o.read_frs2 = 1'b1; decode_o.read_frs3 = 1'b0; @@ -364,103 +363,103 @@ always_comb begin fp_decode_o.fpu_int_op = eFEQ; unique casez (instruction_i) - `RV32_FADD_S: begin + `VANILLA_FADD_S: begin fp_decode_o.is_fpu_float_op = 1'b1; fp_decode_o.fpu_float_op = eFADD; end - `RV32_FSUB_S: begin + `VANILLA_FSUB_S: begin fp_decode_o.is_fpu_float_op = 1'b1; fp_decode_o.fpu_float_op = eFSUB; end - `RV32_FMUL_S: begin + `VANILLA_FMUL_S: begin fp_decode_o.is_fpu_float_op = 1'b1; fp_decode_o.fpu_float_op = eFMUL; end - `RV32_FSGNJ_S: begin + `VANILLA_FSGNJ_S: begin fp_decode_o.is_fpu_float_op = 1'b1; fp_decode_o.fpu_float_op = eFSGNJ; end - `RV32_FSGNJN_S: begin + `VANILLA_FSGNJN_S: begin fp_decode_o.is_fpu_float_op = 1'b1; fp_decode_o.fpu_float_op = eFSGNJN; end - `RV32_FSGNJX_S: begin + `VANILLA_FSGNJX_S: begin fp_decode_o.is_fpu_float_op = 1'b1; fp_decode_o.fpu_float_op = eFSGNJX; end - `RV32_FMIN_S: begin + `VANILLA_FMIN_S: begin fp_decode_o.is_fpu_float_op = 1'b1; fp_decode_o.fpu_float_op = eFMIN; end - `RV32_FMAX_S: begin + `VANILLA_FMAX_S: begin fp_decode_o.is_fpu_float_op = 1'b1; fp_decode_o.fpu_float_op = eFMAX; end // i2f signed - `RV32_FCVT_S_W: begin + `VANILLA_FCVT_S_W: begin fp_decode_o.is_fpu_float_op = 1'b1; fp_decode_o.fpu_float_op = eFCVT_S_W; end // i2f unsigned - `RV32_FCVT_S_WU: begin + `VANILLA_FCVT_S_WU: begin fp_decode_o.is_fpu_float_op = 1'b1; fp_decode_o.fpu_float_op = eFCVT_S_WU; end // move i->f - `RV32_FMV_W_X: begin + `VANILLA_FMV_W_X: begin fp_decode_o.is_fpu_float_op = 1'b1; fp_decode_o.fpu_float_op = eFMV_W_X; end - `RV32_FMADD_S: begin + `VANILLA_FMADD_S: begin fp_decode_o.is_fpu_float_op = 1'b1; fp_decode_o.fpu_float_op = eFMADD; end - `RV32_FMSUB_S: begin + `VANILLA_FMSUB_S: begin fp_decode_o.is_fpu_float_op = 1'b1; fp_decode_o.fpu_float_op = eFMSUB; end - `RV32_FNMSUB_S: begin + `VANILLA_FNMSUB_S: begin fp_decode_o.is_fpu_float_op = 1'b1; fp_decode_o.fpu_float_op = eFNMSUB; end - `RV32_FNMADD_S: begin + `VANILLA_FNMADD_S: begin fp_decode_o.is_fpu_float_op = 1'b1; fp_decode_o.fpu_float_op = eFNMADD; end - `RV32_FDIV_S: begin + `VANILLA_FDIV_S: begin fp_decode_o.is_fdiv_op = 1'b1; end - `RV32_FSQRT_S: begin + `VANILLA_FSQRT_S: begin fp_decode_o.is_fsqrt_op = 1'b1; end - `RV32_FEQ_S: begin + `VANILLA_FEQ_S: begin fp_decode_o.is_fpu_int_op = 1'b1; fp_decode_o.fpu_int_op = eFEQ; end - `RV32_FLE_S: begin + `VANILLA_FLE_S: begin fp_decode_o.is_fpu_int_op = 1'b1; fp_decode_o.fpu_int_op = eFLE; end - `RV32_FLT_S: begin + `VANILLA_FLT_S: begin fp_decode_o.is_fpu_int_op = 1'b1; fp_decode_o.fpu_int_op = eFLT; end // f2i signed - `RV32_FCVT_W_S: begin + `VANILLA_FCVT_W_S: begin fp_decode_o.is_fpu_int_op = 1'b1; fp_decode_o.fpu_int_op = eFCVT_W_S; end // f2i unsigned - `RV32_FCVT_WU_S: begin + `VANILLA_FCVT_WU_S: begin fp_decode_o.is_fpu_int_op = 1'b1; fp_decode_o.fpu_int_op = eFCVT_WU_S; end - `RV32_FCLASS_S: begin + `VANILLA_FCLASS_S: begin fp_decode_o.is_fpu_int_op = 1'b1; fp_decode_o.fpu_int_op = eFCLASS; end // move f->i - `RV32_FMV_X_W: begin + `VANILLA_FMV_X_W: begin fp_decode_o.is_fpu_int_op = 1'b1; fp_decode_o.fpu_int_op = eFMV_X_W; end @@ -479,7 +478,7 @@ end // mulh, mulhsu, mulhu always_comb begin unique casez (instruction_i) - `RV32_MULH, `RV32_MULHSU, `RV32_MULHU: begin + `VANILLA_MULH, `VANILLA_MULHSU, `VANILLA_MULHU: begin decode_o.unsupported = 1'b1; end default: begin @@ -489,4 +488,3 @@ always_comb begin end endmodule - diff --git a/v/vanilla_bean/fcsr.v b/v/vanilla_bean/fcsr.v index 73ae57b64..2be54aab7 100644 --- a/v/vanilla_bean/fcsr.v +++ b/v/vanilla_bean/fcsr.v @@ -3,7 +3,7 @@ * */ -`include "bsg_vanilla_defines.vh" +`include "bsg_manycore_instruction_defines.vh" module fcsr import bsg_vanilla_pkg::*; @@ -41,27 +41,27 @@ module fcsr always_comb begin if (v_i) begin case (funct3_i) - `VANILLA_CSRRW_FUN3: begin + `MANYCORE_CSRRW_FUN3: begin write_mask = {8{1'b1}}; write_data = data_i; end - `VANILLA_CSRRS_FUN3: begin + `MANYCORE_CSRRS_FUN3: begin write_mask = data_i; write_data = data_i; end - `VANILLA_CSRRC_FUN3: begin + `MANYCORE_CSRRC_FUN3: begin write_mask = data_i; write_data = ~data_i; end - `VANILLA_CSRRWI_FUN3: begin + `MANYCORE_CSRRWI_FUN3: begin write_mask = {8{1'b1}}; write_data = {3'b000, rs1_i}; end - `VANILLA_CSRRSI_FUN3: begin + `MANYCORE_CSRRSI_FUN3: begin write_mask = {3'b000, rs1_i}; write_data = {3'b000, rs1_i}; end - `VANILLA_CSRRCI_FUN3: begin + `MANYCORE_CSRRCI_FUN3: begin write_mask = {3'b000, rs1_i}; write_data = {3'b000, ~rs1_i}; end @@ -87,12 +87,12 @@ module fcsr always_comb begin case (addr_i) // frm - `VANILLA_CSR_FRM_ADDR: begin + `MANYCORE_CSR_FRM_ADDR: begin frm_write_mask = write_mask[0+:frm_width_lp]; frm_write_data = write_data[0+:frm_width_lp]; end // fcsr - `VANILLA_CSR_FCSR_ADDR: begin + `MANYCORE_CSR_FCSR_ADDR: begin frm_write_mask = write_mask[fflags_width_lp+:frm_width_lp]; frm_write_data = write_data[fflags_width_lp+:frm_width_lp]; end @@ -120,8 +120,8 @@ module fcsr if (v_i) begin case (addr_i) // fflags, fcsr - `VANILLA_CSR_FFLAGS_ADDR, - `VANILLA_CSR_FCSR_ADDR: begin + `MANYCORE_CSR_FFLAGS_ADDR, + `MANYCORE_CSR_FCSR_ADDR: begin fflags_write_mask = write_mask[0+:fflags_width_lp]; fflags_write_data = write_data[0+:fflags_width_lp]; end @@ -158,16 +158,16 @@ module fcsr // output always_comb begin case (addr_i) - `VANILLA_CSR_FFLAGS_ADDR: begin + `MANYCORE_CSR_FFLAGS_ADDR: begin data_o = {3'b0, fflags_r}; data_v_o = 1'b1; end - `VANILLA_CSR_FRM_ADDR: begin + `MANYCORE_CSR_FRM_ADDR: begin data_o = {5'b0, frm_r}; data_v_o = 1'b1; end - `VANILLA_CSR_FCSR_ADDR: begin - data_o = {frm_r, fflags_r}; + `MANYCORE_CSR_FCSR_ADDR: begin + data_o = {frm_r, fflags_r}; data_v_o = 1'b1; end default: begin @@ -185,7 +185,7 @@ module fcsr if (~reset_i) begin // this assertion checks that there are no fflags exception being accrued // while fflags are being accessed by CSR instruction in ID. - if (v_i & ((addr_i == `VANILLA_CSR_FFLAGS_ADDR) || (addr_i == `VANILLA_CSR_FCSR_ADDR))) begin + if (v_i & ((addr_i == `MANYCORE_CSR_FFLAGS_ADDR) || (addr_i == `MANYCORE_CSR_FCSR_ADDR))) begin assert(~(|fflags_v_i)) else $error("[BSG_ERROR] Exception cannot be accrued while being written by fcsr op."); end end diff --git a/v/vanilla_bean/fpu_float_fma.v b/v/vanilla_bean/fpu_float_fma.v index 55d9af624..960ddb56a 100644 --- a/v/vanilla_bean/fpu_float_fma.v +++ b/v/vanilla_bean/fpu_float_fma.v @@ -4,7 +4,7 @@ */ -`include "bsg_vanilla_defines.vh" +`include "bsg_manycore_instruction_defines.vh" `include "HardFloat_consts.vi" `include "HardFloat_specialize.vi" diff --git a/v/vanilla_bean/fpu_fmin_fmax.v b/v/vanilla_bean/fpu_fmin_fmax.v index e91805f86..32f429599 100644 --- a/v/vanilla_bean/fpu_fmin_fmax.v +++ b/v/vanilla_bean/fpu_fmin_fmax.v @@ -10,7 +10,7 @@ // If only one operand is a NaN, the result is non-NaN operand. // Signaling NaN inputs set the invalid exception flag, even when the result is not NaN. -`include "bsg_vanilla_defines.vh" +`include "bsg_manycore_instruction_defines.vh" module fpu_fmin_fmax #(`BSG_INV_PARAM(exp_width_p) diff --git a/v/vanilla_bean/icache.v b/v/vanilla_bean/icache.v index c59c8966e..d546c9b8e 100644 --- a/v/vanilla_bean/icache.v +++ b/v/vanilla_bean/icache.v @@ -9,7 +9,7 @@ * https://docs.google.com/presentation/d/1ZeRHYhqMHJQ0mRgDTilLuWQrZF7On-Be_KNNosgeW0c/edit#slide=id.g10d2e6febb9_1_0 */ -`include "bsg_vanilla_defines.vh" +`include "bsg_manycore_instruction_defines.vh" module icache import bsg_vanilla_pkg::*; @@ -103,14 +103,14 @@ module icache // instruction_s w_instr; assign w_instr = w_instr_i; - wire write_branch_instr = w_instr.op ==? `VANILLA_BRANCH; - wire write_jal_instr = w_instr.op ==? `VANILLA_JAL_OP; + wire write_branch_instr = w_instr.op ==? `MANYCORE_BRANCH; + wire write_jal_instr = w_instr.op ==? `MANYCORE_JAL_OP; // BYTE address computation - wire [branch_pc_low_width_lp-1:0] branch_imm_val = `Vanilla_Bimm_13extract(w_instr); + wire [branch_pc_low_width_lp-1:0] branch_imm_val = `MANYCORE_Bimm_13extract(w_instr); wire [branch_pc_low_width_lp-1:0] branch_pc_val = branch_pc_low_width_lp'({w_pc_i, 2'b0}); - wire [jal_pc_low_width_lp-1:0] jal_imm_val = `Vanilla_Jimm_21extract(w_instr); + wire [jal_pc_low_width_lp-1:0] jal_imm_val = `MANYCORE_Jimm_21extract(w_instr); wire [jal_pc_low_width_lp-1:0] jal_pc_val = jal_pc_low_width_lp'({w_pc_i, 2'b0}); logic [branch_pc_low_width_lp-1:0] branch_pc_lower_res; @@ -124,9 +124,9 @@ module icache // Inject the 2-BYTE (half) address, the LSB is ignored. wire [instr_width_gp-1:0] injected_instr = write_branch_instr - ? `Vanilla_Bimm_12inject1(w_instr, branch_pc_lower_res) + ? `MANYCORE_Bimm_12inject1(w_instr, branch_pc_lower_res) : (write_jal_instr - ? `Vanilla_Jimm_20inject1(w_instr, jal_pc_lower_res) + ? `MANYCORE_Jimm_20inject1(w_instr, jal_pc_lower_res) : w_instr); wire imm_sign = write_branch_instr @@ -275,15 +275,15 @@ module icache end end - wire is_jal_instr = instr_out.op == `VANILLA_JAL_OP; - wire is_jalr_instr = instr_out.op == `VANILLA_JALR_OP; + wire is_jal_instr = instr_out.op == `MANYCORE_JAL_OP; + wire is_jalr_instr = instr_out.op == `MANYCORE_JALR_OP; // these are bytes address logic [pc_width_lp+2-1:0] jal_pc; logic [pc_width_lp+2-1:0] branch_pc; - assign branch_pc = {branch_pc_high_out, `Vanilla_Bimm_13extract(instr_out)}; - assign jal_pc = {jal_pc_high_out, `Vanilla_Jimm_21extract(instr_out)}; + assign branch_pc = {branch_pc_high_out, `MANYCORE_Bimm_13extract(instr_out)}; + assign jal_pc = {jal_pc_high_out, `MANYCORE_Jimm_21extract(instr_out)}; // assign outputs. assign instr_o = instr_out; diff --git a/v/vanilla_bean/mcsr.v b/v/vanilla_bean/mcsr.v index 8bf56f1d1..47901b746 100644 --- a/v/vanilla_bean/mcsr.v +++ b/v/vanilla_bean/mcsr.v @@ -87,186 +87,30 @@ module mcsr // mstatus - // priority (high to low) - // 1) mret - // 2) interrupt taken - // 3) csr instr - // *1,2 are mutually exclusive events. + // Not used in Vanilla ISA Manycore. RISCV uses a seperate mcsr.v files in + // bsg_manycore_ISA. always_comb begin mstatus_n = mstatus_r; - - if (mret_called_i) begin - mstatus_n.mie = mstatus_r.mpie; - mstatus_n.mpie = 1'b0; - end - else if (interrupt_entered_i) begin - mstatus_n.mie = 1'b0; - mstatus_n.mpie = mstatus_r.mie; - end - else if (we_i & (addr_i == `VANILLA_CSR_MSTATUS_ADDR)) begin - case (funct3_i) - `VANILLA_CSRRW_FUN3: begin - mstatus_n.mpie = data_i[`VANILLA_MSTATUS_MPIE_BIT_IDX]; - mstatus_n.mie = data_i[`VANILLA_MSTATUS_MIE_BIT_IDX]; - end - `VANILLA_CSRRS_FUN3: begin - mstatus_n.mpie = data_i[`VANILLA_MSTATUS_MPIE_BIT_IDX] - ? 1'b1 - : mstatus_r.mpie; - mstatus_n.mie = data_i[`VANILLA_MSTATUS_MIE_BIT_IDX] - ? 1'b1 - : mstatus_r.mie; - end - `VANILLA_CSRRC_FUN3: begin - mstatus_n.mpie = data_i[`VANILLA_MSTATUS_MPIE_BIT_IDX] - ? 1'b0 - : mstatus_r.mpie; - mstatus_n.mie = data_i[`VANILLA_MSTATUS_MIE_BIT_IDX] - ? 1'b0 - : mstatus_r.mie; - end - `VANILLA_CSRRWI_FUN3: begin - mstatus_n.mie = rs1_i[`VANILLA_MSTATUS_MIE_BIT_IDX]; - end - `VANILLA_CSRRSI_FUN3: begin - mstatus_n.mie = rs1_i[`VANILLA_MSTATUS_MIE_BIT_IDX] - ? 1'b1 - : mstatus_r.mie; - end - `VANILLA_CSRRCI_FUN3: begin - mstatus_n.mie = rs1_i[`VANILLA_MSTATUS_MIE_BIT_IDX] - ? 1'b0 - : mstatus_r.mie; - end - default: begin - mstatus_n = mstatus_r; - end - endcase - end + mstatus_n.mie = 1'b0; + mstatus_n.mpie = 1'b0; end - // mie - // this can be only modified by csr instr. + // mie : Do nothing for vanilla ISA always_comb begin mie_n = mie_r; - if (we_i & (addr_i == `VANILLA_CSR_MIE_ADDR)) begin - case (funct3_i) - `VANILLA_CSRRW_FUN3: begin - mie_n = data_i[17:16]; - end - `VANILLA_CSRRS_FUN3: begin - mie_n.trace = data_i[17] - ? 1'b1 - : mie_r.trace; - mie_n.remote = data_i[16] - ? 1'b1 - : mie_r.remote; - end - `VANILLA_CSRRC_FUN3: begin - mie_n.trace = data_i[17] - ? 1'b0 - : mie_r.trace; - mie_n.remote = data_i[16] - ? 1'b0 - : mie_r.remote; - end - default: mie_n = mie_r; - endcase - end end - // mip - // mip.trace is set when an instruction is executed (ID->EXE), while outside interrupt. - // mip.remote can be set/clear by remote packet. - // Both can be modified by CSR instr, which has lower priority. + // mip : Do nothing for vanilla ISA always_comb begin mip_n = mip_r; - - // trace - // if trace enable bit is low, then execute instruction signal does not set the trace pending bit. - if (instr_executed_i & mie_r.trace) begin - mip_n.trace = 1'b1; - end - else if (we_i & (addr_i == `VANILLA_CSR_MIP_ADDR)) begin - case (funct3_i) - `VANILLA_CSRRW_FUN3: begin - mip_n.trace = data_i[17]; - end - `VANILLA_CSRRS_FUN3: begin - mip_n.trace = data_i[17] - ? 1'b1 - : mip_r.trace; - end - `VANILLA_CSRRC_FUN3: begin - mip_n.trace = data_i[17] - ? 1'b0 - : mip_r.trace; - end - default: mip_n = mip_r; - endcase - end - - // remote - if (remote_interrupt_set_i) begin - mip_n.remote = 1'b1; - end - else if (remote_interrupt_clear_i) begin - mip_n.remote = 1'b0; - end - else if (we_i & (addr_i == `VANILLA_CSR_MIP_ADDR)) begin - case (funct3_i) - `VANILLA_CSRRW_FUN3: begin - mip_n.remote = data_i[16]; - end - `VANILLA_CSRRS_FUN3: begin - mip_n.remote = data_i[16] - ? 1'b1 - : mip_r.remote; - end - `VANILLA_CSRRC_FUN3: begin - mip_n.remote = data_i[16] - ? 1'b0 - : mip_r.remote; - end - default: mip_n = mip_r; - endcase - end end - // mepc - // mepc is set when the interrupt is taken. - // when the interrupt is taken, ID stage will be flushed, so CSR instr in ID will not get a chance to modify. + // mepc : Do nothing for vanilla ISA always_comb begin mepc_n = mepc_r; - - if (interrupt_entered_i) begin - mepc_n = npc_r_i; - end - else if (we_i & (addr_i == `VANILLA_CSR_MEPC_ADDR)) begin - case (funct3_i) - `VANILLA_CSRRW_FUN3: begin - mepc_n = data_i[2+:pc_width_p]; - end - `VANILLA_CSRRS_FUN3: begin - for (integer i = 0; i < pc_width_p; i++) begin - mepc_n[i] = data_i[2+i] - ? 1'b1 - : mepc_r[i]; - end - end - `VANILLA_CSRRC_FUN3: begin - for (integer i = 0; i < pc_width_p; i++) begin - mepc_n[i] = data_i[2+i] - ? 1'b0 - : mepc_r[i]; - end - end - default: mepc_n = mepc_r; - endcase - end end @@ -340,24 +184,11 @@ module mcsr always_comb begin data_o = '0; case (addr_i) - `VANILLA_CSR_MSTATUS_ADDR: begin - data_o[`VANILLA_MSTATUS_MPIE_BIT_IDX] = mstatus_r.mpie; - data_o[`VANILLA_MSTATUS_MIE_BIT_IDX] = mstatus_r.mie; - end - `VANILLA_CSR_MIE_ADDR: begin - data_o[17:16] = mie_r; - end - `VANILLA_CSR_MIP_ADDR: begin - data_o[17:16] = mip_r; - end - `VANILLA_CSR_MEPC_ADDR: begin - data_o[2+:pc_width_p] = mepc_r; - end `VANILLA_CSR_CREDIT_LIMIT_ADDR: begin data_o[0+:credit_counter_width_p] = credit_limit_r; end `VANILLA_CSR_CFG_POD_ADDR: begin - data_o[0+:cfg_pod_width_p] = cfg_pod_r; + data_o[0+:cfg_pod_width_p] = cfg_pod_r; end `VANILLA_CSR_BARCFG_ADDR: begin data_o[0+:barrier_dirs_p] = barrier_src_r; @@ -369,7 +200,6 @@ module mcsr `VANILLA_CSR_BAR_PI_ADDR: begin data_o[0] = barrier_data_r; end - default: data_o = '0; endcase end diff --git a/v/vanilla_bean/vanilla_core.v b/v/vanilla_bean/vanilla_core.v index 847921e82..09042658a 100644 --- a/v/vanilla_bean/vanilla_core.v +++ b/v/vanilla_bean/vanilla_core.v @@ -7,7 +7,7 @@ */ `include "bsg_manycore_defines.vh" -`include "bsg_vanilla_defines.vh" +`include "bsg_manycore_instruction_defines.vh" module vanilla_core import bsg_vanilla_pkg::*; @@ -481,9 +481,9 @@ module vanilla_core // calculate mem address offset // wire [Iimm_width_gp-1:0] mem_addr_op2 = id_r.decode.is_store_op - ? `Vanilla_Simm_12extract(id_r.instruction) + ? `MANYCORE_Simm_12extract(id_r.instruction) : (id_r.decode.is_load_op - ? `Vanilla_Iimm_12extract(id_r.instruction) + ? `MANYCORE_Iimm_12extract(id_r.instruction) : '0); // 'aq' register @@ -1469,8 +1469,8 @@ module vanilla_core // stall_fcsr assign stall_fcsr = (id_r.decode.is_csr_op) - & ((id_r.instruction[31:20] == `VANILLA_CSR_FFLAGS_ADDR) - |(id_r.instruction[31:20] == `VANILLA_CSR_FCSR_ADDR)) + & ((id_r.instruction[31:20] == `MANYCORE_CSR_FFLAGS_ADDR) + |(id_r.instruction[31:20] == `MANYCORE_CSR_FCSR_ADDR)) & (fp_exe_ctrl_r.fp_decode.is_fpu_float_op |fp_exe_ctrl_r.fp_decode.is_fpu_int_op |fp_exe_ctrl_r.fp_decode.is_fdiv_op From 0298eb766d67e3c3c15886e6cbe9b245e4b3b8bc Mon Sep 17 00:00:00 2001 From: Prateek Mahajan Date: Thu, 11 Jan 2024 17:10:27 -0800 Subject: [PATCH 5/9] Convert .v files to .sv --- testbenches/common/v/{nb_waw_detector.v => nb_waw_detector.sv} | 0 .../common/v/{remote_load_trace.v => remote_load_trace.sv} | 0 .../{vanilla_core_pc_histogram.v => vanilla_core_pc_histogram.sv} | 0 .../v/{vanilla_core_profiler.v => vanilla_core_profiler.sv} | 0 .../common/v/{vanilla_core_trace.v => vanilla_core_trace.sv} | 0 ...a_exe_bubble_classifier.v => vanilla_exe_bubble_classifier.sv} | 0 ...vanilla_scoreboard_tracker.v => vanilla_scoreboard_tracker.sv} | 0 .../{test_fpu_fdiv_fsqrt.v => test_fpu_fdiv_fsqrt.sv} | 0 v/vanilla_bean/{alu.v => alu.sv} | 0 .../{bsg_manycore_proc_vanilla.v => bsg_manycore_proc_vanilla.sv} | 0 .../{bsg_vanilla_defines.vh => bsg_vanilla_defines.svh} | 0 v/vanilla_bean/{bsg_vanilla_pkg.v => bsg_vanilla_pkg.sv} | 0 v/vanilla_bean/{cl_decode.v => cl_decode.sv} | 0 v/vanilla_bean/{fcsr.v => fcsr.sv} | 0 v/vanilla_bean/{fpu_fdiv_fsqrt.v => fpu_fdiv_fsqrt.sv} | 0 v/vanilla_bean/{fpu_float.v => fpu_float.sv} | 0 v/vanilla_bean/{fpu_float_aux.v => fpu_float_aux.sv} | 0 v/vanilla_bean/{fpu_float_fma.v => fpu_float_fma.sv} | 0 v/vanilla_bean/{fpu_fmin_fmax.v => fpu_fmin_fmax.sv} | 0 v/vanilla_bean/{fpu_int.v => fpu_int.sv} | 0 v/vanilla_bean/{icache.v => icache.sv} | 0 v/vanilla_bean/{idiv.v => idiv.sv} | 0 v/vanilla_bean/{load_packer.v => load_packer.sv} | 0 v/vanilla_bean/{lsu.v => lsu.sv} | 0 v/vanilla_bean/{mcsr.v => mcsr.sv} | 0 25 files changed, 0 insertions(+), 0 deletions(-) rename testbenches/common/v/{nb_waw_detector.v => nb_waw_detector.sv} (100%) rename testbenches/common/v/{remote_load_trace.v => remote_load_trace.sv} (100%) rename testbenches/common/v/{vanilla_core_pc_histogram.v => vanilla_core_pc_histogram.sv} (100%) rename testbenches/common/v/{vanilla_core_profiler.v => vanilla_core_profiler.sv} (100%) rename testbenches/common/v/{vanilla_core_trace.v => vanilla_core_trace.sv} (100%) rename testbenches/common/v/{vanilla_exe_bubble_classifier.v => vanilla_exe_bubble_classifier.sv} (100%) rename testbenches/common/v/{vanilla_scoreboard_tracker.v => vanilla_scoreboard_tracker.sv} (100%) rename testbenches/hardfloat/fpu_fdiv_fsqrt/{test_fpu_fdiv_fsqrt.v => test_fpu_fdiv_fsqrt.sv} (100%) rename v/vanilla_bean/{alu.v => alu.sv} (100%) rename v/vanilla_bean/{bsg_manycore_proc_vanilla.v => bsg_manycore_proc_vanilla.sv} (100%) rename v/vanilla_bean/{bsg_vanilla_defines.vh => bsg_vanilla_defines.svh} (100%) rename v/vanilla_bean/{bsg_vanilla_pkg.v => bsg_vanilla_pkg.sv} (100%) rename v/vanilla_bean/{cl_decode.v => cl_decode.sv} (100%) rename v/vanilla_bean/{fcsr.v => fcsr.sv} (100%) rename v/vanilla_bean/{fpu_fdiv_fsqrt.v => fpu_fdiv_fsqrt.sv} (100%) rename v/vanilla_bean/{fpu_float.v => fpu_float.sv} (100%) rename v/vanilla_bean/{fpu_float_aux.v => fpu_float_aux.sv} (100%) rename v/vanilla_bean/{fpu_float_fma.v => fpu_float_fma.sv} (100%) rename v/vanilla_bean/{fpu_fmin_fmax.v => fpu_fmin_fmax.sv} (100%) rename v/vanilla_bean/{fpu_int.v => fpu_int.sv} (100%) rename v/vanilla_bean/{icache.v => icache.sv} (100%) rename v/vanilla_bean/{idiv.v => idiv.sv} (100%) rename v/vanilla_bean/{load_packer.v => load_packer.sv} (100%) rename v/vanilla_bean/{lsu.v => lsu.sv} (100%) rename v/vanilla_bean/{mcsr.v => mcsr.sv} (100%) diff --git a/testbenches/common/v/nb_waw_detector.v b/testbenches/common/v/nb_waw_detector.sv similarity index 100% rename from testbenches/common/v/nb_waw_detector.v rename to testbenches/common/v/nb_waw_detector.sv diff --git a/testbenches/common/v/remote_load_trace.v b/testbenches/common/v/remote_load_trace.sv similarity index 100% rename from testbenches/common/v/remote_load_trace.v rename to testbenches/common/v/remote_load_trace.sv diff --git a/testbenches/common/v/vanilla_core_pc_histogram.v b/testbenches/common/v/vanilla_core_pc_histogram.sv similarity index 100% rename from testbenches/common/v/vanilla_core_pc_histogram.v rename to testbenches/common/v/vanilla_core_pc_histogram.sv diff --git a/testbenches/common/v/vanilla_core_profiler.v b/testbenches/common/v/vanilla_core_profiler.sv similarity index 100% rename from testbenches/common/v/vanilla_core_profiler.v rename to testbenches/common/v/vanilla_core_profiler.sv diff --git a/testbenches/common/v/vanilla_core_trace.v b/testbenches/common/v/vanilla_core_trace.sv similarity index 100% rename from testbenches/common/v/vanilla_core_trace.v rename to testbenches/common/v/vanilla_core_trace.sv diff --git a/testbenches/common/v/vanilla_exe_bubble_classifier.v b/testbenches/common/v/vanilla_exe_bubble_classifier.sv similarity index 100% rename from testbenches/common/v/vanilla_exe_bubble_classifier.v rename to testbenches/common/v/vanilla_exe_bubble_classifier.sv diff --git a/testbenches/common/v/vanilla_scoreboard_tracker.v b/testbenches/common/v/vanilla_scoreboard_tracker.sv similarity index 100% rename from testbenches/common/v/vanilla_scoreboard_tracker.v rename to testbenches/common/v/vanilla_scoreboard_tracker.sv diff --git a/testbenches/hardfloat/fpu_fdiv_fsqrt/test_fpu_fdiv_fsqrt.v b/testbenches/hardfloat/fpu_fdiv_fsqrt/test_fpu_fdiv_fsqrt.sv similarity index 100% rename from testbenches/hardfloat/fpu_fdiv_fsqrt/test_fpu_fdiv_fsqrt.v rename to testbenches/hardfloat/fpu_fdiv_fsqrt/test_fpu_fdiv_fsqrt.sv diff --git a/v/vanilla_bean/alu.v b/v/vanilla_bean/alu.sv similarity index 100% rename from v/vanilla_bean/alu.v rename to v/vanilla_bean/alu.sv diff --git a/v/vanilla_bean/bsg_manycore_proc_vanilla.v b/v/vanilla_bean/bsg_manycore_proc_vanilla.sv similarity index 100% rename from v/vanilla_bean/bsg_manycore_proc_vanilla.v rename to v/vanilla_bean/bsg_manycore_proc_vanilla.sv diff --git a/v/vanilla_bean/bsg_vanilla_defines.vh b/v/vanilla_bean/bsg_vanilla_defines.svh similarity index 100% rename from v/vanilla_bean/bsg_vanilla_defines.vh rename to v/vanilla_bean/bsg_vanilla_defines.svh diff --git a/v/vanilla_bean/bsg_vanilla_pkg.v b/v/vanilla_bean/bsg_vanilla_pkg.sv similarity index 100% rename from v/vanilla_bean/bsg_vanilla_pkg.v rename to v/vanilla_bean/bsg_vanilla_pkg.sv diff --git a/v/vanilla_bean/cl_decode.v b/v/vanilla_bean/cl_decode.sv similarity index 100% rename from v/vanilla_bean/cl_decode.v rename to v/vanilla_bean/cl_decode.sv diff --git a/v/vanilla_bean/fcsr.v b/v/vanilla_bean/fcsr.sv similarity index 100% rename from v/vanilla_bean/fcsr.v rename to v/vanilla_bean/fcsr.sv diff --git a/v/vanilla_bean/fpu_fdiv_fsqrt.v b/v/vanilla_bean/fpu_fdiv_fsqrt.sv similarity index 100% rename from v/vanilla_bean/fpu_fdiv_fsqrt.v rename to v/vanilla_bean/fpu_fdiv_fsqrt.sv diff --git a/v/vanilla_bean/fpu_float.v b/v/vanilla_bean/fpu_float.sv similarity index 100% rename from v/vanilla_bean/fpu_float.v rename to v/vanilla_bean/fpu_float.sv diff --git a/v/vanilla_bean/fpu_float_aux.v b/v/vanilla_bean/fpu_float_aux.sv similarity index 100% rename from v/vanilla_bean/fpu_float_aux.v rename to v/vanilla_bean/fpu_float_aux.sv diff --git a/v/vanilla_bean/fpu_float_fma.v b/v/vanilla_bean/fpu_float_fma.sv similarity index 100% rename from v/vanilla_bean/fpu_float_fma.v rename to v/vanilla_bean/fpu_float_fma.sv diff --git a/v/vanilla_bean/fpu_fmin_fmax.v b/v/vanilla_bean/fpu_fmin_fmax.sv similarity index 100% rename from v/vanilla_bean/fpu_fmin_fmax.v rename to v/vanilla_bean/fpu_fmin_fmax.sv diff --git a/v/vanilla_bean/fpu_int.v b/v/vanilla_bean/fpu_int.sv similarity index 100% rename from v/vanilla_bean/fpu_int.v rename to v/vanilla_bean/fpu_int.sv diff --git a/v/vanilla_bean/icache.v b/v/vanilla_bean/icache.sv similarity index 100% rename from v/vanilla_bean/icache.v rename to v/vanilla_bean/icache.sv diff --git a/v/vanilla_bean/idiv.v b/v/vanilla_bean/idiv.sv similarity index 100% rename from v/vanilla_bean/idiv.v rename to v/vanilla_bean/idiv.sv diff --git a/v/vanilla_bean/load_packer.v b/v/vanilla_bean/load_packer.sv similarity index 100% rename from v/vanilla_bean/load_packer.v rename to v/vanilla_bean/load_packer.sv diff --git a/v/vanilla_bean/lsu.v b/v/vanilla_bean/lsu.sv similarity index 100% rename from v/vanilla_bean/lsu.v rename to v/vanilla_bean/lsu.sv diff --git a/v/vanilla_bean/mcsr.v b/v/vanilla_bean/mcsr.sv similarity index 100% rename from v/vanilla_bean/mcsr.v rename to v/vanilla_bean/mcsr.sv From 08c47a8d6d7b24408eb0fc662f4bba50fca3b244 Mon Sep 17 00:00:00 2001 From: Prateek Mahajan Date: Mon, 15 Jan 2024 10:17:16 -0800 Subject: [PATCH 6/9] Fixes to get Vanilla Instruction Set Working --- machines/Makefile | 4 +- testbenches/common/v/vanilla_core_profiler.sv | 76 +++++++++---------- .../common/v/vanilla_scoreboard_tracker.sv | 2 +- v/vanilla_bean/bsg_vanilla_defines.svh | 2 +- 4 files changed, 42 insertions(+), 42 deletions(-) diff --git a/machines/Makefile b/machines/Makefile index 004d9e08b..156a06b26 100644 --- a/machines/Makefile +++ b/machines/Makefile @@ -26,9 +26,9 @@ all: $(DEFAULT_TARGETS) $(DEFAULT_DEBUG_TARGETS) $(DEFAULT_PROFILE_TARGETS) # Include source lists # We include different source lists for different ISAs -ifeq ($(BSG_MANYCORE_ISA_DIR),VANILLA) +ifeq ($(BSG_MACHINE_ISA),VANILLA) include $(BSG_MANYCORE_DIR)/machines/arch_filelist.mk -else ifeq ($(BSG_MANYCORE_ISA_DIR),RISCV) +else ifeq ($(BSG_MACHINE_ISA),RISCV) include $(BSG_MANYCORE_ISA_DIR)/RISCV/arch_filelist.mk endif diff --git a/testbenches/common/v/vanilla_core_profiler.sv b/testbenches/common/v/vanilla_core_profiler.sv index 93fa7d6dd..f39f67eaa 100644 --- a/testbenches/common/v/vanilla_core_profiler.sv +++ b/testbenches/common/v/vanilla_core_profiler.sv @@ -1,5 +1,5 @@ /** - * vanilla_core_profiler.v + * vanilla_core_profiler.sv * */ @@ -207,12 +207,12 @@ module vanilla_core_profiler wire amoadd_inc = exe_r.decode.is_amo_op & (exe_r.decode.amo_type == e_vanilla_amoadd); // branch & jump - wire beq_inc = exe_r.decode.is_branch_op & (exe_r.instruction ==? `RV32_BEQ); - wire bne_inc = exe_r.decode.is_branch_op & (exe_r.instruction ==? `RV32_BNE); - wire blt_inc = exe_r.decode.is_branch_op & (exe_r.instruction ==? `RV32_BLT); - wire bge_inc = exe_r.decode.is_branch_op & (exe_r.instruction ==? `RV32_BGE); - wire bltu_inc = exe_r.decode.is_branch_op & (exe_r.instruction ==? `RV32_BLTU); - wire bgeu_inc = exe_r.decode.is_branch_op & (exe_r.instruction ==? `RV32_BGEU); + wire beq_inc = exe_r.decode.is_branch_op & (exe_r.instruction ==? `VANILLA_BEQ); + wire bne_inc = exe_r.decode.is_branch_op & (exe_r.instruction ==? `VANILLA_BNE); + wire blt_inc = exe_r.decode.is_branch_op & (exe_r.instruction ==? `VANILLA_BLT); + wire bge_inc = exe_r.decode.is_branch_op & (exe_r.instruction ==? `VANILLA_BGE); + wire bltu_inc = exe_r.decode.is_branch_op & (exe_r.instruction ==? `VANILLA_BLTU); + wire bgeu_inc = exe_r.decode.is_branch_op & (exe_r.instruction ==? `VANILLA_BGEU); wire jal_inc = exe_r.decode.is_jal_op; wire jalr_inc = exe_r.decode.is_jalr_op; @@ -227,29 +227,29 @@ module vanilla_core_profiler wire jalr_miss_inc = jalr_inc & jalr_mispredict; // ALU - wire sll_inc = (exe_r.instruction ==? `RV32_SLL); - wire slli_inc = (exe_r.instruction ==? `RV32_SLLI); - wire srl_inc = (exe_r.instruction ==? `RV32_SRL); - wire srli_inc = (exe_r.instruction ==? `RV32_SRLI); - wire sra_inc = (exe_r.instruction ==? `RV32_SRA); - wire srai_inc = (exe_r.instruction ==? `RV32_SRAI); - - wire add_inc = (exe_r.instruction ==? `RV32_ADD); - wire addi_inc = (exe_r.instruction ==? `RV32_ADDI); - wire sub_inc = (exe_r.instruction ==? `RV32_SUB); - wire lui_inc = (exe_r.instruction ==? `RV32_LUI); - wire auipc_inc = (exe_r.instruction ==? `RV32_AUIPC); - wire xor_inc = (exe_r.instruction ==? `RV32_XOR); - wire xori_inc = (exe_r.instruction ==? `RV32_XORI); - wire or_inc = (exe_r.instruction ==? `RV32_OR); - wire ori_inc = (exe_r.instruction ==? `RV32_ORI); - wire and_inc = (exe_r.instruction ==? `RV32_AND); - wire andi_inc = (exe_r.instruction ==? `RV32_ANDI); - - wire slt_inc = (exe_r.instruction ==? `RV32_SLT); - wire slti_inc = (exe_r.instruction ==? `RV32_SLTI); - wire sltu_inc = (exe_r.instruction ==? `RV32_SLTU); - wire sltiu_inc = (exe_r.instruction ==? `RV32_SLTIU); + wire sll_inc = (exe_r.instruction ==? `VANILLA_SLL); + wire slli_inc = (exe_r.instruction ==? `VANILLA_SLLI); + wire srl_inc = (exe_r.instruction ==? `VANILLA_SRL); + wire srli_inc = (exe_r.instruction ==? `VANILLA_SRLI); + wire sra_inc = (exe_r.instruction ==? `VANILLA_SRA); + wire srai_inc = (exe_r.instruction ==? `VANILLA_SRAI); + + wire add_inc = (exe_r.instruction ==? `VANILLA_ADD); + wire addi_inc = (exe_r.instruction ==? `VANILLA_ADDI); + wire sub_inc = (exe_r.instruction ==? `VANILLA_SUB); + wire lui_inc = (exe_r.instruction ==? `VANILLA_LUI); + wire auipc_inc = (exe_r.instruction ==? `VANILLA_AUIPC); + wire xor_inc = (exe_r.instruction ==? `VANILLA_XOR); + wire xori_inc = (exe_r.instruction ==? `VANILLA_XORI); + wire or_inc = (exe_r.instruction ==? `VANILLA_OR); + wire ori_inc = (exe_r.instruction ==? `VANILLA_ORI); + wire and_inc = (exe_r.instruction ==? `VANILLA_AND); + wire andi_inc = (exe_r.instruction ==? `VANILLA_ANDI); + + wire slt_inc = (exe_r.instruction ==? `VANILLA_SLT); + wire slti_inc = (exe_r.instruction ==? `VANILLA_SLTI); + wire sltu_inc = (exe_r.instruction ==? `VANILLA_SLTU); + wire sltiu_inc = (exe_r.instruction ==? `VANILLA_SLTIU); // IDIV wire div_inc = exe_r.decode.is_idiv_op & (exe_r.decode.idiv_op == eDIV); @@ -264,16 +264,16 @@ module vanilla_core_profiler wire fence_inc = exe_r.decode.is_fence_op; // CSR - wire csrrw_inc = (exe_r.instruction ==? `RV32_CSRRW); - wire csrrs_inc = (exe_r.instruction ==? `RV32_CSRRS); - wire csrrc_inc = (exe_r.instruction ==? `RV32_CSRRC); - wire csrrwi_inc = (exe_r.instruction ==? `RV32_CSRRWI); - wire csrrsi_inc = (exe_r.instruction ==? `RV32_CSRRSI); - wire csrrci_inc = (exe_r.instruction ==? `RV32_CSRRCI); + wire csrrw_inc = (exe_r.instruction ==? `VANILLA_CSRRW); + wire csrrs_inc = (exe_r.instruction ==? `VANILLA_CSRRS); + wire csrrc_inc = (exe_r.instruction ==? `VANILLA_CSRRC); + wire csrrwi_inc = (exe_r.instruction ==? `VANILLA_CSRRWI); + wire csrrsi_inc = (exe_r.instruction ==? `VANILLA_CSRRSI); + wire csrrci_inc = (exe_r.instruction ==? `VANILLA_CSRRCI); // Barrier Instruction - wire barsend_inc = (exe_r.instruction ==? `RV32_FENCE_OP) & (exe_r.instruction[31:28] == `RV32_BARSEND_FM); - wire barrecv_inc = (exe_r.instruction ==? `RV32_FENCE_OP) & (exe_r.instruction[31:28] == `RV32_BARRECV_FM); + wire barsend_inc = (exe_r.instruction ==? `VANILLA_FENCE_OP) & (exe_r.instruction[31:28] == `VANILLA_BARSEND_FM); + wire barrecv_inc = (exe_r.instruction ==? `VANILLA_FENCE_OP) & (exe_r.instruction[31:28] == `VANILLA_BARRECV_FM); // Track bubbles in the EXE stage // and their associated PC diff --git a/testbenches/common/v/vanilla_scoreboard_tracker.sv b/testbenches/common/v/vanilla_scoreboard_tracker.sv index 47dc3ee33..ceab8514f 100644 --- a/testbenches/common/v/vanilla_scoreboard_tracker.sv +++ b/testbenches/common/v/vanilla_scoreboard_tracker.sv @@ -40,7 +40,7 @@ module vanilla_scoreboard_tracker wire [reg_addr_width_lp-1:0] id_rs1 = id_r.instruction.rs1; wire [reg_addr_width_lp-1:0] id_rd = id_r.instruction.rd; wire [9:0] id_imm_plus4 = 1'b1 + mem_addr_op2[11:2]; - wire [11:0] if_load_imm = `Vanilla_Iimm_12extract(instruction); + wire [11:0] if_load_imm = `VANILLA_Iimm_12extract(instruction); wire is_seq_lw = id_r.decode.is_load_op & decode.is_load_op & id_r.decode.write_rd & decode.write_rd diff --git a/v/vanilla_bean/bsg_vanilla_defines.svh b/v/vanilla_bean/bsg_vanilla_defines.svh index c6d29da86..6950a9ed1 100644 --- a/v/vanilla_bean/bsg_vanilla_defines.svh +++ b/v/vanilla_bean/bsg_vanilla_defines.svh @@ -84,7 +84,7 @@ `define VANILLA_ORI `MANYCORE_ORI `define VANILLA_ANDI `MANYCORE_ANDI `define VANILLA_SLLI `MANYCORE_SLLI -`define VANILLA_SRLI `MANYCORE_SLRI +`define VANILLA_SRLI `MANYCORE_SRLI `define VANILLA_SRAI `MANYCORE_SRAI `define VANILLA_ADD `MANYCORE_ADD `define VANILLA_SUB `MANYCORE_SUB From 27aa9db7794380f7f0c0d6ef3359ff9fb9128995 Mon Sep 17 00:00:00 2001 From: Prateek Mahajan Date: Wed, 17 Jan 2024 10:29:02 -0800 Subject: [PATCH 7/9] Makefile and Platform Changes --- machines/Makefile | 11 ++++++----- machines/platform.mk | 5 +++++ 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/machines/Makefile b/machines/Makefile index 156a06b26..87434fc86 100644 --- a/machines/Makefile +++ b/machines/Makefile @@ -17,10 +17,6 @@ DEFAULT_TARGETS = $(foreach machine, $(DEFAULT_MACHINES),$(machine)/$(BSG_SIM_BA DEFAULT_DEBUG_TARGETS = $(foreach machine, $(DEFAULT_MACHINES),$(machine)/$(BSG_SIM_BASE)-debug) DEFAULT_PROFILE_TARGETS = $(foreach machine, $(DEFAULT_MACHINES),$(machine)/$(BSG_SIM_BASE)-profile) -# Default Machine ISA is Vanilla. This can be modified to any of the supported ISA in the repository bsg_manycore_ISA -# Note that you would have to sync the above repository as well to use another ISA -BSG_MACHINE_ISA ?= VANILLA - # set_vcs_machine_variables includes the Makefile.machine.include file and sets the all: $(DEFAULT_TARGETS) $(DEFAULT_DEBUG_TARGETS) $(DEFAULT_PROFILE_TARGETS) @@ -32,7 +28,12 @@ else ifeq ($(BSG_MACHINE_ISA),RISCV) include $(BSG_MANYCORE_ISA_DIR)/RISCV/arch_filelist.mk endif -include sim_filelist.mk +# We include different sim lists for different ISAs +ifeq ($(BSG_MACHINE_ISA),VANILLA) +include $(BSG_MANYCORE_DIR)/machines/sim_filelist.mk +else ifeq ($(BSG_MACHINE_ISA),RISCV) +include $(BSG_MANYCORE_ISA_DIR)/RISCV/sim_filelist.mk +endif include Makefile.vcs include Makefile.verilator diff --git a/machines/platform.mk b/machines/platform.mk index 3d2065787..1b4ce66e3 100644 --- a/machines/platform.mk +++ b/machines/platform.mk @@ -1,5 +1,10 @@ BSG_PLATFORM ?= vcs +# Default Machine ISA is Vanilla. This can be modified to any of the supported ISA in the repository bsg_manycore_ISA +# Note that you would have to sync the above repository as well to use another ISA +# You can change the below to modify the machine built +BSG_MACHINE_ISA ?= VANILLA +# BSG_MACHINE_ISA ?= RISCV ifeq ($(BSG_PLATFORM),vcs) DEFAULT_MACHINES = pod_1x1 pod_1x1_hbm2 pod_4x4 pod_4x4_hbm2 From 16debdd57afd7e2b13498860d15c422f42849861 Mon Sep 17 00:00:00 2001 From: Prateek Mahajan Date: Sat, 17 Feb 2024 14:36:09 -0800 Subject: [PATCH 8/9] Some changes to fix build, but still looks like address translation issues are present --- machines/platform.mk | 4 ++-- .../v/bsg_nonsynth_manycore_vanilla_core_pc_cov.sv | 6 +++--- testbenches/common/v/vanilla_core_pc_histogram.sv | 2 +- testbenches/common/v/vanilla_core_profiler.sv | 2 +- .../common/v/vanilla_exe_bubble_classifier.sv | 2 +- testbenches/common/v/vanilla_scoreboard_tracker.sv | 6 +++--- v/vanilla_bean/cl_decode.sv | 5 +++++ v/vanilla_bean/vanilla_core.sv | 13 +++++++------ 8 files changed, 23 insertions(+), 17 deletions(-) diff --git a/machines/platform.mk b/machines/platform.mk index 1b4ce66e3..8c0f38cad 100644 --- a/machines/platform.mk +++ b/machines/platform.mk @@ -3,8 +3,8 @@ BSG_PLATFORM ?= vcs # Default Machine ISA is Vanilla. This can be modified to any of the supported ISA in the repository bsg_manycore_ISA # Note that you would have to sync the above repository as well to use another ISA # You can change the below to modify the machine built -BSG_MACHINE_ISA ?= VANILLA -# BSG_MACHINE_ISA ?= RISCV +# BSG_MACHINE_ISA ?= VANILLA +BSG_MACHINE_ISA ?= RISCV ifeq ($(BSG_PLATFORM),vcs) DEFAULT_MACHINES = pod_1x1 pod_1x1_hbm2 pod_4x4 pod_4x4_hbm2 diff --git a/testbenches/common/v/bsg_nonsynth_manycore_vanilla_core_pc_cov.sv b/testbenches/common/v/bsg_nonsynth_manycore_vanilla_core_pc_cov.sv index 54bdde94f..44c8669ac 100644 --- a/testbenches/common/v/bsg_nonsynth_manycore_vanilla_core_pc_cov.sv +++ b/testbenches/common/v/bsg_nonsynth_manycore_vanilla_core_pc_cov.sv @@ -16,7 +16,7 @@ module bsg_nonsynth_manycore_vanilla_core_pc_cov ,input reset_down // Instruction - ,input instruction_s instruction + ,input instruction_s instruction_r // Pipeline registers ,input id_signals_s id_r @@ -47,7 +47,7 @@ module bsg_nonsynth_manycore_vanilla_core_pc_cov ,input coverage_en_i ); - wire take_br = decode.is_branch_op & instruction[0]; + wire take_br = decode.is_branch_op & instruction_r[0]; wire take_jalr = decode.is_jal_op | decode.is_jalr_op; covergroup cg_pc_reset @(negedge clk_i); @@ -131,7 +131,7 @@ module bsg_nonsynth_manycore_vanilla_core_pc_cov covergroup cg_pc_take_jump @(negedge clk_i iff ~reset_down); br_op: coverpoint decode.is_branch_op; - instr0: coverpoint instruction[0]; + instr0: coverpoint instruction_r[0]; jal_op: coverpoint decode.is_jal_op; jalr_op: coverpoint decode.is_jalr_op; diff --git a/testbenches/common/v/vanilla_core_pc_histogram.sv b/testbenches/common/v/vanilla_core_pc_histogram.sv index c0ce583f3..4b4e7df6b 100644 --- a/testbenches/common/v/vanilla_core_pc_histogram.sv +++ b/testbenches/common/v/vanilla_core_pc_histogram.sv @@ -28,7 +28,7 @@ module vanilla_core_pc_histogram , input [data_width_p-1:0] if_pc , input [data_width_p-1:0] id_pc , input [data_width_p-1:0] exe_pc - , input instruction_s instruction + , input instruction_s instruction_r , input decode_s decode , input flush diff --git a/testbenches/common/v/vanilla_core_profiler.sv b/testbenches/common/v/vanilla_core_profiler.sv index f39f67eaa..738630d74 100644 --- a/testbenches/common/v/vanilla_core_profiler.sv +++ b/testbenches/common/v/vanilla_core_profiler.sv @@ -94,7 +94,7 @@ module vanilla_core_profiler , input fp_exe_ctrl_signals_s fp_exe_ctrl_r // IF stage - , input instruction_s instruction + , input instruction_s instruction_r , input decode_s decode , input [x_cord_width_p-1:0] global_x_i diff --git a/testbenches/common/v/vanilla_exe_bubble_classifier.sv b/testbenches/common/v/vanilla_exe_bubble_classifier.sv index 740062028..0b0ff96dc 100644 --- a/testbenches/common/v/vanilla_exe_bubble_classifier.sv +++ b/testbenches/common/v/vanilla_exe_bubble_classifier.sv @@ -56,7 +56,7 @@ module vanilla_exe_bubble_classifier ,input exe_signals_s exe_r ,input fp_exe_ctrl_signals_s fp_exe_ctrl_r - ,input instruction_s instruction + ,input instruction_s instruction_r ,input decode_s decode ,output [pc_width_p-1:0] exe_bubble_pc_o diff --git a/testbenches/common/v/vanilla_scoreboard_tracker.sv b/testbenches/common/v/vanilla_scoreboard_tracker.sv index ceab8514f..6b7a8060c 100644 --- a/testbenches/common/v/vanilla_scoreboard_tracker.sv +++ b/testbenches/common/v/vanilla_scoreboard_tracker.sv @@ -26,7 +26,7 @@ module vanilla_scoreboard_tracker ,input exe_signals_s exe_r ,input fp_exe_ctrl_signals_s fp_exe_ctrl_r - ,input instruction_s instruction + ,input instruction_s instruction_r ,input decode_s decode ,output vanilla_isb_info_s [reg_els_gp-1:0] int_sb_o @@ -36,11 +36,11 @@ module vanilla_scoreboard_tracker ,output logic is_id_seq_flw_o ); - wire [reg_addr_width_lp-1:0] if_rs1 = instruction.rs1; + wire [reg_addr_width_lp-1:0] if_rs1 = instruction_r.rs1; wire [reg_addr_width_lp-1:0] id_rs1 = id_r.instruction.rs1; wire [reg_addr_width_lp-1:0] id_rd = id_r.instruction.rd; wire [9:0] id_imm_plus4 = 1'b1 + mem_addr_op2[11:2]; - wire [11:0] if_load_imm = `VANILLA_Iimm_12extract(instruction); + wire [11:0] if_load_imm = `VANILLA_Iimm_12extract(instruction_r); wire is_seq_lw = id_r.decode.is_load_op & decode.is_load_op & id_r.decode.write_rd & decode.write_rd diff --git a/v/vanilla_bean/cl_decode.sv b/v/vanilla_bean/cl_decode.sv index 31cc60bda..d0d3b67c5 100644 --- a/v/vanilla_bean/cl_decode.sv +++ b/v/vanilla_bean/cl_decode.sv @@ -20,6 +20,7 @@ import bsg_manycore_pkg::*; input instruction_s instruction_i , output decode_s decode_o , output fp_decode_s fp_decode_o + , output instruction_s instruction_o ); @@ -474,6 +475,10 @@ always_comb begin endcase end +always_comb begin + instruction_o <= instruction_i; +end + // Unsupported ops: // mulh, mulhsu, mulhu always_comb begin diff --git a/v/vanilla_bean/vanilla_core.sv b/v/vanilla_bean/vanilla_core.sv index 76da0088d..78fe80f8d 100644 --- a/v/vanilla_bean/vanilla_core.sv +++ b/v/vanilla_bean/vanilla_core.sv @@ -152,7 +152,7 @@ module vanilla_core logic [data_width_p-1:0] icache_winstr; logic [pc_width_lp-1:0] pc_n, pc_r; - instruction_s instruction; + instruction_s instruction_n, instruction_r; logic icache_miss; logic icache_flush; logic icache_flush_r_lo; @@ -182,7 +182,7 @@ module vanilla_core ,.pc_i(pc_n) ,.jalr_prediction_i(jalr_prediction) - ,.instr_o(instruction) + ,.instr_o(instruction_n) ,.pred_or_jump_addr_o(pred_or_jump_addr) ,.pc_r_o(pc_r) ,.icache_miss_o(icache_miss) @@ -218,9 +218,10 @@ module vanilla_core fp_decode_s fp_decode; cl_decode decode0 ( - .instruction_i(instruction) + .instruction_i(instruction_n) ,.decode_o(decode) ,.fp_decode_o(fp_decode) + ,.instruction_o(instruction_r) ); @@ -263,7 +264,7 @@ module vanilla_core ,.w_data_i(int_rf_wdata) ,.r_v_i(int_rf_read) - ,.r_addr_i({instruction.rs2, instruction.rs1}) + ,.r_addr_i({instruction_r.rs2, instruction_r.rs1}) ,.r_data_o(int_rf_rdata) ); @@ -324,7 +325,7 @@ module vanilla_core ,.w_data_i(float_rf_wdata) ,.r_v_i(float_rf_read) - ,.r_addr_i({instruction[31:27], instruction.rs2, instruction.rs1}) + ,.r_addr_i({instruction_r[31:27], instruction_r.rs2, instruction_r.rs1}) ,.r_data_o(float_rf_rdata) ); @@ -1273,7 +1274,7 @@ module vanilla_core id_n = '{ pc_plus4: {{(data_width_p-pc_width_lp-2){1'b0}}, pc_plus4, 2'b0}, pred_or_jump_addr: {{(data_width_p-pc_width_lp-2){1'b0}}, pred_or_jump_addr, 2'b0}, - instruction: instruction, + instruction: instruction_r, decode: decode, fp_decode: fp_decode, icache_miss: 1'b0, From decd1cc42c21f01208bec748aaea7d6cfb0adb1c Mon Sep 17 00:00:00 2001 From: Prateek Mahajan Date: Sun, 18 Feb 2024 23:04:47 -0800 Subject: [PATCH 9/9] RISCV Functionality Final Fixes --- v/vanilla_bean/bsg_manycore_instruction_defines.svh | 9 +++++++-- v/vanilla_bean/bsg_vanilla_defines.svh | 6 ++++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/v/vanilla_bean/bsg_manycore_instruction_defines.svh b/v/vanilla_bean/bsg_manycore_instruction_defines.svh index 2f407a349..2b1717006 100644 --- a/v/vanilla_bean/bsg_manycore_instruction_defines.svh +++ b/v/vanilla_bean/bsg_manycore_instruction_defines.svh @@ -70,8 +70,10 @@ `define MANYCORE_signext_Jimm(instr) {{12{``instr``[31]}},``instr``[19:12],``instr``[20],``instr``[30:21], {1'b0}} `define MANYCORE_Bimm_12inject1(instr,value) {``value``[12], ``value``[10:5], ``instr``[24:12],\ - ``value``[4:1],``value``[11],``instr``[6:0]} -`define MANYCORE_Jimm_20inject1(instr,value) {``value``[20], ``value``[10:1], ``value``[11],``value``[19:12], ``instr``[11:0]} + ``value``[4:1],``value``[11],``instr``[0],``instr``[1],``instr``[2],``instr``[3],\ + ``instr``[4],``instr``[5],``instr``[6]} +`define MANYCORE_Jimm_20inject1(instr,value) {``value``[20], ``value``[10:1], ``value``[11],``value``[19:12], ``instr``[11:7],\ + ``instr``[0],``instr``[1],``instr``[2],``instr``[3],``instr``[4],``instr``[5],``instr``[6]} // Both JAL and BRANCH use 2-byte address, we need to pad 1'b0 at MSB to get // the real byte address @@ -150,5 +152,8 @@ `define MANYCORE_CSR_BAR_PI_ADDR 12'hfc2 `define MANYCORE_CSR_BAR_PO_ADDR 12'hfc3 +// FENCE defines +`define MANYCORE_FENCE_FUN3 3'b000 +`define MANYCORE_FENCE_OP {4'b????,4'b????,4'b????,5'b00000,`MANYCORE_FENCE_FUN3,5'b00000,`MANYCORE_MISC_MEM} `endif diff --git a/v/vanilla_bean/bsg_vanilla_defines.svh b/v/vanilla_bean/bsg_vanilla_defines.svh index 6950a9ed1..1d6a934ed 100644 --- a/v/vanilla_bean/bsg_vanilla_defines.svh +++ b/v/vanilla_bean/bsg_vanilla_defines.svh @@ -45,8 +45,10 @@ `define VANILLA_signext_Jimm(instr) {{12{``instr``[31]}},``instr``[19:12],``instr``[20],``instr``[30:21], {1'b0}} `define VANILLA_Bimm_12inject1(instr,value) {``value``[12], ``value``[10:5], ``instr``[24:12],\ - ``value``[4:1],``value``[11],``instr``[6:0]} -`define VANILLA_Jimm_20inject1(instr,value) {``value``[20], ``value``[10:1], ``value``[11],``value``[19:12], ``instr``[11:0]} + ``value``[4:1],``value``[11],``instr``[0],``instr``[1],``instr``[2],\ + ``instr``[3],``instr``[4],``instr``[5],``instr``[6]} +`define VANILLA_Jimm_20inject1(instr,value) {``value``[20], ``value``[10:1], ``value``[11],``value``[19:12], ``instr``[11:7],\ + ``instr``[0],``instr``[1],``instr``[2],``instr``[3],``instr``[4].``instr``[5],``instr``[6]} // Both JAL and BRANCH use 2-byte address, we need to pad 1'b0 at MSB to get // the real byte address