wavedrom / bitfield

:cake: bit field diagram renderer
MIT License
340 stars 26 forks source link

Ability to skip drawing empty bitfields #43

Closed gabrielrad closed 2 years ago

gabrielrad commented 2 years ago

This PR request will allow represent packed structs/unions when in compact mode, by skipping empty bitfields. Empty bitfield == no name && no type

Input example:

{reg: [
{bits:2, name:'id', type:5, attr:''},
{bits:32, name:'union_fields', type:7, attr:''},
{bits:8, name:'nested', type:4, attr:''},
{bits: 34},
{bits:1, name:'a', type:3, attr:''},
{bits:2, name:'b', type:3, attr:''},
{bits:5, name:'other_nested', type:4, attr:''},
{bits: 2},
{bits:32, name:'type_0', type:4, attr:''},
{bits: 3},
{bits:5, name:'c', type:3, attr:''},
{bits: 2},
{bits:8, name:'field_0', type:3, attr:''},
{bits:8, name:'field_1', type:3, attr:''},
{bits:8, name:'field_2', type:3, attr:''},
{bits:8, name:'field_3', type:3, attr:''},
{bits: 8},
{bits: 42},
{bits: 2},
{bits:32, name:'type_1', type:4, attr:''},
{bits: 8},
{bits: 2},
{bits:16, name:'field_a', type:3, attr:''},
{bits:16, name:'field_b', type:3, attr:''},
{bits: 8},
{bits: 42},
{bits: 2},
{bits:32, name:'type_2', type:4, attr:''},
{bits: 8},
{bits: 2},
{bits:32, name:'field_alpha', type:3, attr:''},
{bits: 8},
{bits: 42},
{bits: 2},
{bits:32, name:'type_3', type:4, attr:''},
{bits: 8},
{bits: 2},
{bits:24, name:'padding', type:3, attr:''},
{bits:8, name:'other_field', type:4, attr:''},
{bits: 8},
{bits: 26},
{bits:1, name:'x', type:3, attr:''},
{bits:1, name:'y', type:3, attr:''},
{bits:6, name:'z', type:3, attr:''},
{bits: 8},
]
, config:{bits:588, lanes: 14, hspace:1050, compact: true, hflip: true }
}

Output:

bitfields_of_top_struct_t (1)

drom commented 2 years ago

LGTM

drom commented 2 years ago

merged you changes