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

Feature request: frame counter accessible from HPS #84

Open
tonytoon opened this issue Jul 9, 2024 · 3 comments
Open

Feature request: frame counter accessible from HPS #84

tonytoon opened this issue Jul 9, 2024 · 3 comments

Comments

@tonytoon
Copy link

tonytoon commented Jul 9, 2024

How feasible would it to be to update a region of memory accessible from the HPS every time a core generates vblank?

It could be implemented as a simple counter that is incremented with every vblank and rolls over if it overflows. This would provide the HPS side with a timer that self adjusts to the core's speed.

As an example: autofire could be rewritten to simply trigger every x frames. The input loop would check the assigned memory address and if the value changes, it knows it's a new frame and acts accordingly. The need to check the system clock would be removed and the resulting code would be more maintainable.

I am willing to rewrite the existing autofire code in input.cpp to take advantage of this if it was implemented. I've mocked up a version that tries to calculate frame counts based on video timings from video.cpp but I know that's probably not a good way to do it.

I can't personally think of other uses but any HPS code that would benefit from synchronizing with the core's video output would have a much easier pathway to do it.

I've not touched vhdl/verilog since college or I'd submit a sample implementation myself. If this is a reasonable feature but out prioritized by other issues I may take a stab at it myself as a learning exercise.

@sorgelig
Copy link
Member

sorgelig commented Jul 9, 2024

Writing to memory from FPGA is very costly operation. It's impossible to write like in normal computer. You have to reserve a time on memory bus and then write it my some module.
So, I don't see a reason to waste so much resources for autofire which is already working fine.

@birdybro
Copy link
Member

birdybro commented Jul 9, 2024

Since the hdmi_config stuff was moved to Main_MiSTer isn't the vblank already captured on the ARM/HPS side, or is that just an approximation based on the pixel clock and other factors?

@sorgelig
Copy link
Member

sorgelig commented Jul 9, 2024

vblank can be captured in HPS, but again resources (in this context time resource) not worth the feature.

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

No branches or pull requests

3 participants