vault backup: 2025-02-03 11:19:08

This commit is contained in:
arc 2025-02-03 11:19:08 -07:00
parent 116ab612fc
commit 32186127e2
2 changed files with 31 additions and 1 deletions

View File

@ -21,7 +21,7 @@ Below is an example of the structure of a half adder module:
```verilog ```verilog
module half_adder( module half_adder(
input a, input a,
input b input b,
output sum_bit, output sum_bit,
output carry_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. - `output`: Output ports can be written to, but not read from.
- `inout`: Inout ports can send *and* receive values. - `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 ### Port types
If no type is defined, ports are implicitly defined as *nets* of type `wire`. 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. > 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
```

View File

@ -77,4 +77,12 @@ reg [7:0] foo;
// Write to bit 0 // Write to bit 0
foo [0] = 1; 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;
``` ```