bitstream

package
v0.23.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 23, 2021 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// OpenCLUUID is a special AFU UUID that is used for all OpenCL BSP based FPGA bitstreams.
	OpenCLUUID = "18b79ffa2ee54aa096ef4230dafacb5f"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Bitstream

type Bitstream struct {
	// Embed ReaderAt for ReadAt method.
	// Do not embed SectionReader directly
	// to avoid having Read and Seek.
	// If a client wants Read and Seek it must use
	// Open() to avoid fighting over the seek offset
	// with other clients.
	io.ReaderAt

	// embed common bitstream interfaces
	File

	Size uint64
	// contains filtered or unexported fields
}

A Bitstream represents a raw bitsream data (RBF) in the GBS binary.

func (*Bitstream) Data

func (b *Bitstream) Data() ([]byte, error)

Data reads and returns the contents of the bitstream.

func (*Bitstream) Open

func (b *Bitstream) Open() io.ReadSeeker

Open returns a new ReadSeeker reading the bitsream body.

type File

type File interface {
	io.Closer
	// RawBitstreamReader returns Reader for raw bitstream data
	RawBitstreamReader() io.ReadSeeker
	// RawBitstreamData returns raw bitstream byte array
	RawBitstreamData() ([]byte, error)
	// InterfaceUUID returns bitstream's Interface UUID
	InterfaceUUID() string
	// AcceleratorTypeUUID returns bitstream's AFU UUID
	AcceleratorTypeUUID() string
	// UniqueUUID returns UUID that uniquely identifies bitstream
	UniqueUUID() string
	// InstallPath returns unique filename for bitstream relative to given directory
	InstallPath(string) string
	// ExtraMetadata returns map of key/value with additional metadata that can be detected from bitstream
	ExtraMetadata() map[string]string
}

File defines interfaces that are common for all supported bitstream file formats It should provide mechanisms to get raw bitstream data as a reader or as a byte array as well as mechanisms to identify bitstreams.

func GetFPGABitstream

func GetFPGABitstream(bitstreamDir, region, afu string) (File, error)

GetFPGABitstream scans bitstream storage and returns first found bitstream by region and afu id.

func Open

func Open(fname string) (File, error)

Open bitstream file, detecting type based on the filename extension.

type FileAOCX

type FileAOCX struct {
	GBS *FileGBS

	// embed common bitstream interfaces
	File
	AutoDiscovery          string
	AutoDiscoveryXML       string
	Board                  string
	BoardPackage           string
	BoardSpecXML           string
	CompilationEnvironment string
	Hash                   string
	KernelArgInfoXML       string
	QuartusInputHash       string
	QuartusReport          string
	Target                 string
	Version                string
	// contains filtered or unexported fields
}

A FileAOCX represents an open AOCX file.

func NewFileAOCX

func NewFileAOCX(r io.ReaderAt) (*FileAOCX, error)

NewFileAOCX creates a new File for accessing an ELF binary in an underlying reader. The ELF binary is expected to start at position 0 in the ReaderAt.

func OpenAOCX

func OpenAOCX(name string) (*FileAOCX, error)

OpenAOCX opens the named file using os.Open and prepares it for use as GBS.

func (*FileAOCX) AcceleratorTypeUUID

func (f *FileAOCX) AcceleratorTypeUUID() (ret string)

AcceleratorTypeUUID returns underlying GBS AFU ID.

func (*FileAOCX) Close

func (f *FileAOCX) Close() (err error)

Close closes the FileAOCX. If the FileAOCX was created using NewFileAOCX directly instead of Open, Close has no effect.

func (*FileAOCX) ExtraMetadata

func (f *FileAOCX) ExtraMetadata() map[string]string

ExtraMetadata returns map of key/value with additional metadata that can be detected from bitstream.

func (*FileAOCX) InstallPath

func (f *FileAOCX) InstallPath(root string) (ret string)

InstallPath returns unique filename for bitstream relative to given directory.

func (*FileAOCX) InterfaceUUID

func (f *FileAOCX) InterfaceUUID() (ret string)

InterfaceUUID returns underlying GBS InterfaceUUID.

func (*FileAOCX) RawBitstreamData

func (f *FileAOCX) RawBitstreamData() ([]byte, error)

RawBitstreamData returns raw bitstream data.

func (*FileAOCX) RawBitstreamReader

func (f *FileAOCX) RawBitstreamReader() io.ReadSeeker

RawBitstreamReader returns Reader for raw bitstream data.

func (*FileAOCX) UniqueUUID

func (f *FileAOCX) UniqueUUID() string

UniqueUUID represents the unique field that identifies bitstream. For AOCX it is the unique Hash in the header.

type FileGBS

type FileGBS struct {
	Bitstream *Bitstream

	Metadata Metadata
	Header
	// contains filtered or unexported fields
}

FileGBS represents an open GBS file.

func NewFileGBS

func NewFileGBS(r bitstreamReader) (*FileGBS, error)

NewFileGBS creates a new FileGBS for accessing an ELF binary in an underlying reader. The ELF binary is expected to start at position 0 in the ReaderAt.

func OpenGBS

func OpenGBS(name string) (*FileGBS, error)

OpenGBS opens the named file using os.Open and prepares it for use as GBS.

func (*FileGBS) AcceleratorTypeUUID

func (f *FileGBS) AcceleratorTypeUUID() (ret string)

AcceleratorTypeUUID returns list of normalized AFU UUID from the metadata. Empty string returned in case of errors in Metadata.

func (*FileGBS) Close

func (f *FileGBS) Close() (err error)

Close closes the FileGBS. If the FileGBS was created using NewFileGBS directly instead of Open, Close has no effect.

func (*FileGBS) ExtraMetadata

func (f *FileGBS) ExtraMetadata() map[string]string

ExtraMetadata returns map of key/value with additional metadata that can be detected from bitstream.

func (*FileGBS) InstallPath

func (f *FileGBS) InstallPath(root string) (ret string)

InstallPath returns unique filename for bitstream relative to given directory.

func (*FileGBS) InterfaceUUID

func (f *FileGBS) InterfaceUUID() string

InterfaceUUID returns normalized Metadata.AfuImage.InterfaceUUID.

func (*FileGBS) RawBitstreamData

func (f *FileGBS) RawBitstreamData() ([]byte, error)

RawBitstreamData returns raw bitstream data.

func (*FileGBS) RawBitstreamReader

func (f *FileGBS) RawBitstreamReader() io.ReadSeeker

RawBitstreamReader returns Reader for raw bitstream data.

func (*FileGBS) UniqueUUID

func (f *FileGBS) UniqueUUID() string

UniqueUUID represents the unique field that identifies bitstream. For GBS it is the AFU ID.

type Header struct {
	GUID1          uint64
	GUID2          uint64
	MetadataLength uint32
}

Header represents header struct of the GBS file.

type Metadata

type Metadata struct {
	PlatformName string `json:"platform-name,omitempty"`
	AfuImage     struct {
		InterfaceUUID   string `json:"interface-uuid,omitempty"`
		AfuTopInterface struct {
			Class       string `json:"class"`
			ModulePorts []struct {
				Params struct {
					Clock string `json:"clock,omitempty"`
				} `json:"params"`
				Class    string `json:"class,omitempty"`
				Optional bool   `json:"optional,omitempty"`
			} `json:"module-ports,omitempty"`
		} `json:"afu-top-interface"`
		ClockFrequencyHigh  interface{} `json:"clock-frequency-high,omitempty"`
		ClockFrequencyLow   interface{} `json:"clock-frequency-low,omitempty"`
		AcceleratorClusters []struct {
			AcceleratorTypeUUID string `json:"accelerator-type-uuid"`
			Name                string `json:"name"`
			TotalContexts       int    `json:"total-contexts"`
		} `json:"accelerator-clusters"`
		MagicNo int `json:"magic-no,omitempty"`
		Power   int `json:"power"`
	} `json:"afu-image"`
	Version int `json:"version"`
}

Metadata represents parsed JSON metadata of GBS file.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL