GithubHelp home page GithubHelp logo

zipcpu / wbi2c Goto Github PK

View Code? Open in Web Editor NEW
41.0 7.0 10.0 750 KB

Wishbone controlled I2C controllers

Makefile 6.95% C++ 22.32% C 1.33% Verilog 57.05% Shell 1.28% Lex 6.96% Assembly 0.33% Perl 3.22% HTML 0.55%
fpga verilator verilog wishbone-bus i2c-master i2c i2c-slave gplv3

wbi2c's Introduction

I2C Core(s)

This repository contains contains a couple of I2C cores. There's a basic, Wishbone accessible I2C master, as well as a basic Wishbone accessible I2C slave controller. Both work using a small piece of shared memory, which may be read or written to via the wishbone bus. Changes made to the slave's memory can be read/written by the I2C master when it chooses to make a transaction happen. With respect to the I2C master controller, changes made to the shared memory will require an explicit command in order to push those changes from the master to the slave, or for example to read them back from the slave.

Since writing those original basic controllers, I've now added an I2C CPU. This is really more of a scripted FSM than a full purpose CPU, however it does fit in nicely with many of the telemetry projects I'm dealing with. There are now two versions of this I2C CPU contained within this repository: a Wishbone version and an AXI-Lite version. Other than the bus implementation (and possibly any bus induced endianness issues), the two should be compatible at the software level.

The Slave Core

The basic I2C slave core acts as a simple two port memory interface to 128 octets of memory. The first port may be accessed via a 32-bit Wishbone bus. The second port may be accessed via an I2C bus, where this core sits as a slave. Both ports may read or written at the same time, and the core properly sets the wishbone stall line on any collision, so as to arbitrate who gets to write.

The Master Core

The wishbone master core has been used successfully to query monitors for their EDID information. This also acts as a memory. Given a command, the memory will be written to or read from the slave.

Sadly, this core is tied to an I2C device requiring a specific command format: I2C ADDR, SLV ADDR, SEND data, or I2C ADDR, READ data. Devices that have either no address, or a two byte address, will not work with this particular master--although they can still be queried by the CPU following.

The I2C CPU

This module works by following an externally provided script describing its interaction. This script can either be provided via a bus slave port, or it can be read from external memory, using either Wishbone or AXI-lite bus protocols. The script contains commands that will then be fed to the I2C controller within. Specific commands include sending a START condition, STOP condition, particular bytes or data, or reading bytes of data. Other commands, such as repeating a sequence or halting, are also available to control the instruction handler. The full command list can be found here, and its (most recent) documentation may be found here.

A small assembler exists in the SW/ directory which can either assemble a given script or disassemble such a script. Run "make test" in the sw/ directory to build this assembler, assemble a test "program", and then to disassemble it back to its component instructions for verification purposes.

The output of this CPU is an AXI stream containing all of the bytes that have been read from the interface while following the script.

Status

Both the slave and master controllers have been tested as part of the EDID support to (now) multiple video applications.

The I2C CPU has also proven itself valuable for both temperature reading (and monitoring), EDID handling, DDR3 configuration reading, SFP+ configuration reading, Si5324 controlling, and I2C OLED control. Example software may be found here. The demonstration control scripts, linked above, also included commands for a TCA9548 I2C hub, used for deconflicting the I2C addresses of multiple (otherwise identical) I2C devices.

An external Wishbone DMA also exists, to put data read from this controller into memory. That DMA has yet to be integrated into this repository. An AXI-Lite version of this DMA is also planned, but not yet built.

The biggest item missing from this repository at present is a good specification for these IP components.

Bottom line: this IP has been such a success, that it is likely to be used in multiple projects going forward.

License

Gisselquist Technology is pleased to offer this core to all who are interested, subject to the GPLv3 license.

Commercial Opportunities

If the GPLv3 license is insufficient for your needs, other licenses may be purchased from Gisselquist Technology, LLC.

wbi2c's People

Contributors

john-k avatar zipcpu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

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.