Giter VIP home page Giter VIP logo

gray-code's Introduction

Gray code

Build Status

SystemVerilog code for generating a Gray code of arbitrary width.

Why?

I needed an efficient, easy way to generate gray codes for dual clock FIFOs. It's a pain to manually write out a gray code. Why not let a module do the heavy lifting for you?

Usage

  1. Take files from src/ and add them to your own project. If you use hdlmake, you can add this repository itself as a remote module.
  2. Other helpful modules are also available in this GitHub organization.
  3. Consult the testbench in test/gray_code_tb.sv for example usage.
  4. Read through the parameter descriptions in gray_code.sv and tailor any instantiations to your situation.
  5. Please create an issue if you run into a problem or have any questions.

To-do List

gray-code's People

Contributors

sameer avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

jankcorn

gray-code's Issues

Balanced gray codes

There are methods to produce balanced gray codes: gray codes where the transitions of each bit are evenly distributed across the mapping.

Wikipedia entry describes it better in more concrete mathematical terms.

One algorithm I thought of:

  • Generate a gray code hypercube -- a graph where each vertex is a binary code, and it is connected to all vertices which are 1 bit different (i.e. for bit width of 4, there are 4 adjacent vertices to 0: 1, 2, 4, 8)
  • Find hamiltonian cycles in the graph
  • Check hamiltonian cycles for balance, pick the first balanced one

I read some papers about it, but I don't have an algorithm that would be simple enough to implement in SystemVerilog.

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.