diff --git a/wally-pipelined/lint-wally b/wally-pipelined/lint-wally index 59d6bf153..ed67dbab6 100755 --- a/wally-pipelined/lint-wally +++ b/wally-pipelined/lint-wally @@ -1,9 +1,11 @@ +#!/bin/bash # check for warnings in Verilog code # The verilator lint tool is faster and better than Modelsim so it is best to run this first. +basepath=$(dirname $0) for config in rv64ic rv32ic; do echo "$config linting..." - if !(verilator --lint-only "$@" --top-module wallypipelinedsoc "-Iconfig/$config" src/*/*.sv); then + if !(verilator --lint-only "$@" --top-module wallypipelinedsoc "-I$basepath/config/$config" $basepath/src/*/*.sv); then echo "Exiting after $config lint due to errors or warnings" exit 1 fi diff --git a/wally-pipelined/regression/regression-wally.py b/wally-pipelined/regression/regression-wally.py index 2b272e3b4..aa64424c7 100755 --- a/wally-pipelined/regression/regression-wally.py +++ b/wally-pipelined/regression/regression-wally.py @@ -36,6 +36,11 @@ configs = [ cmd="vsim > {} -c < {}", + grepstr="All lints run with no errors or warnings" + ), ] import multiprocessing, os diff --git a/wally-pipelined/regression/wave.do b/wally-pipelined/regression/wave.do index 428bf5b97..ec9194a01 100644 --- a/wally-pipelined/regression/wave.do +++ b/wally-pipelined/regression/wave.do @@ -3,6 +3,8 @@ quietly virtual function -install /testbench/dut/hart/ifu/icache/cachemem -env / quietly WaveActivateNextPane {} 0 add wave -noupdate /testbench/clk add wave -noupdate /testbench/reset +add wave -noupdate /testbench/memfilename +add wave -noupdate -expand -group {Execution Stage} /testbench/FunctionName/FunctionName/FunctionName add wave -noupdate -expand -group {Execution Stage} /testbench/dut/hart/ifu/PCE add wave -noupdate -expand -group {Execution Stage} /testbench/InstrEName add wave -noupdate -expand -group {Execution Stage} /testbench/dut/hart/ifu/InstrE @@ -19,13 +21,13 @@ add wave -noupdate -expand -group HDU -group traps /testbench/dut/hart/priv/trap add wave -noupdate -expand -group HDU -group traps /testbench/dut/hart/priv/trap/LoadPageFaultM add wave -noupdate -expand -group HDU -group traps /testbench/dut/hart/priv/trap/StorePageFaultM add wave -noupdate -expand -group HDU -group traps /testbench/dut/hart/priv/trap/InterruptM -add wave -noupdate -expand -group HDU -expand -group hazards /testbench/dut/hart/hzu/BPPredWrongE -add wave -noupdate -expand -group HDU -expand -group hazards /testbench/dut/hart/hzu/CSRWritePendingDEM -add wave -noupdate -expand -group HDU -expand -group hazards /testbench/dut/hart/hzu/RetM -add wave -noupdate -expand -group HDU -expand -group hazards /testbench/dut/hart/hzu/TrapM -add wave -noupdate -expand -group HDU -expand -group hazards /testbench/dut/hart/hzu/LoadStallD -add wave -noupdate -expand -group HDU -expand -group hazards /testbench/dut/hart/hzu/DataStall -add wave -noupdate -expand -group HDU -expand -group hazards /testbench/dut/hart/MulDivStallD +add wave -noupdate -expand -group HDU -group hazards /testbench/dut/hart/hzu/BPPredWrongE +add wave -noupdate -expand -group HDU -group hazards /testbench/dut/hart/hzu/CSRWritePendingDEM +add wave -noupdate -expand -group HDU -group hazards /testbench/dut/hart/hzu/RetM +add wave -noupdate -expand -group HDU -group hazards /testbench/dut/hart/hzu/TrapM +add wave -noupdate -expand -group HDU -group hazards /testbench/dut/hart/hzu/LoadStallD +add wave -noupdate -expand -group HDU -group hazards /testbench/dut/hart/hzu/DataStall +add wave -noupdate -expand -group HDU -group hazards /testbench/dut/hart/MulDivStallD add wave -noupdate -expand -group HDU -expand -group Flush -color Yellow /testbench/dut/hart/hzu/FlushF add wave -noupdate -expand -group HDU -expand -group Flush -color Yellow /testbench/dut/hart/FlushD add wave -noupdate -expand -group HDU -expand -group Flush -color Yellow /testbench/dut/hart/FlushE @@ -36,25 +38,25 @@ add wave -noupdate -expand -group HDU -expand -group Stall -color Orange /testbe add wave -noupdate -expand -group HDU -expand -group Stall -color Orange /testbench/dut/hart/StallE add wave -noupdate -expand -group HDU -expand -group Stall -color Orange /testbench/dut/hart/StallM add wave -noupdate -expand -group HDU -expand -group Stall -color Orange /testbench/dut/hart/StallW -add wave -noupdate -expand -group Bpred -expand -group prediction /testbench/dut/hart/ifu/bpred/bpred/BPPredF -add wave -noupdate -expand -group Bpred -expand -group prediction /testbench/dut/hart/ifu/bpred/bpred/BTBValidF -add wave -noupdate -expand -group Bpred -expand -group prediction /testbench/dut/hart/ifu/bpred/bpred/BPInstrClassF -add wave -noupdate -expand -group Bpred -expand -group prediction /testbench/dut/hart/ifu/bpred/bpred/BTBPredPCF -add wave -noupdate -expand -group Bpred -expand -group prediction /testbench/dut/hart/ifu/bpred/bpred/RASPCF -add wave -noupdate -expand -group Bpred -expand -group update -expand -group dir /testbench/dut/hart/ifu/bpred/bpred/Predictor/DirPredictor/UpdatePC -add wave -noupdate -expand -group Bpred -expand -group update -expand -group dir /testbench/dut/hart/ifu/bpred/bpred/Predictor/DirPredictor/UpdateEN -add wave -noupdate -expand -group Bpred -expand -group update -expand -group dir /testbench/dut/hart/ifu/bpred/bpred/Predictor/DirPredictor/UpdatePrediction -add wave -noupdate -expand -group Bpred -expand -group update -expand -group BTB /testbench/dut/hart/ifu/bpred/bpred/TargetPredictor/UpdateEN -add wave -noupdate -expand -group Bpred -expand -group update -expand -group BTB /testbench/dut/hart/ifu/bpred/bpred/TargetPredictor/UpdatePC -add wave -noupdate -expand -group Bpred -expand -group update -expand -group BTB /testbench/dut/hart/ifu/bpred/bpred/TargetPredictor/UpdateTarget -add wave -noupdate -expand -group Bpred -expand -group {bp wrong} /testbench/dut/hart/ifu/bpred/bpred/TargetWrongE -add wave -noupdate -expand -group Bpred -expand -group {bp wrong} /testbench/dut/hart/ifu/bpred/bpred/FallThroughWrongE -add wave -noupdate -expand -group Bpred -expand -group {bp wrong} /testbench/dut/hart/ifu/bpred/bpred/PredictionPCWrongE -add wave -noupdate -expand -group Bpred -expand -group {bp wrong} /testbench/dut/hart/ifu/bpred/bpred/InstrClassE -add wave -noupdate -expand -group Bpred -expand -group {bp wrong} /testbench/dut/hart/ifu/bpred/bpred/PredictionInstrClassWrongE -add wave -noupdate -expand -group Bpred -expand -group {bp wrong} /testbench/dut/hart/ifu/bpred/bpred/BPPredClassNonCFIWrongE -add wave -noupdate -expand -group Bpred -expand -group {bp wrong} /testbench/dut/hart/ifu/bpred/bpred/BPPredWrongE -add wave -noupdate -expand -group Bpred /testbench/dut/hart/ifu/bpred/bpred/BPPredWrongE +add wave -noupdate -group Bpred -expand -group prediction /testbench/dut/hart/ifu/bpred/bpred/BPPredF +add wave -noupdate -group Bpred -expand -group prediction /testbench/dut/hart/ifu/bpred/bpred/BTBValidF +add wave -noupdate -group Bpred -expand -group prediction /testbench/dut/hart/ifu/bpred/bpred/BPInstrClassF +add wave -noupdate -group Bpred -expand -group prediction /testbench/dut/hart/ifu/bpred/bpred/BTBPredPCF +add wave -noupdate -group Bpred -expand -group prediction /testbench/dut/hart/ifu/bpred/bpred/RASPCF +add wave -noupdate -group Bpred -expand -group update -expand -group dir /testbench/dut/hart/ifu/bpred/bpred/Predictor/DirPredictor/UpdatePC +add wave -noupdate -group Bpred -expand -group update -expand -group dir /testbench/dut/hart/ifu/bpred/bpred/Predictor/DirPredictor/UpdateEN +add wave -noupdate -group Bpred -expand -group update -expand -group dir /testbench/dut/hart/ifu/bpred/bpred/Predictor/DirPredictor/UpdatePrediction +add wave -noupdate -group Bpred -expand -group update -expand -group BTB /testbench/dut/hart/ifu/bpred/bpred/TargetPredictor/UpdateEN +add wave -noupdate -group Bpred -expand -group update -expand -group BTB /testbench/dut/hart/ifu/bpred/bpred/TargetPredictor/UpdatePC +add wave -noupdate -group Bpred -expand -group update -expand -group BTB /testbench/dut/hart/ifu/bpred/bpred/TargetPredictor/UpdateTarget +add wave -noupdate -group Bpred -expand -group {bp wrong} /testbench/dut/hart/ifu/bpred/bpred/TargetWrongE +add wave -noupdate -group Bpred -expand -group {bp wrong} /testbench/dut/hart/ifu/bpred/bpred/FallThroughWrongE +add wave -noupdate -group Bpred -expand -group {bp wrong} /testbench/dut/hart/ifu/bpred/bpred/PredictionPCWrongE +add wave -noupdate -group Bpred -expand -group {bp wrong} /testbench/dut/hart/ifu/bpred/bpred/InstrClassE +add wave -noupdate -group Bpred -expand -group {bp wrong} /testbench/dut/hart/ifu/bpred/bpred/PredictionInstrClassWrongE +add wave -noupdate -group Bpred -expand -group {bp wrong} /testbench/dut/hart/ifu/bpred/bpred/BPPredClassNonCFIWrongE +add wave -noupdate -group Bpred -expand -group {bp wrong} /testbench/dut/hart/ifu/bpred/bpred/BPPredWrongE +add wave -noupdate -group Bpred /testbench/dut/hart/ifu/bpred/bpred/BPPredWrongE add wave -noupdate -expand -group {instruction pipeline} /testbench/InstrFName add wave -noupdate -expand -group {instruction pipeline} /testbench/dut/hart/ifu/InstrD add wave -noupdate -expand -group {instruction pipeline} /testbench/dut/hart/ifu/InstrE @@ -112,8 +114,6 @@ add wave -noupdate -group dcache /testbench/dut/hart/MemPAdrM add wave -noupdate -group dcache /testbench/dut/hart/dmem/MemAccessM add wave -noupdate -group dcache /testbench/dut/hart/dmem/AtomicMaskedM add wave -noupdate -group dcache /testbench/dut/hart/dmem/MemAckW -add wave -noupdate -group dcache /testbench/dut/hart/dmem/genblk1/lrM -add wave -noupdate -group dcache /testbench/dut/hart/dmem/genblk1/scM add wave -noupdate -group Forward /testbench/dut/hart/ieu/fw/Rs1D add wave -noupdate -group Forward /testbench/dut/hart/ieu/fw/Rs2D add wave -noupdate -group Forward /testbench/dut/hart/ieu/fw/Rs1E @@ -203,7 +203,6 @@ add wave -noupdate -expand -group icache -expand -group {instr to cpu} /testbenc add wave -noupdate -expand -group icache -expand -group {instr to cpu} /testbench/dut/hart/ifu/icache/controller/AlignedInstrRawD add wave -noupdate -expand -group icache -expand -group {instr to cpu} /testbench/dut/hart/ifu/icache/controller/FlushDLastCyclen add wave -noupdate -expand -group icache -expand -group {instr to cpu} /testbench/dut/hart/ifu/icache/controller/InstrRawD -add wave -noupdate -expand -group icache -expand -group pc /testbench/dut/hart/ifu/icache/controller/PCNextPF add wave -noupdate -expand -group icache -expand -group pc /testbench/dut/hart/ifu/icache/controller/PCPF add wave -noupdate -expand -group icache -expand -group pc /testbench/dut/hart/ifu/icache/controller/PCPreFinalF add wave -noupdate -expand -group icache -expand -group pc /testbench/dut/hart/ifu/icache/controller/PCPFinalF @@ -223,10 +222,11 @@ add wave -noupdate -group AHB /testbench/dut/hart/ebu/HMASTLOCK add wave -noupdate -group AHB /testbench/dut/hart/ebu/HADDRD add wave -noupdate -group AHB /testbench/dut/hart/ebu/HSIZED add wave -noupdate -group AHB /testbench/dut/hart/ebu/HWRITED -add wave -noupdate /testbench/dut/hart/dmem/genblk1/scM +add wave -noupdate /testbench/dut/hart/ifu/icache/PCTagF +add wave -noupdate /testbench/dut/hart/ifu/icache/cachemem/OldReadPAdr TreeUpdate [SetDefaultTree] -WaveRestoreCursors {{Cursor 2} {12215488 ns} 0} {{Cursor 4} {22127 ns} 0} -quietly wave cursor active 2 +WaveRestoreCursors {{Cursor 2} {9951515 ns} 0} {{Cursor 4} {1318991 ns} 0} +quietly wave cursor active 1 configure wave -namecolwidth 250 configure wave -valuecolwidth 513 configure wave -justifyvalue left @@ -241,4 +241,4 @@ configure wave -griddelta 40 configure wave -timeline 0 configure wave -timelineunits ns update -WaveRestoreZoom {21993 ns} {22181 ns} +WaveRestoreZoom {9951431 ns} {9951599 ns} diff --git a/wally-pipelined/src/cache/dmapped.sv b/wally-pipelined/src/cache/dmapped.sv index 34864d393..f40da412a 100644 --- a/wally-pipelined/src/cache/dmapped.sv +++ b/wally-pipelined/src/cache/dmapped.sv @@ -125,128 +125,6 @@ module rodirectmappedmem #(parameter NUMLINES=512, parameter LINESIZE = 256, par assign DataValid = DataValidBit && (DataTag == ReadTag); endmodule -module rodirectmappedmemre #(parameter NUMLINES=512, parameter LINESIZE = 256, parameter WORDSIZE = `XLEN) ( - // Pipeline stuff - input logic clk, - input logic reset, - input logic re, - // If flush is high, invalidate the entire cache - input logic flush, - // Select which address to read (broken for efficiency's sake) - input logic [`XLEN-1:12] ReadUpperPAdr, - input logic [11:0] ReadLowerAdr, - // Write new data to the cache - input logic WriteEnable, - input logic [LINESIZE-1:0] WriteLine, - input logic [`XLEN-1:0] WritePAdr, - // Output the word, as well as if it is valid - output logic [31:0] DataWord, // *** was WORDSIZE-1 - output logic DataValid -); - - // Various compile-time constants - localparam integer WORDWIDTH = $clog2(WORDSIZE/8); - localparam integer OFFSETWIDTH = $clog2(LINESIZE/WORDSIZE); - localparam integer SETWIDTH = $clog2(NUMLINES); - localparam integer TAGWIDTH = `XLEN - OFFSETWIDTH - SETWIDTH - WORDWIDTH; - - localparam integer OFFSETBEGIN = WORDWIDTH; - localparam integer OFFSETEND = OFFSETBEGIN+OFFSETWIDTH-1; - localparam integer SETBEGIN = OFFSETEND+1; - localparam integer SETEND = SETBEGIN + SETWIDTH - 1; - localparam integer TAGBEGIN = SETEND + 1; - localparam integer TAGEND = TAGBEGIN + TAGWIDTH - 1; - - // Machinery to read from and write to the correct addresses in memory - logic [`XLEN-1:0] ReadPAdr; - logic [`XLEN-1:0] OldReadPAdr; - logic [OFFSETWIDTH-1:0] ReadOffset, WriteOffset; - logic [SETWIDTH-1:0] ReadSet, WriteSet; - logic [TAGWIDTH-1:0] ReadTag, WriteTag; - logic [LINESIZE-1:0] ReadLine; - logic [LINESIZE/WORDSIZE-1:0][WORDSIZE-1:0] ReadLineTransformed; - - // Machinery to check if a given read is valid and is the desired value - logic [TAGWIDTH-1:0] DataTag; - logic [NUMLINES-1:0] ValidOut; - logic DataValidBit; - - flopenr #(`XLEN) ReadPAdrFlop(clk, reset, re, ReadPAdr, OldReadPAdr); - - // Assign the read and write addresses in cache memory - always_comb begin - ReadOffset = OldReadPAdr[OFFSETEND:OFFSETBEGIN]; - ReadPAdr = {ReadUpperPAdr, ReadLowerAdr}; - ReadSet = ReadPAdr[SETEND:SETBEGIN]; - ReadTag = OldReadPAdr[TAGEND:TAGBEGIN]; - - WriteOffset = WritePAdr[OFFSETEND:OFFSETBEGIN]; - WriteSet = WritePAdr[SETEND:SETBEGIN]; - WriteTag = WritePAdr[TAGEND:TAGBEGIN]; - end - - // Depth is number of bits in one "word" of the memory, width is number of such words - Sram1Read1Write #(.DEPTH(LINESIZE), .WIDTH(NUMLINES)) cachemem ( - .*, - .ReadAddr(ReadSet), - .ReadData(ReadLine), - .WriteAddr(WriteSet), - .WriteData(WriteLine) - ); - Sram1Read1Write #(.DEPTH(TAGWIDTH), .WIDTH(NUMLINES)) cachetags ( - .*, - .ReadAddr(ReadSet), - .ReadData(DataTag), - .WriteAddr(WriteSet), - .WriteData(WriteTag) - ); - - // Pick the right bits coming out the read line - //assign DataWord = ReadLineTransformed[ReadOffset]; - //logic [31:0] tempRD; - always_comb begin - case (OldReadPAdr[4:1]) - 0: DataWord = ReadLine[31:0]; - 1: DataWord = ReadLine[47:16]; - 2: DataWord = ReadLine[63:32]; - 3: DataWord = ReadLine[79:48]; - - 4: DataWord = ReadLine[95:64]; - 5: DataWord = ReadLine[111:80]; - 6: DataWord = ReadLine[127:96]; - 7: DataWord = ReadLine[143:112]; - - 8: DataWord = ReadLine[159:128]; - 9: DataWord = ReadLine[175:144]; - 10: DataWord = ReadLine[191:160]; - 11: DataWord = ReadLine[207:176]; - - 12: DataWord = ReadLine[223:192]; - 13: DataWord = ReadLine[239:208]; - 14: DataWord = ReadLine[255:224]; - 15: DataWord = {16'b0, ReadLine[255:240]}; - endcase - end - genvar i; - generate - for (i=0; i < LINESIZE/WORDSIZE; i++) begin - assign ReadLineTransformed[i] = ReadLine[(i+1)*WORDSIZE-1:i*WORDSIZE]; - end - endgenerate - - // Correctly handle the valid bits - always_ff @(posedge clk, posedge reset) begin - if (reset || flush) begin - ValidOut <= {NUMLINES{1'b0}}; - end else begin - if (WriteEnable) begin - ValidOut[WriteSet] <= 1; - end - end - DataValidBit <= ValidOut[ReadSet]; - end - assign DataValid = DataValidBit && (DataTag == ReadTag); -endmodule // Write-through direct-mapped memory module wtdirectmappedmem #(parameter NUMLINES=512, parameter LINESIZE = 256, parameter WORDSIZE = `XLEN) ( diff --git a/wally-pipelined/src/cache/sram1rw.sv b/wally-pipelined/src/cache/sram1rw.sv new file mode 100644 index 000000000..a74593881 --- /dev/null +++ b/wally-pipelined/src/cache/sram1rw.sv @@ -0,0 +1,21 @@ +// Depth is number of bits in one "word" of the memory, width is number of such words +module sram1rw #(parameter DEPTH=128, WIDTH=256) ( + input logic clk, + // port 1 is read only + input logic [$clog2(WIDTH)-1:0] Addr, + output logic [DEPTH-1:0] ReadData, + + // port 2 is write only + input logic [DEPTH-1:0] WriteData, + input logic WriteEnable +); + + logic [WIDTH-1:0][DEPTH-1:0] StoredData; + + always_ff @(posedge clk) begin + ReadData <= StoredData[Addr]; + if (WriteEnable) begin + StoredData[Addr] <= WriteData; + end + end +endmodule 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