fix samples ntt bugs & set PLL & optimize matmul
This commit is contained in:
@@ -43,15 +43,16 @@
|
||||
|
||||
`include "defines.vh"
|
||||
|
||||
/* verilator lint_off UNUSED */
|
||||
/* verilator lint_off UNUSEDPARAM */
|
||||
(* use_dsp = "no" *)
|
||||
module sample_ntt_sync_shared #(parameter K = 4) (
|
||||
/* verilator lint_on UNUSED */
|
||||
/* verilator lint_on UNUSEDPARAM */
|
||||
input clk,
|
||||
input rst_n,
|
||||
input [255:0] rho_i,
|
||||
/* verilator lint_off UNUSED */
|
||||
/* verilator lint_off UNUSEDSIGNAL */
|
||||
input [2:0] k_i,
|
||||
/* verilator lint_on UNUSED */
|
||||
/* verilator lint_on UNUSEDSIGNAL */
|
||||
input [1:0] i_idx,
|
||||
input [1:0] j_idx,
|
||||
input valid_i,
|
||||
@@ -67,9 +68,9 @@ module sample_ntt_sync_shared #(parameter K = 4) (
|
||||
output kc_ready_i,
|
||||
output [1599:0] kc_state_i,
|
||||
output kc_valid_i,
|
||||
/* verilator lint_off UNUSED */
|
||||
/* verilator lint_off UNUSEDSIGNAL */
|
||||
input kc_ready_o
|
||||
/* verilator lint_on UNUSED */
|
||||
/* verilator lint_on UNUSEDSIGNAL */
|
||||
);
|
||||
|
||||
// ================================================================
|
||||
@@ -95,12 +96,12 @@ module sample_ntt_sync_shared #(parameter K = 4) (
|
||||
// ================================================================
|
||||
// Registered inputs (captured on valid_i)
|
||||
// ================================================================
|
||||
/* verilator lint_off UNUSED */
|
||||
/* verilator lint_off UNUSEDSIGNAL */
|
||||
reg [255:0] rho_r;
|
||||
reg [2:0] k_r;
|
||||
reg [1:0] i_r;
|
||||
reg [1:0] j_r;
|
||||
/* verilator lint_on UNUSED */
|
||||
/* verilator lint_on UNUSEDSIGNAL */
|
||||
|
||||
// ================================================================
|
||||
// Coefficient counter (0..256). 9 bits to avoid overflow when
|
||||
@@ -223,6 +224,10 @@ module sample_ntt_sync_shared #(parameter K = 4) (
|
||||
// d2 rejected, no longer need coefficients, or d2 was just accepted out.
|
||||
wire grp_done = (state_r == ST_SQUEEZE) && (sq_phase_r == 2'd2) &&
|
||||
(!d2_acc_r || !need_more || (valid_o_r && ready_i));
|
||||
// `need_more` observes the registered counter before the final d2
|
||||
// handshake increments it. Detect that boundary explicitly so a full
|
||||
// rate block does not launch an unnecessary final re-permutation.
|
||||
wire completes_output = valid_o_r && ready_i && (coeff_cnt_r == 9'd255);
|
||||
|
||||
// ================================================================
|
||||
// FSM: state_next (combinational)
|
||||
@@ -248,7 +253,7 @@ module sample_ntt_sync_shared #(parameter K = 4) (
|
||||
// next group in this block, re-permute (block exhausted), or
|
||||
// finish.
|
||||
if (grp_done) begin
|
||||
if (!need_more)
|
||||
if (!need_more || completes_output)
|
||||
state_next = ST_DONE;
|
||||
else if (grp_ptr_r < GRP_MAX)
|
||||
state_next = ST_SQUEEZE; // next group, no re-permute
|
||||
|
||||
Reference in New Issue
Block a user