Skip to content

Commit

Permalink
clean up, simulate sdram
Browse files Browse the repository at this point in the history
  • Loading branch information
vk2seb committed Sep 23, 2023
1 parent c297f7a commit 236a72e
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 17 deletions.
22 changes: 8 additions & 14 deletions firmware/litex-fw/src/log.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use litex_pac as pac;
use litex_hal::prelude::*;
use litex_hal::uart::UartError;
use core::arch::asm;
use crate::BUF_IN_CP;
use crate::{BUF_IN, BUF_IN_CP};
use core::sync::atomic::fence;
use core::sync::atomic::compiler_fence;
use core::sync::atomic::Ordering;
Expand Down Expand Up @@ -51,35 +51,29 @@ fn default_handler() {

let peripherals = unsafe { pac::Peripherals::steal() };
if (pending & (1u32 << pac::Interrupt::DMA_WRITER0 as u32)) != 0 {
let pending_type = peripherals.DMA_WRITER0.ev_pending.read().bits();
let offset = peripherals.DMA_WRITER0.offset.read().bits();
//info!("dmaw0 {:x} {:x}", pending_type, offset);
unsafe {
peripherals.DMA_WRITER0.ev_pending.write(|w| w.bits(pending_type));
}

let mut buf_copy: [u32; 0x10] = [0; 0x10];
let base = peripherals.DMA_WRITER0.base0.read().bits();
let buf = base as *const u32;

fence(Ordering::Release);
compiler_fence(Ordering::Release);

if offset == 0x10 {
for i in 0..0x10 {
unsafe {
BUF_IN_CP[i] = *buf.add(i);
BUF_IN_CP[i] = BUF_IN[i];
}
}
}

if offset == 0x1f {
for i in 0x10..0x20 {
unsafe {
BUF_IN_CP[i] = *buf.add(i);
BUF_IN_CP[i] = BUF_IN[i];
}
}
}

let pending_type = peripherals.DMA_WRITER0.ev_pending.read().bits();
unsafe {
peripherals.DMA_WRITER0.ev_pending.write(|w| w.bits(pending_type));
}
}

if (pending & (1u32 << pac::Interrupt::DMA_READER0 as u32)) != 0 {
Expand Down
2 changes: 1 addition & 1 deletion firmware/litex-fw/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ fn main() -> ! {

}
}
timer.delay_ms(10u32);
/*
log::info!("jack_detect {:x}", peripherals.EURORACK_PMOD0.csr_jack.read().bits() as u8);
log::info!("input0 {}", peripherals.EURORACK_PMOD0.csr_cal_in0.read().bits() as i16);
Expand All @@ -95,7 +96,6 @@ fn main() -> ! {
log::info!("input3 {}", peripherals.EURORACK_PMOD0.csr_cal_in3.read().bits() as i16);
log::info!("serial {:x}", peripherals.EURORACK_PMOD0.csr_eeprom_serial.read().bits() as u32);
timer.delay_ms(10u32);
log::info!("tick - elapsed {} msec", (elapsed * 1000.0) as u32);
elapsed += 0.01f32;
*/
Expand Down
4 changes: 2 additions & 2 deletions nominal.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ set -e

# SVD only
echo "Generate SVD"
./sim.py --integrated-main-ram-size=0x10000 --cpu-type vexriscv --cpu-variant imac --csr-svd build/sim/csr.svd --no-compile-gateware
./sim.py --with-sdram --cpu-type vexriscv --cpu-variant imac --csr-svd build/sim/csr.svd --no-compile-gateware
# FW only
echo "Build FW"
cd firmware
OBJCOPY=riscv64-linux-gnu-objcopy BOARD=sim ./build.sh
cd ..
# Boot firmware after BIOS
echo "Simulate GW+FW"
./sim.py --integrated-main-ram-size=0x10000 --ram-init build/sim/rust-fw.bin --cpu-type vexriscv --cpu-variant imac
./sim.py --with-sdram --sdram-init build/sim/rust-fw.bin --cpu-type vexriscv --cpu-variant imac

0 comments on commit 236a72e

Please sign in to comment.