Datapaths but first Keyboard - PowerPoint PPT Presentation

1 / 48
About This Presentation
Title:

Datapaths but first Keyboard

Description:

http://panda.cs.ndsu.nodak.edu/~achapwes/PICmicro/keyboard/scancodes2.html ... Video (and movies) are a series of stills. If it goes fast enough ... – PowerPoint PPT presentation

Number of Views:175
Avg rating:3.0/5.0
Slides: 49
Provided by: anselmo9
Category:

less

Transcript and Presenter's Notes

Title: Datapaths but first Keyboard


1
Datapaths(but first Keyboard Video)
  • Anselmo Lastra

2
Today
  • Peripherals
  • How PS/2 keyboards work
  • VGA and basics of video
  • Chapter 7 Datapaths
  • Basic definitions today

3
PS/2 Keyboard
  • Uses a synchronous serial protocol
  • What does that mean?

4
Physical Interface
  • Two lines
  • Clock (10-20KHz)
  • Data
  • Pulled high by resistors
  • Asserted low
  • Takes away your pushbutton unless you do clever
    stuff

5
Bidirectional
  • Kybd-to-host and host-to-kybd on same wires
  • CAPS LOCK light for example
  • To send, host takes data line low
  • Sometimes take clk low first
  • Then kybd starts clocking
  • Host sends data synced to kybd clock
  • You shouldnt need to send to kybd

6
Protocol
  • 11 bits
  • Start always 0
  • 8 bits of data
  • Odd parity bit
  • Stop bit always 1
  • Clocked by keyboard
  • Value should be latched on negedge of keyboard
    clock

Illustration from http//www.beyondlogic.org/keybo
ard/keybrd.htm
7
What is Sent
  • ASCII is not sent
  • Scan codes for keys
  • Least significant bit first

Illustration from http//www.beyondlogic.org/keybo
ard/keybrd.htm
8
Scan Codes
  • Normally translated by software
  • You remap your keys, for example
  • Software takes care of
  • Shift, caps lock, control

9
Some Scan Codes Long
  • Two code sequence common
  • Have a look at Break key!

10
Even More Complicated
  • Scan code generated when you press
  • And when you release
  • Two codes F0 followed by key scan code
  • Example
  • Space pressed, 29 sent
  • Space released, F0 29 sent
  • If you hold key, scan code repeated

11
Resources
  • Web pages
  • http//www.beyondlogic.org/keyboard/keybrd.htm
  • http//govschl.ndsu.nodak.edu/achapwes/PICmicro/P
    S2/ps2.htm
  • Scan codes
  • http//panda.cs.ndsu.nodak.edu/achapwes/PICmicro/
    keyboard/scancodes2.html
  • There is also Verilog for keyboard interfaces
    available on web. Much more complex than yours!

12
Lab
  • Make circuit to read from keyboard
  • Latch output scan code
  • Suggestions
  • Always use master clock for FFs
  • always_at_(posedge clk)
  • Synchronize keyboard clock
  • always _at_ (posedge clk)
  • ps2_clk_s

13
How?
  • I would (did) use
  • Shift register to shift bits in
  • Counter to count 11 bits
  • Counter for timeout
  • Reset bit counter if no activity for time longer
    than it takes for scan code to be sent
  • Used derived 25MHz clock to make it easier to
    probe signals

14
How Do Monitors Work?
  • Origin is TV, so lets look at that
  • Relies on your brain to do two things
  • Integrate over space
  • Integrate over time

15
Dots to a Picture
  • Brain can make this into something recognizable

Images from howstuffworks.com
16
Many still Images
  • Video (and movies) are a series of stills
  • If it goes fast enough
  • 50-60 Hz or more to not see flicker
  • Your brain interprets as moving imagery

17
Simple Scanning TV
  • Electron beam scans across
  • Turned off when
  • Scanning back to the left (horizontal retrace)
  • Scanning to the top (vertical retrace)

18
Inside TV
19
Deflection Coils
20
Scanning
  • TVs use interlacing
  • Every other scan line is swept per field
  • Two fields per frame (30Hz)
  • Way to make movement less disturbing
  • Computers use progressive scan
  • Whole frame refreshed at once
  • 60Hz or more, 72Hz looks better

21
Color
  • Three colors of phosphor
  • Beams hit each
  • Black beam off
  • White all on

22
Aside
  • Frustrated with Verilog
  • See what to do to relieve stress
  • http//entertainment.howstuffworks.com/what-if-sho
    ot-tv.htm
  • Educational too

23
VGA Signaling
  • RGB and two synchronization pulses, horizontal
    and vertical

24
VGA Timing
  • Monitor synchronizes with input in more complex
    way than keyboard
  • You supply two pulses, hsync and vsync, that let
    the monitor lock onto timing
  • One hsync per scan line
  • One vsync per frame

Image from dell.com
25
Horizontal Timing Terms
  • hsync pulse
  • Back porch (left side of display)
  • Active Video
  • Video should be blanked (not sent) at other times
  • Front porch (right side)

26
Horizontal Timing
  • 640 Horizonal Dots
  • Horiz. Sync Polarity NEG
  • Scanline time (A) 31.77 us
  • Sync pulse length (B) 3.77 us
  • Back porch (C) 1.89 us
  • Active video (D) 25.17 us
  • Front porch (E) 0.94 us

Image from http//www.epanorama.net/documents/pc/v
ga_timing.html
27
Vertical Timing (note ms, not us)
  • Vert. Sync Polarity NEG
  • Vertical Frequency 60Hz
  • Total frame time (O) 16.68 ms
  • Sync length (P) 0.06 ms
  • Back porch (Q) 1.02 ms
  • Active video (R) 15.25 ms
  • Front porch (S) 0.35 ms

28
Timing as Pixels
  • Easiest to derive all timing from single-pixel
    timing
  • How long is a pixel?
  • Active video / number of pixels
  • 25.17 us / 640 39.32ns
  • Conveniently close to 25 MHz just use that
  • I calculated some, but also see
  • http//www.epanorama.net/documents/pc/vga_timing.h
    tml

29
Color Depth
  • Voltage of each of RGB determines color
  • 2-bit color here (4 shades)
  • Turn all on for white

30
What To Do?
  • Make Verilog module to generate hsync, vsync,
    horizontal count, vertical count, and signal to
    indicate active video
  • Use that from higher-level to drive RGB using
    counts gated by active
  • Later will use memory addressed by counts
  • For now do something simple

31
Links
  • VGA Timing
  • http//www.epanorama.net/documents/pc/vga_timing.h
    tml
  • http//appsrv.cse.cuhk.edu.hk/ceg3480/Tutorial7/t
    ut7.doc
  • Code (more complex than you want)
  • http//www.stanford.edu/class/ee183/index.shtml
  • Interesting
  • http//www.howstuffworks.com/tv.htm
  • http//computer.howstuffworks.com/monitor.htm

32
Back to CPUs
  • Datapath
  • The registers and logic to perform operations on
    them
  • Control unit
  • Generates signals to control datapath

33
Memory and I/O
  • Are connected to the data/control in and out
    lines
  • Example register to memory ops

34
Microoperations
  • Basic operations of the datapath
  • Example moving data from one register to another
  • Not necessarily microprogrammed control
  • Microoperation expected to complete in one clock
  • Register transfer notation, next

35
Register Transfer Language (RTL)
  • Registers named in uppercase
  • PC, IR (instruction), R3
  • Little endian

36
RT
  • Transfer from R1 to R2
  • R2 ? R1
  • R2 is destination
  • R1 is source
  • Conditional
  • If(K1 1) then (R2 ? R1)
  • K1 R2 ? R1 as a shorter form

37
Transfer
  • Transfer at the clock edge
  • When K1 is high
  • n bits wide

38
Symbols
  • Note memory transfers

39
Syntax not Verilog (similar)
40
Types of Microoperations
  • Transfer have looked at
  • Arithmetic
  • Logic
  • Shift

41
Arithmetic
  • Basic ops (not multiply, divide)
  • R0 ? R1 R2
  • Subtraction by 2s complement

42
Notation is Shorthand for Hardware
  • Consider
  • and
  • Note overflow
  • and carry registers

43
Logic Microoperations
  • Or notation a little confusing
  • shows two ORs

44
Shift Microoperations
  • Here just the basic one-bit shifts
  • Bit falls off the end, zero shifted in

45
Multiplexer-Based Transfers
  • Consider
  • Which can also be expressed as
  • Block diagram next

46
Multiplexer Block Diagram
  • Detailed block diagram next

47
Detailed
  • Simpler is easier to follow and to derive

48
Today
  • Looked at two I/O devices
  • Keyboard
  • VGA display
  • Datapaths
  • Microoperations
  • Next
  • Fill out datapaths
  • Look at full ALU
Write a Comment
User Comments (0)
About PowerShow.com