|
연산의 속도를 개선하기 위해서 LUT의 입력 수를 고려하여 cacaded LUT가 발생하지 않도록 최소한의 LUT로
파이프 라인을 설계하도록 한다.
이는 파이프 처리 속도가 지원되는 동작 속도를 개선하는데 기여한다.
`timescale 1ns/10ps
module serial_ex1
#(parameter N=32)
(
(* IOB = "TRUE" *) input clk,rst,io_ctl,
(* IOB = "TRUE" *) input [3:0] sel_sig,
input [N-1:0] data,
(* IOB = "TRUE" *) input [N-1:0] a,
(* IOB = "TRUE" *) input [N-1:0] b,
(* IOB = "TRUE" *) input [N-1:0] c,
(* IOB = "TRUE" *) input [N-1:0] d,
(* IOB = "TRUE" *) output wire [N-1:0] Qa,
(* IOB = "TRUE" *) output wire [N-1:0] Qb,
(* IOB = "TRUE" *) output wire [N-1:0] Qc,Qd,
(* IOB = "TRUE" *) output wire co1,co2
);
(* dont_touch="yes" *) wire[N-1:0] a_1,b_1,c_1,d_1;
(* dont_touch="yes" *) reg [N-1:0] ca_1,ca_2;
(* dont_touch="yes" *) wire[N-1:0] a_2,b_2,c_2,d_2;
(* dont_touch="yes" *) reg [N-1:0] gpr_0[5:0];
(* dont_touch="yes" *) reg [N-1:0] gpr_1[5:0];
(* dont_touch="yes" *) reg [N-1:0] gpr_2[5:0];
(* dont_touch="yes" *) reg [N-1:0] gpr_3[5:0];
(* dont_touch="yes" *) wire[N-1:0] A1,B1,C1,D1,A2,B2,C2,D2;
wire [N-1:0] ca_1_w,ca_2_w;
(* dont_touch="yes" *) reg [N-1:0] oRctl;
wire sel;
assign sel =io_ctl;
reg rst_n,locked_d;
(* dont_touch="yes" *) reg [6:0] pipe_ctrl_r;
(* dont_touch="yes" *)reg [N-1:0] ca_1w1;
(* dont_touch="yes" *)reg [N-1:0] ca_2w1;
(* dont_touch="yes" *)reg [N-1:0] ca_1w2;
(* dont_touch="yes" *)reg [N-1:0] ca_2w2;
(* dont_touch="yes" *)reg [N-1:0] ca_1w3;
(* dont_touch="yes" *)reg [N-1:0] ca_2w3;
(* dont_touch="yes" *)reg [N-1:0] ca_1w4;
(* dont_touch="yes" *)reg [N-1:0] ca_2w4;
(* dont_touch="yes" *)reg [N-1:0] ca_1w5;
(* dont_touch="yes" *)reg [N-1:0] ca_2w5;
(* dont_touch="yes" *)reg [N-1:0] ca_1w6;
(* dont_touch="yes" *)reg [N-1:0] ca_2w6;
(* dont_touch="yes" *)reg [N-1:0] ca_1w7;
(* dont_touch="yes" *)reg [N-1:0] ca_2w7;
(* dont_touch="yes" *)reg [N-1:0] a_1w1;
(* dont_touch="yes" *)reg [N-1:0] a_2w1;
(* dont_touch="yes" *)reg [N-1:0] a_1w01;
(* dont_touch="yes" *)reg [N-1:0] a_2w01;
(* dont_touch="yes" *)reg [N-1:0] ca_1w01;
(* dont_touch="yes" *)reg [N-1:0] ca_2w01;
(* dont_touch="yes" *)reg [N-1:0] B1_r;
(* dont_touch="yes" *)reg [N-1:0] B2_r;
(* dont_touch="yes" *)reg [N-1:0] b_1w1;
(* dont_touch="yes" *)reg [N-1:0] b_2w1;
(* dont_touch="yes" *)reg [N-1:0] b_1w01;
(* dont_touch="yes" *)reg [N-1:0] b_2w01;
reg [31:0] opsel_index;
reg [14:0] op_sel_l[5:0];
reg [14:0] op_sel_h[5:0];
reg mode;
reg [1:0] sel_a [5:0];
reg [1:0] sel_b [5:0];
reg [1:0] sel_c [5:0];
reg [1:0] sel_d [5:0];
always @(posedge clk3)
begin
locked_d<=locked;
rst_n=~(locked & ~locked_d);
end
wire CE=1'b1;
integer i;
genvar j;
clk_wiz_0 U0 (.clk_out1(clk1),.clk_out2(clk2),.clk_out3(clk3),.reset(rst),.locked(locked),.clk_in1(clk));
// DDR_Pipe #(32,3) P1 (.clk(clk3),.sel(sel),.a(a_1),.an(a_2),.out1(A1),.out2(A2));
DDR_Pipe #(32,3) P1 (.clk(clk3),.sel(sel),.a(ca_1),.an(ca_2),.out1(A1),.out2(A2));
DDR_Pipe #(32,3) P2 (.clk(clk3),.sel(sel),.a(b_1),.an(b_2),.out1(B1),.out2(B2));
DDR_Pipe #(32,3) P3 (.clk(clk3),.sel(sel),.a(c_1),.an(c_2),.out1(C1),.out2(C2));
DDR_Pipe #(32,3) P4 (.clk(clk3),.sel(sel),.a(d_1),.an(d_2),.out1(D1),.out2(D2));
DDR_COUNTER #(.N(32),.M(3)) CNT0
(
.clk(clk3),
.rst_n(rst_n),
.out1(ca_1_w),
.out2(ca_2_w),
.co1(co1),
.co2(co2)
);
wire [N-1:0] ps_out [5:0];
(* dont_touch="yes" *) reg [N-1:0] OP_A,OP_B,OP_C,OP_D;
wire [N-1:0] OP_A1,OP_B1,OP_C1;
wire [N-1:0] OP_A2,OP_B2,OP_C2;
wire [N-1:0] OP_A3,OP_B3,OP_C3;
wire [N-1:0] OP_A4,OP_B4,OP_C4;
wire [N-1:0] OP_A5,OP_B5,OP_C5;
reg io_ctl_r;
wire [N-1:0] Qb1;
DLPS_PS #(.N(32)) PS1 (
.out(ps_out[0]),
.out_a(OP_A1),.out_b(OP_B1),.out_c(OP_C1),
.opsel(op_sel_h[0][13:0]),
.sel_c(op_sel_h[0][14]),
.in_a(OP_A),.in_b(OP_B),.in_c(OP_C),
.clk(clk1)
);
wire [31:0] op_a1 = (sel_a[0][0]==1'b0) ? ps_out[0] : gpr_0[1];
//wire [31:0] op_b1 = (sel_a[0][1]==1'b0) ? OP_B1 : gpr_1[1];
//wire [31:0] op_a1 = OP_A1;
wire [31:0] op_b1 = gpr_1[1];
DLPS_PS #(.N(32)) PS2 (
.out(ps_out[1]),
.out_a(OP_A2),.out_b(OP_B2),.out_c(OP_C2),
.opsel(op_sel_h[1][13:0]),
.sel_c(op_sel_h[1][14]),
.in_a(op_a1),.in_b(op_b1),.in_c(OP_C1),
.clk(clk1)
);
wire [31:0] op_a2 = (sel_a[1][0]==1'b0) ? ps_out[1] : gpr_0[2];
//wire [31:0] op_b2 = (sel_a[1][1]==1'b0) ? OP_B2 : gpr_1[2];
//wire [31:0] op_a2 = OP_A2;
wire [31:0] op_b2 = gpr_1[2];
DLPS_PS #(.N(32)) PS3 (
.out(ps_out[2]),
.out_a(OP_A3),.out_b(OP_B3),.out_c(OP_C3),
.opsel(op_sel_h[2][13:0]),
.sel_c(op_sel_h[2][14]),
.in_a(op_a2),.in_b(op_b2),.in_c(OP_C2),
.clk(clk1)
);
wire [31:0] op_a3 = (sel_a[2][0]==1'b0) ? ps_out[2]: gpr_0[3];
// wire [31:0] op_b3 = (sel_a[2][1]==1'b0) ? OP_B3: gpr_1[3];
//wire [31:0] op_a3 = OP_A3;
wire [31:0] op_b3 = gpr_1[3];
DLPS_PS #(.N(32)) PS4 (
.out(ps_out[3]),
.out_a(OP_A4),.out_b(OP_B4),.out_c(OP_C4),
.opsel(op_sel_h[3][13:0]),
.sel_c(op_sel_h[3][14]),
.in_a(op_a3),.in_b(op_b3),.in_c(OP_C3),
.clk(clk1)
);
wire [31:0] op_a4 = (sel_a[3][0]==1'b0) ? ps_out[3]: gpr_0[4];
// wire [31:0] op_b4 = (sel_a[3][1]==1'b0) ? OP_B4: gpr_1[4];
//wire [31:0] op_a4 = OP_A4;
wire [31:0] op_b4 = gpr_1[4];
DLPS_PS #(.N(32)) PS5 (
.out(ps_out[4]),
.out_a(OP_A5),.out_b(OP_B5),.out_c(OP_C5),
.opsel(op_sel_h[4][13:0]),
.sel_c(op_sel_h[4][14]),
.in_a(op_a4),.in_b(op_b4),.in_c(OP_C4),
.clk(clk1)
);
wire [31:0] op_a5 = (sel_a[4][0]==1'b0) ? ps_out[4]: gpr_0[5];
// wire [31:0] op_b5 = (sel_a[4][1]==1'b0) ? OP_B5: gpr_1[5];
//wire [31:0] op_a5 = OP_A5;
wire [31:0] op_b5 = gpr_1[5];
DLPS_PS #(.N(32)) PS6 (
.out(ps_out[5]),
.out_a(OP_A6),.out_b(OP_B6),.out_c(OP_C6),
.opsel(op_sel_h[5][13:0]),
.sel_c(op_sel_h[5][14]),
.in_a(op_a5),.in_b(op_b5),.in_c(OP_C5),
.clk(clk1)
);
always @(posedge clk3)
begin
ca_1w1 <= ca_1_w;
ca_2w1 <= ca_2_w;
end
always @(posedge clk1)
begin
a_1w1 <= a_1;
a_2w1 <= a_2;
a_1w01 <= a_1w1;
a_2w01 <= a_2w1;
OP_A <= gpr_0[0];
OP_B <= gpr_1[0];
OP_C <= gpr_2[0];
OP_D <= gpr_3[0];
ca_1w01 <= ca_1w1 ;
ca_2w01 <= ca_2w1 ;
// ca_1w02 <= ca_1w01;
// ca_2w02 <= ca_2w01;
ca_1w2 <= (pipe_ctrl_r[0]==1'b0) ? ca_1w01: ps_out[0];
ca_2w2 <= (pipe_ctrl_r[0]==1'b0) ? ca_2w01: ps_out[0];
ca_1w3 <= (pipe_ctrl_r[1]==1'b0) ? ca_1w2 : ps_out[1];
ca_2w3 <= (pipe_ctrl_r[1]==1'b0) ? ca_2w2 : ps_out[1];
ca_1w4 <= (pipe_ctrl_r[2]==1'b0) ? ca_1w3 : ps_out[2];
ca_2w4 <= (pipe_ctrl_r[2]==1'b0) ? ca_2w3 : ps_out[2];
ca_1w5 <= (pipe_ctrl_r[3]==1'b0) ? ca_1w4 : ps_out[3];
ca_2w5 <= (pipe_ctrl_r[3]==1'b0) ? ca_2w4 : ps_out[3];
ca_1w6 <= (pipe_ctrl_r[4]==1'b0) ? ca_1w5 : ps_out[4];
ca_2w6 <= (pipe_ctrl_r[4]==1'b0) ? ca_2w5 : ps_out[4];
ca_1w7 <= (pipe_ctrl_r[5]==1'b0) ? ca_1w6 : ps_out[5];
ca_2w7 <= (pipe_ctrl_r[5]==1'b0) ? ca_2w6 : ps_out[5];
ca_1 <= (pipe_ctrl_r[5]==1'b0) ? ca_1w7 : ca_1w01;
ca_2 <= (pipe_ctrl_r[5]==1'b0) ? ca_2w7 : ca_2w01;
b_1w1 <= b_1;
b_2w1 <= b_2;
// b_1w01 <= b_1w1;
// b_2w01 <= b_2w1;
B1_r <= (pipe_ctrl_r[0]==1'b1) ? B1 :
(pipe_ctrl_r[1]==1'b1) ? a_1w1 :
(pipe_ctrl_r[2]==1'b1) ? ps_out[1] :
(pipe_ctrl_r[3]==1'b1) ? ps_out[2] :
(pipe_ctrl_r[4]==1'b1) ? ps_out[3] :
(pipe_ctrl_r[5]==1'b1) ? A1 :
(pipe_ctrl_r[6]==1'b1) ? ps_out[4] :
ps_out[5];
B2_r <= (pipe_ctrl_r[0]==1'b1) ? B2:
(pipe_ctrl_r[1]==1'b1) ? a_2w1 :
(pipe_ctrl_r[2]==1'b1) ? ps_out[1] :
(pipe_ctrl_r[3]==1'b1) ? ps_out[2] :
(pipe_ctrl_r[4]==1'b1) ? ps_out[3] :
(pipe_ctrl_r[5]==1'b1) ? A2 :
(pipe_ctrl_r[6]==1'b1) ? ps_out[4] :
ps_out[5];
end
generate
for(j=0; j<N; j=j+1)
begin
IDDR #(
.DDR_CLK_EDGE("SAME_EDGE"), // "OPPOSITE_EDGE", "SAME_EDGE"
// .DDR_CLK_EDGE("OPPOSITE_EDGE"), // "OPPOSITE_EDGE", "SAME_EDGE"
// or "SAME_EDGE_PIPELINED"
.INIT_Q1(1'b0), // Initial value of Q1: 1'b0 or 1'b1
.INIT_Q2(1'b0), // Initial value of Q2: 1'b0 or 1'b1
.SRTYPE("SYNC") // Set/Reset type: "SYNC" or "ASYNC"
) IDDR_a (
.Q1(a_2[j]), // 1-bit output for positive edge of clock
.Q2(a_1[j]), // 1-bit output for negative edge of clock
.C(clk1), // 1-bit clock input
.CE(CE), // 1-bit clock enable input
.D(a[j]), // 1-bit DDR data input
.R(1'b0),//1-bit reset
.S(1'b0) // 1-bit set
);
IDDR #(
.DDR_CLK_EDGE("SAME_EDGE"), // "OPPOSITE_EDGE", "SAME_EDGE"
// or "SAME_EDGE_PIPELINED"
.INIT_Q1(1'b0), // Initial value of Q1: 1'b0 or 1'b1
.INIT_Q2(1'b0), // Initial value of Q2: 1'b0 or 1'b1
.SRTYPE("SYNC") // Set/Reset type: "SYNC" or "ASYNC"
) IDDR_b (
.Q1(b_2[j]), // 1-bit output for positive edge of clock
.Q2(b_1[j]), // 1-bit output for negative edge of clock
.C(clk1), // 1-bit clock input
.CE(CE), // 1-bit clock enable input
.D(b[j]), // 1-bit DDR data input
.R(1'b0),//1-bit reset
.S(1'b0) // 1-bit set
);
IDDR #(
.DDR_CLK_EDGE("SAME_EDGE"), // "OPPOSITE_EDGE", "SAME_EDGE"
// or "SAME_EDGE_PIPELINED"
.INIT_Q1(1'b0), // Initial value of Q1: 1'b0 or 1'b1
.INIT_Q2(1'b0), // Initial value of Q2: 1'b0 or 1'b1
.SRTYPE("SYNC") // Set/Reset type: "SYNC" or "ASYNC"
) IDDR_c (
.Q1(c_2[j]), // 1-bit output for positive edge of clock
.Q2(c_1[j]), // 1-bit output for negative edge of clock
.C(clk1), // 1-bit clock input
.CE(CE), // 1-bit clock enable input
.D(c[j]), // 1-bit DDR data input
.R(1'b0),//1-bit reset
.S(1'b0) // 1-bit set
);
IDDR #(
.DDR_CLK_EDGE("SAME_EDGE"), // "OPPOSITE_EDGE", "SAME_EDGE"
// or "SAME_EDGE_PIPELINED"
.INIT_Q1(1'b0), // Initial value of Q1: 1'b0 or 1'b1
.INIT_Q2(1'b0), // Initial value of Q2: 1'b0 or 1'b1
.SRTYPE("SYNC") // Set/Reset type: "SYNC" or "ASYNC"
) IDDR_d (
.Q1(d_2[j]), // 1-bit output for positive edge of clock
.Q2(d_1[j]), // 1-bit output for negative edge of clock
.C(clk1), // 1-bit clock input
.CE(CE), // 1-bit clock enable input
.D(d[j]), // 1-bit DDR data input
.R(1'b0),//1-bit reset
.S(1'b0) // 1-bit set
);
ODDR #(
.DDR_CLK_EDGE("SAME_EDGE"), // "OPPOSITE_EDGE" or "SAME_EDGE"
.INIT(1'b0), // Initial value of Q: 1'b0 or 1'b1
.SRTYPE("SYNC") // Set/Reset type: "SYNC" or "ASYNC"
) ODDR_a (
.Q(Qa[j]), // 1-bit DDR output
.C(clk1), // 1-bit clock input
.CE(CE), // 1-bit clock enable input
.D1(ca_1[j]), //.D1(A1[j]), // 1-bit data input (positive edge)
.D2(ca_2[j]), //.D2(A2[j]), // 1-bit data input (negative edge)
.R(1'b0), // 1-bit reset
.S(1'b0) // 1-bit set
);
ODDR #(
.DDR_CLK_EDGE("SAME_EDGE"), // "OPPOSITE_EDGE" or "SAME_EDGE"
.INIT(1'b0), // Initial value of Q: 1'b0 or 1'b1
.SRTYPE("SYNC") // Set/Reset type: "SYNC" or "ASYNC"
) ODDR_b (
.Q(Qb[j]), // 1-bit DDR output
.C(clk1), // 1-bit clock input
.CE(CE), // 1-bit clock enable input
.D1(B1_r[j]), // 1-bit data input (positive edge)
.D2(B2_r[j]), // 1-bit data input (negative edge)
.R(1'b0), // 1-bit reset
.S(1'b0) // 1-bit set
);
ODDR #(
.DDR_CLK_EDGE("SAME_EDGE"), // "OPPOSITE_EDGE" or "SAME_EDGE"
.INIT(1'b0), // Initial value of Q: 1'b0 or 1'b1
.SRTYPE("SYNC") // Set/Reset type: "SYNC" or "ASYNC"
) ODDR_c (
.Q(Qc[j]), // 1-bit DDR output
.C(clk1), // 1-bit clock input
.CE(CE), // 1-bit clock enable input
.D1(C1[j]), // 1-bit data input (positive edge)
.D2(C2[j]), // 1-bit data input (negative edge)
.R(1'b0), // 1-bit reset
.S(1'b0) // 1-bit set
);
ODDR #(
.DDR_CLK_EDGE("SAME_EDGE"), // "OPPOSITE_EDGE" or "SAME_EDGE"
.INIT(1'b0), // Initial value of Q: 1'b0 or 1'b1
.SRTYPE("SYNC") // Set/Reset type: "SYNC" or "ASYNC"
) ODDR_d (
.Q(Qd[j]), // 1-bit DDR output
.C(clk1), // 1-bit clock input
.CE(CE), // 1-bit clock enable input
.D1(D1[j]), // 1-bit data input (positive edge)
.D2(D2[j]), // 1-bit data input (negative edge)
.R(1'b0), // 1-bit reset
.S(1'b0) // 1-bit set
);
end
endgenerate
wire sel_sig0,sel_sig1,sel_sig2,sel_sig3;
IBUF G0 (.O(sel_sig0),.I(sel_sig[0]));
IBUF G1 (.O(sel_sig1),.I(sel_sig[1]));
IBUF G2 (.O(sel_sig2),.I(sel_sig[2]));
IBUF G3 (.O(sel_sig3),.I(sel_sig[3]));
reg [2:0] cnt;
reg wen;
always @(posedge clk1)
begin
if(sel_sig0==1'b1 || sel_sig1==1'b1 || sel_sig2==1'b1 || sel_sig3==1'b1)
cnt<=cnt+1'b1;
else
cnt<=0;
end
always @(posedge clk1)
begin
// wen <= (mode==1'b0) ? 'b1 :(mode==1'b1 && cnt==3'b011)?1'b1: 1'b0;
wen <= (cnt==3'b011)?1'b1: 1'b0;
end
// always @(posedge clk2)
always @(posedge clk1)
begin
if(rst==1'b1)
begin
gpr_0[opsel_index[30:24]]<=32'h0;
pipe_ctrl_r <=6'b0;
end
else if(sel_sig0==1'b1 && wen==1'b1 && io_ctl==1'b0) gpr_0[opsel_index[24+6:24]] <= data ;
if(rst==1'b1)
gpr_1[opsel_index[30:24]] <=32'h0;
else if(sel_sig1==1'b1 && wen==1'b1 && io_ctl==1'b0) gpr_1[opsel_index[30:24]] <= data ;
if(rst==1'b1)
gpr_2[opsel_index[30:24]] <=32'h0;
else if(sel_sig2==1'b1 && wen==1'b1 && io_ctl==1'b0) gpr_2[opsel_index[30:24]] <= data ;
if(rst==1'b1)
gpr_3[opsel_index[30:24]] <=32'h0;
else if(sel_sig3==1'b1 && wen==1'b1 && io_ctl==1'b0) begin
gpr_3[opsel_index[30:24]] <= data ;
end
if(rst==1'b1)
begin
oRctl<=32'h0;
op_sel_l[0] = 0;
op_sel_l[1] = 0;
op_sel_l[2] = 0;
op_sel_l[3] = 0;
op_sel_l[4] = 0;
op_sel_l[5] = 0;
op_sel_h[0] = 0;
op_sel_h[1] = 0;
op_sel_h[2] = 0;
op_sel_h[3] = 0;
op_sel_h[4] = 0;
op_sel_h[5] = 0;
end
else if(sel_sig0==1'b1 && wen==1'b1 && io_ctl==1'b1) begin
oRctl<= data ;
pipe_ctrl_r <=data[6:0];
mode <= data[31];
end
else if(sel_sig1==1'b1 && wen==1'b1 && io_ctl==1'b1) begin
opsel_index <=data;
end
else if(sel_sig2==1'b1 && wen==1'b1 && io_ctl==1'b1) begin
if(opsel_index[31]==1'b1 && opsel_index[0]==1'b1)
op_sel_h[0] = data;
if(opsel_index[31]==1'b1 && opsel_index[1]==1'b1)
op_sel_h[1] = data;
if(opsel_index[31]==1'b1 && opsel_index[2]==1'b1)
op_sel_h[2] = data;
if(opsel_index[31]==1'b1 && opsel_index[3]==1'b1)
op_sel_h[3] = data;
if(opsel_index[31]==1'b1 && opsel_index[4]==1'b1)
op_sel_h[4] = data;
if(opsel_index[31]==1'b1 && opsel_index[5]==1'b1)
op_sel_h[5] = data;
if(opsel_index[31]==1'b1 && opsel_index[16]==1'b1)
{sel_a[5],sel_a[4],sel_a[3],sel_a[2],sel_a[1],sel_a[0]} = data[11:0];
if(opsel_index[31]==1'b1 && opsel_index[17]==1'b1)
{sel_b[5],sel_b[4],sel_b[3],sel_b[2],sel_b[1],sel_b[0]} = data[11:0];
if(opsel_index[31]==1'b1 && opsel_index[18]==1'b1)
{sel_c[5],sel_c[4],sel_c[3],sel_c[2],sel_c[1],sel_c[0]} = data[11:0];
if(opsel_index[31]==1'b1 && opsel_index[19]==1'b1)
{sel_d[5],sel_d[4],sel_d[3],sel_d[2],sel_d[1],sel_d[0]} = data[11:0];
if(opsel_index[30]==1'b1 && opsel_index[0]==1'b1)
op_sel_l[0] = data;
if(opsel_index[30]==1'b1 && opsel_index[1]==1'b1)
op_sel_l[1] = data;
if(opsel_index[30]==1'b1 && opsel_index[2]==1'b1)
op_sel_l[2] = data;
if(opsel_index[30]==1'b1 && opsel_index[3]==1'b1)
op_sel_l[3] = data;
if(opsel_index[30]==1'b1 && opsel_index[4]==1'b1)
op_sel_l[4] = data;
if(opsel_index[30]==1'b1 && opsel_index[5]==1'b1)
op_sel_l[5] = data;
end
end
endmodule
`timescale 1ns/10ps
module DDR_Pipe
#(parameter N=32,M=3)
(
input clk,
input sel,
input [N-1:0] a,
input [N-1:0] an,
output reg [N-1:0] out1,
output reg [N-1:0] out2
);
wire [31:0] lo0,lo1;
generate
genvar i;
for(i=0; i<32; i=i+1)
begin
LUT3 #(.INIT(8'b1100_1010)) L0 (.I2(sel),.I1(an[i]),.I0(a[i]),.O(lo0[i]));
LUT3 #(.INIT(8'b1100_1010)) L1 (.I2(sel),.I1(an[i]),.I0(a[i]),.O(lo1[i]));
end
endgenerate
always @(posedge clk)
begin
out1<=lo0;
out2<=lo1;
end
endmodule
`timescale 1ns/10ps
module DDR_COUNTER
#(parameter N=32,M=3)
(
input clk,
input rst_n,
output wire [N-1:0] out1,
output wire [N-1:0] out2,
output wire co1,co2
);
localparam ADJ = 5'b1_1111;
wire cclk1; //,cclk2,cclk3;
wire cclk11; //,cclk12,cclk13;
assign out1[0]=1'b0;
assign out2[0]=1'b1;
COUNTER10_e #(ADJ) CNT1 (.clk(clk) ,.rst_n(rst_n),.en(1'b1),.q(out1[10:1]) ,.co(cclk1));
//COUNTER10_e CNT2 (.clk(clk),.rst_n(rst_n),.en(cclk1),.q(out1[20:11]),.co(cclk2));
//COUNTER10_e CNT3 (.clk(clk),.rst_n(rst_n),.en(cclk2_en),.q(out1[30:21]),.co(cclk3));
//COUNTER10_3 CNT4 (.clk(clk),.rst_n(rst_n),.en(cclk3_en),.q(out1[31]),.co(cclk4));
COUNTER27 CNT4 (.clk(clk),.rst_n(rst_n),.en(cclk1),.q(out1[31:11]),.co(co1));
COUNTER10_e #(ADJ) CNT5 (.clk(clk) ,.rst_n(rst_n),.en(1'b1),.q(out2[10:1]) ,.co(cclk11));
//COUNTER10_e CNT6 (.clk(clk),.rst_n(rst_n),.en(cclk11),.q(out2[20:11]),.co(cclk12));
//COUNTER10_e CNT7 (.clk(clk),.rst_n(rst_n),.en(cclk12_en),.q(out2[30:21]),.co(cclk13));
//COUNTER10_3 CNT8 (.clk(clk),.rst_n(rst_n),.en(cclk13_en),.q(out2[31]),.co(cclk14));
COUNTER27 CNT8 (.clk(clk),.rst_n(rst_n),.en(cclk11),.q(out2[31:11]),.co(co2));
endmodule
`timescale 1ns/10ps
module DDR_OP1
#(parameter N=32)
(
input clk,
input [N-1:0] a,
input [N-1:0] an,
output reg [N-1:0] out
);
always @(posedge clk)
out = a & an;
integer i;
specify
(an[i]=> out[i]) =0.6; //0.5
(a[i]=> out[i]) =0.5; //0.5
endspecify /* pin2pin delay 5.87 6.005 6.04 */
endmodule
`timescale 1ns/10ps
module DDR_OP2
#(parameter N=32)
(
input clk,
input [N-1:0] a,
input [N-1:0] an,
output reg [N-1:0] out
);
always @(posedge clk)
out = a | an;
integer i;
specify
(an[i]=> out[i]) =0.6; //0.5
(a[i]=> out[i]) =0.5; //0.5
endspecify /* pin2pin delay 5.87 6.005 6.04 */
endmodule
`timescale 1ns/10ps
module DDR_OP3
#(parameter N=32)
(
input clk,
input [N-1:0] a,
input [N-1:0] an,
output reg [N-1:0] out
);
always @(posedge clk)
out = ~(a & an);
integer i;
specify
(an[i]=> out[i]) =0.6; //0.5
(a[i]=> out[i]) =0.5; //0.5
endspecify /* pin2pin delay 5.87 6.005 6.04 */
endmodule
`timescale 1ns/10ps
module DDR_OP4
#(parameter N=32)
(
input clk,
input [N-1:0] a,
input [N-1:0] an,
output reg [N-1:0] out
);
always @(posedge clk)
out = ~(a | an);
integer i;
specify
(an[i]=> out[i]) =0.6; //0.5
(a[i]=> out[i]) =0.5; //0.5
endspecify /* pin2pin delay 5.87 6.005 6.04 */
endmodule
module COUNTER3
(
input clk,rst_n,en,
output reg [2:0] q
);
always @(posedge clk)
begin
if(rst_n==1'b0)
q<=0;
else if(en)
q<=q+1'b1;
end
endmodule
module COUNTER4
(
input clk,rst_n,en,
output reg [3:0] q
);
always @(posedge clk or negedge rst_n)
begin
if(rst_n==1'b0)
q<=0;
else if(en)
q<=q+1'b1;
end
endmodule
module COUNTER5
(
input clk,rst_n,en,
output reg [4:0] q
);
always @(posedge clk or negedge rst_n)
begin
if(rst_n==1'b0)
q<=0;
else if(en)
q<=q+1'b1;
end
endmodule
module COUNTER5_0
(
input clk,rst_n,en,
output reg [4:0] q
);
always @(posedge clk or negedge rst_n)
begin
if(rst_n==1'b0)
q<=5'b00001;
else if(en)
q<=q+1'b1;
end
endmodule
module COUNTER5_inc2_0
(
input clk,rst_n,en,
output reg [4:0] q
);
always @(posedge clk or negedge rst_n)
begin
if(rst_n==1'b0)
q<=0;
else if(en)
q<=q+2'b01;
end
endmodule
module COUNTER5_inc2_1
(
input clk,rst_n,en,
output reg [4:0] q
);
always @(posedge clk or negedge rst_n)
begin
if(rst_n==1'b0)
q<=5'b00001;
else if(en)
q<=q+2'b01;
end
endmodule
module COUNTER10_e
#(parameter ADJ=5'b1_1110)
(
input clk,rst_n,en,
output wire [9:0] q,
output reg co
);
reg en1,en1_1;
reg en_2;
reg co_r;
reg en_1, en_1d;
reg rst_ns;
reg rst_ns1;
reg co1;
always @(*)
begin
en_1 <= en_1d;
co <=co1;
end
COUNTER5_inc2_0 U0 (.clk(clk),.rst_n(rst_n),.en(en),.q(q[4:0]));
always @(posedge clk)
begin
en_1d<= q[4:0]==5'b1_1110;
co1 <= q[4:0]==5'b1_1110 && q[9:5]==5'b1_1111;
co_r <=q[4:0]==5'b1_1111 && q[9:5]==5'b1_1111;
rst_ns <= rst_n & ~co_r;
end
COUNTER5 U1 (.clk(clk),.rst_n(rst_ns),.en(en_1),.q(q[9:5]));
endmodule
module COUNTER10_o
#(parameter ADJ=5'b1_1110)
(
input clk,rst_n,en,
output wire [9:0] q,
output reg co
);
reg en1,en1_1;
reg en_1, en_1d;
always @(*)
en_1d<= q[4:0]==5'b11111;
COUNTER5_inc2_1 U0 (.clk(clk),.rst_n(rst_n),.en(en),.q(q[4:0]));
reg en_2;
reg co_r;
reg rst_ns;
reg rst_ns1;
always @(posedge clk)
begin
co <= q[4:0]==5'b1_1110 && q[9:5]==5'b1_1111;
co_r <= q[4:0]==5'b1_1111 && q[9:5]==5'b1_1111;
rst_ns <= rst_n & ~co_r;
end
/*
always @(negedge clk)
begin
rst_ns <= rst_ns1;
end
*/
COUNTER5 U1 (.clk(clk),.rst_n(rst_ns),.en(en_1d),.q(q[9:5]));
endmodule
module COUNTER10_1
(
input clk,rst_n,en,
output wire [9:0] q,
output reg co
);
reg en1,en1_1;
reg en_1dr;
reg en_2;
reg en_1, en_1d;
always @(*)
begin
en1= q[4:0]==5'b11110;
en1_1=q[4:0]==5'b11111;
end
COUNTER5 U0 (.clk(clk),.rst_n(rst_n),.en(en),.q(q[4:0]));
always @(posedge clk)
en_1d<=en==1'b1 && q[4:0]==5'b11111;
always @(posedge clk)
begin
en_1dr <= q[4:0]==5'b11110;
end
always @(posedge clk)
begin
if(en)
en_1d<= en_1dr;
else
en_1d<= 1'b0;
end
always @(posedge clk)
begin
co <= en1_1==1'b1&&q[9:5]==5'b1_1111;
end
COUNTER5 U1 (.clk(clk),.rst_n(rst_n),.en(en_1d),.q(q[9:5]));
endmodule
module COUNTER10_2
(
input clk,rst_n,en,
output wire [9:0] q,
output reg co
);
reg en1,en1_1;
always @(*)
begin
en1= q[4:0]==5'b11110;
en1_1=q[4:0]==5'b11111;
end
COUNTER5 U0 (.clk(clk),.rst_n(rst_n),.en(en),.q(q[4:0]));
reg en_2;
reg en_1, en_1d;
always @(negedge clk)
en_1d<= q[4:0]==5'b11111;
always @(posedge clk)
en_1 <= en&en1;
always @(posedge clk)
begin
co <= en1_1==1'b1&&q[9:5]==5'b1_1111;
end
COUNTER5 U1 (.clk(clk),.rst_n(rst_n),.en(en_1),.q(q[9:5]));
endmodule
module COUNTER10_3
(
input clk,rst_n,en,
output reg q,
output reg co
);
always @(posedge clk or negedge rst_n)
begin
if(rst_n==1'b0)
q<=2'b0;
else if(en)
begin
q<=q+1'b1;
co<=q==2'b00;
end
end
endmodule
module COUNTER27
(
input clk,rst_n,en,
output reg[20:0] q,
output wire co
);
assign co = (q == 21'b1_1111_1111_1111_1111_1111)?1'b1:1'b0;
wire rst=~rst_n;
always @(posedge clk or posedge rst)
begin
if(rst==1'b1)
begin
q <= 21'b0;
end
else if(en)
begin
q <= q+1'b1;
end
end
endmodule
module DLPS_AND // Digital Logic Pipe Stage AND
#(parameter N=8)
(
output reg [N-1:0] out,
input sel,
input [N-1:0] in_a,in_b,in_c,
input clk,
input en
);
wire [N-1:0] in_op = (sel==1'b1) ? in_c : in_b;
always @(posedge clk)
begin
if(en==1'b1)
out <= in_a & in_op;
end
endmodule
module DLPS_NAND // Digital Logic Pipe Stage NAND
#(parameter N=8)
(
output reg [N-1:0] out,
input sel,
input [N-1:0] in_a,in_b,in_c,
input clk,
input en
);
wire [N-1:0] in_op = (sel==1'b1) ? in_c : in_b;
always @(posedge clk)
begin
if(en==1'b1)
out <= ~in_a | ~ in_op;
end
endmodule
module DLPS_OR // Digital Logic Pipe Stage OR
#(parameter N=8)
(
output reg [N-1:0] out,
input sel,
input [N-1:0] in_a,in_b,in_c,
input clk,
input en
);
wire [N-1:0] in_op = (sel==1'b1) ? in_c : in_b;
always @(posedge clk)
begin
if(en==1'b1)
out <= in_a | in_op;
end
endmodule
module DLPS_NOR // Digital Logic Pipe Stage NOR
#(parameter N=8)
(
output reg [N-1:0] out,
input sel,
input [N-1:0] in_a,in_b,in_c,
input clk,
input en
);
wire [N-1:0] in_op = (sel==1'b1) ? in_c : in_b;
always @(posedge clk)
begin
if(en==1'b1)
out <= ~in_a & ~in_op;
end
endmodule
module DLPS_ADD // Digital Logic Pipe Stage ADD
#(parameter N=8)
(
output reg [N-1:0] out,
input sel,
input [N-1:0] in_a,in_b,in_c,
input clk,
input en
);
wire [N-1:0] in_op = (sel==1'b1) ? in_c : in_b;
always @(posedge clk)
begin
if(en==1'b1)
out <= in_a + in_op;
end
endmodule
module DLPS_SUB // Digital Logic Pipe Stage SUB
#(parameter N=8)
(
output reg [N-1:0] out,
input sel,
input [N-1:0] in_a,in_b,in_c,
input clk,
input en
);
wire [N-1:0] in_op = (sel==1'b1) ? in_c : in_b;
always @(posedge clk)
begin
if(en==1'b1)
out <= in_a - in_op;
end
endmodule
module DLPS_MUL // Digital Logic Pipe Stage MUL
#(parameter N=8)
(
output reg [N-1:0] out,
input sel,
input [N-1:0] in_a,in_b,in_c,
input clk,
input en
);
wire [N-1:0] in_op = (sel==1'b1) ? in_c : in_b;
always @(posedge clk)
begin
if(en==1'b1)
out <= in_a * in_op;
end
endmodule
module DLPS_DIV // Digital Logic Pipe Stage DIV
#(parameter N=8)
(
output reg [N-1:0] out,
input sel,
input [N-1:0] in_a,in_b,in_c,
input clk,
input en
);
wire [N-1:0] in_op = (sel==1'b1) ? in_c : in_b;
always @(posedge clk)
begin
// if(en==1'b1)
// out <= in_a / in_op;
#1 if(en) $display (" %d / %d =%d",in_a,in_b,out);
end
endmodule
module DLPS_PS
#(parameter N=8)
(
output reg [N-1:0] out,
output reg [N-1:0] out_a,out_b,out_c,
input [13:0] opsel,
input sel_c,
input [N-1:0] in_a,in_b,in_c,
input clk
);
wire [7:0] en;
wire [N-1:0] and_o,nand_o,or_o,nor_o,add_o,sub_o,mul_o,div_o;
assign en[0]=opsel==13'b0_0000_0000_0001;
assign en[1]=opsel==13'b0_0000_0000_0010;
assign en[2]=opsel==13'b0_0000_0000_0100;
assign en[3]=opsel==13'b0_0000_0000_1000;
assign en[4]=opsel==13'b0_0000_0001_0000;
assign en[5]=opsel==13'b0_0000_0010_0000;
assign en[6]=opsel==13'b0_0000_0100_0000;
assign en[7]=opsel==13'b0_0000_1000_0000;
always @(posedge clk)
begin
out_a <=in_a;
out_b <=in_b;
out_c <=in_c;
case(opsel)
3'b000: out <=and_o;
3'b001: out <=nand_o;
3'b010: out <=or_o;
3'b011: out <=nor_o;
3'b100: out <=add_o;
3'b101: out <=sub_o;
3'b110: out <=mul_o;
3'b111: out <=div_o;
endcase
end
DLPS_AND #(.N(N)) U0
(
.out(and_o),
.sel(sel_c),
.in_a(in_a),.in_b(in_b),.in_c(in_c),
.clk(clk),
.en(en[0])
);
DLPS_NAND #(.N(N)) U1
(
.out(nand_o),
.sel(sel_c),
.in_a(in_a),.in_b(in_b),.in_c(in_c),
.clk(clk),
.en(en[1])
);
DLPS_OR #(.N(N)) U2
(
.out(or_o),
.sel(sel_c),
.in_a(in_a),.in_b(in_b),.in_c(in_c),
.clk(clk),
.en(en[2])
);
DLPS_NOR #(.N(N)) U3
(
.out(nor_o),
.sel(sel_c),
.in_a(in_a),.in_b(in_b),.in_c(in_c),
.clk(clk),
.en(en[3])
);
DLPS_ADD #(.N(N)) U4
(
.out(add_o),
.sel(sel_c),
.in_a(in_a),.in_b(in_b),.in_c(in_c),
.clk(clk),
.en(en[4])
);
DLPS_SUB #(.N(N)) U5
(
.out(sub_o),
.sel(sel_c),
.in_a(in_a),.in_b(in_b),.in_c(in_c),
.clk(clk),
.en(en[5])
);
DLPS_MUL #(.N(N)) U6
(
.out(mul_o),
.sel(sel_c),
.in_a(in_a),.in_b(in_b),.in_c(in_c),
.clk(clk),
.en(en[6])
);
DLPS_DIV #(.N(N)) U7
(
.out(div_o),
.sel(sel_c),
.in_a(in_a),.in_b(in_b),.in_c(in_c),
.clk(clk),
.en(en[7])
);
endmodule
|