-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy path74161.v
55 lines (46 loc) · 1.08 KB
/
74161.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
// 4-bit modulo 16 binary counter with parallel load, asynchronous clear
// (c) Tim Rudy, GPL3
/* verilator lint_off DECLFILENAME */
module ttl_74161 #(parameter WIDTH = 4, DELAY_RISE = 22, DELAY_FALL = 22)
(
input Clear_bar,
input Load_bar,
input ENT,
input ENP,
input [WIDTH-1:0] D,
input Clk,
output RCO,
output [WIDTH-1:0] Q
);
//------------------------------------------------//
wire RCO_current;
reg [WIDTH-1:0] Q_current;
wire [WIDTH-1:0] Q_next;
assign Q_next = Q_current + 1;
always @(posedge Clk or negedge Clear_bar)
begin
if (!Clear_bar)
begin
Q_current <= {WIDTH{1'b0}};
end
else
begin
if (!Load_bar)
begin
Q_current <= D;
end
if (Load_bar && ENT && ENP)
begin
Q_current <= Q_next;
end
end
end
// outputs
assign RCO_current = ENT && (&Q_current);
//------------------------------------------------//
/* verilator lint_off ASSIGNDLY */
assign #(DELAY_RISE, DELAY_FALL) RCO = RCO_current;
assign #(DELAY_RISE, DELAY_FALL) Q = Q_current;
/* verilator lint_on ASSIGNDLY */
endmodule
/* verilator lint_on DECLFILENAME */