Académique Documents
Professionnel Documents
Culture Documents
Design example
Serial line transmitter/receiver
Acknowledge
Design techniques
Timing Diagram
- Oversampling needs to pick up falling edge of input signal
and interacts with counters
- Handshaking is between asynchronous circuits and
synchronous circuits
- In general, timing diagram is very important in digital
design
Top Down & Bubble-and-arc Diagram
- Top Down design
define larger block and break it into smaller blocks
- Bubble-and-arc
It is used for finite state machines
Implementation
ResetS ResetR
ClkS ClkR
Keyboard Display
7 8
RS DB E
8 8
Send AckS Rcvd AckR
CharToSend CharRcvd
TxD RxD
Sender Receiver
Implementation(Cont.)
Sender
- Keyboard
It is input device
- Keyboard Decoder
It decodes the signals from the keypad and turn them into the
appropriate character code for the button
- Sender
It takes the byte and serially transmits it over the single wire
Receiver
- Display
It is LCD output
- Display Controller
It takes the data and control the LCD appropriately to get the
corresponding character to show up on the screen.
- Reciever
It observes the signal wire coming from the sender and determines
when a byte has been received.
Keyboard
R
Row 1
Row 2
Row 3
Row 4
Col 1
Col 2
Col 3
Common
1 2 3
4 5 6
C
7 8 9
* 0 #
Key XY
Ro w X
Co mmon
Co lumn Y
Keyp ad
Keyboard decoder
It decodes key presses into the 8-bit
character code
Handshake
Send ResetS
ClkS
Data
Keyboard
AckS 7
Keyboard
Send Decoder
Send 8 AckS
AckS CharToSend
Sender TxD
Data valid data
Keyboard decoder(Cont.)
AckS
Send
AckS
ClkS
Send
AckS
Send
AckS
8b00110001
8b00110010 FF DOut
8b00100011
FF Send
module KeyboardDecoder (ClkS, ResetS, R1, R2, R3, R4, always @ (posedge ClkS) begin
if (KeyPressed & !AckS) begin
C1, C2, C3, AckS, Send, DOut); if (R1 & C1) DOut <= 8b 00110001;
//code for 1
input ClkS, ResetS, AckS; else if (R1 & C2) DOut <= 8b 00110010;
//code for 2
input R1, R2, R3, R4, C1, C2, C3; else if (R1 & C3) DOut <= 8b 00110011;
output Send; //code for 3
output [7:0] DOut; else if (R2 & C1) DOut <= 8b 00110100;
//code for 4
else if (R2 & C2) DOut <= 8b 00110101;
reg [7:0] DOut; //code for 5
reg send; else if (R2 & C3) DOut <= 8b 00110110;
//code for 6
Wire KeyPressed; else if (R3 & C1) DOut <= 8b 00110111;
//code for 7
assign KeyPressed = (R1 | R2 | R3 | R4) & (C1 | C2 | C3); else if (R3 & C2) DOut <= 8b 00111000;
//code for 8
else if (R3 & C3) DOut <= 8b 00111001;
always @ (posedge ClkS) begin //code for 9
else if (R4 & C1) DOut <= 8b 00101010;
if (ResetS) //code for *
Send <= 0; else if (R4 & C2) DOut <= 8b 00110000;
//code for 0
else if (KeyPressed & !AckS) else if (R4 & C3) DOut <= 8b 00100011;
//code for #
Send <= 1; end
else if (AckS) end We use ASCII
Send <= 0; endmodule codes because of
end display using
Sender
It serializes data into the RS232 format
It implements the other half of the handshake
with the Keyboard Decoder module
It sends 10 bits over the serial line for each
key pressed on the keyboard
AckS
TxD
Shift
Register
DIn
TxD
0
Send
~AckS AckS
BitCount[3]
Sender(Cont.)
BitCount == 9 AckR
module Receiver (ClockR, ResetR, RxD, AckR,
DOut, Rcvd);
Receiver(Cont.)
input ClockR, ResetR, RxD, AckR;
output [7:0] DOut;
output Rcvd;
BitCount == 9 && CycleCount
reg [7:0] DOut, Data;
reg Rcvd, Receiving;
~Rcvd Rcvd
wire [3:0] BitCount;
wire [1:0] CycleCount;
AckR
always @ (posedge ClockR) begin
if (ResetR)
Receiving <= 0;
else if (~Receiving & ~RxD) always @ (posedge ClkR) begin
Receiving <= 1; if (ResetR)
else if (Receiving && BitCount == 9) Rcvd <= 0;
Receiving <= 0; else if (BitCount == 9 && CycleCount == 0)
end Rcvd <=1;
~RxD else if (AckR)
Rcvd <= 0;
~Receiving Receiving end
BitCount == 9
Receiver(Cont.)
Counter Cycle ShiftRegister SIPO
( (
.Clock(ClockR), .PIn(),
.Reset(ResetR | (~Receiving & ~RxD)), .SIn(RxD),
.Set(1b0), .POut(Data),
.Load(), .SOut(),
.Enable(Receiving), .Load(),
.In(), .Enable(Receiving && CycleCount == 1),
.Count(CycleCount) .Clock(ClkR),
); .Reset(ResetR)
defparam Cycle.width = 2; );
Counter Bit Register DataRegister
( (
.Clock(ClockR),
.Reset(ResetR | (~Receiving & ~RxD)), .Clock(ClkR),
.Set(1b0), .Reset(ResetR),
.Load(), .Set(),
.Enable(Receiving & CycleCount == 3), .Enable(BitCount == 9 && CycleCount == 0),
.In(),
.Count(BitCount) .In(Data),
); .Out(DOut)
defparam Bit.width = 4;
);
endmodule
LCD
Enable driven interface
At a falling edge of the Enable signal, LCD
interprets the mode and the data inputs
Setup Time and Hold Time of LCD < ~10ns
Our Clock is much slower than this
setup hold
time time
DB valid data
RS valid mode
LCD(Cont.)
Operation RS DB7...DB0
Clear Display 0 0000 0001
Function Set 0 0011 0011
Display On 0 0000 1100
Entry Mode Set 0 0000 0110
Write Character 1 DDDD DDDD
Display controller
Two main tasks:
- Initialize LCD ~initMode initMode
- Display the
characters received CS == 9
by the receiver
module En=1 0
1 9
Handshake with the En=0 DB=8b00000001 En=0
2 8
Receiver module using
DB=8b00000110
Rcvd and AckR 7
En=1 3 DB=8b00110011 En=1
4 6
~initMode & Rcvd En=0
En=0 5
~AckR DB=8b00001100
AckR
En=1