From 9c08ce5359cee12f7d9abfe1f412b48ae5902679 Mon Sep 17 00:00:00 2001 From: bbracker Date: Fri, 30 Apr 2021 06:26:31 -0400 Subject: [PATCH 1/5] rv32 plic test and lint fixes --- wally-pipelined/config/rv32ic/wally-config.vh | 2 +- wally-pipelined/src/ebu/ahblite.sv | 14 ++- wally-pipelined/src/uncore/gpio.sv | 101 +++++++++--------- wally-pipelined/src/uncore/plic.sv | 74 ++++++------- .../testbench/testbench-imperas.sv | 4 +- 5 files changed, 97 insertions(+), 98 deletions(-) diff --git a/wally-pipelined/config/rv32ic/wally-config.vh b/wally-pipelined/config/rv32ic/wally-config.vh index fa16fdb86..1016f81f4 100644 --- a/wally-pipelined/config/rv32ic/wally-config.vh +++ b/wally-pipelined/config/rv32ic/wally-config.vh @@ -85,7 +85,7 @@ // Test modes // Tie GPIO outputs back to inputs -`define GPIO_LOOPBACK_TEST 0 +`define GPIO_LOOPBACK_TEST 1 // Busybear special CSR config to match OVPSim `define OVPSIM_CSR_CONFIG 0 diff --git a/wally-pipelined/src/ebu/ahblite.sv b/wally-pipelined/src/ebu/ahblite.sv index 23ae2eb65..378a5c78e 100644 --- a/wally-pipelined/src/ebu/ahblite.sv +++ b/wally-pipelined/src/ebu/ahblite.sv @@ -31,7 +31,7 @@ `include "wally-config.vh" package ahbliteState; - typedef enum {IDLE, MEMREAD, MEMWRITE, INSTRREAD, INSTRREADC, ATOMICREAD, ATOMICWRITE, MMUTRANSLATE} statetype; + typedef enum {IDLE, MEMREAD, MEMWRITE, INSTRREAD, ATOMICREAD, ATOMICWRITE, MMUTRANSLATE} statetype; endpackage module ahblite ( @@ -127,7 +127,7 @@ module ahblite ( else if (InstrReadF) NextBusState = INSTRREAD; else NextBusState = IDLE; MEMREAD: if (~HREADY) NextBusState = MEMREAD; - else if (InstrReadF) NextBusState = INSTRREADC; + else if (InstrReadF) NextBusState = INSTRREAD; else NextBusState = IDLE; MEMWRITE: if (~HREADY) NextBusState = MEMWRITE; else if (InstrReadF) NextBusState = INSTRREAD; @@ -135,8 +135,6 @@ module ahblite ( INSTRREAD: if (~HREADY) NextBusState = INSTRREAD; else NextBusState = IDLE; // if (InstrReadF still high) - INSTRREADC: if (~HREADY) NextBusState = INSTRREADC; // "C" for "competing", meaning please don't mess up the memread in the W stage. - else NextBusState = IDLE; default: NextBusState = IDLE; endcase @@ -147,12 +145,12 @@ module ahblite ( (NextBusState == ATOMICREAD) || (NextBusState == ATOMICWRITE) || MMUStall); - assign #1 InstrStall = ((NextBusState == INSTRREAD) || (NextBusState == INSTRREADC) || - MMUStall); + //assign #1 InstrStall = ((NextBusState == INSTRREAD) || (NextBusState == INSTRREADC) || + // MMUStall); // Determine access type (important for determining whether to fault) assign Atomic = ((NextBusState == ATOMICREAD) || (NextBusState == ATOMICWRITE)); - assign Execute = ((NextBusState == INSTRREAD) || (NextBusState == INSTRREADC)); + assign Execute = ((NextBusState == INSTRREAD)); assign Write = ((NextBusState == MEMWRITE) || (NextBusState == ATOMICWRITE)); assign Read = ((NextBusState == MEMREAD) || (NextBusState == ATOMICREAD) || (NextBusState == MMUTRANSLATE)); @@ -187,7 +185,7 @@ module ahblite ( assign MMUReady = (BusState == MMUTRANSLATE && NextBusState == IDLE); assign InstrRData = HRDATA; - assign InstrAckF = (BusState == INSTRREAD) && (NextBusState != INSTRREAD) || (BusState == INSTRREADC) && (NextBusState != INSTRREADC); + assign InstrAckF = (BusState == INSTRREAD) && (NextBusState != INSTRREAD); assign MemAckW = (BusState == MEMREAD) && (NextBusState != MEMREAD) || (BusState == MEMWRITE) && (NextBusState != MEMWRITE) || ((BusState == ATOMICREAD) && (NextBusState != ATOMICREAD)) || ((BusState == ATOMICWRITE) && (NextBusState != ATOMICWRITE)); assign MMUReadPTE = HRDATA; diff --git a/wally-pipelined/src/uncore/gpio.sv b/wally-pipelined/src/uncore/gpio.sv index 97e9f2ea6..887ff74f0 100644 --- a/wally-pipelined/src/uncore/gpio.sv +++ b/wally-pipelined/src/uncore/gpio.sv @@ -82,23 +82,6 @@ module gpio ( // register access always_ff @(posedge HCLK, negedge HRESETn) begin - // reads - case(entry) - 8'h00: Dout <= #1 input_val; - 8'h04: Dout <= #1 input_en; - 8'h08: Dout <= #1 output_en; - 8'h0C: Dout <= #1 output_val; - 8'h18: Dout <= #1 rise_ie; - 8'h1C: Dout <= #1 rise_ip; - 8'h20: Dout <= #1 fall_ie; - 8'h24: Dout <= #1 fall_ip; - 8'h28: Dout <= #1 high_ie; - 8'h2C: Dout <= #1 high_ip; - 8'h30: Dout <= #1 low_ie; - 8'h34: Dout <= #1 low_ip; - 8'h40: Dout <= #1 0; // OUT_XOR reads as 0 - default: Dout <= #1 0; - endcase // writes if (~HRESETn) begin // asynch reset @@ -114,22 +97,57 @@ module gpio ( high_ip <= #1 0; low_ie <= #1 0; low_ip <= #1 0; - end else if (memwrite) - // According to FE310 spec: Once the interrupt is pending, it will remain set until a 1 is written to the *_ip register at that bit. - case(entryd) - 8'h04: input_en <= #1 Din; - 8'h08: output_en <= #1 Din; - 8'h0C: output_val <= #1 Din; - 8'h18: rise_ie <= #1 Din; - 8'h1C: rise_ip <= #1 rise_ip & ~Din; - 8'h20: fall_ie <= #1 Din; - 8'h24: fall_ip <= #1 fall_ip & ~Din; - 8'h28: high_ie <= #1 Din; - 8'h2C: high_ip <= #1 high_ip & ~Din; - 8'h30: low_ie <= #1 Din; - 8'h34: low_ip <= #1 low_ip & ~Din; - 8'h40: output_val <= #1 output_val ^ Din; // OUT_XOR + end else begin + // writes + if (memwrite) + // According to FE310 spec: Once the interrupt is pending, it will remain set until a 1 is written to the *_ip register at that bit. + /* verilator lint_off CASEINCOMPLETE */ + case(entryd) + 8'h04: input_en <= #1 Din; + 8'h08: output_en <= #1 Din; + 8'h0C: output_val <= #1 Din; + 8'h18: rise_ie <= #1 Din; + 8'h20: fall_ie <= #1 Din; + 8'h28: high_ie <= #1 Din; + 8'h30: low_ie <= #1 Din; + 8'h40: output_val <= #1 output_val ^ Din; // OUT_XOR + endcase + /* verilator lint_on CASEINCOMPLETE */ + // reads + case(entry) + 8'h00: Dout <= #1 input_val; + 8'h04: Dout <= #1 input_en; + 8'h08: Dout <= #1 output_en; + 8'h0C: Dout <= #1 output_val; + 8'h18: Dout <= #1 rise_ie; + 8'h1C: Dout <= #1 rise_ip; + 8'h20: Dout <= #1 fall_ie; + 8'h24: Dout <= #1 fall_ip; + 8'h28: Dout <= #1 high_ie; + 8'h2C: Dout <= #1 high_ip; + 8'h30: Dout <= #1 low_ie; + 8'h34: Dout <= #1 low_ip; + 8'h40: Dout <= #1 0; // OUT_XOR reads as 0 + default: Dout <= #1 0; endcase + // interrupts + if (memwrite && (entryd == 8'h1C)) + rise_ip <= rise_ip & ~Din | (input2d & ~input3d); + else + rise_ip <= rise_ip | (input2d & ~input3d); + if (memwrite && (entryd == 8'h24)) + fall_ip <= fall_ip & ~Din | (~input2d & input3d); + else + fall_ip <= fall_ip | (~input2d & input3d); + if (memwrite && (entryd == 8'h2C)) + high_ip <= high_ip & ~Din | input3d; + else + high_ip <= high_ip | input3d; + if (memwrite && (entryd == 8'h34)) + low_ip <= low_ip & ~Din | ~input3d; + else + low_ip <= low_ip | ~input3d; + end end // chip i/o @@ -147,25 +165,6 @@ module gpio ( assign GPIOPinsOut = output_val; assign GPIOPinsEn = output_en; - // interrupts - always_ff @(posedge HCLK) begin - if (memwrite && (entryd == 8'h1C)) - rise_ip <= rise_ip & ~Din | (input2d & ~input3d); - else - rise_ip <= rise_ip | (input2d & ~input3d); - if (memwrite && (entryd == 8'h24)) - fall_ip <= fall_ip & ~Din | (~input2d & input3d); - else - fall_ip <= fall_ip | (~input2d & input3d); - if (memwrite && (entryd == 8'h2C)) - high_ip <= high_ip & ~Din | input3d; - else - high_ip <= high_ip | input3d; - if (memwrite && (entryd == 8'h34)) - low_ip <= low_ip & ~Din | ~input3d; - else - low_ip <= low_ip | ~input3d; - end assign GPIOIntr = |{(rise_ip & rise_ie),(fall_ip & fall_ip),(high_ip & high_ie),(low_ip & low_ie)}; endmodule diff --git a/wally-pipelined/src/uncore/plic.sv b/wally-pipelined/src/uncore/plic.sv index c9395dafc..4ee4ffbac 100644 --- a/wally-pipelined/src/uncore/plic.sv +++ b/wally-pipelined/src/uncore/plic.sv @@ -106,42 +106,44 @@ module plic ( intThreshold <= #1 3'b0; intInProgress <= #1 {N{1'b0}}; // writing - end else if (memwrite) - casez(entryd) - 28'hc0000??: intPriority[entryd[7:2]] <= #1 Din[2:0]; - `ifdef PLIC_NUM_SRC_LT_32 - 28'hc002000: intEn[N:1] <= #1 Din[N:1]; - `endif - `ifndef PLIC_NUM_SRC_LT_32 - 28'hc002000: intEn[31:1] <= #1 Din[31:1]; - 28'hc002004: intEn[N:32] <= #1 Din[31:0]; - `endif - 28'hc200000: intThreshold[2:0] <= #1 Din[2:0]; - 28'hc200004: intInProgress <= #1 intInProgress & ~(1'b1 << (Din[5:0]-1)); // lower "InProgress" to signify completion - endcase - // reading - if (memread) - casez(entry) - 28'hc0000??: Dout <= #1 {{(`XLEN-3){1'b0}},intPriority[entry[7:2]]}; - `ifdef PLIC_NUM_SRC_LT_32 - 28'hc001000: Dout <= #1 {{(31-N){1'b0}},intPending[N:1],1'b0}; - 28'hc002000: Dout <= #1 {{(31-N){1'b0}},intEn[N:1],1'b0}; - `endif - `ifndef PLIC_NUM_SRC_LT_32 - 28'hc001000: Dout <= #1 {intPending[31:1],1'b0}; - 28'hc001004: Dout <= #1 {{(63-N){1'b0}},intPending[N:32]}; - 28'hc002000: Dout <= #1 {intEn[31:1],1'b0}; - 28'hc002004: Dout <= #1 {{(63-N){1'b0}},intEn[N:32]}; - `endif - 28'hc200000: Dout <= #1 {29'b0,intThreshold[2:0]}; - 28'hc200004: begin - Dout <= #1 {26'b0,intClaim}; - intInProgress <= #1 intInProgress | (1'b1 << (intClaim-1)); // claimed requests are currently in progress of being serviced until they are completed - end - default: Dout <= #1 32'hdeadbeef; // invalid access - endcase - else - Dout <= #1 32'h0; + end else begin + if (memwrite) + casez(entryd) + 28'hc0000??: intPriority[entryd[7:2]] <= #1 Din[2:0]; + `ifdef PLIC_NUM_SRC_LT_32 + 28'hc002000: intEn[N:1] <= #1 Din[N:1]; + `endif + `ifndef PLIC_NUM_SRC_LT_32 + 28'hc002000: intEn[31:1] <= #1 Din[31:1]; + 28'hc002004: intEn[N:32] <= #1 Din[31:0]; + `endif + 28'hc200000: intThreshold[2:0] <= #1 Din[2:0]; + 28'hc200004: intInProgress <= #1 intInProgress & ~(1'b1 << (Din[5:0]-1)); // lower "InProgress" to signify completion + endcase + // reading + if (memread) + casez(entry) + 28'hc0000??: Dout <= #1 {{(`XLEN-3){1'b0}},intPriority[entry[7:2]]}; + `ifdef PLIC_NUM_SRC_LT_32 + 28'hc001000: Dout <= #1 {{(31-N){1'b0}},intPending[N:1],1'b0}; + 28'hc002000: Dout <= #1 {{(31-N){1'b0}},intEn[N:1],1'b0}; + `endif + `ifndef PLIC_NUM_SRC_LT_32 + 28'hc001000: Dout <= #1 {intPending[31:1],1'b0}; + 28'hc001004: Dout <= #1 {{(63-N){1'b0}},intPending[N:32]}; + 28'hc002000: Dout <= #1 {intEn[31:1],1'b0}; + 28'hc002004: Dout <= #1 {{(63-N){1'b0}},intEn[N:32]}; + `endif + 28'hc200000: Dout <= #1 {29'b0,intThreshold[2:0]}; + 28'hc200004: begin + Dout <= #1 {26'b0,intClaim}; + intInProgress <= #1 intInProgress | (1'b1 << (intClaim-1)); // claimed requests are currently in progress of being serviced until they are completed + end + default: Dout <= #1 32'hdeadbeef; // invalid access + endcase + else + Dout <= #1 32'h0; + end end // connect sources to requests diff --git a/wally-pipelined/testbench/testbench-imperas.sv b/wally-pipelined/testbench/testbench-imperas.sv index f99ee1aff..6223edfc3 100644 --- a/wally-pipelined/testbench/testbench-imperas.sv +++ b/wally-pipelined/testbench/testbench-imperas.sv @@ -29,7 +29,7 @@ module testbench(); parameter DEBUG = 0; parameter TESTSBP = 0; - parameter TESTSPERIPH = 0; // set to 0 for regression + parameter TESTSPERIPH = 0 ; // set to 0 for regression logic clk; logic reset; @@ -425,7 +425,7 @@ module testbench(); if (TESTSPERIPH) begin tests = tests32periph; end else begin - tests = {tests32i, tests32p};//,tests32periph}; *** broken at the moment + tests = {tests32i, tests32p, tests32periph}; if (`C_SUPPORTED % 2 == 1) tests = {tests, tests32ic}; else tests = {tests, tests32iNOc}; if (`M_SUPPORTED % 2 == 1) tests = {tests, tests32m}; From fb0910d9c02aebeae199ba501240450722ddf580 Mon Sep 17 00:00:00 2001 From: bbracker Date: Mon, 3 May 2021 09:25:22 -0400 Subject: [PATCH 2/5] ifu lint fixes --- wally-pipelined/src/ifu/ifu.sv | 2 +- wally-pipelined/src/ifu/localHistoryPredictor.sv | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/wally-pipelined/src/ifu/ifu.sv b/wally-pipelined/src/ifu/ifu.sv index 1df3b5ff5..371205051 100644 --- a/wally-pipelined/src/ifu/ifu.sv +++ b/wally-pipelined/src/ifu/ifu.sv @@ -184,7 +184,7 @@ module ifu ( assign BPPredDirWrongE = 1'b0; assign BTBPredPCWrongE = 1'b0; assign RASPredPCWrongE = 1'b0; - assign BPPredClassNonCFIWrong = 1'b0; + assign BPPredClassNonCFIWrongE = 1'b0; end endgenerate // The true correct target is PCTargetE if PCSrcE is 1 else it is the fall through PCLinkE. diff --git a/wally-pipelined/src/ifu/localHistoryPredictor.sv b/wally-pipelined/src/ifu/localHistoryPredictor.sv index 70e85562e..2d5469fd9 100644 --- a/wally-pipelined/src/ifu/localHistoryPredictor.sv +++ b/wally-pipelined/src/ifu/localHistoryPredictor.sv @@ -44,7 +44,7 @@ module localHistoryPredictor ); logic [2**m-1:0][k-1:0] LHRNextF; - logic [k-1:0] LHRF, ForwardLHRNext; + logic [k-1:0] LHRF, LHRFNext, ForwardLHRNext; logic [m-1:0] LookUpPCIndex, UpdatePCIndex; logic [1:0] PredictionMemory; logic DoForwarding, DoForwardingF, DoForwardingPHT, DoForwardingPHTF; From 1db608fbc6697bb272dd3abdc1c00b428574afa2 Mon Sep 17 00:00:00 2001 From: bbracker Date: Mon, 3 May 2021 10:06:44 -0400 Subject: [PATCH 3/5] small rv64 plic test bugfix --- wally-pipelined/regression/wave-dos/peripheral-waves.do | 1 - 1 file changed, 1 deletion(-) diff --git a/wally-pipelined/regression/wave-dos/peripheral-waves.do b/wally-pipelined/regression/wave-dos/peripheral-waves.do index 257e85f58..6f268a512 100644 --- a/wally-pipelined/regression/wave-dos/peripheral-waves.do +++ b/wally-pipelined/regression/wave-dos/peripheral-waves.do @@ -10,7 +10,6 @@ add wave /testbench/reset add wave -divider add wave /testbench/dut/hart/DataStall -add wave /testbench/dut/hart/InstrStall add wave /testbench/dut/hart/StallF add wave /testbench/dut/hart/StallD add wave /testbench/dut/hart/StallE From 3f05e319541e02942051a047a7f917788d1503c8 Mon Sep 17 00:00:00 2001 From: Katherine Parry Date: Mon, 3 May 2021 19:17:09 +0000 Subject: [PATCH 4/5] fpu warnings fixed/commented --- wally-pipelined/src/fpu/compressors.sv | 135 ++++++++++++------------ wally-pipelined/src/fpu/fma2.sv | 11 +- wally-pipelined/src/fpu/fpu.sv | 10 +- wally-pipelined/src/fpu/fpuaddcvt2.sv | 4 +- wally-pipelined/src/fpu/multiply.sv | 138 +++++++++++++------------ wally-pipelined/src/fpu/round.sv | 10 +- 6 files changed, 159 insertions(+), 149 deletions(-) diff --git a/wally-pipelined/src/fpu/compressors.sv b/wally-pipelined/src/fpu/compressors.sv index 0c2bece86..1e975e43c 100644 --- a/wally-pipelined/src/fpu/compressors.sv +++ b/wally-pipelined/src/fpu/compressors.sv @@ -1,90 +1,93 @@ -module add3comp2(a, b, c, carry, sum); -///////////////////////////////////////////////////////////////////////////// -//look into diffrent implementations of the compressors? +// //***breaks lint with warnings like: %Warning-UNOPTFLAT: Example path: src/fpu/compressors.sv:37: ASSIGNW +// //%Warning-UNOPTFLAT: Example path: src/fpu/compressors.sv:32: wallypipelinedsoc.hart.fpu.fma1.multiply.genblk5[0].add4.cout + +// module add3comp2(a, b, c, carry, sum); +// ///////////////////////////////////////////////////////////////////////////// +// //look into diffrent implementations of the compressors? - parameter BITS = 4; - input logic [BITS-1:0] a; - input logic [BITS-1:0] b; - input logic [BITS-1:0] c; - output logic [BITS-1:0] carry; - output logic [BITS-1:0] sum; - genvar i; +// parameter BITS = 4; +// input logic [BITS-1:0] a; +// input logic [BITS-1:0] b; +// input logic [BITS-1:0] c; +// output logic [BITS-1:0] carry; +// output logic [BITS-1:0] sum; +// genvar i; - generate - for(i= 0; i Date: Mon, 3 May 2021 15:29:20 -0400 Subject: [PATCH 5/5] Extended maximum signature length to 1M --- wally-pipelined/testbench/testbench-imperas.sv | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/wally-pipelined/testbench/testbench-imperas.sv b/wally-pipelined/testbench/testbench-imperas.sv index 76989c6d4..debbd96c0 100644 --- a/wally-pipelined/testbench/testbench-imperas.sv +++ b/wally-pipelined/testbench/testbench-imperas.sv @@ -30,13 +30,14 @@ module testbench(); parameter DEBUG = 0; parameter TESTSBP = 0; parameter TESTSPERIPH = 0 ; // set to 0 for regression + localparam MAXSIGLEN = 1000000; logic clk; logic reset; int test, i, errors, totalerrors; - logic [31:0] sig32[0:10000]; - logic [`XLEN-1:0] signature[0:10000]; + logic [31:0] sig32[0:MAXSIGLEN]; + logic [`XLEN-1:0] signature[0:MAXSIGLEN]; logic [`XLEN-1:0] testadr; string InstrFName, InstrDName, InstrEName, InstrMName, InstrWName; logic [31:0] InstrW; @@ -602,7 +603,7 @@ string tests32f[] = '{ $display("Code ended with ecall with gp = 1"); #60; // give time for instructions in pipeline to finish // clear signature to prevent contamination from previous tests - for(i=0; i<10000; i=i+1) begin + for(i=0; i