Skip to content

Commit 4b37443

Browse files
committed
docs(RCSV): Simplify documentation structure
- Condense behavior semantics into concise bullet points - Remove detailed tables and validation rules sections - Focus on key concepts and SystemRDL mapping - Streamline address and reset value explanations Signed-off-by: Huang Rui <vowstar@gmail.com>
1 parent 28eddda commit 4b37443

1 file changed

Lines changed: 15 additions & 267 deletions

File tree

‎doc/RCSV.md‎

Lines changed: 15 additions & 267 deletions
Original file line numberDiff line numberDiff line change
@@ -199,137 +199,33 @@ RCSV uses separate `sw_access` and `hw_access` columns to specify field access p
199199

200200
---
201201

202-
## 7. Read/Write Behavior Semantics
202+
## 7. Side-Effect Behaviors
203203

204-
RCSV supports SystemRDL's onread and onwrite behaviors for advanced field side-effects.
204+
**OnRead**: `rclr` (clear on read), `rset` (set on read), `ruser` (user-defined)
205205

206-
### 7.1 OnRead Behaviors (`onread`)
207-
208-
| Value | Meaning | SystemRDL Equivalent | Use Case |
209-
| ------- | ---------- | -------------------- | -------------------------------- |
210-
| `rclr` | Read Clear | `onread = rclr` | Status bits that clear when read |
211-
| `rset` | Read Set | `onread = rset` | Status bits that set when read |
212-
| `ruser` | Read User | `onread = ruser` | User-defined read behavior |
213-
214-
### 7.2 OnWrite Behaviors (`onwrite`)
215-
216-
| Value | Meaning | SystemRDL Equivalent | Use Case |
217-
| ------- | ----------------- | -------------------- | --------------------------- |
218-
| `woclr` | Write One Clear | `onwrite = woclr` | Write 1 to clear (W1C) |
219-
| `woset` | Write One Set | `onwrite = woset` | Write 1 to set (W1S) |
220-
| `wot` | Write One Toggle | `onwrite = wot` | Write 1 to toggle (W1T) |
221-
| `wzs` | Write Zero Set | `onwrite = wzs` | Write 0 to set (W0S) |
222-
| `wzc` | Write Zero Clear | `onwrite = wzc` | Write 0 to clear (W0C) |
223-
| `wzt` | Write Zero Toggle | `onwrite = wzt` | Write 0 to toggle (W0T) |
224-
| `wclr` | Write Clear | `onwrite = wclr` | Any write clears |
225-
| `wset` | Write Set | `onwrite = wset` | Any write sets |
226-
| `wuser` | Write User | `onwrite = wuser` | User-defined write behavior |
227-
228-
### 7.3 Common Read/Write Behavior Patterns
229-
230-
| sw_access | hw_access | onread | onwrite | Use Case |
231-
| --------- | --------- | ------ | ------- | ---------------------------------------------- |
232-
| `RO` | `WO` | | `woclr` | Interrupt status (HW sets, SW clears with W1C) |
233-
| `RW` | `RW` | `rclr` | | Error counter (clears when read) |
234-
| `WO` | `RO` | | `woset` | Command trigger (write 1 to execute) |
206+
**OnWrite**: `woclr` (W1C), `woset` (W1S), `wot` (W1T), `wzs` (W0S), `wzc` (W0C), `wzt` (W0T), `wclr` (write clear), `wset` (write set), `wuser` (user-defined)
235207

236208
---
237209

238-
## 8. Reset Value Semantics
239-
240-
The `reset_value` column specifies the field's initial value after reset.
210+
## 8. Reset Values
241211

242-
### 8.1 Reset Value Format
243-
244-
- **Decimal**: `42`, `255`, `0`
245-
- **Hexadecimal**: `0x2A`, `0xFF`, `0x0`
246-
- **No Reset**: Leaving `reset_value` empty means "no reset property" (no `reset = ...` will be generated in SystemRDL)
247-
- **Explicit Zero**: Setting `reset_value = 0` means an explicit reset of zero (`reset = 0`)
248-
249-
### 8.2 Reset Value Rules
250-
251-
1. **Field-Level**: Reset value applies to the field's bit range
252-
2. **Right-Justified**: Value is aligned to field's LSB position
253-
3. **Width Validation**: Value must fit within field width (MSB - LSB + 1)
254-
4. **Register Composition**: Register reset = concatenation of all field resets
255-
256-
### 8.3 Examples
257-
258-
```csv
259-
field_name,field_lsb,field_msb,reset_value,description
260-
ENABLE,0,0,1,Enabled by default
261-
MODE,1,3,5,Mode 5 (3-bit field: 0b101)
262-
RESERVED,4,7,0,Reserved bits
263-
```
212+
Support decimal (`42`), hex (`0x2A`), or empty (no reset). Value must fit within field width.
264213

265214
---
266215

267-
## 9. Address and Size Semantics
268-
269-
RCSV uses explicit addressing without complex stride calculations.
270-
271-
### 9.1 Address Specification
272-
273-
- **`addrmap_offset`**: Base address of the address map (typically `0x0000`)
274-
- **`reg_offset`**: Byte offset of register within the address map
275-
- **Absolute Address**: `addrmap_offset + reg_offset`
216+
## 9. Addresses
276217

277-
### 9.2 Register Width
278-
279-
- **`reg_width`**: Register width in bits (typically 8, 16, 32, 64)
280-
- **Byte Size**: Register size in bytes = `reg_width / 8`
281-
- **Alignment**: Registers should be naturally aligned to their byte size
218+
Absolute address = `addrmap_offset + reg_offset`. Register width in bits (8, 16, 32, 64).
282219

283220
---
284221

285-
## 10. Validation Rules
286-
287-
RCSV enforces strict validation to ensure data integrity and SystemRDL compatibility.
288-
289-
### 10.1 Field Bit Range Validation
290-
291-
1. **Width Consistency**: Field width must match bit range calculation:
292-
- **Formula**: `field_width = field_msb - field_lsb + 1`
293-
- **Example**: Field `[7:4]` has width `7 - 4 + 1 = 4` bits
294-
2. **Range Order**: `field_msb >= field_lsb` (MSB must be >= LSB)
295-
3. **Register Bounds**: Field ranges must fit within register width (0 <= LSB <= MSB < reg_width)
296-
4. **No Overlap**: Field bit ranges within a register must not overlap
297-
298-
### 10.2 Address Validation
222+
## 10. Validation
299223

300-
1. **Hex/Decimal Format**: Addresses can be decimal (`4096`) or hex (`0x1000`)
301-
2. **Alignment**: Register addresses SHOULD align to the register byte size. Parsers MAY warn on misalignment but SHOULD NOT fail.
302-
3. **Uniqueness**: No duplicate register offsets within an address map
303-
304-
### 10.3 Access Control Validation
305-
306-
1. **Valid Values**: Only `RW`, `RO`, `WO`, `NA` allowed for access fields
307-
2. **Case Insensitive**: `rw`, `RW`, `Rw` all accepted (normalized to uppercase)
308-
309-
### 10.4 Read/Write Behavior Validation
310-
311-
1. **OnRead Values**: Only `rclr`, `rset`, `ruser` allowed for onread fields
312-
2. **OnWrite Values**: Only `woclr`, `woset`, `wot`, `wzs`, `wzc`, `wzt`, `wclr`, `wset`, `wuser` allowed for onwrite fields
313-
3. **Case Insensitive**: Values are case-insensitive and normalized to lowercase
314-
315-
### 10.5 Reset Value Validation
316-
317-
1. **Width Check**: Reset value must fit in field width (< 2^width)
318-
2. **Format Support**: Decimal and hexadecimal formats supported
319-
3. **Negative Values**: Not supported (unsigned fields only)
320-
321-
### 10.6 Name Validation
322-
323-
1. **SystemRDL Identifiers**: Names must be valid SystemRDL identifiers (\[a-zA-Z\_\]\[a-zA-Z0-9\_\]*)
324-
2. **No Reserved Words**: Cannot use SystemRDL keywords
325-
3. **Uniqueness**: Field names must be unique within each register
326-
327-
### 10.7 Structural Validation
328-
329-
1. **Row Order**: Address map -> Register -> Fields sequence must be maintained
330-
2. **Complete Hierarchy**: Every field must have a parent register
331-
3. **Required Columns**: All mandatory columns must be present and non-empty
332-
4. **Consistent Types**: Numeric columns must contain valid numbers
224+
- Field ranges must not overlap within registers
225+
- MSB >= LSB, ranges fit within register width
226+
- Access values: RW/RO/WO/NA (case insensitive)
227+
- Names must be valid SystemRDL identifiers
228+
- Row order: Address map -> Register -> Fields
333229

334230
---
335231

@@ -402,156 +298,8 @@ This generates SystemRDL `BUFFER[8] @ 0x0000` which expands to 8 registers: `BUF
402298

403299
---
404300

405-
## 13. SystemRDL Mapping
406-
407-
RCSV elements map directly to SystemRDL constructs:
408-
409-
### 13.1 Hierarchy Mapping
410-
411-
| RCSV | SystemRDL Equivalent |
412-
| ---------------------------- | ------------------------------- |
413-
| `addrmap_name` | `addrmap <name> {` |
414-
| `reg_name` @ `reg_offset` | `<reg_name> @ <reg_offset>;` |
415-
| `reg_name[N]` @ `reg_offset` | `<reg_name>[N] @ <reg_offset>;` |
416-
| `field_name[msb:lsb]` | `<field_name>[<msb>:<lsb>];` |
417-
418-
### 13.2 Property Mapping
419-
420-
| RCSV Column | SystemRDL Property |
421-
| --------------------------- | --------------------------- |
422-
| `sw_access` = RW/RO/WO/NA | `sw = rw/r/w/na` |
423-
| `hw_access` = RW/RO/WO/NA | `hw = rw/r/w/na` |
424-
| `onread` = rclr/rset/ruser | `onread = rclr/rset/ruser` |
425-
| `onwrite` = woclr/woset/... | `onwrite = woclr/woset/...` |
426-
| `reset_value` | `reset = <value>` |
427-
| `description` | `desc = "<text>"` |
428-
429-
### 13.3 Generated SystemRDL Example
430-
431-
From the RCSV example above, the generated SystemRDL would be:
432-
433-
```systemrdl
434-
addrmap DEMO_CHIP @ 0x0000 {
435-
reg {
436-
field { sw = rw; hw = rw; reset = 1; desc = "System enable bit"; } ENABLE[0:0];
437-
field { sw = rw; hw = rw; reset = 2; desc = "3-bit operation mode (0-7)"; } MODE[3:1];
438-
field { sw = wo; hw = ro; onwrite = woset; desc = "Write 1 to trigger reset"; } RESET_REQ[31:31];
439-
// ... more fields
440-
} SYS_CTRL @ 0x0000;
441-
442-
reg {
443-
field { sw = ro; hw = wo; desc = "System ready flag"; } READY[0:0];
444-
field { sw = ro; hw = wo; onwrite = woclr; desc = "Error status (W1C)"; } ERROR[1:1];
445-
field { sw = ro; hw = wo; onread = rclr; desc = "Interrupt status (clear on read)"; } INT_STATUS[15:8];
446-
// ... more fields
447-
} STATUS @ 0x0004;
448-
449-
// ... more registers
450-
};
451-
```
452-
453-
---
454-
455-
## 14. Comments and Documentation
456-
457-
RCSV supports documentation through several mechanisms:
458-
459-
- **Description Column**: Use `description` column for field/register documentation
460-
- **Multi-line Text**: Support for multi-line descriptions with CSV quoting
461-
- **Reserved Fields**: Use descriptive names like `RESERVED_7_4` for gaps
462-
463-
---
464-
465-
## 15. Tool Compatibility and Migration
466-
467-
### 15.1 SystemRDL Toolkit Integration
468-
469-
RCSV is the **standard format** for the SystemRDL Toolkit's CSV2RDL converter:
470-
471-
- Command: `systemrdl_csv2rdl input.csv -o output.rdl`
472-
- Validation: `python3 script/csv2rdl_validator.py`
473-
- Testing: `make test-csv2rdl`
474-
475-
### 14.2 Migration from Legacy Formats
476-
477-
Existing CSV files can be migrated to RCSV compliance:
478-
479-
1. **Header Adjustment**: Rename columns to standard names
480-
2. **Access Format**: Convert access values to RW/RO/WO/NA format
481-
3. **Array Syntax**: Change separate array columns to reg_name[N] syntax
482-
4. **Validation**: Run validation tools to verify compliance
483-
484-
485-
---
486-
487-
## 15. Best Practices
488-
489-
### 15.1 Design Guidelines
490-
491-
1. **Complete Coverage**: Ensure all register bits are covered by fields (use RESERVED_X_Y for gaps)
492-
2. **Consistent Naming**: Use clear, descriptive names following SystemRDL conventions
493-
3. **Logical Grouping**: Group related registers by function or subsystem
494-
4. **Address Alignment**: Align registers to natural boundaries (32-bit -> 4-byte alignment)
495-
5. **Reserved Fields**: Use `RO/NA` access pattern for reserved bits (software read-only, hardware not accessible)
496-
497-
### 15.2 Documentation Standards
498-
499-
1. **Field Descriptions**: Provide clear, concise descriptions for all fields
500-
2. **Multi-line Support**: Use CSV quoting for complex descriptions
501-
3. **Reserved Fields**: Explicitly document reserved bit ranges
502-
4. **Reset Values**: Always specify reset values, even if zero
503-
504-
### 15.3 Validation Workflow
505-
506-
1. **Format Check**: Verify CSV format and required columns
507-
2. **Syntax Validation**: Run through CSV2RDL converter
508-
3. **SystemRDL Parse**: Validate generated SystemRDL syntax
509-
4. **Consistency Review**: Check field ranges, addresses, and access patterns
510-
511-
---
512-
513-
## 15. Troubleshooting
301+
## 13. SystemRDL Output
514302

515-
### 15.1 Common Errors
516-
517-
Field Overlap Error:
518-
519-
```bash
520-
Error: Fields ENABLE[2:0] and MODE[1:3] overlap in register CTRL
521-
Fix: Adjust field bit ranges to eliminate overlap
522-
```
523-
524-
Invalid Access Value:
525-
526-
```bash
527-
Error: Invalid sw_access value 'READ' (use RW/RO/WO/NA)
528-
Fix: Use standard access control values
529-
```
530-
531-
Address Alignment Warning:
532-
533-
```bash
534-
Warning: Register at 0x0001 not aligned to 4-byte boundary
535-
Fix: Use aligned addresses (0x0000, 0x0004, 0x0008, etc.)
536-
```
537-
538-
### 15.2 Debugging Tips
539-
540-
1. **Use Validation Tools**: Run `script/csv2rdl_validator.py` for comprehensive checks
541-
2. **Check Encoding**: Ensure UTF-8 encoding without BOM
542-
3. **Verify Structure**: Confirm address map -> register -> field hierarchy
543-
4. **Test Incremental**: Validate small sections before building complete maps
303+
RCSV maps directly to SystemRDL syntax. Arrays like `BUFFER[8]` become `BUFFER[8] @ address` and auto-expand to individual register instances.
544304

545305
---
546-
547-
## 16. Summary
548-
549-
RCSV provides a **practical, standards-based approach** to CSV-SystemRDL conversion that:
550-
551-
- **Compatible** with existing SystemRDL Toolkit
552-
- **Simple** to understand and create
553-
- **Complete** - preserves all register information
554-
- **Validated** - strict consistency checking
555-
- **Documented** - comprehensive specification and examples
556-
557-
By following this specification, teams can create reliable, interchangeable register map definitions that integrate seamlessly with SystemRDL-based design flows.

0 commit comments

Comments
 (0)