mirror of
https://github.com/openhwgroup/cvw
synced 2025-02-11 06:05:49 +00:00
64-bit AMO debugged
This commit is contained in:
parent
be0bd317e9
commit
d4e84c58ed
@ -159,7 +159,9 @@ module ahblite (
|
|||||||
generate
|
generate
|
||||||
if (`A_SUPPORTED) begin
|
if (`A_SUPPORTED) begin
|
||||||
logic [`XLEN-1:0] AMOResult;
|
logic [`XLEN-1:0] AMOResult;
|
||||||
amoalu amoalu(.a(HRDATA), .b(WriteDataM), .funct(Funct7M), .width(MemSizeM),
|
// amoalu amoalu(.a(HRDATA), .b(WriteDataM), .funct(Funct7M), .width(MemSizeM),
|
||||||
|
// .result(AMOResult));
|
||||||
|
amoalu amoalu(.srca(ReadDataPreW), .srcb(WriteDataM), .funct(Funct7M), .width(MemSizeM),
|
||||||
.result(AMOResult));
|
.result(AMOResult));
|
||||||
mux2 #(`XLEN) wdmux(WriteDataM, AMOResult, AtomicM[1], WriteData);
|
mux2 #(`XLEN) wdmux(WriteDataM, AMOResult, AtomicM[1], WriteData);
|
||||||
end else
|
end else
|
||||||
|
@ -26,12 +26,15 @@
|
|||||||
`include "wally-config.vh"
|
`include "wally-config.vh"
|
||||||
|
|
||||||
module amoalu (
|
module amoalu (
|
||||||
input logic [`XLEN-1:0] a, b,
|
input logic [`XLEN-1:0] srca, srcb,
|
||||||
input logic [6:0] funct,
|
input logic [6:0] funct,
|
||||||
input logic [1:0] width,
|
input logic [1:0] width,
|
||||||
output logic [`XLEN-1:0] result);
|
output logic [`XLEN-1:0] result);
|
||||||
|
|
||||||
logic [`XLEN-1:0] y;
|
logic [`XLEN-1:0] a, b, y;
|
||||||
|
|
||||||
|
// *** can this be muxed into the regular ALU to avoid needing a second one? Only a good
|
||||||
|
// idea if the regular ALU is not the critical path
|
||||||
|
|
||||||
// *** see how synthesis generates this and optimize more structurally if necessary to share hardware
|
// *** see how synthesis generates this and optimize more structurally if necessary to share hardware
|
||||||
// a single carry chain should be shared for + and the four min/max
|
// a single carry chain should be shared for + and the four min/max
|
||||||
@ -43,22 +46,31 @@ module amoalu (
|
|||||||
5'b00100: y = a ^ b; // amoxor
|
5'b00100: y = a ^ b; // amoxor
|
||||||
5'b01100: y = a & b; // amoand
|
5'b01100: y = a & b; // amoand
|
||||||
5'b01000: y = a | b; // amoor
|
5'b01000: y = a | b; // amoor
|
||||||
5'b10000: y = (a < b) ? a : b; // amomin
|
5'b10000: y = ($signed(a) < $signed(b)) ? a : b; // amomin
|
||||||
5'b10100: y = (a >= b) ? a : b; // amomax
|
5'b10100: y = ($signed(a) >= $signed(b)) ? a : b; // amomax
|
||||||
5'b11000: y = ({1'b0, a} < {1'b0, b}) ? a : b; // amominu
|
5'b11000: y = ($unsigned(a) < $unsigned(b)) ? a : b; // amominu
|
||||||
5'b11100: y = ({1'b0, a} >= {1'b0, b}) ? a : b; // amomaxu
|
5'b11100: y = ($unsigned(a) >= $unsigned(b)) ? a : b; // amomaxu
|
||||||
default: y = 'bx; // undefined; *** could change to b for efficiency
|
default: y = 'bx; // undefined; *** could change to b for efficiency
|
||||||
endcase
|
endcase
|
||||||
|
|
||||||
// sign extend if necessary
|
// sign extend if necessary
|
||||||
generate
|
generate
|
||||||
if (`XLEN == 32) begin
|
if (`XLEN == 32) begin
|
||||||
|
assign a = srca;
|
||||||
|
assign b = srcb;
|
||||||
assign result = y;
|
assign result = y;
|
||||||
end else begin // `XLEN = 64
|
end else begin // `XLEN = 64
|
||||||
always_comb
|
always_comb
|
||||||
if (width == 2'b10) // sign-extend word-length operations
|
if (width == 2'b10) begin // sign-extend word-length operations
|
||||||
|
// *** it would be more efficient to look at carry out of bit 31 to determine comparisons than do this big mux on and b
|
||||||
|
a = {{32{srca[31]}}, srca[31:0]};
|
||||||
|
b = {{32{srcb[31]}}, srcb[31:0]};
|
||||||
result = {{32{y[31]}}, y[31:0]};
|
result = {{32{y[31]}}, y[31:0]};
|
||||||
else result = y;
|
end else begin
|
||||||
|
a = srca;
|
||||||
|
b = srcb;
|
||||||
|
result = y;
|
||||||
|
end
|
||||||
end
|
end
|
||||||
endgenerate
|
endgenerate
|
||||||
|
|
||||||
|
@ -119,7 +119,7 @@ module controller(
|
|||||||
else if (InstrD[31:27] == 5'b00011)
|
else if (InstrD[31:27] == 5'b00011)
|
||||||
ControlsD = `CTRLW'b1_101_01_01_101_0_00_0_0_0_0_0_0_01_0; // sc
|
ControlsD = `CTRLW'b1_101_01_01_101_0_00_0_0_0_0_0_0_01_0; // sc
|
||||||
else
|
else
|
||||||
ControlsD = `CTRLW'b1_101_00_11_001_0_00_0_0_0_0_0_0_10_0;; // amo
|
ControlsD = `CTRLW'b1_101_01_11_001_0_00_0_0_0_0_0_0_10_0;; // amo
|
||||||
end else
|
end else
|
||||||
ControlsD = `CTRLW'b0_000_00_00_000_0_00_0_0_0_0_0_0_00_1; // non-implemented instruction
|
ControlsD = `CTRLW'b0_000_00_00_000_0_00_0_0_0_0_0_0_00_1; // non-implemented instruction
|
||||||
7'b0110011: if (Funct7D == 7'b0000000 || Funct7D == 7'b0100000)
|
7'b0110011: if (Funct7D == 7'b0000000 || Funct7D == 7'b0100000)
|
||||||
|
@ -38,6 +38,7 @@ module testbench();
|
|||||||
//logic [31:0] InstrW;
|
//logic [31:0] InstrW;
|
||||||
logic [`XLEN-1:0] meminit;
|
logic [`XLEN-1:0] meminit;
|
||||||
string tests64a[] = '{
|
string tests64a[] = '{
|
||||||
|
"rv64a/WALLY-AMO", "2110",
|
||||||
"rv64a/WALLY-LRSC", "2110"
|
"rv64a/WALLY-LRSC", "2110"
|
||||||
};
|
};
|
||||||
string tests64m[] = '{
|
string tests64m[] = '{
|
||||||
|
Loading…
Reference in New Issue
Block a user