mirror of
https://github.com/openhwgroup/cvw
synced 2025-02-11 06:05:49 +00:00
C register and other various fixes
This commit is contained in:
parent
3483b92480
commit
9d4acc9ddb
@ -57,7 +57,7 @@ module srt (
|
|||||||
logic qp, qz, qm; // quotient is +1, 0, or -1
|
logic qp, qz, qm; // quotient is +1, 0, or -1
|
||||||
logic [`NE-1:0] calcExp;
|
logic [`NE-1:0] calcExp;
|
||||||
logic calcSign;
|
logic calcSign;
|
||||||
logic [`DIVLEN+3:0] X, Dpreproc;
|
logic [`DIVLEN+3:0] X, Dpreproc, C;
|
||||||
logic [`DIVLEN+3:0] WS, WSA, WSN, WC, WCA, WCN, D, Db, Dsel;
|
logic [`DIVLEN+3:0] WS, WSA, WSN, WC, WCA, WCN, D, Db, Dsel;
|
||||||
logic [$clog2(`XLEN+1)-1:0] intExp, dur, calcDur;
|
logic [$clog2(`XLEN+1)-1:0] intExp, dur, calcDur;
|
||||||
logic intSign;
|
logic intSign;
|
||||||
@ -91,7 +91,11 @@ module srt (
|
|||||||
// Partial Product Generation
|
// Partial Product Generation
|
||||||
csa #(`DIVLEN+4) csa(WS, WC, Dsel, qp, WSA, WCA);
|
csa #(`DIVLEN+4) csa(WS, WC, Dsel, qp, WSA, WCA);
|
||||||
|
|
||||||
otfc2 #(`DIVLEN) otfc2(clk, Start, qp, qz, qm, Quot);
|
// If only implementing division, use divide otfc
|
||||||
|
// otfc2 #(`DIVLEN) otfc2(clk, Start, qp, qz, qm, Quot);
|
||||||
|
// otherwise use sotfc
|
||||||
|
creg sotfcC(clk, Start, C);
|
||||||
|
sotfc2 #(`DIVLEN) sotfc2(clk, Start, qp, qn, C, Quot);
|
||||||
|
|
||||||
expcalc expcalc(.XExp, .YExp, .calcExp, .Sqrt);
|
expcalc expcalc(.XExp, .YExp, .calcExp, .Sqrt);
|
||||||
|
|
||||||
@ -138,9 +142,9 @@ module srtpreproc (
|
|||||||
assign PreprocY = {SrcYFrac, {`EXTRAFRACBITS{1'b0}}};
|
assign PreprocY = {SrcYFrac, {`EXTRAFRACBITS{1'b0}}};
|
||||||
|
|
||||||
assign DivX = Int ? PreprocA : PreprocX;
|
assign DivX = Int ? PreprocA : PreprocX;
|
||||||
assign SqrtX = {XExp[0] ? 4'b0000 : 4'b1111, SrcXFrac};
|
assign SqrtX = XExp[0] ? {4'b0000, SrcXFrac, 1'b0} : {5'b11111, SrcXFrac};
|
||||||
|
|
||||||
assign X = Sqrt ? SqrtX : {4'b0001, DivX};
|
assign X = Sqrt ? {SqrtX, {(`EXTRAINTBITS-1){1'b0}}} : {4'b0001, DivX};
|
||||||
assign D = {4'b0001, Int ? PreprocB : PreprocY};
|
assign D = {4'b0001, Int ? PreprocB : PreprocY};
|
||||||
assign intExp = zeroCntB - zeroCntA + 1;
|
assign intExp = zeroCntB - zeroCntA + 1;
|
||||||
assign intSign = Signed & (SrcA[`XLEN - 1] ^ SrcB[`XLEN - 1]);
|
assign intSign = Signed & (SrcA[`XLEN - 1] ^ SrcB[`XLEN - 1]);
|
||||||
@ -253,22 +257,22 @@ endmodule
|
|||||||
///////////////////////////////
|
///////////////////////////////
|
||||||
// Square Root OTFC, Radix 2 //
|
// Square Root OTFC, Radix 2 //
|
||||||
///////////////////////////////
|
///////////////////////////////
|
||||||
module softc2(
|
module sotfc2(
|
||||||
input logic clk,
|
input logic clk,
|
||||||
input logic Start,
|
input logic Start,
|
||||||
input logic sp, sn,
|
input logic sp, sn,
|
||||||
input logic [N+3:0] C,
|
input logic [`DIVLEN+3:0] C,
|
||||||
output logic [N-1:0] Sq,
|
output logic [`DIVLEN-1:0] Sq,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
// The on-the-fly converter transfers the square root
|
// The on-the-fly converter transfers the square root
|
||||||
// bits to the quotient as they come.
|
// bits to the quotient as they come.
|
||||||
logic [N+2:0] S, SM, SNext, SMNext, SMMux;
|
logic [`DIVLEN+3:0] S, SM, SNext, SMNext, SMux;
|
||||||
|
|
||||||
flopr #(N+3) Sreg(clk, Start, SNext, S);
|
flopr #(`DIVLEN+4) Sreg(clk, Start, SMNext, SM);
|
||||||
mux2 #(`DIVLEN+3) Smux(SMNext, {`DIVLEN+3{1'b1}}, Start, SMMux);
|
mux2 #(`DIVLEN+4) Smux(SNext, {4'b0001, (`DIVLEN){1'b0}}, Start, SMux);
|
||||||
flop #(`DIVLEN+3) SMreg(clk, SMMux, SM);
|
flop #(`DIVLEN+4) SMreg(clk, SMux, M);
|
||||||
|
|
||||||
always_comb begin
|
always_comb begin
|
||||||
if (sp) begin
|
if (sp) begin
|
||||||
@ -282,9 +286,23 @@ module softc2(
|
|||||||
SMNext = SM | ((C << 2) & ~(C << 1));
|
SMNext = SM | ((C << 2) & ~(C << 1));
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
assign Sq = S[N+2] ? S[N+1:2] : S[N:1];
|
assign Sq = S[`DIVLEN-1:0];
|
||||||
|
|
||||||
endmodule
|
endmodule
|
||||||
|
|
||||||
|
//////////////////////////
|
||||||
|
// C Register for SOTFC //
|
||||||
|
//////////////////////////
|
||||||
|
module creg(input logic clk,
|
||||||
|
input logic Start,
|
||||||
|
output logic [`DIVLEN+3:0] C
|
||||||
|
);
|
||||||
|
logic [`DIVLEN+3:0] CMux;
|
||||||
|
|
||||||
|
mux2 #(`DIVLEN+4) Cmux({1'b1, C[`DIVLEN+3:1]}, {6'b111111, (`DIVLEN-2){1'b0}}, Start, CMux);
|
||||||
|
flop #(`DIVLEN+4) cflop(clk, CMux, C);
|
||||||
|
endmodule
|
||||||
|
|
||||||
/////////////
|
/////////////
|
||||||
// counter //
|
// counter //
|
||||||
/////////////
|
/////////////
|
||||||
|
Loading…
Reference in New Issue
Block a user