update removal of underscores from kmu

This commit is contained in:
James E. Stine 2024-03-09 19:00:31 -06:00
parent 3b16238a37
commit 55e019c9dd
11 changed files with 150 additions and 161 deletions

View File

@ -30,30 +30,29 @@ module packer #(parameter WIDTH=32) (
input logic [2:0] PackSelect,
output logic [WIDTH-1:0] PackResult);
logic [WIDTH/2-1:0] low_half, high_half;
logic [7:0] low_halfh, high_halfh;
logic [15:0] low_halfw, high_halfw;
logic [WIDTH-1:0] Pack;
logic [WIDTH-1:0] PackH;
logic [WIDTH-1:0] PackW;
logic [WIDTH/2-1:0] lowhalf, highhalf;
logic [7:0] lowhalfh, highhalfh;
logic [15:0] lowhalfw, highhalfw;
assign low_half = A[WIDTH/2-1:0];
assign high_half = B[WIDTH/2-1:0];
assign low_halfh = A[7:0];
assign high_halfh = B[7:0];
assign low_halfw = A[15:0];
assign high_halfw = B[15:0];
assign Pack = {high_half, low_half};
assign PackH = {{(WIDTH-16){1'b0}}, high_halfh, low_halfh};
assign PackW = {{(WIDTH-32){high_halfw[15]}}, high_halfw, low_halfw};
always_comb
begin
if (PackSelect[1:0] == 2'b11) PackResult = PackH;
else if (PackSelect[2] == 1'b0) PackResult = Pack;
else PackResult = PackW;
end
logic [WIDTH-1:0] Pack;
logic [WIDTH-1:0] PackH;
logic [WIDTH-1:0] PackW;
assign lowhalf = A[WIDTH/2-1:0];
assign highhalf = B[WIDTH/2-1:0];
assign lowhalfh = A[7:0];
assign highhalfh = B[7:0];
assign lowhalfw = A[15:0];
assign highhalfw = B[15:0];
assign Pack = {highhalf, lowhalf};
assign PackH = {{(WIDTH-16){1'b0}}, highhalfh, lowhalfh};
assign PackW = {{(WIDTH-32){highhalfw[15]}}, highhalfw, lowhalfw};
always_comb
begin
if (PackSelect[1:0] == 2'b11) PackResult = PackH;
else if (PackSelect[2] == 1'b0) PackResult = Pack;
else PackResult = PackW;
end
endmodule

View File

@ -41,6 +41,5 @@ module zbkb #(parameter WIDTH=32)
zipper #(WIDTH) zip(.A, .ZipSelect(Funct3[2]), .ZipResult);
// ZBKB Result Select Mux
mux3 #(WIDTH) zbkbresultmux(ByteResult, PackResult, ZipResult, ZBKBSelect[1:0], ZBKBResult);
mux3 #(WIDTH) zbkbresultmux(ByteResult, PackResult, ZipResult, ZBKBSelect[1:0], ZBKBResult);
endmodule

View File

@ -30,22 +30,21 @@ module zbkx #(parameter WIDTH=32)
input logic [2:0] ZBKXSelect,
output logic [WIDTH-1:0] ZBKXResult);
logic [WIDTH-1:0] xperm_lookup;
integer i;
logic [WIDTH-1:0] xpermlookup;
integer i;
always_comb begin
if (ZBKXSelect[0] == 1'b0) begin
for(i=0; i<WIDTH; i=i+8) begin: xperm8
xperm_lookup = A >> {B[i+:8], 3'b0};
ZBKXResult[i+:8] = xperm_lookup[7:0];
xpermlookup = A >> {B[i+:8], 3'b0};
ZBKXResult[i+:8] = xpermlookup[7:0];
end
end
else begin
for(i=0; i<WIDTH; i=i+4) begin: xperm4
xperm_lookup = A >> {B[i+:4], 2'b0};
ZBKXResult[i+:4] = xperm_lookup[3:0];
xpermlookup = A >> {B[i+:4], 2'b0};
ZBKXResult[i+:4] = xpermlookup[3:0];
end
end
end
end
endmodule

View File

@ -36,12 +36,10 @@ module zipper #(parameter WIDTH=64)
for (i=0; i<WIDTH/2; i+=1) begin: loop
assign zip[2*i] = A[i];
assign zip [2*i+1] = A[i + WIDTH/2];
assign zip [2*i+1] = A[i + WIDTH/2];
assign unzip[i] = A[2*i];
assign unzip[i+WIDTH/2] = A[2*i+1];
end
mux2 #(WIDTH) ZipMux(zip, unzip, ZipSelect, ZipResult);
mux2 #(WIDTH) ZipMux(zip, unzip, ZipSelect, ZipResult);
endmodule

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////
// zknd_32.sv
// zknd32.sv
//
// Written: kelvin.tran@okstate.edu, james.stine@okstate.edu
// Created: 27 November 2023
@ -26,7 +26,7 @@
// and limitations under the License.
////////////////////////////////////////////////////////////////////////////////////////////////
module zknd_32 #(parameter WIDTH=32)
module zknd32 #(parameter WIDTH=32)
(input logic [WIDTH-1:0] A, B,
input logic [6:0] Funct7,
input logic [2:0] ZKNDSelect,
@ -36,9 +36,8 @@ module zknd_32 #(parameter WIDTH=32)
logic [31:0] aes32dsmiRes;
// RV32
aes32dsi aes32dsi (.bs(Funct7[6:5]), .rs1(A), .rs2(B), .Data_Out(aes32dsiRes));
aes32dsmi aes32dsmi (.bs(Funct7[6:5]), .rs1(A), .rs2(B), .Data_Out(aes32dsmiRes));
aes32dsi aes32dsi (.bs(Funct7[6:5]), .rs1(A), .rs2(B), .DataOut(aes32dsiRes));
aes32dsmi aes32dsmi (.bs(Funct7[6:5]), .rs1(A), .rs2(B), .DataOut(aes32dsmiRes));
mux2 #(WIDTH) zkndmux (aes32dsiRes, aes32dsmiRes, ZKNDSelect[0], ZKNDResult);
endmodule

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////
// zknd_64.sv
// zknd64.sv
//
// Written: kelvin.tran@okstate.edu, james.stine@okstate.edu
// Created: 27 November 2023
@ -26,7 +26,7 @@
// and limitations under the License.
////////////////////////////////////////////////////////////////////////////////////////////////
module zknd_64 #(parameter WIDTH=32)
module zknd64 #(parameter WIDTH=32)
(input logic [WIDTH-1:0] A, B,
input logic [6:0] Funct7,
input logic [3:0] RNUM,
@ -40,12 +40,11 @@ module zknd_64 #(parameter WIDTH=32)
logic [63:0] aes64ks2Res;
// RV64
aes64ds aes64ds (.rs1(A), .rs2(B), .Data_Out(aes64dsRes));
aes64dsm aes64dsm (.rs1(A), .rs2(B), .Data_Out(aes64dsmRes));
aes64im aes64im (.rs1(A), .Data_Out(aes64imRes));
aes64ds aes64ds (.rs1(A), .rs2(B), .DataOut(aes64dsRes));
aes64dsm aes64dsm (.rs1(A), .rs2(B), .DataOut(aes64dsmRes));
aes64im aes64im (.rs1(A), .DataOut(aes64imRes));
aes64ks1i aes64ks1i (.roundnum(RNUM), .rs1(A), .rd(aes64ks1iRes));
aes64ks2 aes64ks2 (.rs2(B), .rs1(A), .rd(aes64ks2Res));
mux5 #(WIDTH) zkndmux (aes64dsRes, aes64dsmRes, aes64imRes, aes64ks1iRes, aes64ks2Res, ZKNDSelect, ZKNDResult);
endmodule

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////
// zkne_32.sv
// zkne32.sv
//
// Written: kelvin.tran@okstate.edu, james.stine@okstate.edu
// Created: 21 November 2023
@ -26,7 +26,7 @@
// and limitations under the License.
////////////////////////////////////////////////////////////////////////////////////////////////
module zkne_32 #(parameter WIDTH=32)
module zkne32 #(parameter WIDTH=32)
(input logic [WIDTH-1:0] A, B,
input logic [6:0] Funct7,
input logic [2:0] ZKNESelect,
@ -36,9 +36,8 @@ module zkne_32 #(parameter WIDTH=32)
logic [31:0] aes32esmiRes;
// RV32
aes32esi aes32esi (.bs(Funct7[6:5]), .rs1(A), .rs2(B), .Data_Out(aes32esiRes));
aes32esmi aes32esmi (.bs(Funct7[6:5]), .rs1(A), .rs2(B), .Data_Out(aes32esmiRes));
aes32esi aes32esi (.bs(Funct7[6:5]), .rs1(A), .rs2(B), .DataOut(aes32esiRes));
aes32esmi aes32esmi (.bs(Funct7[6:5]), .rs1(A), .rs2(B), .DataOut(aes32esmiRes));
mux2 #(WIDTH) zknemux (aes32esiRes, aes32esmiRes, ZKNESelect[0], ZKNEResult);
endmodule

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////
// zkne_64.sv
// zkne64.sv
//
// Written: kelvin.tran@okstate.edu, james.stine@okstate.edu
// Created: 21 November 2023
@ -26,7 +26,7 @@
// and limitations under the License.
////////////////////////////////////////////////////////////////////////////////////////////////
module zkne_64 #(parameter WIDTH=32)
module zkne64 #(parameter WIDTH=32)
(input logic [WIDTH-1:0] A, B,
input logic [6:0] Funct7,
input logic [3:0] RNUM,
@ -39,12 +39,11 @@ module zkne_64 #(parameter WIDTH=32)
logic [63:0] aes64ks2Res;
// RV64
aes64es aes64es (.rs1(A), .rs2(B), .Data_Out(aes64esRes));
aes64esm aes64esm (.rs1(A), .rs2(B), .Data_Out(aes64esmRes));
aes64es aes64es (.rs1(A), .rs2(B), .DataOut(aes64esRes));
aes64esm aes64esm (.rs1(A), .rs2(B), .DataOut(aes64esmRes));
aes64ks1i aes64ks1i (.roundnum(RNUM), .rs1(A), .rd(aes64ks1iRes));
aes64ks2 aes64ks2 (.rs2(B), .rs1(A), .rd(aes64ks2Res));
// 010 is a placeholder to match the select of ZKND's AES64KS1I since they share some instruction
mux5 #(WIDTH) zknemux (aes64esRes, aes64esmRes, 64'b0, aes64ks1iRes, aes64ks2Res, ZKNESelect, ZKNEResult);
mux5 #(WIDTH) zknemux (aes64esRes, aes64esmRes, 64'b0, aes64ks1iRes, aes64ks2Res, ZKNESelect, ZKNEResult);
endmodule

71
src/ieu/kmu/zknh32.sv Normal file
View File

@ -0,0 +1,71 @@
///////////////////////////////////////////
// zknh32.sv
//
// Written: kelvin.tran@okstate.edu, james.stine@okstate.edu
// Created: 13 February 2024
//
// Purpose: RISC-V ZKNH 32-Bit top level unit
//
// A component of the CORE-V-WALLY configurable RISC-V project.
// https://github.com/openhwgroup/cvw
//
// Copyright (C) 2021-24 Harvey Mudd College & Oklahoma State University
//
// SPDX-License-Identifier: Apache-2.0 WITH SHL-2.1
//
// Licensed under the Solderpad Hardware License v 2.1 (the “License”); you may not use this file
// except in compliance with the License, or, at your option, the Apache License version 2.0. You
// may obtain a copy of the License at
//
// https://solderpad.org/licenses/SHL-2.1/
//
// Unless required by applicable law or agreed to in writing, any work distributed under the
// License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
// either express or implied. See the License for the specific language governing permissions
// and limitations under the License.
////////////////////////////////////////////////////////////////////////////////////////////////
module zknh32 (input logic [31:0] A, B,
input logic [3:0] ZKNHSelect,
output logic [31:0] ZKNHResult);
logic [31:0] sha256sig0res;
logic [31:0] sha256sig1res;
logic [31:0] sha256sum0res;
logic [31:0] sha256sum1res;
logic [31:0] sha512sig0hres;
logic [31:0] sha512sig0lres;
logic [31:0] sha512sig1hres;
logic [31:0] sha512sig1lres;
logic [31:0] sha512sum0rres;
logic [31:0] sha512sum1rres;
sha256sig0 #(32) sha256sig0(A, sha256sig0res);
sha256sig1 #(32) sha256sig1(A, sha256sig1res);
sha256sum0 #(32) sha256sum0(A, sha256sum0res);
sha256sum1 #(32) sha256sum1(A, sha256sum1res);
sha512sig0h sha512sig0h(A, B, sha512sig0hres);
sha512sig0l sha512sig0l(A, B, sha512sig0lres);
sha512sig1h sha512sig1h(A, B, sha512sig1hres);
sha512sig1l sha512sig1l(A, B, sha512sig1lres);
sha512sum0r sha512sum0r(A, B, sha512sum0rres);
sha512sum1r sha512sum1r(A, B, sha512sum1rres);
// Result Select Mux
always_comb begin
casez(ZKNHSelect)
4'b0000: ZKNHResult = sha256sig0res;
4'b0001: ZKNHResult = sha256sig1res;
4'b0010: ZKNHResult = sha256sum0res;
4'b0011: ZKNHResult = sha256sum1res;
4'b0100: ZKNHResult = sha512sig0hres;
4'b0101: ZKNHResult = sha512sig0lres;
4'b0110: ZKNHResult = sha512sig1hres;
4'b0111: ZKNHResult = sha512sig1lres;
4'b1000: ZKNHResult = sha512sum0rres;
4'b1001: ZKNHResult = sha512sum1rres;
default ZKNHResult = 0;
endcase
end
endmodule

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////
// zknh_64.sv
// zknh64.sv
//
// Written: kelvin.tran@okstate.edu, james.stine@okstate.edu
// Created: 13 February 2024
@ -25,41 +25,40 @@
// and limitations under the License.
////////////////////////////////////////////////////////////////////////////////////////////////
module zknh_64 (input logic [63:0] A, B, input logic [3:0] ZKNHSelect,
output logic [63:0] ZKNHResult);
module zknh64 (input logic [63:0] A, B, input logic [3:0] ZKNHSelect,
output logic [63:0] ZKNHResult);
logic [63:0] sha256sig0_res;
logic [63:0] sha256sig1_res;
logic [63:0] sha256sum0_res;
logic [63:0] sha256sum1_res;
logic [63:0] sha256sig0res;
logic [63:0] sha256sig1res;
logic [63:0] sha256sum0res;
logic [63:0] sha256sum1res;
logic [63:0] sha512sig0_res;
logic [63:0] sha512sig1_res;
logic [63:0] sha512sum0_res;
logic [63:0] sha512sum1_res;
logic [63:0] sha512sig0res;
logic [63:0] sha512sig1res;
logic [63:0] sha512sum0res;
logic [63:0] sha512sum1res;
sha256sig0 #(64) sha256sig0(A, sha256sig0_res);
sha256sig1 #(64) sha256sig1(A, sha256sig1_res);
sha256sum0 #(64) sha256sum0(A, sha256sum0_res);
sha256sum1 #(64) sha256sum1(A, sha256sum1_res);
sha512sig0 sha512sig0(A, sha512sig0_res);
sha512sig1 sha512sig1(A, sha512sig1_res);
sha512sum0 sha512sum0(A, sha512sum0_res);
sha512sum1 sha512sum1(A, sha512sum1_res);
sha256sig0 #(64) sha256sig0(A, sha256sig0res);
sha256sig1 #(64) sha256sig1(A, sha256sig1res);
sha256sum0 #(64) sha256sum0(A, sha256sum0res);
sha256sum1 #(64) sha256sum1(A, sha256sum1res);
sha512sig0 sha512sig0(A, sha512sig0res);
sha512sig1 sha512sig1(A, sha512sig1res);
sha512sum0 sha512sum0(A, sha512sum0res);
sha512sum1 sha512sum1(A, sha512sum1res);
// Result Select Mux
always_comb begin
casez(ZKNHSelect)
4'b0000: ZKNHResult = sha256sig0_res;
4'b0001: ZKNHResult = sha256sig1_res;
4'b0010: ZKNHResult = sha256sum0_res;
4'b0011: ZKNHResult = sha256sum1_res;
4'b1010: ZKNHResult = sha512sig0_res;
4'b1011: ZKNHResult = sha512sig1_res;
4'b1100: ZKNHResult = sha512sum0_res;
4'b1101: ZKNHResult = sha512sum1_res;
4'b0000: ZKNHResult = sha256sig0res;
4'b0001: ZKNHResult = sha256sig1res;
4'b0010: ZKNHResult = sha256sum0res;
4'b0011: ZKNHResult = sha256sum1res;
4'b1010: ZKNHResult = sha512sig0res;
4'b1011: ZKNHResult = sha512sig1res;
4'b1100: ZKNHResult = sha512sum0res;
4'b1101: ZKNHResult = sha512sum1res;
default ZKNHResult = 0;
endcase
end
endmodule

View File

@ -1,72 +0,0 @@
///////////////////////////////////////////
// zknh_32.sv
//
// Written: kelvin.tran@okstate.edu, james.stine@okstate.edu
// Created: 13 February 2024
//
// Purpose: RISC-V ZKNH 32-Bit top level unit
//
// A component of the CORE-V-WALLY configurable RISC-V project.
// https://github.com/openhwgroup/cvw
//
// Copyright (C) 2021-24 Harvey Mudd College & Oklahoma State University
//
// SPDX-License-Identifier: Apache-2.0 WITH SHL-2.1
//
// Licensed under the Solderpad Hardware License v 2.1 (the “License”); you may not use this file
// except in compliance with the License, or, at your option, the Apache License version 2.0. You
// may obtain a copy of the License at
//
// https://solderpad.org/licenses/SHL-2.1/
//
// Unless required by applicable law or agreed to in writing, any work distributed under the
// License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
// either express or implied. See the License for the specific language governing permissions
// and limitations under the License.
////////////////////////////////////////////////////////////////////////////////////////////////
module zknh_32 (input logic [31:0] A, B,
input logic [3:0] ZKNHSelect,
output logic [31:0] ZKNHResult);
logic [31:0] sha256sig0_res;
logic [31:0] sha256sig1_res;
logic [31:0] sha256sum0_res;
logic [31:0] sha256sum1_res;
logic [31:0] sha512sig0h_res;
logic [31:0] sha512sig0l_res;
logic [31:0] sha512sig1h_res;
logic [31:0] sha512sig1l_res;
logic [31:0] sha512sum0r_res;
logic [31:0] sha512sum1r_res;
sha256sig0 #(32) sha256sig0(A, sha256sig0_res);
sha256sig1 #(32) sha256sig1(A, sha256sig1_res);
sha256sum0 #(32) sha256sum0(A, sha256sum0_res);
sha256sum1 #(32) sha256sum1(A, sha256sum1_res);
sha512sig0h sha512sig0h(A, B, sha512sig0h_res);
sha512sig0l sha512sig0l(A, B, sha512sig0l_res);
sha512sig1h sha512sig1h(A, B, sha512sig1h_res);
sha512sig1l sha512sig1l(A, B, sha512sig1l_res);
sha512sum0r sha512sum0r(A, B, sha512sum0r_res);
sha512sum1r sha512sum1r(A, B, sha512sum1r_res);
// Result Select Mux
always_comb begin
casez(ZKNHSelect)
4'b0000: ZKNHResult = sha256sig0_res;
4'b0001: ZKNHResult = sha256sig1_res;
4'b0010: ZKNHResult = sha256sum0_res;
4'b0011: ZKNHResult = sha256sum1_res;
4'b0100: ZKNHResult = sha512sig0h_res;
4'b0101: ZKNHResult = sha512sig0l_res;
4'b0110: ZKNHResult = sha512sig1h_res;
4'b0111: ZKNHResult = sha512sig1l_res;
4'b1000: ZKNHResult = sha512sum0r_res;
4'b1001: ZKNHResult = sha512sum1r_res;
default ZKNHResult = 0;
endcase
end
endmodule