Announcements

# Can a datapath ALU result be stored in D0?

## Can a datapath ALU result be stored in D0?

Level 4
Level 4

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?

6 Replies

## Re: Can a datapath ALU result be stored in D0?

Employee
Employee

Yes, you can. There is an input signal called d0_load. It loads A0 to D0.

## Re: Can a datapath ALU result be stored in D0?

Level 4
Level 4

I can't find it, neither in the datasheet nor in the datapath input confguration dialog. It only shows these:

Attachments are accessible only for community members.

## Re: Can a datapath ALU result be stored in D0?

Level 4
Level 4

I managed to copy ALUout to F0 at the end of the first calculation step (which is probably as fast and easy as it gets), but copying to D0 doesn't want to show the desired result. Current state of the experiment is attached.

## Re: Can a datapath ALU result be stored in D0?

Level 4
Level 4

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.

## Re: Can a datapath ALU result be stored in D0?

Employee
Employee

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.

Attachments are accessible only for community members.

## Re: Can a datapath ALU result be stored in D0?

Level 4
Level 4

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.