FPGA Intellectual Property
PCI Express*, Networking and Connectivity, Memory Interfaces, DSP IP, and Video IP
6343 Discussions

Multiply and Accumlate MF. Clearing the Accumulator

Altera_Forum
Honored Contributor II
1,238 Views

Hi, I am trying to take the dot product of a matrix row using the Multiply and Accumulate (MAC) megafunction. The problem is, even though I toggle the async_clear port at the end of every row, my accumulator never clears. I haven't tried holding it for a few clock cycles or using the accum_sload ports, but those paths don't seem to lead to a solution after re-reading the data sheets.  

 

So basically, my question is, how do I clear the accumulator portion of a MAC block? 

 

Thanks 

 

Matt
0 Kudos
4 Replies
Altera_Forum
Honored Contributor II
268 Views

Hi, 

 

I am using mulacc on CYCLONE IV. Because there is no DSP block on Cyclone IV but only HW multipliers , i have writen the accumulation part of the mulacc in vhdl. I fact my mulacc is a custom whdl compoenent... 

 

By the away if your are making a custom mulacc instruction for nios2 i am interested. 

 

 

good luck!
0 Kudos
Altera_Forum
Honored Contributor II
268 Views

A custom mulacc instruction would have to be a clocked (not combinatorial one) but is otherwise simple. 

If you only need/have a 32bit result it can be inconditionally latched as the instruction 'result' - use the writerc bit to stop the write into the register file. 

To avoid needing a second custom instruction to clear the accumulater, you could detect rA being zero (no point doing a mulacc with a fixed zero!). Or clear readra (and readrb) and use the 5bit rA as an opcode. 

A similar 'trick' could be used to read the high part of a 64bit result. 

 

I've actually wondered how much fpga 'real estate' a full multiplier takes. Having the option of a fast multiply (and/or the high 32bits of the product) on all processor families could be useful. The 64bit result is very useful for fixed point arithmetic and dividing by constants.
0 Kudos
Altera_Forum
Honored Contributor II
268 Views

Not that I have ever used that block but shouldn't you be using the accum_sload signal to clear the accumulator register??? From my quick read it seems like you would pulse it when you start on the next set of MAC operations since the multiplication result will load the accumulator register.

0 Kudos
Altera_Forum
Honored Contributor II
268 Views

Actually, the "aclear" port did the trick. For some reason, Quartus did not create a mux for me in the netlist. Not sure why, very aggrivating to find it though.  

 

Anyway, once I got the straightened out I was able to clear the MAC.
0 Kudos
Reply