05a Section4 Notes CPD SDDS1 Topdown1
05a Section4 Notes CPD SDDS1 Topdown1
05a Section4 Notes CPD SDDS1 Topdown1
===================
Sept Dec
===================
..
..
===================
Top Down Design 1 (TDD1)
===================
Richard Gahan
richard.gahan@tudublin.ie
Contents
1 Top Down Design 2
1.1 FIFO Design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.1.1 FIFO4 Top Level DFD . . . . . . . . . . . . . . . . . . . . . . . . . 4
1.1.2 bytesInFIFOCounter Design . . . . . . . . . . . . . . . . . . . . . . 5
1.1.3 countControl Design . . . . . . . . . . . . . . . . . . . . . . . . . . 6
1.1.4 counterDecode Design . . . . . . . . . . . . . . . . . . . . . . . . . 7
1.1.5 UpDownCounter Design . . . . . . . . . . . . . . . . . . . . . . . . 8
1.1.6 4byteStore Functional Partition . . . . . . . . . . . . . . . . . . . . 9
1.2 TestQuestion1 FIFO Design and Code . . . . . . . . . . . . . . . . . . . 10
Section 1
2. It accepts data from a byte interface and stores that data into the next available
FIFO location if one is available otherwise it drops (ignores) the incoming data.
3. When there is data in the FIFO the oldest data is presented on foData[7:0] and
waits there until byteTaken(H) asserts.
4. When byteTaken(H) asserts, the next stored byte is presented after the next rising
CLK edge.
6. dataAvail(H) asserts when there is one or more locations of the FIFO holding data.
The rst step in the solution is to break the problem down into sensible and logic subsec-
tions. There are many possibilities but the key to successful partition is to make it easier
to understand and explain how the design will work.
1. writeEn(H)
This signal asserts when a byte of data is to be written into the 4ByteStore Block.
2. wrAdr[1:0]
This is the 2 bit address in memory where the rxByte[7:0] will be written into on
the next rising edge of the clock.
3. rdAdr[1:0]
This is the 2 bit address in memory where the foData[7:0] is being read from. This
is an asynchronous read i.e. once the address asserts the data becomes valid after
combinational delays of intervening logic.
The block called 4ByteStore holds the bytes in the FIFO but it is under the control of the
bytesInFIFOCounter.
The writeEn signal asserts when a byte is to be written to the memory, to the address as
given on wrAdr[1:0]. In this dataow diagram the datapath is distinct from the control
path.
The next task is to either design the blocks as shown in the DFD or to break them down
further. In this example it is instructive to break bytesInFIFOCounter down further
and to design the 4ByteStore.
TUDublin ©
rgahan Page 4 of 10
CPD SDDS1 - TopDown1 Rev A01
1. increment(H)
This signal asserts when a byte is being written into the FIFO to tell the upDown-
Counter to count up so we know how many valid bytes are in the FIFO.
2. decrement(H)
This signal asserts when a byte is being read from the FIFO to tell the upDown-
Counter to count down so we know how many valid bytes are in the FIFO
3. foByteCount[2:0]
This is a count of the valid number of bytes in the FIFO. There can be 0,1,2,3 or 4
bytes in the FIFO. When there are 4 bytes in the FIFO it is full.
This design works as follows the upDownCounter keeps track of how many valid bytes
are stored in the memory. The value may be incremented or decremented. When a value
is being written into memory the value is incremented and when a value is read from (or
taken out of ) memory the count is decremented.
The countControl block determines whether the counter should be incremented, decre-
mented or neither as can happen when there is a write and a read from memory at the
same time the amount of data stored stays the same!.
The counterDecode block decodes the foFull and dataAvail signals from the value of
foByteCount[2:0].
This owchart goes through all the possibilities of writing and reading the memory. This is
fairly self-evident. However take notice of the path with rxByteAvail=1 and byteTaken=1
notice that neither increment or decrement asserts as they cancel each other out. And
this can happen even if the FIFO is full.
This block is so simple it is ready for code. However we can represent it in an FSM
diagram yet.
Modify the FIFO4 design to take account of the changed functionality on the input side.
rxAckH asserts to take the byte presented on rxByte[7:0] as indicated by rxByteAvailH,
otherwise the byte remains presented on the interface until rxAckH asserts.
Write verilog code for this design and a simple testbench to test the functionality.