<commit_before>use byteorder::{BigEndian, ByteOrder};

pub const PIF_ROM_START: u32 = 0x0000;
pub const PIF_ROM_END: u32 = 0x07bf;
pub const PIF_RAM_SIZE: usize = 0x40;
pub const PIF_RAM_START: u32 = 0x07c0;
pub const PIF_RAM_END: u32 = PIF_RAM_START + (PIF_RAM_SIZE as u32) - 1;

pub struct Pif {
    rom: Box<[u8]>,
    ram: Box<[u8]>,
}

impl Pif {
    pub fn new(pifrom: Box<[u8]>) -> Pif {
        Pif {
            rom: pifrom,
            ram: vec![0u8; PIF_RAM_SIZE].into_boxed_slice(),
        }
    }

    pub fn read(&self, addr: u32) -> u32 {
        match addr {
            PIF_ROM_START...PIF_ROM_END => {
                BigEndian::read_u32(&self.rom[(addr - PIF_ROM_START) as usize..])
            }
            PIF_RAM_START...PIF_RAM_END => {
                BigEndian::read_u32(&self.ram[(addr - PIF_RAM_START) as usize..])
            }
            _ => panic!("Address out of range"),
        }
    }

    pub fn write(&mut self, addr: u32, value: u32) {
        match addr {
            PIF_ROM_START...PIF_ROM_END => {
                panic!("Cannot write to PIF ROM");
            }
            PIF_RAM_START...PIF_RAM_END => {
                BigEndian::write_u32(&mut self.ram[(PIF_RAM_START) as usize..], value);
            }
            _ => {
                panic!("Address out of range");
            }
        }
    }
}<commit_msg>Fix error in writing to pif ram<commit_after>use byteorder::{BigEndian, ByteOrder};

pub const PIF_ROM_START: u32 = 0x0000;
pub const PIF_ROM_END: u32 = 0x07bf;
pub const PIF_RAM_SIZE: usize = 0x40;
pub const PIF_RAM_START: u32 = 0x07c0;
pub const PIF_RAM_END: u32 = PIF_RAM_START + (PIF_RAM_SIZE as u32) - 1;

pub struct Pif {
    rom: Box<[u8]>,
    ram: Box<[u8]>,
}

impl Pif {
    pub fn new(pifrom: Box<[u8]>) -> Pif {
        Pif {
            rom: pifrom,
            ram: vec![0u8; PIF_RAM_SIZE].into_boxed_slice(),
        }
    }

    pub fn read(&self, addr: u32) -> u32 {
        match addr {
            PIF_ROM_START...PIF_ROM_END => {
                BigEndian::read_u32(&self.rom[(addr - PIF_ROM_START) as usize..])
            }
            PIF_RAM_START...PIF_RAM_END => {
                BigEndian::read_u32(&self.ram[(addr - PIF_RAM_START) as usize..])
            }
            _ => panic!("Address out of range"),
        }
    }

    pub fn write(&mut self, addr: u32, value: u32) {
        match addr {
            PIF_ROM_START...PIF_ROM_END => {
                panic!("Cannot write to PIF ROM");
            }
            PIF_RAM_START...PIF_RAM_END => {
                BigEndian::write_u32(&mut self.ram[(addr - PIF_RAM_START) as usize..], value);
            }
            _ => {
                panic!("Address out of range");
            }
        }
    }
}
{'fraction_non_alphanumeric': 0.132486388384755, 'fraction_numerical': 0.032667876588021776, 'mean_word_length': 1.772635814889336, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7619198', 'n_tokens_mistral': 1076, 'n_tokens_neox': 1004, 'n_words': 207}