vault backup: 2025-02-03 09:59:19
This commit is contained in:
parent
d697cba7ba
commit
d54cecc801
@ -4,11 +4,38 @@ Each module can be thought of as a black box with a series of inputs, and a seri
|
|||||||
|
|
||||||
Module definitions are started with the `module` keyword, and closed with the `endmodule` keyword.
|
Module definitions are started with the `module` keyword, and closed with the `endmodule` keyword.
|
||||||
|
|
||||||
|
## Syntax
|
||||||
The general syntax of a module is as follows:
|
The general syntax of a module is as follows:
|
||||||
```verilog
|
```verilog
|
||||||
module <name> ([port_list]);
|
module <name> ([port_list]);
|
||||||
// Contents of the module
|
// Contents of the module
|
||||||
endmodule
|
endmodule
|
||||||
|
|
||||||
// The por
|
// The port list is optional
|
||||||
```
|
module <name>;
|
||||||
|
// Contents
|
||||||
|
endmodule
|
||||||
|
```
|
||||||
|
|
||||||
|
Below is an example of the structure of a half adder module:
|
||||||
|
```verilog
|
||||||
|
module half_adder(
|
||||||
|
input a,
|
||||||
|
input b
|
||||||
|
output sum_bit,
|
||||||
|
output carry_bit
|
||||||
|
);
|
||||||
|
// ------- snip ------------
|
||||||
|
endmodule
|
||||||
|
```
|
||||||
|
|
||||||
|
## Ports
|
||||||
|
Ports are a set of signals that act as input and outputs for a particular module.
|
||||||
|
|
||||||
|
There are 3 kinds of ports:
|
||||||
|
- `input`: Input ports can only receive values from the outside. `input` ports cannot be written to.
|
||||||
|
- `output`: Output ports can be written to, but not read from.
|
||||||
|
- `inout`: Inout ports can send *and* receive values.
|
||||||
|
|
||||||
|
### Port types
|
||||||
|
If no
|
Loading…
x
Reference in New Issue
Block a user