Code Monkey home page Code Monkey logo

Comments (1)

HWoidt avatar HWoidt commented on August 20, 2024

Comment by HWoidt
Thursday Jan 21, 2016 at 15:32 GMT


This issue is a bit more involved than initially thought:

There is a simulation mismatch between Haskell and VHDL concerning the Integer types:

  • Haskell: Native Int8,Int16,... have traditional wrap-around semantics
  • VHDL: Integers will not wrap around (-128 -1 = -129 which is not a valid Integer value)

For this specific example, the bug originates in the fact, that all processes are executed once initially. That way the nextState function is called once with the initial value of the delayOut signal, and not with the one assigned by the reset statement (if reset then delay = 0...).

This nextState function is not formally correct VHDL as it produces an invalid output for the valid (although not normally attainable) input of -128. This specific input value is the default initial value for the Integer type.

There are some options for solving this:

  1. Fix the simulation mismatch: Implement the Int8 type using numeric_std.unsigned instead of Integer in VHDL. This has the correct semantics regarding the Haskell-Int8 type and would make this simulate correctly in this context.
  2. Fix the initial values of all signals connected to the delay element. This would need to have some way of tracing the netlist and catch all the important signals.
  3. fix the example to behave correctly for out-of range values less then 0 (which doesn't solve the underlying issue):
nextStateFun = $(newProcFun
   [d| nextState state dir
          = if dir == H then
              if state < 9 then state + 1
              else 0
            else
              if state <= 0 then 9
              else state - 1
     |])

I currently have no estimate of the amount of work needed for either 1. or 2.

from forsyde-deep.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.