From 1ea0519a2b6b81e0ba324cd69f8785735e7cbef5 Mon Sep 17 00:00:00 2001 From: Alejandro Soto Date: Tue, 8 Nov 2022 21:33:59 -0600 Subject: Fix handling of multi-cycle Avalon waitrequest states in bus master --- tb/mem.cpp | 10 ++++++++-- tb/mem.hpp | 3 +++ tb/sim/fibonacci.py | 2 +- tb/sim/sdram.py | 2 +- 4 files changed, 13 insertions(+), 4 deletions(-) (limited to 'tb') diff --git a/tb/mem.cpp b/tb/mem.cpp index bfbc3ea..6eeb7df 100644 --- a/tb/mem.cpp +++ b/tb/mem.cpp @@ -16,7 +16,7 @@ namespace taller::avalon bool mem::read(std::uint32_t addr, std::uint32_t &data) { data = block[addr]; - return true; + return ready(); } bool mem::write(std::uint32_t addr, std::uint32_t data, unsigned byte_enable) @@ -44,6 +44,12 @@ namespace taller::avalon } block[addr] = (data & bytes) | (block[addr] & ~bytes); - return true; + return ready(); + } + + bool mem::ready() noexcept + { + count = count > 0 ? count - 1 : 2; + return count == 0; } } diff --git a/tb/mem.hpp b/tb/mem.hpp index 016fdc0..a76780d 100644 --- a/tb/mem.hpp +++ b/tb/mem.hpp @@ -36,6 +36,9 @@ namespace taller::avalon std::unique_ptr block; std::uint32_t base; std::uint32_t mask; + unsigned count = 0; + + bool ready() noexcept; }; template diff --git a/tb/sim/fibonacci.py b/tb/sim/fibonacci.py index fb20b63..f8bec8a 100644 --- a/tb/sim/fibonacci.py +++ b/tb/sim/fibonacci.py @@ -1,7 +1,7 @@ BASE = 0x0001_0000 COUNT = 20 -cycles = 500 +cycles = 1024 mem_dumps = [range(BASE, BASE + 4 * COUNT)] def final(): diff --git a/tb/sim/sdram.py b/tb/sim/sdram.py index 2225941..fbc2c97 100644 --- a/tb/sim/sdram.py +++ b/tb/sim/sdram.py @@ -1,7 +1,7 @@ START = 0x0000_1000 END = 0x0000_2000 -cycles = 15000 +cycles = 30000 mem_dumps = [range(START, END)] def final(): -- cgit v1.2.3