-
Notifications
You must be signed in to change notification settings - Fork 43
[HW] Floating-point compare instructions #75
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Navaneeth-KunhiPurayil
merged 8 commits into
pulp-platform:main
from
FondazioneChipsIT:rgiunti/pulp/fp-cond-instr
Apr 14, 2026
Merged
Changes from 7 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
eecd399
[HW] add decoding for compare instr
rgiunti 38bbd28
[HW] mod VFU for cmp instr support
rgiunti 3622583
[SW] add tests for cmp instr
rgiunti ae2efd1
[FIX/SW] add macros for 32b config
rgiunti 7698a73
[OPT] single write to VRF
rgiunti a584834
[TEST] commented vmfne w sNaN
rgiunti fe0a6e5
[FIX] update LMUL in tests
rgiunti 4faeeaf
[FIX] trailing spaces
rgiunti File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -205,6 +205,10 @@ | |
| logic [N_FU*ELENB-1:0] result_valid; | ||
| logic result_ready; | ||
|
|
||
| // it represents the VRF word index | ||
| logic [$clog2(NrWordsPerVector):0] word_idx_d, word_idx_q; | ||
| `FF(word_idx_q, word_idx_d, '0) | ||
|
|
||
| always_comb begin: control_proc | ||
| // Maintain state | ||
| vl_d = vl_q; | ||
|
|
@@ -445,7 +449,7 @@ | |
| word_issued = spatz_req_valid && &(in_ready | ~valid_operations) && operands_ready && !stall; | ||
|
|
||
| // Are we ready to accept a result? | ||
| result_ready = &(result_valid | ~pending_results) && ((result_tag.wb && vfu_rsp_ready_i) || vrf_wvalid_i); | ||
| result_ready = &(result_valid | ~pending_results) && ((result_tag.wb && vfu_rsp_ready_i) || vrf_wvalid_i || (spatz_req.op == VFCMP && !result_tag.last)); | ||
|
|
||
| // Initialize the pointers | ||
| reduction_pointer_d = '0; | ||
|
|
@@ -758,12 +762,12 @@ | |
| if (word_issued) begin | ||
| vreg_addr_d[0] = vreg_addr_d[0] + (!spatz_req.op_arith.widen_vs2 || widening_upper_q); | ||
| vreg_addr_d[1] = vreg_addr_d[1] + (!spatz_req.op_arith.widen_vs1 || widening_upper_q); | ||
| vreg_addr_d[2] = vreg_addr_d[2] + (!spatz_req.op_arith.is_reduction && (!spatz_req.op_arith.is_narrowing || narrowing_upper_q)); | ||
| vreg_addr_d[2] = vreg_addr_d[2] + (!spatz_req.op_arith.is_reduction && (!spatz_req.op_arith.is_narrowing || narrowing_upper_q) && (spatz_req.op != VFCMP)); | ||
| end | ||
| end else if (spatz_req_valid && vl_q < spatz_req.vl && word_issued) begin | ||
| vreg_addr_d[0] = vreg_addr_q[0] + (!spatz_req.op_arith.widen_vs2 || widening_upper_q); | ||
| vreg_addr_d[1] = vreg_addr_q[1] + (!spatz_req.op_arith.widen_vs1 || widening_upper_q); | ||
| vreg_addr_d[2] = vreg_addr_q[2] + (!spatz_req.op_arith.is_reduction && (!spatz_req.op_arith.is_narrowing || narrowing_upper_q)); | ||
| vreg_addr_d[2] = vreg_addr_q[2] + (!spatz_req.op_arith.is_reduction && (!spatz_req.op_arith.is_narrowing || narrowing_upper_q) && (spatz_req.op != VFCMP)); | ||
| end | ||
| end: vreg_addr_proc | ||
|
|
||
|
|
@@ -784,6 +788,12 @@ | |
| if (result_tag.narrowing) begin | ||
| // Only write half of the elements | ||
| vreg_wbe = result_tag.narrowing_upper ? {{(N_FU*ELENB/2){1'b1}}, {(N_FU*ELENB/2){1'b0}}} : {{(N_FU*ELENB/2){1'b0}}, {(N_FU*ELENB/2){1'b1}}}; | ||
| end else if (spatz_req.op == VFCMP) begin | ||
| // every vector element requires 1 bit of wbe --> ceil(vl/8) | ||
| automatic logic [$clog2((MAXVL+7)/8+1)-1:0] mask_bytes; | ||
| vreg_we = result_tag.last; | ||
| mask_bytes = (spatz_req.vl + 7) >> 3; | ||
| vreg_wbe = (mask_bytes >= N_FU*ELENB) ? '1 : vrf_be_t'((vrf_be_t'(1) << mask_bytes) - 1); | ||
| end | ||
| end | ||
|
|
||
|
|
@@ -799,7 +809,22 @@ | |
| end | ||
| end : operand_req_proc | ||
|
|
||
| logic [N_FU*ELEN-1:0] vreg_wdata; | ||
| logic vfcmp_result_accepted; | ||
| assign vfcmp_result_accepted = (spatz_req.op == VFCMP) && &(result_valid | ~pending_results) && result_ready; | ||
|
|
||
| always_comb begin : VRF_cnt_proc | ||
| word_idx_d = word_idx_q; | ||
| if (spatz_req.op != VFCMP) | ||
| word_idx_d = '0; | ||
| else if (vfcmp_result_accepted) begin | ||
| if (result_tag.last) | ||
| word_idx_d = '0; | ||
| else | ||
| word_idx_d = word_idx_q + 1; | ||
| end | ||
| end | ||
|
|
||
| logic [N_FU*ELEN-1:0] vreg_wdata, wdata_d, wdata_q; | ||
| always_comb begin: align_result | ||
| // Data from the FU to be written to the VRF | ||
| // For reductions, if the result is present in the buffer used for intra-lane reductions | ||
|
|
@@ -819,14 +844,50 @@ | |
| end | ||
| default:; | ||
| endcase | ||
| end else if (spatz_req.op == VFCMP) begin | ||
| // default | ||
| vreg_wdata = '0; | ||
| unique case (spatz_req.vtype.vsew) | ||
| EW_8: begin | ||
| for (int i = 0; i < VRFWordWidth/8; i++) | ||
| vreg_wdata[i+(VRFWordWidth/8*word_idx_q)] = result[i*8]; | ||
| end | ||
| EW_16: begin | ||
| for (int i = 0; i < VRFWordWidth/16; i++) | ||
| vreg_wdata[i+(VRFWordWidth/16*word_idx_q)] = result[i*16]; | ||
|
Check warning on line 857 in hw/ip/spatz/src/spatz_vfu.sv
|
||
| end | ||
| EW_32: begin | ||
| for (int i = 0; i < VRFWordWidth/32; i++) | ||
| vreg_wdata[i+(VRFWordWidth/32*word_idx_q)] = result[i*32]; | ||
|
Check warning on line 861 in hw/ip/spatz/src/spatz_vfu.sv
|
||
| end | ||
| EW_64: begin | ||
| for (int i = 0; i < VRFWordWidth/64; i++) | ||
| vreg_wdata[i+(VRFWordWidth/64*word_idx_q)] = result[i*64]; | ||
|
Check warning on line 865 in hw/ip/spatz/src/spatz_vfu.sv
|
||
| end | ||
| default:; | ||
| endcase | ||
| end | ||
| end | ||
|
|
||
| always_comb begin : wdata_proc | ||
| wdata_d = wdata_q; | ||
| if (spatz_req.op != VFCMP) begin | ||
| wdata_d = '0; | ||
| end else if (vfcmp_result_accepted) begin | ||
| if (result_tag.last) | ||
| wdata_d = '0; | ||
| else | ||
| wdata_d = wdata_q | vreg_wdata; | ||
| end | ||
| end | ||
|
|
||
| `FF(wdata_q, wdata_d, '0) | ||
|
|
||
| // Register file signals | ||
| assign vrf_re_o = vreg_r_req; | ||
| assign vrf_we_o = vreg_we; | ||
| assign vrf_wbe_o = vreg_wbe; | ||
| assign vrf_wdata_o = vreg_wdata; | ||
| assign vrf_wdata_o = (spatz_req.op == VFCMP) ? (wdata_q | vreg_wdata) : vreg_wdata; | ||
|
Navaneeth-KunhiPurayil marked this conversation as resolved.
|
||
| assign vrf_id_o = {result_tag.id, {3{spatz_req.id}}}; | ||
|
|
||
| ////////// | ||
|
|
@@ -1089,6 +1150,9 @@ | |
| VFCMP : begin | ||
| fpu_op = fpnew_pkg::CMP; | ||
| fpu_dst_fmt = fpu_src_fmt; | ||
| if (spatz_req.rm == fpnew_pkg::RUP) | ||
| // Boolean result inverted | ||
| fpu_op_mode = 1'b1; | ||
| end | ||
|
|
||
| VF2F: fpu_op = fpnew_pkg::F2F; | ||
|
|
@@ -1188,7 +1252,7 @@ | |
| `FFL(fpu_int_fmt_q, fpu_int_fmt, int_fpu_in_valid && int_fpu_in_ready, fpnew_pkg::INT8) | ||
| `FFL(fpu_op_mode_q, fpu_op_mode, int_fpu_in_valid && int_fpu_in_ready, 1'b0) | ||
| `FFL(fpu_vectorial_op_q, fpu_vectorial_op, int_fpu_in_valid && int_fpu_in_ready, 1'b0) | ||
| `FFL(rm_q, spatz_req.rm, int_fpu_in_valid && int_fpu_in_ready, fpnew_pkg::RNE) | ||
| `FFL(rm_q, (spatz_req.op == VFCMP && spatz_req.rm == fpnew_pkg::RUP) ? fpnew_pkg::RDN : spatz_req.rm, int_fpu_in_valid && int_fpu_in_ready, fpnew_pkg::RNE) | ||
| `FFL(input_tag_q, input_tag, int_fpu_in_valid && int_fpu_in_ready, '{vsew: EW_8, default: '0}) | ||
| `FFL(fpu_in_valid_q, int_fpu_in_valid, int_fpu_in_ready, 1'b0) | ||
| assign int_fpu_in_ready = !fpu_in_valid_q || fpu_in_valid_q && fpu_in_ready_d; | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.