Skip to content

Conversation

@ezelioli
Copy link
Contributor

@ezelioli ezelioli commented Nov 26, 2025

This PR replaces the timer unit module with an OBI-compliant implementation of the RISC-V Core Local Interrupt Controller (CLINT). The idea is to have a cleaner, more understandable implementation and a RISC-V compliant software stack to manage interrupts. In addition, a configurable number of simpler OBI timer units (e.g. adapted from PULP's APB timer) can be added in parallel and connected to custom external interrupt lines. Finally, this is intended to simplify the documentation of interrupt handling in Croc.

Checklist:

@ezelioli ezelioli marked this pull request as ready for review November 27, 2025 15:56
@ezelioli ezelioli requested a review from phsauter November 27, 2025 15:56
enable_d = enable_q;

// Reset count when timer expires
if (Autoreset && expired_o)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think Autoreset should be a software-setable register, not a parameter.

end

// Output assignment
assign expired_o = (compare_q != 32'h0 && compare_q <= count_q) ? 1'b1 : 1'b0;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure if I like that expired_o may trigger during configuration of the timer itself without it being enabled.
I would consider using something like ... ? enable_q : 1'b0.


// Output assignment
assign expired_o = (compare_q != 32'h0 && compare_q <= count_q) ? 1'b1 : 1'b0;
assign overflow_o = (count_q == 32'hffff_ffff) ? 1'b1 : 1'b0;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would consider using something like ... ? enable_q : 1'b0.
Should there be a sticky overflow register as well?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A sticky option would make sense depending on the type of interrupt handling.

Comment on lines +31 to +32
set_interrupt_enable(1, IRQ_TIMER);
set_global_irq_enable(1);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not a big fan of enabling interrupts in functions without the explicit knowledge of users. I think its better to 'clean up' at the end.

@phsauter
Copy link
Collaborator

phsauter commented Dec 4, 2025

Apart from the comments in the code there are two more questions:
Whats the impact of adding the interrupt table to minimum binary size?
Whats the timing impact of another peripheral below the periph mux?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants