Skip to content

Idea bit arrays #28

@NiJen

Description

@NiJen

I try to make a dataclass with not only byte size fields.
I have a 64bit word with the following structure:
8 Bits
4 Bits
8 Bits
8 Bits
1 Bit
7 Bits
16 bits
8 Bits
8 Bits

I try to create a dataclass but, I made something the wrong or did not have the right idea how to handle it, nothing works so far.

My idea is something like this:

class packet_header:
  header_length : dcs.U8 = field(default=0)
  data_width : dcs.UBits[4] = field(default=0)
  stream_type : dcs.U8 = field(default=0)
  sub_stream_type : dcs.U8 = field(default=0)
  crc : dcs.UBits[1] = field(default=False)
  pad : dcs.Ubits[3] = field(default=0, repr=False, init=False)
  point_packets : dcs.U16 = field(default=0)
  header_type : dcs.U8 = field(default=0)
  header_version : dcs.U8 = field(default=0)

So we have an array of bits, so we are not limited to the byte size?

Maybe this is possible?

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions