minor update

This commit is contained in:
Blaise Tine 2024-07-10 09:29:41 -07:00
parent 0acf7761ef
commit 13d5a9c969
2 changed files with 55 additions and 54 deletions

View file

@ -1,10 +1,10 @@
// Copyright © 2019-2023
//
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -21,7 +21,7 @@ module VX_fpu_fma import VX_fpu_pkg::*; #(
parameter TAG_WIDTH = 1
) (
input wire clk,
input wire reset,
input wire reset,
output wire ready_in,
input wire valid_in,
@ -29,7 +29,7 @@ module VX_fpu_fma import VX_fpu_pkg::*; #(
input wire [NUM_LANES-1:0] mask_in,
input wire [TAG_WIDTH-1:0] tag_in,
input wire [`INST_FRM_BITS-1:0] frm,
input wire is_madd,
@ -39,7 +39,7 @@ module VX_fpu_fma import VX_fpu_pkg::*; #(
input wire [NUM_LANES-1:0][31:0] dataa,
input wire [NUM_LANES-1:0][31:0] datab,
input wire [NUM_LANES-1:0][31:0] datac,
output wire [NUM_LANES-1:0][31:0] result,
output wire [NUM_LANES-1:0][31:0] result,
output wire has_fflags,
output wire [`FP_FLAGS_BITS-1:0] fflags,
@ -52,11 +52,11 @@ module VX_fpu_fma import VX_fpu_pkg::*; #(
`UNUSED_VAR (frm)
wire [NUM_LANES-1:0][3*32-1:0] data_in;
wire [NUM_LANES-1:0] mask_out;
wire [NUM_LANES-1:0] mask_out;
wire [NUM_LANES-1:0][(`FP_FLAGS_BITS+32)-1:0] data_out;
wire [NUM_LANES-1:0][`FP_FLAGS_BITS-1:0] fflags_out;
wire pe_enable;
wire pe_enable;
wire [NUM_PES-1:0][3*32-1:0] pe_data_in;
wire [NUM_PES-1:0][(`FP_FLAGS_BITS+32)-1:0] pe_data_out;
@ -66,7 +66,7 @@ module VX_fpu_fma import VX_fpu_pkg::*; #(
always @(*) begin
if (is_madd) begin
// MADD / MSUB / NMADD / NMSUB
a[i] = is_neg ? {~dataa[i][31], dataa[i][30:0]} : dataa[i];
a[i] = is_neg ? {~dataa[i][31], dataa[i][30:0]} : dataa[i];
b[i] = datab[i];
c[i] = (is_neg ^ is_sub) ? {~datac[i][31], datac[i][30:0]} : datac[i];
end else begin
@ -81,7 +81,7 @@ module VX_fpu_fma import VX_fpu_pkg::*; #(
b[i] = dataa[i];
c[i] = is_sub ? {~datab[i][31], datab[i][30:0]} : datab[i];
end
end
end
end
end
@ -90,15 +90,15 @@ module VX_fpu_fma import VX_fpu_pkg::*; #(
assign data_in[i][32 +: 32] = b[i];
assign data_in[i][64 +: 32] = c[i];
end
VX_pe_serializer #(
.NUM_LANES (NUM_LANES),
.NUM_PES (NUM_PES),
.NUM_LANES (NUM_LANES),
.NUM_PES (NUM_PES),
.LATENCY (`LATENCY_FMA),
.DATA_IN_WIDTH(3*32),
.DATA_OUT_WIDTH(`FP_FLAGS_BITS + 32),
.TAG_WIDTH (NUM_LANES + TAG_WIDTH),
.PE_REG (1)
.PE_REG ((NUM_LANES != NUM_PES) ? 1 : 0)
) pe_serializer (
.clk (clk),
.reset (reset),
@ -123,7 +123,7 @@ module VX_fpu_fma import VX_fpu_pkg::*; #(
fflags_t [NUM_LANES-1:0] per_lane_fflags;
`ifdef QUARTUS
for (genvar i = 0; i < NUM_PES; ++i) begin
acl_fmadd fmadd (
.clk (clk),
@ -136,7 +136,7 @@ module VX_fpu_fma import VX_fpu_pkg::*; #(
);
assign pe_data_out[i][32 +: `FP_FLAGS_BITS] = 'x;
end
assign has_fflags = 0;
assign per_lane_fflags = 'x;
@ -144,7 +144,7 @@ module VX_fpu_fma import VX_fpu_pkg::*; #(
for (genvar i = 0; i < NUM_PES; ++i) begin
wire [2:0] tuser;
xil_fma fma (
.aclk (clk),
.aclken (pe_enable),
@ -172,15 +172,15 @@ module VX_fpu_fma import VX_fpu_pkg::*; #(
`UNUSED_VAR (r)
fflags_t f;
always @(*) begin
always @(*) begin
dpi_fmadd (
pe_enable,
int'(0),
{32'hffffffff, pe_data_in[i][0 +: 32]},
{32'hffffffff, pe_data_in[i][32 +: 32]},
{32'hffffffff, pe_data_in[i][64 +: 32]},
frm,
r,
pe_enable,
int'(0),
{32'hffffffff, pe_data_in[i][0 +: 32]},
{32'hffffffff, pe_data_in[i][32 +: 32]},
{32'hffffffff, pe_data_in[i][64 +: 32]},
frm,
r,
f
);
end

View file

@ -1,10 +1,10 @@
// Copyright © 2019-2023
//
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -15,8 +15,8 @@
`TRACING_OFF
module VX_pe_serializer #(
parameter NUM_LANES = 1,
parameter NUM_PES = 1,
parameter NUM_LANES = 1,
parameter NUM_PES = 1,
parameter LATENCY = 1,
parameter DATA_IN_WIDTH = 1,
parameter DATA_OUT_WIDTH = 1,
@ -28,12 +28,12 @@ module VX_pe_serializer #(
// input
input wire valid_in,
input wire [NUM_LANES-1:0][DATA_IN_WIDTH-1:0] data_in,
input wire [NUM_LANES-1:0][DATA_IN_WIDTH-1:0] data_in,
input wire [TAG_WIDTH-1:0] tag_in,
output wire ready_in,
// PE
output wire pe_enable,
output wire pe_enable,
output wire [NUM_PES-1:0][DATA_IN_WIDTH-1:0] pe_data_in,
input wire [NUM_PES-1:0][DATA_OUT_WIDTH-1:0] pe_data_out,
@ -43,6 +43,7 @@ module VX_pe_serializer #(
output wire [TAG_WIDTH-1:0] tag_out,
input wire ready_out
);
wire [NUM_PES-1:0][DATA_IN_WIDTH-1:0] pe_data_in_s;
wire valid_out_s;
wire [TAG_WIDTH-1:0] tag_out_s;
wire enable;
@ -59,6 +60,17 @@ module VX_pe_serializer #(
.data_out ({valid_out_s, tag_out_s})
);
VX_pipe_register #(
.DATAW (NUM_PES * DATA_IN_WIDTH),
.DEPTH (PE_REG)
) pe_reg (
.clk (clk),
.reset (reset),
.enable (enable),
.data_in (pe_data_in_s),
.data_out (pe_data_in)
);
if (NUM_LANES != NUM_PES) begin
localparam BATCH_SIZE = NUM_LANES / NUM_PES;
@ -67,6 +79,10 @@ module VX_pe_serializer #(
reg [BATCH_SIZEW-1:0] batch_in_idx;
reg [BATCH_SIZEW-1:0] batch_out_idx;
for (genvar i = 0; i < NUM_PES; ++i) begin
assign pe_data_in_s[i] = data_in[batch_in_idx * NUM_PES + i];
end
always @(posedge clk) begin
if (reset) begin
batch_in_idx <= '0;
@ -81,30 +97,14 @@ module VX_pe_serializer #(
end
end
wire batch_in_done = (batch_in_idx == BATCH_SIZEW'(BATCH_SIZE-1));
wire batch_in_done = (batch_in_idx == BATCH_SIZEW'(BATCH_SIZE-1));
wire batch_out_done = (batch_out_idx == BATCH_SIZEW'(BATCH_SIZE-1));
wire [NUM_PES-1:0][DATA_IN_WIDTH-1:0] pe_data_in_s;
for (genvar i = 0; i < NUM_PES; ++i) begin
assign pe_data_in_s[i] = data_in[batch_in_idx * NUM_PES + i];
end
VX_pipe_register #(
.DATAW (NUM_PES * DATA_IN_WIDTH),
.DEPTH (PE_REG)
) pe_reg (
.clk (clk),
.reset (reset),
.enable (enable),
.data_in (pe_data_in_s),
.data_out (pe_data_in)
);
reg valid_out_r;
reg [BATCH_SIZE-1:0][NUM_PES-1:0][DATA_OUT_WIDTH-1:0] data_out_r;
reg [TAG_WIDTH-1:0] tag_out_r;
wire valid_out_b = valid_out_s && batch_out_done;
wire valid_out_b = valid_out_s && batch_out_done;
wire enable_r = ready_out || ~valid_out;
always @(posedge clk) begin
@ -113,13 +113,13 @@ module VX_pe_serializer #(
end else if (enable_r) begin
valid_out_r <= valid_out_b;
end
if (enable_r) begin
if (enable_r) begin
data_out_r[batch_out_idx] <= pe_data_out;
tag_out_r <= tag_out_s;
end
end
assign enable = (enable_r || ~valid_out_b);
assign enable = enable_r || ~valid_out_b;
assign ready_in = enable && batch_in_done;
assign pe_enable = enable;
@ -130,16 +130,17 @@ module VX_pe_serializer #(
end else begin
assign pe_data_in_s = data_in;
assign enable = ready_out || ~valid_out;
assign ready_in = enable;
assign pe_enable = enable;
assign pe_data_in= data_in;
assign valid_out = valid_out_s;
assign valid_out = valid_out_s;
assign data_out = pe_data_out;
assign tag_out = tag_out_s;
end
endmodule