/// EE 4755 - Digital Design Using HDLs // // Pipelining and Pipelined Multipliers ////////////////////////////////////////////////////////////////////////////// /// Pipelining Concept /// Pipelining Concept <-- Very Important but Tricky Concept, Pay Attention! // // // :Def: Pipelining // Performing an operation in *stages* on multiple data items. // :Example: // // Output x has the value that input a had two cycles in the past. // module very_simple_pipe #( int w = 16 ) ( output logic [w-1:0] x, input uwire [w-1:0] a, input uwire clk ); logic [w-1:0] r; always_ff @( posedge clk ) r <= a; always_ff @( posedge clk ) x <= r; endmodule // :Image:20em:ill-p-very-simple.plain.svg // :Example: // // Pipeline that passes data through unchanged. // Output x has the value that input a had nstages cycles in the past. // module simple_pipe2 #( int w = 16, int nstages = 4 ) ( output uwire [w-1:0] x, input uwire [w-1:0] a, input uwire clk ); logic [w-1:0] r[nstages]; always_ff @( posedge clk ) begin r[0] <= a; // Non-blocking assignment here, blocking in simple_pipe2_ba. for ( int i=1; i adder: 1 + 4w // Register Delay: 6 // // Clock Period // 1 + 4w + 6 = 4w + 7 // Latency // (w+1) (4w+7) = 4w^2 + 11w + 7 /// :Example: Basic Pipelined Multiplier -- mult_pipe // // Computes m partial products per stage. // module mult_pipe #( int w = 16, int m = 2 ) ( output logic [2*w-1:0] prod, input logic [w-1:0] plier, input logic [w-1:0] cand, input clk); localparam int stages = ( w + m - 1 ) / m; // Note: pl is for pipeline latch. logic [2*w-1:0] pl_accum[0:stages]; logic [w-1:0] pl_plier[0:stages]; logic [w-1:0] pl_cand[0:stages]; always_ff @( posedge clk ) begin pl_accum[0] = 0; pl_plier[0] = plier; pl_cand[0] = cand; for ( int stage=0; stage