-
Notifications
You must be signed in to change notification settings - Fork 41
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
Simulating write-before-read memory #11
Comments
There are 2 types of memory in Hardcaml - asynchronously read, and synchronously read. The former include the The synchronous ones are By synchronous we mean it takes 1 clock cycle to read the data. I dont think this issue is caused by the simulator, and I suspect the function you want exists as
That said you say:
That has to be the case for a synchronous read ram (there is a register in the read path - without that you are not describing a RAM that can be implemented on the FPGA). If what you want is an asynchronous read ram, but with write before read you will need to construct that by detecting this case outside the memory ie
|
Looking back over our implementation again, I forgot to mention that we made a tweak to
In particular, instead of using
And Vivado simulation confirmed that it can read/write as expected in the same clock cycle. |
Right. This is a limitation of the Hardcaml simulator. We only support the usual synchronous logic design pattern which implies only using one edge of the clock. It's actually probably not that hard for us to support both edges except
I still expect we can build something reasonable for a register file though.
|
Makes sense, thanks for the clarification! Would it make sense to add a comment discouraging falling edge use to edge.mli?
We initially planned to explicitly forward writeback => decode as a workaround. This is much neater, thanks! |
I will update the simulator documentation - this is not said explicitly enough there. |
Closing this out. There is some explicit new documentation for the simulator features and restrictions which will appear soon. |
We're running into a bit of trouble simulating our register file. We'd like to implement it as "write before read", so that we can write to a register in writeback and read from the same register in decode without needing to explicitly forward writeback => decode. By default, it looks like synchronous reads occur before writes.
ram_wbr
doesn't work because it only supports one read port. We're extended this to 2 read ports, and that works. We've confirmed so by generating RTL and simulating in Vivado.However, in our Hardcaml simulator tests, the written data is only read on the next cycle. My guess is that this occurs because Cyclesim only reads at the start of every clock cycle, and might be mitigated by reading at every clock edge. We haven't found configuration for evaluating the signal graph twice a cycle though. Is there support for simulating write-before-read memory in Hardcaml?
The text was updated successfully, but these errors were encountered: