Skip to content

Commit 46a1d7a

Browse files
author
Frédéric REQUIN
committed
Updated shift register primitives
1 parent 70414d4 commit 46a1d7a

File tree

4 files changed

+56
-20
lines changed

4 files changed

+56
-20
lines changed

SRL16E.v

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@
1010
//
1111

1212
module SRL16E
13+
#(
14+
parameter [15:0] INIT = 16'h0,
15+
parameter [0:0] IS_CLK_INVERTED = 1'b0
16+
)
1317
(
1418
// Clock
1519
input wire CLK,
@@ -22,7 +26,6 @@ module SRL16E
2226
// Data out
2327
output wire Q
2428
);
25-
parameter [15:0] INIT = 16'h0000;
2629

2730
wire [3:0] _w_addr = { A3, A2, A1, A0 };
2831

@@ -35,12 +38,24 @@ module SRL16E
3538
end
3639

3740
// Shifter logic
38-
always @(posedge CLK) begin : SHIFTER_16B
39-
40-
if (CE) begin
41-
_r_srl <= { _r_srl[14:0], D };
41+
generate
42+
if (IS_CLK_INVERTED) begin : GEN_CLK_NEG
43+
always @(negedge CLK) begin : SHIFTER_16B
44+
45+
if (CE) begin
46+
_r_srl <= { _r_srl[14:0], D };
47+
end
48+
end
4249
end
43-
end
50+
else begin : GEN_CLK_POS
51+
always @(posedge CLK) begin : SHIFTER_16B
52+
53+
if (CE) begin
54+
_r_srl <= { _r_srl[14:0], D };
55+
end
56+
end
57+
end
58+
endgenerate
4459

4560
// Data out
4661
assign Q = _r_srl[_w_addr];

SRL32E.v

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@
1010
//
1111

1212
module SRL32E
13+
#(
14+
parameter [31:0] INIT = 32'h0,
15+
parameter [0:0] IS_CLK_INVERTED = 1'b0
16+
)
1317
(
1418
// Clock
1519
input wire CLK,
@@ -22,8 +26,6 @@ module SRL32E
2226
// Data out
2327
output wire Q
2428
);
25-
parameter [31:0] INIT = 32'h00000000;
26-
parameter [0:0] IS_CLK_INVERTED = 1'b0;
2729

2830
// 32-bit shift register
2931
reg [31:0] _r_srl;
@@ -36,14 +38,14 @@ module SRL32E
3638
// Shifter logic
3739
generate
3840
if (IS_CLK_INVERTED) begin : GEN_CLK_NEG
39-
always @(negedge CLK) begin
41+
always @(negedge CLK) begin : SHIFTER_32B
4042
if (CE) begin
4143
_r_srl <= { _r_srl[30:0], D };
4244
end
4345
end
4446
end
4547
else begin : GEN_CLK_POS
46-
always @(posedge CLK) begin
48+
always @(posedge CLK) begin : SHIFTER_32B
4749
if (CE) begin
4850
_r_srl <= { _r_srl[30:0], D };
4951
end

SRLC16E.v

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@
1010
//
1111

1212
module SRLC16E
13+
#(
14+
parameter [15:0] INIT = 16'h0,
15+
parameter [0:0] IS_CLK_INVERTED = 1'b0
16+
)
1317
(
1418
// Clock
1519
input wire CLK,
@@ -24,8 +28,6 @@ module SRLC16E
2428
// Cascading data out
2529
output wire Q15
2630
);
27-
parameter [15:0] INIT = 16'h0000;
28-
parameter [0:0] IS_CLK_INVERTED = 1'b0;
2931

3032
// 32-bit shift register
3133
reg [15:0] _r_srl;
@@ -41,14 +43,16 @@ module SRLC16E
4143
// Shifter logic
4244
generate
4345
if (IS_CLK_INVERTED) begin : GEN_CLK_NEG
44-
always @(negedge CLK) begin
46+
always @(negedge CLK) begin : SHIFTER_16B
47+
4548
if (CE) begin
4649
_r_srl <= { _r_srl[14:0], D };
4750
end
4851
end
4952
end
5053
else begin : GEN_CLK_POS
51-
always @(posedge CLK) begin
54+
always @(posedge CLK) begin : SHIFTER_16B
55+
5256
if (CE) begin
5357
_r_srl <= { _r_srl[14:0], D };
5458
end

SRLC32E.v

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@
1010
//
1111

1212
module SRLC32E
13+
#(
14+
parameter [31:0] INIT = 32'h0,
15+
parameter [0:0] IS_CLK_INVERTED = 1'b0
16+
)
1317
(
1418
// Clock
1519
input wire CLK,
@@ -24,7 +28,6 @@ module SRLC32E
2428
// Cascading data out
2529
output wire Q31
2630
);
27-
parameter [31:0] INIT = 32'h00000000;
2831

2932
// 32-bit shift register
3033
reg [31:0] _r_srl;
@@ -35,12 +38,24 @@ module SRLC32E
3538
end
3639

3740
// Shifter logic
38-
always @(posedge CLK) begin : SHIFTER_32B
39-
40-
if (CE) begin
41-
_r_srl <= { _r_srl[30:0], D };
41+
generate
42+
if (IS_CLK_INVERTED) begin : GEN_CLK_NEG
43+
always @(negedge CLK) begin : SHIFTER_32B
44+
45+
if (CE) begin
46+
_r_srl <= { _r_srl[30:0], D };
47+
end
48+
end
4249
end
43-
end
50+
else begin : GEN_CLK_POS
51+
always @(posedge CLK) begin : SHIFTER_32B
52+
53+
if (CE) begin
54+
_r_srl <= { _r_srl[30:0], D };
55+
end
56+
end
57+
end
58+
endgenerate
4459

4560
// Data out
4661
assign Q = _r_srl[A];

0 commit comments

Comments
 (0)