-
Notifications
You must be signed in to change notification settings - Fork 3
/
SRLC32E.v
68 lines (59 loc) · 1.46 KB
/
SRLC32E.v
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
`ifdef verilator3
`else
`timescale 1 ps / 1 ps
`endif
//
// SRLC32E primitive for Xilinx FPGAs
// Compatible with Verilator tool (www.veripool.org)
// Copyright (c) 2019-2022 Frédéric REQUIN
// License : BSD
//
/* verilator coverage_off */
module SRLC32E
#(
parameter [31:0] INIT = 32'h0,
parameter [0:0] IS_CLK_INVERTED = 1'b0
)
(
// Clock
input wire CLK,
// Clock enable
input wire CE,
// Bit output position
input wire [4:0] A,
// Data in
input wire D,
// Data out
output wire Q,
// Cascading data out
output wire Q31
);
// 32-bit shift register
reg [31:0] _r_srl;
// Power-up value
initial begin
_r_srl = INIT;
end
// Shifter logic
generate
if (IS_CLK_INVERTED) begin : GEN_CLK_NEG
always @(negedge CLK) begin : SHIFTER_32B
if (CE) begin
_r_srl <= { _r_srl[30:0], D };
end
end
end
else begin : GEN_CLK_POS
always @(posedge CLK) begin : SHIFTER_32B
if (CE) begin
_r_srl <= { _r_srl[30:0], D };
end
end
end
endgenerate
// Data out
assign Q = _r_srl[A];
// Cascading data out
assign Q31 = _r_srl[31];
endmodule
/* verilator coverage_on */