chore: Update bits syntax to use +<count>

This commit is contained in:
Sidharth Vinod
2025-04-15 12:14:06 +05:30
parent d7730aba46
commit ea321168bd
5 changed files with 56 additions and 38 deletions

View File

@@ -25,14 +25,15 @@ start-end: "Block name" %% Multi-bit blocks
### Bits Syntax (v\<MERMAID_RELEASE_VERSION>+)
Using start and end bit counts can be difficult, especially when modifying a design. For this we add a bit count field, which starts from the end of the previous field automagically. Use `bit` or `bits` interchangeably to set the number of bits, thus:
Using start and end bit counts can be difficult, especially when modifying a design. For this we add a bit count field, which starts from the end of the previous field automagically. Use `+<count>` to set the number of bits, thus:
````md
```md
packet-beta
1bit: "Block name" %% Single-bit block
8bits: "Block name" %% 8-bit block
+1: "Block name" %% Single-bit block
+8: "Block name" %% 8-bit block
9-15: "Manually set start and end, it's fine to mix and match"
... More Fields ...
```
## Examples
@@ -41,8 +42,32 @@ packet-beta
title: "TCP Packet"
---
packet-beta
16bits: "Source Port"
16bits: "Destination Port"
0-15: "Source Port"
16-31: "Destination Port"
32-63: "Sequence Number"
64-95: "Acknowledgment Number"
96-99: "Data Offset"
100-105: "Reserved"
106: "URG"
107: "ACK"
108: "PSH"
109: "RST"
110: "SYN"
111: "FIN"
112-127: "Window"
128-143: "Checksum"
144-159: "Urgent Pointer"
160-191: "(Options and Padding)"
192-255: "Data (variable length)"
```
```mermaid
---
title: "TCP Packet"
---
packet-beta
0-15: "Source Port"
16-31: "Destination Port"
32-63: "Sequence Number"
64-95: "Acknowledgment Number"
96-99: "Data Offset"
@@ -59,13 +84,12 @@ packet-beta
160-191: "(Options and Padding)"
192-255: "Data (variable length)"
```
````
```mermaid-example
packet-beta
title UDP Packet
0-15: "Source Port"
16-31: "Destination Port"
+16: "Source Port"
+16: "Destination Port"
32-47: "Length"
48-63: "Checksum"
64-95: "Data (variable length)"
@@ -74,8 +98,8 @@ title UDP Packet
```mermaid
packet-beta
title UDP Packet
0-15: "Source Port"
16-31: "Destination Port"
+16: "Source Port"
+16: "Destination Port"
32-47: "Length"
48-63: "Checksum"
64-95: "Data (variable length)"