Renamed signals in amoalu.

This commit is contained in:
Ross Thompson 2023-01-18 18:13:18 -06:00
parent 40c0e67930
commit 2048edb7a0
2 changed files with 17 additions and 18 deletions

View File

@ -30,11 +30,11 @@
`include "wally-config.vh" `include "wally-config.vh"
module amoalu ( module amoalu (
input logic [`XLEN-1:0] srca, // LSU's ReadData *** may want to change signal names. input logic [`XLEN-1:0] ReadDataM, // LSU's ReadData
input logic [`XLEN-1:0] srcb, // LSU's WriteData input logic [`XLEN-1:0] IHWriteDataM, // LSU's WriteData
input logic [6:0] funct, // ALU Operation input logic [6:0] LSUFunct7M, // ALU Operation
input logic [1:0] width, // Memoy access width input logic [2:0] LSUFunct3M, // Memoy access width
output logic [`XLEN-1:0] result // ALU output output logic [`XLEN-1:0] AMOResult // ALU output
); );
logic [`XLEN-1:0] a, b, y; logic [`XLEN-1:0] a, b, y;
@ -43,7 +43,7 @@ module amoalu (
// 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
// and the same mux can be used to select b for swap. // and the same mux can be used to select b for swap.
always_comb always_comb
case (funct[6:2]) case (LSUFunct7M[6:2])
5'b00001: y = b; // amoswap 5'b00001: y = b; // amoswap
5'b00000: y = a + b; // amoadd 5'b00000: y = a + b; // amoadd
5'b00100: y = a ^ b; // amoxor 5'b00100: y = a ^ b; // amoxor
@ -58,19 +58,19 @@ module amoalu (
// sign extend if necessary // sign extend if necessary
if (`XLEN == 32) begin:sext if (`XLEN == 32) begin:sext
assign a = srca; assign a = ReadDataM;
assign b = srcb; assign b = IHWriteDataM;
assign result = y; assign AMOResult = y;
end else begin:sext // `XLEN = 64 end else begin:sext // `XLEN = 64
always_comb always_comb
if (width == 2'b10) begin // sign-extend word-length operations if (LSUFunct3M[1:0] == 2'b10) begin // sign-extend word-length operations
a = {{32{srca[31]}}, srca[31:0]}; a = {{32{ReadDataM[31]}}, ReadDataM[31:0]};
b = {{32{srcb[31]}}, srcb[31:0]}; b = {{32{IHWriteDataM[31]}}, IHWriteDataM[31:0]};
result = {{32{y[31]}}, y[31:0]}; AMOResult = {{32{y[31]}}, y[31:0]};
end else begin end else begin
a = srca; a = ReadDataM;
b = srcb; b = IHWriteDataM;
result = y; AMOResult = y;
end end
end end
endmodule endmodule

View File

@ -49,8 +49,7 @@ module atomic (
logic [`XLEN-1:0] AMOResult; logic [`XLEN-1:0] AMOResult;
logic MemReadM; logic MemReadM;
amoalu amoalu(.srca(ReadDataM), .srcb(IHWriteDataM), .funct(LSUFunct7M), .width(LSUFunct3M[1:0]), amoalu amoalu(.ReadDataM, .IHWriteDataM, .LSUFunct7M, .LSUFunct3M, .AMOResult);
.result(AMOResult));
mux2 #(`XLEN) wdmux(IHWriteDataM, AMOResult, LSUAtomicM[1], IMAWriteDataM); mux2 #(`XLEN) wdmux(IHWriteDataM, AMOResult, LSUAtomicM[1], IMAWriteDataM);
assign MemReadM = PreLSURWM[1] & ~IgnoreRequest; assign MemReadM = PreLSURWM[1] & ~IgnoreRequest;