Compute-in-memory LUT-based multiply-add apparatus
A multiply-accumulate (MAC) device for compute-in-memory (CIM) includes an input driver configured to provide a plurality of input signals including a first input signal and a second input signal. A lookup table (LUT) stores or accesses a plurality of CIM weight signals including a first CIM weight signal and a second CIM weight signal. The LUT is configured to receive the first input signal and the second input signal and provide a sum output based on the first and second input signals and the first and second CIM weight signals.
1 . A multiply-accumulate (MAC) device for compute-in-memory (CIM), comprising:
an input driver configured to provide a plurality of input signals including a first input signal, and a second input signal, a third input signal and a fourth input signal;
a first MAC stage first lookup table (LUT) storing a plurality of CIM weight signals including a first CIM weight signal and a second CIM weight signal, the first MAC stage first LUT configured to receive the first input signal and the second input signal and provide a first sum output based on the first and second input signals and the first and second CIM weight signals;
a first MAC stage second LUT storing the plurality of CIM weight signals including the first CIM weight signal and the second CIM weight signal, the first MAC stage second LUT configured to receive the third input signal and the fourth input signal and provide a second sum output based on the third and fourth input signals and the first and second CIM weight signals; and
a second MAC stage including a second MAC stage LUT, the second MAC stage LUT connected to receive the first sum outputs of the first MAC stage first LUT and the second sum outputs of the first MAC stage second LUT.
2 . The device of claim 1 , wherein the plurality of input signals are determined according to a type of an application, and wherein the plurality of CIM weight signals are determined according to a training result or a configuration of a user.
3 . The device of claim 1 , wherein the LUT includes an adder configured to add the first CIM weight signal and the second CIM weight signal, wherein the LUT is configured to provide one of an output of the adder or a static data signal as the sum output based on the first and second input signals.
4 . The device of claim 1 , wherein the LUT includes an adder configured to add the first CIM weight signal and the second CIM weight signal, wherein the LUT is configured to:
provide an output of the adder as the sum output based on a first state of the first and second input signals;
provide the first CIM weight signal as the sum output based on a second state of the first and second input signals;
provide the second CIM weight signal as the sum output based on a third state of the first and second input signals; and
provide a predetermined signal as the sum output based on a fourth state of the first and second input signals.
5 . The device of claim 4 , wherein the LUT further comprises:
a multiplexer (MUX) including:
a first input terminal connected to receive the output of the adder;
a second input terminal connected to receive the first CIM weight signal;
a third input terminal connected to receive the second CIM weight signal;
a fourth input terminal connected to receive the predetermined signal;
an output terminal configured to output the sum output;
wherein the MUX is configured to output one of the output of the adder, the first CIM weight signal, the second CIM weight signal, or the predetermined signal at the output terminal in response to the first input signal and the second input signal.
6 . The device of claim 1 , wherein the LUT is configured to store a first group of CIM weight signals including the first CIM weight signal and a second group of CIM weight signals including the second CIM weight signal, and wherein the LUT is configured to provide a plurality of sum outputs including the sum output based on the first and second input signals and the first and second groups of CIM weight signals.
7 . The device of claim 6 , wherein each of the plurality of first CIM weight signals is a corresponding bit of an n bit first CIM weight, where n is a positive integer, and wherein each of the plurality of second CIM weight signals is a corresponding bit of an n bit second CIM weight.
8 . The device of claim 1 , wherein:
the second MAC stage LUT includes a second MAC stage adder configured to add the first sum output by the first MAC stage first LUT and the second sum output by the first MAC stage second LUT;
the second MAC stage LUT is configured to provide an output of the second MAC stage adder or provide a static data signal as a second MAC stage sum output based on the first, second, third, and fourth input signals.
9 . The device of claim 8 , further comprising:
a second MAC stage MUX including:
a first input terminal connected to receive the output of the second MAC stage adder;
a second input terminal connected to receive the sum output by the first MAC stage first LUT adder;
a third input terminal connected to receive the sum output by the first MAC stage second LUT adder;
a fourth input terminal connected to receive the predetermined data signal;
an output terminal configured to provide the second MAC stage sum output;
a first select input configured to receive a sum of the first and second input signals; and
a second select input configured to receive a sum of the third and fourth input signals.
10 . A multiply-accumulate (MAC) device for compute-in-memory (CIM), comprising:
a first MAC stage including a first lookup table (LUT) and a first adder, and configured to receive first and second CIM weight signals and to provide one of an output of the first adder or a first static data signal as a first MAC stage first sum output based on first and second input signals;
the first MAC stage including a second LUT and a second adder and configured to receive third and fourth CIM weight signals, the first MAC stage second LUT configured to provide one of an output of the second adder or a second static data signal as a first MAC stage second sum output based on third and fourth input signals; and
a second MAC stage including a LUT configured to receive the first MAC stage first and second sum outputs, the second MAC stage LUT including a third adder and configured to provide one of an output of the third adder or a third static data signal as a second MAC stage sum output based on first, second, third and fourth input signals.
11 . The device of claim 10 , wherein the first static data signal includes one of the first CIM weight signal, the second CIM weight signal and 0, and wherein the second static data signal includes one of the third input signal, the fourth input signal and 0.
12 . The device of claim 11 , wherein the first MAC stage includes:
a first MAC stage first multiplexer (MUX) including:
a first input terminal connected to receive the output of the first adder;
a second input terminal connected to receive the first CIM weight signal;
a third input terminal connected to receive the second CIM weight signal;
a fourth input terminal connected to receive the 0;
an output terminal configured to output the first MAC stage first sum output;
wherein the first MAC stage first MUX is configured to output one of the output of the first adder, the first CIM weight signal, the second CIM weight signal, or the 0 at the output terminal in response to the first input signal and the second input signal; and
a first MAC stage second MUX including:
a first input terminal connected to receive the output of the second adder;
a second input terminal connected to receive the third CIM weight signal;
a third input terminal connected to receive the fourth CIM weight signal;
a fourth input terminal connected to receive the 0;
an output terminal configured to output the first MAC stage second sum output;
wherein the first MAC stage second MUX is configured to output one of the output of the second adder, the third CIM weight signal, the fourth CIM weight signal, or the 0 at the output terminal in response to the third input signal and the fourth input signal.
13 . The device of claim 10 , wherein the third static data signal includes one of the first MAC stage first sum output, the first MAC stage second sum output and 0.
14 . The device of claim 13 , wherein the second MAC stage includes:
a second MAC stage MUX including:
a first input terminal connected to receive the output of the third adder;
a second input terminal connected to receive the first MAC stage first sum output;
a third input terminal connected to receive the first MAC stage second sum output;
a fourth input terminal connected to receive the 0;
an output terminal configured to output the second MAC stage sum output;
wherein the second MAC stage MUX is configured to output one of the output of the third adder, the first MAC stage first sum output, the first MAC stage second sum output, or the 0 at the output terminal in response to the sum of the first input signal and the second input signal and the sum of the third input signal and the fourth input signal.
15 . A method, comprising:
receiving a first input signal by a lookup table (LUT);
receiving a second input signal by the LUT;
receiving a first CIM weight signal by the LUT;
receiving a second CIM weight signal by the LUT;
determining a sum of the first CIM weight signal and the second CIM weight signal by an adder;
outputting one of the sum of the first CIM weight signal and the second CIM weight signal or a static data signal in response to the first and second weight signals.
16 . The method of claim 15 , wherein outputting the static data signal includes outputting one of the first CIM weight signal, the second CIM weight signal, and a predetermined signal.
17 . The method of claim 16 , wherein the first and second input signals are received by a multiplexer (MUX) connected to an output of the adder, and wherein the MUX is configured to output one of the output of the adder, the first CIM weight signal, the second CIM weight signal, or the predetermined signal in response to the first and second input signals.
18 . The method of claim 17 , further comprising:
determining the first and second input signals according to a type of an application; and
determining the first and second CIM weight signals according to a training result or a configuration of a user.
19 . The method of claim 16 , further comprising:
outputting the sum of the first CIM weight signal and the second CIM weight signal in response to a first state of the first and second input signals;
outputting the first CIM weight signal in response to a second state of the first and second input signals;
outputting the second CIM weight signal in response to a third state of the first and second input signals; and
outputting the predetermined signal in response to a fourth state of the first and second input signals.
20 . The method of claim 15 , wherein the one of the sum of the first CIM weight signal and the second CIM weight signal or the static data signal are output by a multiplexer (MUX).