pub struct Bitstream { /* private fields */ }
Expand description
ECP5 bitstream in-memory.
Can be loaded from a path or file, and modified as required to change IDCODE checks and SPI mode and frequency.
Implementations
sourceimpl Bitstream
impl Bitstream
sourcepub fn from_path<P: AsRef<Path>>(path: P) -> Result<Self>
pub fn from_path<P: AsRef<Path>>(path: P) -> Result<Self>
Open a bitstream from the provided path.
sourcepub fn from_file(file: &mut File) -> Result<Self>
pub fn from_file(file: &mut File) -> Result<Self>
Open a bitstream from the provided open File
.
sourcepub fn data(&self) -> &[u8]ⓘNotable traits for &[u8]impl Read for &[u8]impl Write for &mut [u8]
pub fn data(&self) -> &[u8]ⓘNotable traits for &[u8]impl Read for &[u8]impl Write for &mut [u8]
Get the underlying bitstream data.
sourcepub fn check_and_fix_idcode(
&mut self,
idcode: ECP5IDCODE,
fix: bool
) -> Result<()>
pub fn check_and_fix_idcode(
&mut self,
idcode: ECP5IDCODE,
fix: bool
) -> Result<()>
Check the provided IDCODE matches the IDCODE check in the bitstream.
If the bitstream does not contain an IDCODE check, no action is taken.
If the bitstream contains a compatible but different IDCODE, and fix
is true, a warning is logged and the bitstream is patched to idcode
.
If the bitstream contains an incompatible IDCODE, an error is logged and this method returns an error.
sourcepub fn remove_idcode(&mut self) -> Result<()>
pub fn remove_idcode(&mut self) -> Result<()>
Replace the VERIFY_ID command, if any, with NOOPs.
If the bitstream does not contain an IDCODE check, no action is taken.
sourcepub fn remove_spimode(&mut self) -> Result<()>
pub fn remove_spimode(&mut self) -> Result<()>
Replace the SPI_MODE command, if any, with NOOPs.
If the bitstream metadata parsing was not successful or no SPI_MODE command was found, no action is taken.