Wishbone tutorials

23
Wishbone Tutorials Wishbone Tutorials Gookyi Dennis A. N. Gookyi Dennis A. N. SoC Design Lab. SoC Design Lab. October.17.2014

description

Verilog code for WISHBONE modules

Transcript of Wishbone tutorials

Page 1: Wishbone tutorials

Wishbone TutorialsWishbone TutorialsWishbone TutorialsWishbone Tutorials

Gookyi Dennis A. N.Gookyi Dennis A. N.

SoC Design Lab.SoC Design Lab.

October.17.2014

Page 2: Wishbone tutorials

ContentContent Round-Robin Arbiter Module

2

Page 3: Wishbone tutorials

Round-Robin ArbiterRound-Robin Arbiter In a shared bus, the arbiter determines which master

can use the bus The bus is granted on a rotary basis much like the

four position rotary switch shown below:

When a master relinquishes the bus, the switch is turned to the next position and the bus is granted to the master on the level

In this way all masters are granted the bus on an equal basis

3

MASTER #0

MASTER #3

MASTER #2

MASTER #1

Page 4: Wishbone tutorials

Round-Robin ArbiterRound-Robin Arbiter Arbiter general topology:

4

LASMASSTATEMACHINE

REGISTER

COMCYCLOGIC

ENCODERLOGIC

ARBITRATIONLOGIC

GNT3 GNT3GNT2GNT1GNT0

GNT2GNT1GNT0

GNT(1..0)

CLK

CLK

CLK

LMAS0LMAS1

RST

RST_I

CYC3CYC2CYC1CYC0

COMCYC

LASMAS

CE

Page 5: Wishbone tutorials

Round-Robin ArbiterRound-Robin Arbiter Bus requests arrive at inputs [ CYC0] to [CYC3] If bus is free, one of the 4 grant lines ([GNT0] to

[GNT1]) is asserted which corresponds to the request signals

5

Page 6: Wishbone tutorials

Round-Robin Arbiter: COMCYCRound-Robin Arbiter: COMCYC The [COMCYC] indicates whether the bus is free or

busy It is asserted whenever a master has both requested

the bus and has been granted the bus by the arbiter

6

Page 7: Wishbone tutorials

Round-Robin Arbiter: COMCYCRound-Robin Arbiter: COMCYC Inputs and outputs:

COMCYC logic diagram:

COMCYC = (CYC3 & GNT3)||(CYC2 & GNT2)|| (CYC1 & GNT1)||(CYC0 & GNT0);

7

Inputs Output

CYC_3, CYC_2, CYC_1, CYC_0GNT_3, GNT_2, GNT_1, GNT_0

COMCYC

CYC_3

CYC_2

GNT_2CYC_1

GNT_1

CYC_0

GNT_0

GNT_3

COMCYC

Page 8: Wishbone tutorials

Round-Robin Arbiter: Encoder Round-Robin Arbiter: Encoder LogicLogic Grant line [GNT0] to [GNT3] are encoded as

[GNT(1..0)] This is used with the [COMCYC] signal to indicate

which master has been granted the bus When [COMCYC] is asserted, the master located on

[GNT(1..0)] is granted the bus

8

Page 9: Wishbone tutorials

Round-Robin Arbiter: Encoder Round-Robin Arbiter: Encoder LogicLogic Inputs and outputs:

Encoder logic diagram:

9

Inputs Outputs

GNT_3, GNT_2, GNT_1, GNT_0

GNT[1], GNT[0]

GNT_3

GNT_1GNT[0] = GNT3 || GNT1

GNT[1] = GNT_2 || GNT_3GNT_2

GNT_3 GNT_2 GNT_1 GNT_0 GNT[1] GNT[0]

0 0 0 1 0 0

0 0 1 0 0 1

0 1 0 0 1 0

1 0 0 0 1 1

0

0

0

0

0

Page 10: Wishbone tutorials

Round-Robin Arbiter: LASMASRound-Robin Arbiter: LASMAS Round-robin arbiters keep track of the level of the

previous master The level is saved in a register that latches the state

of grant signals [GNT(1..0)] The register latches the grant signal when indicated

by the LASMAS state machine

10

CE

Page 11: Wishbone tutorials

Round-Robin Arbiter: LASMASRound-Robin Arbiter: LASMAS LASMAS state machine: state diagram

Input logic: BEG= (CYC0 || CYC1 || CYC2 || CYC3) & (~COMCYC);

From the state diagram:EDG= ( BEG & ~EDG & LASMAS) || ( BEG & EDG & ~LASMAS );LASMAS = ( BEG & ~EDG & ~LASMAS ); 11

Input = BEG

State = {EDG,LASMAS}

CYC0CYC1

CYC2CYC3

COMCYCBEG

Page 12: Wishbone tutorials

Round-Robin Arbiter: Bus Round-Robin Arbiter: Bus TopologyTopology The arbitration logic is as below:

12

MASTER #0

MASTER #3

MASTER #2

MASTER #1

Page 13: Wishbone tutorials

Round-Robin Arbiter: Bus Round-Robin Arbiter: Bus TopologyTopology The arbitration logic is as below:

GNT0 = ( ~RST & ~COMCYC & ~LMAS1 & ~LMAS0 & ~CYC3 & ~CYC2 & ~CYC1 & CYC0 )|| ( ~RST & ~COMCYC & ~LMAS1 & LMAS0 & ~CYC3 & ~CYC2 & CYC0 )|| ( ~RST & ~COMCYC & LMAS1 & ~LMAS0 & ~CYC3 & CYC0 )|| ( ~RST & ~COMCYC & LMAS1 & LMAS0 & CYC0 )|| ( ~RST & COMCYC & GNT0 );

GNT1 = ( ~RST & ~COMCYC & ~LMAS1 & ~LMAS0 & CYC1 )|| ( ~RST & ~COMCYC & ~LMAS1 & LMAS0 & ~CYC3 & ~CYC2 & CYC1 & ~CYC0 )|| ( ~RST & ~COMCYC & LMAS1 & ~LMAS0 & ~CYC3 & CYC1 & ~CYC0 )|| ( ~RST & ~COMCYC & LMAS1 & LMAS0 & CYC1 ~CYC0 )|| ( ~RST & COMCYC & GNT1 );

GNT2 = ( ~RST & ~COMCYC & ~LMAS1 & ~LMAS0 CYC2 & ~CYC1 )|| ( ~RST & ~COMCYC & ~LMAS1 & LMAS0 CYC2 )|| ( ~RST & ~COMCYC & LMAS1 & ~LMAS0 & ~CYC3 & CYC2 & ~CYC1 & ~CYC0 )|| ( ~RST & ~COMCYC & LMAS1 & LMAS0 CYC2 & ~CYC1 & ~CYC0 )|| ( ~RST & COMCYC & GNT2 );

GNT3 = ( ~RST & ~COMCYC & ~LMAS1 & ~LMAS0 & CYC3 & ~CYC2 & ~CYC1 )|| ( ~RST & ~COMCYC & ~LMAS1 & LMAS0 & CYC3 & ~CYC2 )|| ( ~RST & ~COMCYC & LMAS1 & ~LMAS0 & CYC3 )|| ( ~RST & ~COMCYC & LMAS1 & LMAS0 & CYC3 & ~CYC2 & ~CYC1 & ~CYC0 )

13

MASTER #0

MASTER #3

MASTER #2

MASTER #1

Page 14: Wishbone tutorials

Round-Robin Arbiter: Bus Round-Robin Arbiter: Bus TopologyTopology The arbitration logic is as below:

GNT0 = ( ~RST & ~COMCYC & ~LMAS1 & ~LMAS0 & ~CYC3 & ~CYC2 & ~CYC1 & CYC0 )|| ( ~RST & ~COMCYC & ~LMAS1 & LMAS0 & ~CYC3 & ~CYC2 & CYC0 )|| ( ~RST & ~COMCYC & LMAS1 & ~LMAS0 & ~CYC3 & CYC0 )|| ( ~RST & ~COMCYC & LMAS1 & LMAS0 & CYC0 )|| ( ~RST & COMCYC & GNT0 );

GNT1 = ( ~RST & ~COMCYC & ~LMAS1 & ~LMAS0 & CYC1 )|| ( ~RST & ~COMCYC & ~LMAS1 & LMAS0 & ~CYC3 & ~CYC2 & CYC1 & ~CYC0 )|| ( ~RST & ~COMCYC & LMAS1 & ~LMAS0 & ~CYC3 & CYC1 & ~CYC0 )|| ( ~RST & ~COMCYC & LMAS1 & LMAS0 & CYC1 ~CYC0 )|| ( ~RST & COMCYC & GNT1 );

GNT2 = ( ~RST & ~COMCYC & ~LMAS1 & ~LMAS0 CYC2 & ~CYC1 )|| ( ~RST & ~COMCYC & ~LMAS1 & LMAS0 CYC2 )|| ( ~RST & ~COMCYC & LMAS1 & ~LMAS0 & ~CYC3 & CYC2 & ~CYC1 & ~CYC0 )|| ( ~RST & ~COMCYC & LMAS1 & LMAS0 CYC2 & ~CYC1 & ~CYC0 )|| ( ~RST & COMCYC & GNT2 );

GNT3 = ( ~RST & ~COMCYC & ~LMAS1 & ~LMAS0 & CYC3 & ~CYC2 & ~CYC1 )|| ( ~RST & ~COMCYC & ~LMAS1 & LMAS0 & CYC3 & ~CYC2 )|| ( ~RST & ~COMCYC & LMAS1 & ~LMAS0 & CYC3 )|| ( ~RST & ~COMCYC & LMAS1 & LMAS0 & CYC3 & ~CYC2 & ~CYC1 & ~CYC0 )

14

MASTER #0

MASTER #3

MASTER #2

MASTER #1

Page 15: Wishbone tutorials

Round-Robin Arbiter: Bus Round-Robin Arbiter: Bus TopologyTopology The arbitration logic is as below:

GNT0 = ( ~RST & ~COMCYC & ~LMAS1 & ~LMAS0 & ~CYC3 & ~CYC2 & ~CYC1 & CYC0 )|| ( ~RST & ~COMCYC & ~LMAS1 & LMAS0 & ~CYC3 & ~CYC2 & CYC0 )|| ( ~RST & ~COMCYC & LMAS1 & ~LMAS0 & ~CYC3 & CYC0 )|| ( ~RST & ~COMCYC & LMAS1 & LMAS0 & CYC0 )|| ( ~RST & COMCYC & GNT0 );

GNT1 = ( ~RST & ~COMCYC & ~LMAS1 & ~LMAS0 & CYC1 )|| ( ~RST & ~COMCYC & ~LMAS1 & LMAS0 & ~CYC3 & ~CYC2 & CYC1 & ~CYC0 )|| ( ~RST & ~COMCYC & LMAS1 & ~LMAS0 & ~CYC3 & CYC1 & ~CYC0 )|| ( ~RST & ~COMCYC & LMAS1 & LMAS0 & CYC1 ~CYC0 )|| ( ~RST & COMCYC & GNT1 );

GNT2 = ( ~RST & ~COMCYC & ~LMAS1 & ~LMAS0 CYC2 & ~CYC1 )|| ( ~RST & ~COMCYC & ~LMAS1 & LMAS0 CYC2 )|| ( ~RST & ~COMCYC & LMAS1 & ~LMAS0 & ~CYC3 & CYC2 & ~CYC1 & ~CYC0 )|| ( ~RST & ~COMCYC & LMAS1 & LMAS0 CYC2 & ~CYC1 & ~CYC0 )|| ( ~RST & COMCYC & GNT2 );

GNT3 = ( ~RST & ~COMCYC & ~LMAS1 & ~LMAS0 & CYC3 & ~CYC2 & ~CYC1 )|| ( ~RST & ~COMCYC & ~LMAS1 & LMAS0 & CYC3 & ~CYC2 )|| ( ~RST & ~COMCYC & LMAS1 & ~LMAS0 & CYC3 )|| ( ~RST & ~COMCYC & LMAS1 & LMAS0 & CYC3 & ~CYC2 & ~CYC1 & ~CYC0 )

15

MASTER #0

MASTER #3

MASTER #2

MASTER #1

Page 16: Wishbone tutorials

Round-Robin ArbiterRound-Robin Arbiter Code

16

Page 17: Wishbone tutorials

Round-Robin ArbiterRound-Robin Arbiter Code:

17

Page 18: Wishbone tutorials

Round-Robin ArbiterRound-Robin Arbiter RTL schematic

18

Page 19: Wishbone tutorials

Round-Robin ArbiterRound-Robin Arbiter Testbench

19

Page 20: Wishbone tutorials

Round-Robin Arbiter: Round-Robin Arbiter: waveformwaveform Cyc0 request and is granted the bus

20

cyc0 is granted the bus

Page 21: Wishbone tutorials

Round-Robin Arbiter: Round-Robin Arbiter: waveformwaveform Cyc1 and cyc2 both request the bus at the same time

21

comcyc is negated to indicate that the bus is free

Page 22: Wishbone tutorials

Round-Robin Arbiter: Round-Robin Arbiter: waveformwaveform Bus granted to cyc1

22

Bus granted to cyc1 because it is next in line

Page 23: Wishbone tutorials

Round-Robin Arbiter: Round-Robin Arbiter: waveformwaveform Cyc3 request for bus and is granted

23

Bus granted to cyc3