# Solve Equations Verilog

1. ## Solve Equations Verilog

Dear all,
I am trying to solve equation of a^7-2a^5-a^2 = -1. How can one implement this in verilog with minimum hardware?
TIA

2. ## Re: Solve Equations Verilog

A text editor will do. Vi will run on any linux, so you could probably just use a rasberry PI. You'll probably need some kind of screen and a keyboard.

•

3. ## Re: Solve Equations Verilog

The point is that the equation has no variable input, thus it can be calculated at compilation time and doesn't infer hardware.

The equation has however multiple (three or so) solutions, I'm not quite sure how you want to present it.

If you have a meaningful Verilog problem in mind, please share.

•

4. ## Re: Solve Equations Verilog

So i basically start with an initial guess for variable 'a'. Then i try to compute the equation substituting my initial guess for 'a'. The problem is, 'a' can take a decimal value. As in, if a = 2.187, then, how can one compute 2.187^7 -2*2.187^5-2.187^2 +1 in verilog?

•

5. ## Computing exponential in verilog

Dear all,

I have been trying to use exponential function in verilog. I want to calculate an expression like below.
Let x = 3.987
x^6 + x^8- x^5 = 10.

How can this be done in verilog?
TIA

6. ## Re: Solve Equations Verilog

It's power of n, not exponential function and can be calculated as cascaded multiply.

What do you want to achieve? The equation has multiple solutions, but can be calculated at compile time.

7. ## Re: Solve Equations Verilog

Hello,

maybe first famiiarize yourself with one of methods for approximation solving of nonlinear equations - for example Nwewton's method. See links:

https://en.wikipedia.org/wiki/Newton%27s_method

https://www.sciencedirect.com/scienc...10256X1300028X

After you read these descriptions and understood them, you could try to implement one of these method in Verilog.

Regards

BTW: this equotation is contrary and has not solutions ! Substitute 1 for a variable and check it yourself.

See: 1^7-2*1^5-1^2 = -1
1-2-1 =-1
-2=-1 -> equotqtions is contrary and has no solutions!

8. ## Re: Solve Equations Verilog

in post 1, its a^7, in post its x^6 ?

the number of roots is equal to the highest exponent, so 7 roots and 6 roots, receptively

if all you want is a solution, then use Wolfram Alpha
type in something like "what are the roots of a^7-2a^5-a^2 = -1"
enter, and wait a little while

when i did it, Wolfram Alpha provided 3 real roots and 4 more roots as complex conjugates
it took about 10 seconds

side issue: exponentials involve the base of the natural logs, such as e^x,
or the base of the common logs, such as 10^x
the variable is in the exponent

these equations are polynomials - the exponents are integers

9. ## Re: Solve Equations Verilog

[QUOTE=FlyingDutch;1668043]

BTW: this equotation is contrary and has not solutions ! Substitute 1 for a variable and check it yourself.

See: 1^7-2*1^5-1^2 = -1
1-2-1 =-1
-2=-1 -> equotqtions is contrary and has no solutions![/QUOTE

Sorry- English is not my mother tounge. It shouyld be: contradictory equotation

There is no point to solving these eqotation because it is contradictory, and has no solution.

Maybe you made mistake during writing this equotation if yes please give proper form of this eqotqtion.

Regards

10. ## Re: Solve Equations Verilog

this equotation is contrary and has not solutions ! Substitute 1 for a variable and check it yourself.
As shown by wwfeldmann, the post #1 equation has real roots. Similarly the equation in post #5 has two real roots, x=3.987 isn't among it, but x≈-1.2 and x≈1.3.

Post #1 suggests that you want to synthesize hardware logic to perform the calculation. But this is neither useful nor simple.

Firstly it's not useful because the solution is constant and can be calculated at compile time. You can however define a different problem involving variable coefficients as input. Then there's something to calculate at run time.

Secondly it's not simple because real variables aren't synthesisable in logic hardware. You can use either fixed or floating point variables for the calculation.

11. ## Re: Solve Equations Verilog

Originally Posted by FvM
As shown by wwfeldmann, the post #1 equation has real roots. Similarly the equation in post #5 has two real roots, x=3.987 isn't among it, but x≈-1.2 and x≈1.3.

Post #1 suggests that you want to synthesize hardware logic to perform the calculation. But this is neither useful nor simple.

Firstly it's not useful because the solution is constant and can be calculated at compile time. You can however define a different problem involving variable coefficients as input. Then there's something to calculate at run time.

Secondly it's not simple because real variables aren't synthesisable in logic hardware. You can use either fixed or floating point variables for the calculation.
I wonder if the OP wants to create an iterative algorithm to compute the real roots of a polynomial, i.e. enter the polynomial and the design computes the root(s).

One of the issues they seem to be struggling with is that A**B in verilog can't be synthesized unless B is a power of 2 (as that is just a shift operation). To implement an exponentiation of A you have to multiply A (B-1) times using an FSM for example.

•

12. ## Re: Solve Equations Verilog

[QUOTE=FlyingDutch;1668061]
Originally Posted by FlyingDutch

BTW: this equotation is contrary and has not solutions ! Substitute 1 for a variable and check it yourself.

See: 1^7-2*1^5-1^2 = -1
1-2-1 =-1
-2=-1 -> equotqtions is contrary and has no solutions![/QUOTE

Sorry- English is not my mother tounge. It shouyld be: contradictory equotation

There is no point to solving these eqotation because it is contradictory, and has no solution.

Maybe you made mistake during writing this equotation if yes please give proper form of this eqotqtion.

Regards
Sorry,

I did a mistake, some kind of brain fade

regards

--[[ ]]--