-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathimplicit.v
More file actions
47 lines (39 loc) · 722 Bytes
/
implicit.v
File metadata and controls
47 lines (39 loc) · 722 Bytes
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
module implicit();
// it has no in/op ports
// lets define intermediate elements
reg clk, d, rst, pre;
wire q;
// here second port is not connected
dff u0 (q,,clk,d,rst,pre);
endmodule
// D flip-flop
module dff (
q,
q_bar,
clk,
d,
rst,
pre
);
// -------Input Ports-----------------
input clk;
input d;
input rst;
input pre;
// -------Output Ports-----------------
output q;
output q_bar;
// If nothing mentioned.. they are assumed to be wires..
// however, it is a good practice to expilicity specify
// it here...
// ------------Port data type-----------
reg q;
assign q_bar = ~q; // 'q_bar' is a wire
always @(posedge clk) begin
if (rst == 1'b1) begin
q <= 0;
end else begin
q <= d;
end
end
endmodule