diff --git a/src/ieu/kmu/packer.sv b/src/ieu/kmu/packer.sv new file mode 100644 index 000000000..42702d89c --- /dev/null +++ b/src/ieu/kmu/packer.sv @@ -0,0 +1,67 @@ +/////////////////////////////////////////// +// packer.sv +// +// Written: kelvin.tran@okstate.edu, james.stine@okstate.edu +// Created: 5 October 2023 +// +// Purpose: RISCV kbitmanip pack operation 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 packer #(parameter WIDTH=32) ( + input logic [WIDTH-1:0] A, B, + 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 [1:0] MuxSelect; + + 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}; + + // TODO: FIX THIS ... this is completely incorrect way to use if statements + // Solution for now: + always_comb + begin + if (PackSelect[1:0] == 2'b11) + MuxSelect = 2'b01; + else if (PackSelect[2] == 1'b0) + MuxSelect = 2'b00; + else + MuxSelect = 2'b10; + end + + mux3 #(WIDTH) PackMux(Pack, PackH, PackW, MuxSelect, PackResult); + +endmodule diff --git a/src/ieu/kmu/revop.sv b/src/ieu/kmu/revop.sv new file mode 100644 index 000000000..901e1532e --- /dev/null +++ b/src/ieu/kmu/revop.sv @@ -0,0 +1,44 @@ +/////////////////////////////////////////// +// revop.sv +// +// Written: kelvin.tran@okstate.edu, james.stine@okstate.edu +// Created: 5 October 2023 +// +// Purpose: RISCV kbitmanip reverse byte-wise operation 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 revop #(parameter WIDTH=32) + (input logic [WIDTH-1:0] A, // Operands + input logic [WIDTH-1:0] RevA, // A Reversed + input logic revType, // rev8 or brev8 (LSB of immediate) + output logic [WIDTH-1:0] RevResult); // results + + logic [WIDTH-1:0] Rev8Result, Brev8Result; + genvar i; + + for (i=0; i> i) & 1; + if(if_temp[0]) temp = temp ^ (A >> (WIDTH-i)); + else temp = temp; + end + end + else begin // clmul + for (i=0; i> i) & 1; + if(if_temp[0]) temp = temp ^ (A << i); + else temp = temp; + end + end + end + assign ZBKCResult = temp; + +endmodule diff --git a/src/ieu/kmu/zbkx.sv b/src/ieu/kmu/zbkx.sv new file mode 100644 index 000000000..9d42dd372 --- /dev/null +++ b/src/ieu/kmu/zbkx.sv @@ -0,0 +1,50 @@ +/////////////////////////////////////////// +// zbkx.sv +// +// Written: kelvin.tran@okstate.edu, james.stine@okstate.edu +// Created: 1 February 2024 +// +// Purpose: RISC-V ZBKX 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 zbkx #(parameter WIDTH=32) + (input logic [WIDTH-1:0] A, B, + input logic [2:0] ZBKXSelect, + output logic [WIDTH-1:0] ZBKXResult); + + logic [WIDTH-1:0] xperm_lookup[0:WIDTH]; + logic [WIDTH-1:0] XPERM8_Result; + logic [WIDTH-1:0] XPERM4_Result; + genvar i; + + for(i=0; i> {B[i+7:i], 3'b0}; + assign XPERM8_Result[i+7:i] = xperm_lookup[i][7:0]; + end + + for(i=0; i> {B[i+3:i], 2'b0}; + assign XPERM4_Result[i+3:i] = xperm_lookup[i+1][3:0]; + end + + mux2 #(WIDTH) ZbkxMux (XPERM8_Result, XPERM4_Result, ZBKXSelect[0], ZBKXResult); + +endmodule diff --git a/src/ieu/kmu/zipper.sv b/src/ieu/kmu/zipper.sv new file mode 100644 index 000000000..acbd36355 --- /dev/null +++ b/src/ieu/kmu/zipper.sv @@ -0,0 +1,47 @@ +/////////////////////////////////////////// +// zipper.sv +// +// Written: kelvin.tran@okstate.edu, james.stine@okstate.edu +// Created: 9 October 2023 +// +// Purpose: RISCV kbitmanip zip operation 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 zipper #(parameter WIDTH=64) + (input logic [WIDTH-1:0] A, + input logic ZipSelect, + output logic [WIDTH-1:0] ZipResult); + + logic [WIDTH-1:0] zip; + logic [WIDTH-1:0] unzip; + genvar i; + + for (i=0; i