- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I'd like to implement the following calculation with a datapath:
t = (t0+t1)/2 * n, where n is set during runtime - it's not a constant that I could build into the state machine.
The first step is pretty simple and - as I understand it - can be done in one instruction:
preconditions: A0 = t0, A1 = t1, D1 = n
A0 = (A0+A1) >> 1 | 0
Now I can load n from D1, and need to get A0 into D0 so I can create a multiplication loop:
A1 = n
while A1 > 0:
A0 = A0+D0
A1--
How can I store A0 in D0? Or is there another way to do this calculation?
Edit: There are datapath inputs to load F0 with A0, and D0 with F0. is it possible to use these, wrapped in one state machine state that is executed twice? Maybe in single buffer mode?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Yes, you can. There is an input signal called d0_load. It loads A0 to D0.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I can't find it, neither in the datasheet nor in the datapath input confguration dialog. It only shows these:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
It might be easier to have the UDB trigger a DMA transfer from A0 to D0 and wait for that to finish before resuming the calculation, but that would introduce additional delay and uncertainty.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I'm sorry, actually the d0_load signal loads F0 to D0, which means you would need to load the ALU to F0 first, then F0 to D0. Using DMAs will take way longer.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Do you have an example of that? I guess the FIFO would need to be in single buffer mode (no problem in my application), but A0 -> F0 and F0 -> D0 have reversed FIFO direction. If that matters at all in single buffer mode, I don't know.
In the meantime I got it to work with DMA, as attached. So if we can replace the DMA transfer with something more straight forward, that'd be great.