Overview

Pipelined I2C code

Modules

I2C Master

Parameters

Name Description
Address Address for the Slave.
PipeSpec specification of the data coming in and out of the module.
ClockCount Number of clock ticks for each bit (@ 48MHz for 400kbps, count is 48M/400K = 120 )

Ports

Name Direction Size Description
clock In 1 System clock
reset In 1 System reset
slave_address In n Slave Address , -1 if in-pipe instead
read_count In n+1 Words to read, -1 if in-pipe
operation In 1 Operation, 0 write, 1 read, 2 write-read, -1 specified in pipe
send_address In 1 send address as part of the return message
send_operation In 1 send operation as part of the return message
send_write_count In 1 send write count as part of the return message
read_start In 1 Start operation
complete Out 1 Operation complete
error Out 1 Operation failed
write_count Out n Words written
pipe_in InOut p Pipeline of messages to be sent
pipe_out InOut p Pipeline of messages received
scl InOut 1 Communication clock clock out. Open Drain Output
sda InOut 1 Communication data in and out. Open Drain Output

Dependencies

Subsystem File
Pipe pipe_defs.v
  pipe_utils.v

Template


i2c_master #(
        .PipeSpec( PipeSpec ),
        .ClockCount( ClockCount )

    ) i2c_m(
        .clock( clock ),
        .reset( reset ),

        .pipe_in( pipe_in ),
        .pipe_out( pipe_out ),

        .scl( scl ),
        .sda( sda )
    );

I2C Slave

Parameters

Name Description
Address Slave Address.
PipeSpec specification of the data coming in and out of the module.
ClockCount clock ticks per bit

Ports

Name Direction Size Description
clock In 1 System clock
reset In 1 System reset
pipe_in InOut p Pipeline of messages to be sent
pipe_out InOut p Pipeline of messages received
scl In 1 Communication clock in
sda In n Communication data in

Dependencies

Pipe

  • pipe_defs.v
  • pipe_utils.v

Template

Waveforms

Tasks

More doc

Timeouts for clock stretching (else?)

Write-Read mode

More hardware testing

Discussions

How to handle Read length in a pipeline environment?

Same as SPI with header or input options for read/write read count

  ADDRESS
  READ COUNT n = 0
  WRITE DATA 0
  ...
  WRITE DATA m
  ADDRESS
  READ COUNT n =/= 0

Should address be added to the return?

Yes, optionally.

How to handle status (timeout, error, too long)