|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?注册
x
`timescale 1 ns/1 ps
module invvar_gen_divider_32x16
(
rfd,
clk,
dividend,
quotient,
divisor,
fractional
);
/////////////////////////////////////////////////////////////////////
output rfd;
input clk;
input [31:0] dividend;
output [31:0] quotient;
input [15:0] divisor;
output [15:0] fractional;
/////////////////////////////////////////////////////////////////////
reg [31:0] dividend_reg;
reg [15:0] divisor_reg;
/////////////////////////////////////////////////////////////////////
//寄存进来的数据:
always @(posedge clk)
begin
dividend_reg <=dividend;
divisor_reg <=divisor;
end
/////////////////////////////////////////////////////////////////////
//开始除数:需要32拍延时,采用减法和比较的方式实现
reg [31:0] dividend_s1;
reg [15:0] divisor_s1;
reg [16:0] sub_s1;
always @(posedge clk)
begin
dividend_s1 <=dividend_reg[31:0];
divisor_s1 <=divisor_reg;
sub_s1 <={16'h0,dividend_reg[31]} - divisor_reg;
end
/////////////////////////////////////////////////////////////////////
reg [29:0] dividend_s2;
reg [15:0] divisor_s2;
reg [15:0] sub_old_s2;
reg [16:0] sub_s2;
reg quotient_s2;
always @(posedge clk)
begin
dividend_s2 <=dividend_s1[29:0];
divisor_s2 <=divisor_s1;
quotient_s2 <=~sub_s1[16];
if(sub_s1[16]==0)
begin
sub_old_s2 <={sub_s1[14:0],dividend_s1[30]};
sub_s2 <={1'b0,sub_s1[14:0],dividend_s1[30]}-divisor_s1;
end
else
begin
sub_old_s2 <={14'h0,dividend_s1[31:30]};
sub_s2 <={15'h0,dividend_s1[31:30]}-divisor_s1;
end
end
/////////////////////////////////////////////////////////////////////
reg [28:0] dividend_s3;
reg [15:0] divisor_s3;
reg [15:0] sub_old_s3;
reg [16:0] sub_s3;
reg [1:0] quotient_s3;
always @(posedge clk)
begin
dividend_s3 <=dividend_s2[28:0];
divisor_s3 <=divisor_s2;
quotient_s3 <={quotient_s2,~sub_s2[16]};
if(sub_s2[16]==0)
begin
sub_old_s3 <={sub_s2[14:0],dividend_s2[29]};
sub_s3 <={1'b0,sub_s2[14:0],dividend_s2[29]}-divisor_s2;
end
else
begin
sub_old_s3 <={sub_old_s2,dividend_s2[29]};
sub_s3 <={sub_old_s2,dividend_s2[29]}-divisor_s2;
end
end
/////////////////////////////////////////////////////////////////////
reg [27:0] dividend_s4;
reg [15:0] divisor_s4;
reg [15:0] sub_old_s4;
reg [16:0] sub_s4;
reg [2:0] quotient_s4;
always @(posedge clk)
begin
dividend_s4 <=dividend_s3[27:0];
divisor_s4 <=divisor_s3;
quotient_s4 <={quotient_s3,~sub_s3[16]};
if(sub_s3[16]==0)
begin
sub_old_s4 <={sub_s3[14:0],dividend_s3[28]};
sub_s4 <={1'b0,sub_s3[14:0],dividend_s3[28]}-divisor_s3;
end
else
begin
sub_old_s4 <={sub_old_s3,dividend_s3[28]};
sub_s4 <={sub_old_s3,dividend_s3[28]}-divisor_s3;
end
end
/////////////////////////////////////////////////////////////////////
reg [26:0] dividend_s5;
reg [15:0] divisor_s5;
reg [15:0] sub_old_s5;
reg [16:0] sub_s5;
reg [3:0] quotient_s5;
always @(posedge clk)
begin
dividend_s5 <=dividend_s4[26:0];
divisor_s5 <=divisor_s4;
quotient_s5 <={quotient_s4,~sub_s4[16]};
if(sub_s4[16]==0)
begin
sub_old_s5 <={sub_s4[14:0],dividend_s4[27]};
sub_s5 <={1'b0,sub_s4[14:0],dividend_s4[27]}-divisor_s4;
end
else
begin
sub_old_s5 <={sub_old_s4,dividend_s4[27]};
sub_s5 <={sub_old_s4,dividend_s4[27]}-divisor_s4;
end
end
/////////////////////////////////////////////////////////////////////
reg [25:0] dividend_s6;
reg [15:0] divisor_s6;
reg [15:0] sub_old_s6;
reg [16:0] sub_s6;
reg [4:0] quotient_s6;
always @(posedge clk)
begin
dividend_s6 <=dividend_s5[25:0];
divisor_s6 <=divisor_s5;
quotient_s6 <={quotient_s5,~sub_s5[16]};
if(sub_s5[16]==0)
begin
sub_old_s6 <={sub_s5[14:0],dividend_s5[26]};
sub_s6 <={1'b0,sub_s5[14:0],dividend_s5[26]}-divisor_s5;
end
else
begin
sub_old_s6 <={sub_old_s5,dividend_s5[26]};
sub_s6 <={sub_old_s5,dividend_s5[26]}-divisor_s5;
end
end
/////////////////////////////////////////////////////////////////////
reg [24:0] dividend_s7;
reg [15:0] divisor_s7;
reg [15:0] sub_old_s7;
reg [16:0] sub_s7;
reg [5:0] quotient_s7;
always @(posedge clk)
begin
dividend_s7 <=dividend_s6[24:0];
divisor_s7 <=divisor_s6;
quotient_s7 <={quotient_s6,~sub_s6[16]};
if(sub_s6[16]==0)
begin
sub_old_s7 <={sub_s6[14:0],dividend_s6[25]};
sub_s7 <={1'b0,sub_s6[14:0],dividend_s6[25]}-divisor_s6;
end
else
begin
sub_old_s7 <={sub_old_s6,dividend_s6[25]};
sub_s7 <={sub_old_s6,dividend_s6[25]}-divisor_s6;
end
end
/////////////////////////////////////////////////////////////////////
reg [23:0] dividend_s8;
reg [15:0] divisor_s8;
reg [15:0] sub_old_s8;
reg [16:0] sub_s8;
reg [6:0] quotient_s8;
always @(posedge clk)
begin
dividend_s8 <=dividend_s7[23:0];
divisor_s8 <=divisor_s7;
quotient_s8 <={quotient_s7,~sub_s7[16]};
if(sub_s7[16]==0)
begin
sub_old_s8 <={sub_s7[14:0],dividend_s7[24]};
sub_s8 <={1'b0,sub_s7[14:0],dividend_s7[24]}-divisor_s7;
end
else
begin
sub_old_s8 <={sub_old_s7,dividend_s7[24]};
sub_s8 <={sub_old_s7,dividend_s7[24]}-divisor_s7;
end
end
/////////////////////////////////////////////////////////////////////
reg [22:0] dividend_s9;
reg [15:0] divisor_s9;
reg [15:0] sub_old_s9;
reg [16:0] sub_s9;
reg [7:0] quotient_s9;
always @(posedge clk)
begin
dividend_s9 <=dividend_s8[22:0];
divisor_s9 <=divisor_s8;
quotient_s9 <={quotient_s8,~sub_s8[16]};
if(sub_s8[16]==0)
begin
sub_old_s9 <={sub_s8[14:0],dividend_s8[23]};
sub_s9 <={1'b0,sub_s8[14:0],dividend_s8[23]}-divisor_s8;
end
else
begin
sub_old_s9 <={sub_old_s8,dividend_s8[23]};
sub_s9 <={sub_old_s8,dividend_s8[23]}-divisor_s8;
end
end
/////////////////////////////////////////////////////////////////////
reg [21:0] dividend_s10;
reg [15:0] divisor_s10;
reg [15:0] sub_old_s10;
reg [16:0] sub_s10;
reg [8:0] quotient_s10;
always @(posedge clk)
begin
dividend_s10 <=dividend_s9[21:0];
divisor_s10 <=divisor_s9;
quotient_s10 <={quotient_s9,~sub_s9[16]};
if(sub_s9[16]==0)
begin
sub_old_s10 <={sub_s9[14:0],dividend_s9[22]};
sub_s10 <={1'b0,sub_s9[14:0],dividend_s9[22]}-divisor_s9;
end
else
begin
sub_old_s10 <={sub_old_s9,dividend_s9[22]};
sub_s10 <={sub_old_s9,dividend_s9[22]}-divisor_s9;
end
end
/////////////////////////////////////////////////////////////////////
reg [20:0] dividend_s11;
reg [15:0] divisor_s11;
reg [15:0] sub_old_s11;
reg [16:0] sub_s11;
reg [9:0] quotient_s11;
always @(posedge clk)
begin
dividend_s11 <=dividend_s10[20:0];
divisor_s11 <=divisor_s10;
quotient_s11 <={quotient_s10,~sub_s10[16]};
if(sub_s10[16]==0)
begin
sub_old_s11 <={sub_s10[14:0],dividend_s10[21]};
sub_s11 <={1'b0,sub_s10[14:0],dividend_s10[21]}-divisor_s10;
end
else
begin
sub_old_s11 <={sub_old_s10,dividend_s10[21]};
sub_s11 <={sub_old_s10,dividend_s10[21]}-divisor_s10;
end
end
/////////////////////////////////////////////////////////////////////
reg [19:0] dividend_s12;
reg [15:0] divisor_s12;
reg [15:0] sub_old_s12;
reg [16:0] sub_s12;
reg [10:0] quotient_s12;
always @(posedge clk)
begin
dividend_s12 <=dividend_s11[19:0];
divisor_s12 <=divisor_s11;
quotient_s12 <={quotient_s11,~sub_s11[16]};
if(sub_s11[16]==0)
begin
sub_old_s12 <={sub_s11[14:0],dividend_s11[20]};
sub_s12 <={1'b0,sub_s11[14:0],dividend_s11[20]}-divisor_s11;
end
else
begin
sub_old_s12 <={sub_old_s11,dividend_s11[20]};
sub_s12 <={sub_old_s11,dividend_s11[20]}-divisor_s11;
end
end
/////////////////////////////////////////////////////////////////////
reg [18:0] dividend_s13;
reg [15:0] divisor_s13;
reg [15:0] sub_old_s13;
reg [16:0] sub_s13;
reg [11:0] quotient_s13;
always @(posedge clk)
begin
dividend_s13 <=dividend_s12[18:0];
divisor_s13 <=divisor_s12;
quotient_s13 <={quotient_s12,~sub_s12[16]};
if(sub_s12[16]==0)
begin
sub_old_s13 <={sub_s12[14:0],dividend_s12[19]};
sub_s13 <={1'b0,sub_s12[14:0],dividend_s12[19]}-divisor_s12;
end
else
begin
sub_old_s13 <={sub_old_s12,dividend_s12[19]};
sub_s13 <={sub_old_s12,dividend_s12[19]}-divisor_s12;
end
end
/////////////////////////////////////////////////////////////////////
reg [17:0] dividend_s14;
reg [15:0] divisor_s14;
reg [15:0] sub_old_s14;
reg [16:0] sub_s14;
reg [12:0] quotient_s14;
always @(posedge clk)
begin
dividend_s14 <=dividend_s13[17:0];
divisor_s14 <=divisor_s13;
quotient_s14 <={quotient_s13,~sub_s13[16]};
if(sub_s13[16]==0)
begin
sub_old_s14 <={sub_s13[14:0],dividend_s13[18]};
sub_s14 <={1'b0,sub_s13[14:0],dividend_s13[18]}-divisor_s13;
end
else
begin
sub_old_s14 <={sub_old_s13,dividend_s13[18]};
sub_s14 <={sub_old_s13,dividend_s13[18]}-divisor_s13;
end
end
/////////////////////////////////////////////////////////////////////
reg [16:0] dividend_s15;
reg [15:0] divisor_s15;
reg [15:0] sub_old_s15;
reg [16:0] sub_s15;
reg [13:0] quotient_s15;
always @(posedge clk)
begin
dividend_s15 <=dividend_s14[16:0];
divisor_s15 <=divisor_s14;
quotient_s15 <={quotient_s14,~sub_s14[16]};
if(sub_s14[16]==0)
begin
sub_old_s15 <={sub_s14[14:0],dividend_s14[17]};
sub_s15 <={1'b0,sub_s14[14:0],dividend_s14[17]}-divisor_s14;
end
else
begin
sub_old_s15 <={sub_old_s14,dividend_s14[17]};
sub_s15 <={sub_old_s14,dividend_s14[17]}-divisor_s14;
end
end
/////////////////////////////////////////////////////////////////////
reg [15:0] dividend_s16;
reg [15:0] divisor_s16;
reg [15:0] sub_old_s16;
reg [16:0] sub_s16;
reg [14:0] quotient_s16;
always @(posedge clk)
begin
dividend_s16 <=dividend_s15[15:0];
divisor_s16 <=divisor_s15;
quotient_s16 <={quotient_s15,~sub_s15[16]};
if(sub_s15[16]==0)
begin
sub_old_s16 <={sub_s15[14:0],dividend_s15[16]};
sub_s16 <={1'b0,sub_s15[14:0],dividend_s15[16]}-divisor_s15;
end
else
begin
sub_old_s16 <={sub_old_s15,dividend_s15[16]};
sub_s16 <={sub_old_s15,dividend_s15[16]}-divisor_s15;
end
end
/////////////////////////////////////////////////////////////////////
reg [14:0] dividend_s17;
reg [15:0] divisor_s17;
reg [15:0] sub_old_s17;
reg [16:0] sub_s17;
reg [15:0] quotient_s17;
always @(posedge clk)
begin
dividend_s17 <=dividend_s16[14:0];
divisor_s17 <=divisor_s16;
quotient_s17 <={quotient_s16,~sub_s16[16]};
if(sub_s16[16]==0)
begin
sub_old_s17 <={sub_s16[14:0],dividend_s16[15]};
sub_s17 <={1'b0,sub_s16[14:0],dividend_s16[15]}-divisor_s16;
end
else
begin
sub_old_s17 <={sub_old_s16,dividend_s16[15]};
sub_s17 <={sub_old_s16,dividend_s16[15]}-divisor_s16;
end
end
/////////////////////////////////////////////////////////////////////
reg [13:0] dividend_s18;
reg [15:0] divisor_s18;
reg [15:0] sub_old_s18;
reg [16:0] sub_s18;
reg [16:0] quotient_s18;
always @(posedge clk)
begin
dividend_s18 <=dividend_s17[13:0];
divisor_s18 <=divisor_s17;
quotient_s18 <={quotient_s17,~sub_s17[16]};
if(sub_s17[16]==0)
begin
sub_old_s18 <={sub_s17[14:0],dividend_s17[14]};
sub_s18 <={1'b0,sub_s17[14:0],dividend_s17[14]}-divisor_s17;
end
else
begin
sub_old_s18 <={sub_old_s17,dividend_s17[14]};
sub_s18 <={sub_old_s17,dividend_s17[14]}-divisor_s17;
end
end
/////////////////////////////////////////////////////////////////////
reg [12:0] dividend_s19;
reg [15:0] divisor_s19;
reg [15:0] sub_old_s19;
reg [16:0] sub_s19;
reg [17:0] quotient_s19;
always @(posedge clk)
begin
dividend_s19 <=dividend_s18[12:0];
divisor_s19 <=divisor_s18;
quotient_s19 <={quotient_s18,~sub_s18[16]};
if(sub_s18[16]==0)
begin
sub_old_s19 <={sub_s18[14:0],dividend_s18[13]};
sub_s19 <={1'b0,sub_s18[14:0],dividend_s18[13]}-divisor_s18;
end
else
begin
sub_old_s19 <={sub_old_s18,dividend_s18[13]};
sub_s19 <={sub_old_s18,dividend_s18[13]}-divisor_s18;
end
end
/////////////////////////////////////////////////////////////////////
reg [11:0] dividend_s20;
reg [15:0] divisor_s20;
reg [15:0] sub_old_s20;
reg [16:0] sub_s20;
reg [18:0] quotient_s20;
always @(posedge clk)
begin
dividend_s20 <=dividend_s19[11:0];
divisor_s20 <=divisor_s19;
quotient_s20 <={quotient_s19,~sub_s19[16]};
if(sub_s19[16]==0)
begin
sub_old_s20 <={sub_s19[14:0],dividend_s19[12]};
sub_s20 <={1'b0,sub_s19[14:0],dividend_s19[12]}-divisor_s19;
end
else
begin
sub_old_s20 <={sub_old_s19,dividend_s19[12]};
sub_s20 <={sub_old_s19,dividend_s19[12]}-divisor_s19;
end
end
/////////////////////////////////////////////////////////////////////
reg [10:0] dividend_s21;
reg [15:0] divisor_s21;
reg [15:0] sub_old_s21;
reg [16:0] sub_s21;
reg [19:0] quotient_s21;
always @(posedge clk)
begin
dividend_s21 <=dividend_s20[10:0];
divisor_s21 <=divisor_s20;
quotient_s21 <={quotient_s20,~sub_s20[16]};
if(sub_s20[16]==0)
begin
sub_old_s21 <={sub_s20[14:0],dividend_s20[11]};
sub_s21 <={1'b0,sub_s20[14:0],dividend_s20[11]}-divisor_s20;
end
else
begin
sub_old_s21 <={sub_old_s20,dividend_s20[11]};
sub_s21 <={sub_old_s20,dividend_s20[11]}-divisor_s20;
end
end
/////////////////////////////////////////////////////////////////////
reg [9:0] dividend_s22;
reg [15:0] divisor_s22;
reg [15:0] sub_old_s22;
reg [16:0] sub_s22;
reg [20:0] quotient_s22;
always @(posedge clk)
begin
dividend_s22 <=dividend_s21[9:0];
divisor_s22 <=divisor_s21;
quotient_s22 <={quotient_s21,~sub_s21[16]};
if(sub_s21[16]==0)
begin
sub_old_s22 <={sub_s21[14:0],dividend_s21[10]};
sub_s22 <={1'b0,sub_s21[14:0],dividend_s21[10]}-divisor_s21;
end
else
begin
sub_old_s22 <={sub_old_s21,dividend_s21[10]};
sub_s22 <={sub_old_s21,dividend_s21[10]}-divisor_s21;
end
end
/////////////////////////////////////////////////////////////////////
reg [8:0] dividend_s23;
reg [15:0] divisor_s23;
reg [15:0] sub_old_s23;
reg [16:0] sub_s23;
reg [21:0] quotient_s23;
always @(posedge clk)
begin
dividend_s23 <=dividend_s22[8:0];
divisor_s23 <=divisor_s22;
quotient_s23 <={quotient_s22,~sub_s22[16]};
if(sub_s22[16]==0)
begin
sub_old_s23 <={sub_s22[14:0],dividend_s22[9]};
sub_s23 <={1'b0,sub_s22[14:0],dividend_s22[9]}-divisor_s22;
end
else
begin
sub_old_s23 <={sub_old_s22,dividend_s22[9]};
sub_s23 <={sub_old_s22,dividend_s22[9]}-divisor_s22;
end
end
/////////////////////////////////////////////////////////////////////
reg [7:0] dividend_s24;
reg [15:0] divisor_s24;
reg [15:0] sub_old_s24;
reg [16:0] sub_s24;
reg [22:0] quotient_s24;
always @(posedge clk)
begin
dividend_s24 <=dividend_s23[7:0];
divisor_s24 <=divisor_s23;
quotient_s24 <={quotient_s23,~sub_s23[16]};
if(sub_s23[16]==0)
begin
sub_old_s24 <={sub_s23[14:0],dividend_s23[8]};
sub_s24 <={1'b0,sub_s23[14:0],dividend_s23[8]}-divisor_s23;
end
else
begin
sub_old_s24 <={sub_old_s23,dividend_s23[8]};
sub_s24 <={sub_old_s23,dividend_s23[8]}-divisor_s23;
end
end
/////////////////////////////////////////////////////////////////////
reg [6:0] dividend_s25;
reg [15:0] divisor_s25;
reg [15:0] sub_old_s25;
reg [16:0] sub_s25;
reg [23:0] quotient_s25;
always @(posedge clk)
begin
dividend_s25 <=dividend_s24[6:0];
divisor_s25 <=divisor_s24;
quotient_s25 <={quotient_s24,~sub_s24[16]};
if(sub_s24[16]==0)
begin
sub_old_s25 <={sub_s24[14:0],dividend_s24[7]};
sub_s25 <={1'b0,sub_s24[14:0],dividend_s24[7]}-divisor_s24;
end
else
begin
sub_old_s25 <={sub_old_s24,dividend_s24[7]};
sub_s25 <={sub_old_s24,dividend_s24[7]}-divisor_s24;
end
end
/////////////////////////////////////////////////////////////////////
reg [5:0] dividend_s26;
reg [15:0] divisor_s26;
reg [15:0] sub_old_s26;
reg [16:0] sub_s26;
reg [24:0] quotient_s26;
always @(posedge clk)
begin
dividend_s26 <=dividend_s25[5:0];
divisor_s26 <=divisor_s25;
quotient_s26 <={quotient_s25,~sub_s25[16]};
if(sub_s25[16]==0)
begin
sub_old_s26 <={sub_s25[14:0],dividend_s25[6]};
sub_s26 <={1'b0,sub_s25[14:0],dividend_s25[6]}-divisor_s25;
end
else
begin
sub_old_s26 <={sub_old_s25,dividend_s25[6]};
sub_s26 <={sub_old_s25,dividend_s25[6]}-divisor_s25;
end
end
/////////////////////////////////////////////////////////////////////
reg [4:0] dividend_s27;
reg [15:0] divisor_s27;
reg [15:0] sub_old_s27;
reg [16:0] sub_s27;
reg [25:0] quotient_s27;
always @(posedge clk)
begin
dividend_s27 <=dividend_s26[4:0];
divisor_s27 <=divisor_s26;
quotient_s27 <={quotient_s26,~sub_s26[16]};
if(sub_s26[16]==0)
begin
sub_old_s27 <={sub_s26[14:0],dividend_s26[5]};
sub_s27 <={1'b0,sub_s26[14:0],dividend_s26[5]}-divisor_s26;
end
else
begin
sub_old_s27 <={sub_old_s26,dividend_s26[5]};
sub_s27 <={sub_old_s26,dividend_s26[5]}-divisor_s26;
end
end
/////////////////////////////////////////////////////////////////////
reg [3:0] dividend_s28;
reg [15:0] divisor_s28;
reg [15:0] sub_old_s28;
reg [16:0] sub_s28;
reg [26:0] quotient_s28;
always @(posedge clk)
begin
dividend_s28 <=dividend_s27[3:0];
divisor_s28 <=divisor_s27;
quotient_s28 <={quotient_s27,~sub_s27[16]};
if(sub_s27[16]==0)
begin
sub_old_s28 <={sub_s27[14:0],dividend_s27[4]};
sub_s28 <={1'b0,sub_s27[14:0],dividend_s27[4]}-divisor_s27;
end
else
begin
sub_old_s28 <={sub_old_s27,dividend_s27[4]};
sub_s28 <={sub_old_s27,dividend_s27[4]}-divisor_s27;
end
end
/////////////////////////////////////////////////////////////////////
reg [2:0] dividend_s29;
reg [15:0] divisor_s29;
reg [15:0] sub_old_s29;
reg [16:0] sub_s29;
reg [27:0] quotient_s29;
always @(posedge clk)
begin
dividend_s29 <=dividend_s28[2:0];
divisor_s29 <=divisor_s28;
quotient_s29 <={quotient_s28,~sub_s28[16]};
if(sub_s28[16]==0)
begin
sub_old_s29 <={sub_s28[14:0],dividend_s28[3]};
sub_s29 <={1'b0,sub_s28[14:0],dividend_s28[3]}-divisor_s28;
end
else
begin
sub_old_s29 <={sub_old_s28,dividend_s28[3]};
sub_s29 <={sub_old_s28,dividend_s28[3]}-divisor_s28;
end
end
/////////////////////////////////////////////////////////////////////
reg [1:0] dividend_s30;
reg [15:0] divisor_s30;
reg [15:0] sub_old_s30;
reg [16:0] sub_s30;
reg [28:0] quotient_s30;
always @(posedge clk)
begin
dividend_s30 <=dividend_s29[1:0];
divisor_s30 <=divisor_s29;
quotient_s30 <={quotient_s29,~sub_s29[16]};
if(sub_s29[16]==0)
begin
sub_old_s30 <={sub_s29[14:0],dividend_s29[2]};
sub_s30 <={1'b0,sub_s29[14:0],dividend_s29[2]}-divisor_s29;
end
else
begin
sub_old_s30 <={sub_old_s29,dividend_s29[2]};
sub_s30 <={sub_old_s29,dividend_s29[2]}-divisor_s29;
end
end
/////////////////////////////////////////////////////////////////////
reg dividend_s31;
reg [15:0] divisor_s31;
reg [15:0] sub_old_s31;
reg [16:0] sub_s31;
reg [29:0] quotient_s31;
always @(posedge clk)
begin
dividend_s31 <=dividend_s30[0];
divisor_s31 <=divisor_s30;
quotient_s31 <={quotient_s30,~sub_s30[16]};
if(sub_s30[16]==0)
begin
sub_old_s31 <={sub_s30[14:0],dividend_s30[1]};
sub_s31 <={1'b0,sub_s30[14:0],dividend_s30[1]}-divisor_s30;
end
else
begin
sub_old_s31 <={sub_old_s30,dividend_s30[1]};
sub_s31 <={sub_old_s30,dividend_s30[1]}-divisor_s30;
end
end
/////////////////////////////////////////////////////////////////////
reg [15:0] sub_old_s32;
reg [16:0] sub_s32;
reg [30:0] quotient_s32;
always @(posedge clk)
begin
quotient_s32 <={quotient_s31,~sub_s31[16]};
if(sub_s31[16]==0)
begin
sub_old_s32 <={sub_s31[14:0],dividend_s31};
sub_s32 <={1'b0,sub_s31[14:0],dividend_s31}-divisor_s31;
end
else
begin
sub_old_s32 <={sub_old_s31,dividend_s31};
sub_s32 <={sub_old_s31,dividend_s31}-divisor_s31;
end
end
/////////////////////////////////////////////////////////////////////
reg [15:0] sub_old_s33;
reg [31:0] quotient_s33;
always @(posedge clk)
begin
quotient_s33 <={quotient_s32,~sub_s32[16]};
if(sub_s32[16]==0)
sub_old_s33 <=sub_s32[15:0];
else
sub_old_s33 <=sub_old_s32;
end
assign quotient=quotient_s33;
assign fractional=sub_old_s33;
endmodule |
|