vault backup: 2025-02-03 11:19:08
This commit is contained in:
parent
116ab612fc
commit
32186127e2
@ -21,7 +21,7 @@ Below is an example of the structure of a half adder module:
|
||||
```verilog
|
||||
module half_adder(
|
||||
input a,
|
||||
input b
|
||||
input b,
|
||||
output sum_bit,
|
||||
output carry_bit
|
||||
);
|
||||
@ -37,7 +37,29 @@ There are 3 kinds of ports:
|
||||
- `output`: Output ports can be written to, but not read from.
|
||||
- `inout`: Inout ports can send *and* receive values.
|
||||
|
||||
Ports can be declared in the port list, or in the module body. Ports declared in the port list can optionally omit their type, to be specified within the body of the module:
|
||||
```verilog
|
||||
module half_adder(
|
||||
a,
|
||||
b,
|
||||
sum_bit,
|
||||
carry_bit
|
||||
);
|
||||
input a;
|
||||
input b;
|
||||
output sum_bit;
|
||||
output carry_bit;
|
||||
endmodule
|
||||
```
|
||||
|
||||
### Port types
|
||||
If no type is defined, ports are implicitly defined as *nets* of type `wire`.
|
||||
|
||||
> In verilog, the term *net* refers to network, and it refers to a connection that joins two or more devices together.
|
||||
|
||||
Ports can be a vector type:
|
||||
```verilog
|
||||
module test(a, b, c);
|
||||
|
||||
endmodule
|
||||
```
|
@ -78,3 +78,11 @@ reg [7:0] foo;
|
||||
// Write to bit 0
|
||||
foo [0] = 1;
|
||||
```
|
||||
|
||||
## Part selects
|
||||
A range of contiguous bits from within another vector can be selected, referred to as a part select. This range can then be treated as a vector.
|
||||
```verilog
|
||||
reg [31:0] foo;
|
||||
// Select bits 23 through 16 (inclusive), and assign the 8 bit hex value `0xff` to them.
|
||||
foo [23:16] = 8'hff;
|
||||
```
|
Loading…
x
Reference in New Issue
Block a user