Line 36... |
Line 36... |
input valid;
|
input valid;
|
input [N-1:0] a; // variable - positive/negative
|
input [N-1:0] a; // variable - positive/negative
|
output [N :0] p; // product output
|
output [N :0] p; // product output
|
|
|
// FHT constant
|
// FHT constant
|
wire [8:0] mult_constant; // always positive
|
//wire [8:0] mult_constant; // always positive
|
assign mult_constant = 9'd362;
|
//assign mult_constant = 9'd362;
|
|
parameter mult_constant = 9'd362;
|
|
|
reg [N-1:0] a_FF;
|
reg [N-1:0] a_FF;
|
always @(posedge clk)
|
always @(posedge clk)
|
if (!rstn) a_FF <= #1 0;
|
if (!rstn) a_FF <= #1 0;
|
else if (valid) a_FF <= #1 a;
|
else if (valid) a_FF <= #1 a;
|
Line 58... |
Line 59... |
// N-2+1+8+1 - number of bits on the output
|
// N-2+1+8+1 - number of bits on the output
|
// = N+8 = [N+7:0]
|
// = N+8 = [N+7:0]
|
wire [N+7:0] mult_wo_sign; // mult without sign
|
wire [N+7:0] mult_wo_sign; // mult without sign
|
assign mult_wo_sign = b[N-2:0]*mult_constant;
|
assign mult_wo_sign = b[N-2:0]*mult_constant;
|
|
|
// Divide on 256 - [N+7-8:0] = [N-1:0]
|
// Divided by 256 - [N+7-8:0] = [N-1:0]
|
wire [N-1:0] div256; // divided 256
|
wire [N-1:0] div256; // divided 256
|
assign div256 = mult_wo_sign >> 8;
|
assign div256 = mult_wo_sign >> 8;
|
|
|
assign p = a_FF[N-1] ?
|
assign p = a_FF[N-1] ?
|
{1'b1,{~div256[N-1:0] + {{N-1{1'b0}},1'b1}} } :
|
{1'b1,{~div256[N-1:0] + {{N-1{1'b0}},1'b1}} } :
|
{1'b0, div256[N-1:0]}
|
{1'b0, div256[N-1:0]}
|
;
|
;
|
endmodule
|
endmodule
|
|
|
No newline at end of file
|
No newline at end of file
|
|
// Update Log:
|
|
// 27 Jul. 2011
|
|
// wire [8:0] mult_constant replaced by parameter
|
|
|
No newline at end of file
|
No newline at end of file
|