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

Ask a question related to Ibex #2222

Open
kalabYibeltal opened this issue Nov 12, 2024 · 3 comments
Open

Ask a question related to Ibex #2222

kalabYibeltal opened this issue Nov 12, 2024 · 3 comments
Labels
Type:Question Questions

Comments

@kalabYibeltal
Copy link

I tried running Ibex small configuration with different workload by turning the Icache parameter on and off (assigning it 0 and 1) this is what I got in the Simulation statistics

Without Cache

Simulation statistics

Executed cycles: 167525
Wallclock time: 8.708 s
Simulation speed: 19238.1 cycles/s (19.2381 kHz)
Trace file size: 5758073 B

With cache

Simulation statistics

Executed cycles: 167525
Wallclock time: 14.255 s
Simulation speed: 11752 cycles/s (11.752 kHz)
Trace file size: 7273683 B

I tested it with different workloads and different configurations available in ibex. it seems like the Executed cycles should be smaller if a cache exists. On top of that it seems the wallclock time takes longer for a configuration with cache.

I also tried decreasing the clock from 0.5 to 0.05 in ibex_simple_system.sv but still the Executed cycles do not change.

My Environment

I am using wsl on windows and I am running ibex simple system on bare metal
I am using ubuntu Ubuntu 22.04.4 LTS

EDA tool and version:

Operating system:

Version of the Ibex source code:

@kalabYibeltal kalabYibeltal added the Type:Question Questions label Nov 12, 2024
@a-will
Copy link

a-will commented Nov 12, 2024

Did you actually enable the cache in software? The Verilog parameter affects whether the cache is present in hardware. The default state of the CPU still leaves the cache inactive.

https://ibex-core.readthedocs.io/en/latest/03_reference/cs_registers.html#cpu-control-and-status-register-cpuctrlsts

@kalabYibeltal
Copy link
Author

Did you actually enable the cache in software? The Verilog parameter affects whether the cache is present in hardware. The default state of the CPU still leaves the cache inactive.

https://ibex-core.readthedocs.io/en/latest/03_reference/cs_registers.html#cpu-control-and-status-register-cpuctrlsts

Yes, I manually passed 1b'1 values to the initialization of the Icache of for ibex_top.sv before I build it and also I checked ibex_icache is being instantiated by printing values in the ibex_icache.sv file

@GregAC
Copy link
Collaborator

GregAC commented Nov 22, 2024

Enabling the icache requires a specific bit to be set by software in the CPUCTRLSTS CSR. We have a function that can enable/disable it:

* Enables/disables the instruction cache. This has no effect on Ibex
* configurations that do not have an instruction cache and in particular is
* safe to execute on those configurations.
*
* @param enable if non-zero enables, otherwise disables
*/
static inline void icache_enable(int enable) {
if (enable) {
// Set icache enable bit in CPUCTRLSTS
asm volatile("csrs 0x7c0, 1");
} else {
// Clear icache enable bit in CPUCTRLSTS
asm volatile("csrc 0x7c0, 1");
}
}

Also note that in simple system the memory is dual ported with single cycle response (i.e. the most ideal possible memory from a performance perspective) and the icache won't actually have an effect. Indeed you may observe a small decrease in performance. The icache is useful in scenarios where a fetch from instruction memory can take multiple cycles (e.g. if you're fetching from flash).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type:Question Questions
Projects
None yet
Development

No branches or pull requests

3 participants