[go: nahoru, domu]

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Encoding of IN with bit_count = 32 is incorrect #57

Closed
xeniarose opened this issue Mar 20, 2024 · 1 comment · Fixed by #58
Closed

Encoding of IN with bit_count = 32 is incorrect #57

xeniarose opened this issue Mar 20, 2024 · 1 comment · Fixed by #58

Comments

@xeniarose
Copy link

example

use pio::*;
use pio_proc::*;

fn main() {
    let sideset = SideSet::new(false, 0, false);

    let in_example_1 = InstructionOperands::IN {
        source: InSource::Y,
        bit_count: 32,
    }.encode();

    println!("example 1: {:?}", Instruction::decode(in_example_1, sideset));

    let in_example_2 = pio_asm!(
        "in y, 32"
    );

    println!("example 2: {:?}", Instruction::decode(in_example_2.program.code[0], sideset));
}

output

example 1: Some(Instruction { operands: IN { source: NULL, bit_count: 0 }, delay: 0, side_set: None })
example 2: Some(Instruction { operands: IN { source: NULL, bit_count: 0 }, delay: 0, side_set: None })

expected output should contain source: Y instead of source: NULL

the reason is incorrectly encoding the bit_count for IN with the value 32 at

InstructionOperands::IN { source, bit_count } => (*source as u8, *bit_count),

the correct behavior (*bit_count & 0b11111) is done for OUT, but not for IN

@jannic
Copy link
Member
jannic commented Mar 21, 2024

Thanks, @xeniarose, good catch!

jannic added a commit to jannic/pio-rs that referenced this issue Mar 21, 2024
Thanks to @xeniarose for finding and reporting this bug

Fixes rp-rs#57
9names pushed a commit to 9names/pio-rs that referenced this issue May 28, 2024
Thanks to @xeniarose for finding and reporting this bug

Fixes rp-rs#57
@jannic jannic closed this as completed in acd253c Aug 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants