+ Post New Thread
Results 1 to 12 of 12
  1. #1
    Member level 5
    Points: 1,138, Level: 7

    Join Date
    Jan 2016
    Posts
    86
    Helped
    0 / 0
    Points
    1,138
    Level
    7

    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. #2
    Advanced Member level 5
    Points: 38,138, Level: 47
    Achievements:
    7 years registered

    Join Date
    Jun 2010
    Posts
    6,907
    Helped
    2030 / 2030
    Points
    38,138
    Level
    47

    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.



    •   AltAdvertisement

        
       

  3. #3
    Super Moderator
    Points: 263,619, Level: 100
    Awards:
    1st Helpful Member

    Join Date
    Jan 2008
    Location
    Bochum, Germany
    Posts
    45,996
    Helped
    13987 / 13987
    Points
    263,619
    Level
    100

    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.



    •   AltAdvertisement

        
       

  4. #4
    Member level 5
    Points: 1,138, Level: 7

    Join Date
    Jan 2016
    Posts
    86
    Helped
    0 / 0
    Points
    1,138
    Level
    7

    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?



    •   AltAdvertisement

        
       

  5. #5
    Member level 5
    Points: 1,138, Level: 7

    Join Date
    Jan 2016
    Posts
    86
    Helped
    0 / 0
    Points
    1,138
    Level
    7

    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
    Last edited by FvM; 9th December 2019 at 09:12. Reason: Merged with previous closely related thread



  6. #6
    Super Moderator
    Points: 263,619, Level: 100
    Awards:
    1st Helpful Member

    Join Date
    Jan 2008
    Location
    Bochum, Germany
    Posts
    45,996
    Helped
    13987 / 13987
    Points
    263,619
    Level
    100

    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. #7
    Full Member level 3
    Points: 1,254, Level: 8
    FlyingDutch's Avatar
    Join Date
    Dec 2017
    Location
    Bydgoszcz - Poland
    Posts
    166
    Helped
    21 / 21
    Points
    1,254
    Level
    8

    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!
    Last edited by FlyingDutch; 9th December 2019 at 15:43.



  8. #8
    Advanced Member level 1
    Points: 2,576, Level: 11

    Join Date
    Jan 2019
    Posts
    471
    Helped
    121 / 121
    Points
    2,576
    Level
    11

    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
    Last edited by wwfeldman; 9th December 2019 at 15:34.



  9. #9
    Full Member level 3
    Points: 1,254, Level: 8
    FlyingDutch's Avatar
    Join Date
    Dec 2017
    Location
    Bydgoszcz - Poland
    Posts
    166
    Helped
    21 / 21
    Points
    1,254
    Level
    8

    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. #10
    Super Moderator
    Points: 263,619, Level: 100
    Awards:
    1st Helpful Member

    Join Date
    Jan 2008
    Location
    Bochum, Germany
    Posts
    45,996
    Helped
    13987 / 13987
    Points
    263,619
    Level
    100

    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. #11
    Super Moderator
    Points: 31,928, Level: 43
    ads-ee's Avatar
    Join Date
    Sep 2013
    Location
    USA
    Posts
    7,389
    Helped
    1732 / 1732
    Points
    31,928
    Level
    43

    Re: Solve Equations Verilog

    Quote Originally Posted by FvM View Post
    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.



    •   AltAdvertisement

        
       

  12. #12
    Full Member level 3
    Points: 1,254, Level: 8
    FlyingDutch's Avatar
    Join Date
    Dec 2017
    Location
    Bydgoszcz - Poland
    Posts
    166
    Helped
    21 / 21
    Points
    1,254
    Level
    8

    Re: Solve Equations Verilog

    [QUOTE=FlyingDutch;1668061]
    Quote Originally Posted by FlyingDutch View Post

    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



--[[ ]]--