owRead (OneWire.v)

This module implements one or more 1-wire bus-master read cycles. The 1-wire bus is a single-wire bi-directional bus standard originally authored by Dallas Semiconductor. It has a master/slave architecure, capable of handling multiple slave devices. This module reads a configurable number of bits from the bus, with the slot timing intervals in clocks settable via parameters. The defaults apply to a 1-MHz clock.

Ports | Parameters | Notes | Example | Timing diagram

Ports

clkinputThe clock input.
resetinput    The reset input.
goinputPulse to initiate a cycle.
dataoutputThe word read from the bus. Data remain valid until the instance is restarted.
dqin/outThe 1-wire bus. When undriven, it goes high.
busyoutputIndicates that the instance is busy outputting a word.
doneoutputAsserted for a clock when the instance has completed its operation.

Parameters

wWidth of the bit counter (default 3).
bThe bit count of the word read from the bus (default 8). Must be at most 2w.
w1Bit width of the timer for the read-slot pulse duration (default 2).
t1Duration in clocks of the pulse signaling the read cycle to the device (default 4). Must be at most 2w1.
w2Bit width of the timer marking when to sample the bus (default 4).
t2When to read the bit from the 1-wire bus, measured in clocks from the start of the read slot (default 14). Must be at most 2w2.
w3Bit width of the timer for the read-slot duration (default 6).
t3Duration of the read slot in clocks (default 64). Must be at most 2w2.

Notes

Example instantiation in Verilog:

Read the device ROM code.

// read 64-bit ds1825 rom data
tri1			onewire;
wire			busy, done, go;
wire		[63:0]	romdata;
owRead
    #(.w(6), .b(64))
    readrom (
        .clk(clk),		.reset(reset),
        .go(go),		.dq(onewire),
        .data(romdata),
        .busy(busy),		.done(done)
    );

This instance reads the bus until it receives a logical 1. If no device is present or responds, then it exits after the first cycle.

// wait for a device operation to finish
// device is returning zeros as long as the operation is running
// then returns 1 (e.g., DS1825 temperature conversion)
tri1		onewire;
wire		clk, reset, go, busy, donea, done, flag;
owRead
    #(.w(1), .b(1))
    waitfordone (
        .clk(clk),		.reset(reset),
        .go(go || donea && !flag),
        .dq(onewire),		.data(flag),
        .busy(busy),		.done(donea)
    );
wire		done = donea && doneflag;

2/4/2015