Combinational Design, Part 2 - PowerPoint PPT Presentation

1 / 63
About This Presentation
Title:

Combinational Design, Part 2

Description:

Encoders. Multiplexers. More Verilog. Information ... Priority Encoder. Chooses one with highest priority. Largest number, usually. Note 'don't cares' ... – PowerPoint PPT presentation

Number of Views:26
Avg rating:3.0/5.0
Slides: 64
Provided by: anselmo9
Category:

less

Transcript and Presenter's Notes

Title: Combinational Design, Part 2


1
Combinational Design,Part 2
  • Anselmo Lastra

2
Change Order of Topics
  • Move simpler programmable devices to later
  • Sections 3-6, 4-6
  • Adder for Fridays lab
  • Verilog testbenches
  • Look at (simulated) delays

3
Topics
  • Common Logic Functions
  • Decoders
  • Encoders
  • Multiplexers
  • More Verilog
  • Information
  • Outputs in library fcns listed first by convention

4
Comb. Logic in Context
  • Typically part of system with storage
  • Computer looks like this

5
Value Fixing, Transferring, Inverting
  • Only 4 possible functions of one variable
  • 2 constant
  • 1 xfer
  • 1 invert

6
Enable
  • Enable is a common input to logic functions
  • See it in memories, and todays blocks

7
Decoders
  • Typically n inputs and 2n outputs
  • Drives high the output corresponding to binary
    code of input

74139
8
2-to-4 Line Decoder
9
2-to-4 with Enable
10
Truth Table, 3-to-8 Decoder
  • Notice they are minterms

11
Schematic
12
Multi-Level 3-to-8
13
Enable Used for Expansion
14
Multi-Level 6-to-64
15
Uses for Decoders
  • Binary number might serve to select some
    operation
  • Computer op codes are encoded
  • Decoder lines might select add, or subtract, or
    multiply, etc.
  • Memory address lines

16
Variations
  • At right
  • Enable not
  • Inverted outputs

17
Verilog
18
Encoder
  • Encoder is the opposite of decoder
  • 2n inputs (or less maybe BCD in)
  • n outputs

19
Truth Table
20
Inputs are Minterms
  • Can OR them together appropriately
  • A0 D1 D3 D5 D7

21
Whats the Problem?
  • What if D3 and D6 both high?
  • Simple OR circuit will set A to 7

22
Priority Encoder
  • Chooses one with highest priority
  • Largest number, usually
  • Note dont cares

What if all inputs are zero?
23
Need Another Output
  • A Valid output

24
Valid is OR of inputs
25
Multiplexer (or Mux)
  • Selects one of a set of inputs to pass on to
    output
  • Binary control code, n lines
  • Choose from 2n inputs
  • Useful for choosing from sets of data
  • Memory or register to ALU
  • Very common

74153
26
Two Input Mux
27
Logic
28
Logic is Decoder Plus
29
Structural Verilog
  • module mux_4_to_1_line_structural(S, D, Y)
  • input 10 S
  • input 30 D
  • output Y
  • wire 10 not_S
  • wire 03 N
  • not(not_S0, S0)
  • not(not_S1, S1)
  • and(N0, not_S1, not_S0, D0)
  • and(N1, not_S1, S0, D1)
  • and(N2, S1, not_S0, D2)
  • and(N3, S1, S0, D3)
  • or(Y, N0, N1, N2, N3)
  • endmodule

We can do better with dataflow (next)
30
Dataflow Verilog
  • module mux_4_to_1_df(S, D, Y)
  • input 10 S
  • input 30 D
  • output Y
  • assign Y ( S1 S0 D0)
  • ( S1 S0 D1)
  • ( S1 S0 D2)
  • ( S1 S0 D3)
  • endmodule

Can do even better (next)
31
But First an Aside
  • Verilog constants
  • Conditional assignment

32
Constants in Verilog
  • Syntax
  • sizeradixconstant
  • Radix can be d, b, h, or o (default d)
  • Examples
  • assign Y 10 // Decimal 10
  • assign Y b10 // Binary 10, decimal 2
  • assign Y h10 // Hex 10, decimal 16
  • assign Y 8b0100_0011 // Underline ignored
  • Binary values can be 0, 1, or x

33
Conditional Assignment
  • Equality test
  • S 2'b00
  • Assignment
  • assign Y (S 2'b00)?b0b1
  • If true, assign 0 to Y
  • If false, assign 1 to Y

34
4-to-1 Mux as Truth Table
  • module mux_4_to_1_dataflow(S, D, Y)
  • input 10 S
  • input 30 D
  • output Y
  • assign Y (S 2'b00) ? D0
  • (S 2'b01) ? D1
  • (S 2'b10) ? D2
  • (S 2'b11) ? D3 1'bx
  • endmodule

35
Verilog for Decision Tree
  • module mux_4_to_1_binary_decision(S, D, Y)
  • input 10 S
  • input 30 D
  • output Y
  • assign Y S1 ? (S0 ? D3 D2)
  • (S0 ? D1 D0)
  • endmodule

36
Binary Decisions
  • If S1 1, branch one way
  • assign Y S1 ? (S0 ? D3 D2)
  • and decide Y either D2 or D3 based on S0
  • Else
  • (S0 ? D1 D0)
  • decide Y either D2 or D3 based on S0
  • Notice that conditional test is for 1 condition
    like in C

37
Quad 2-to-4 Line Mux
  • Select one set of 4 lines
  • Can gang these
  • Select a whole 64-bit data bus

38
Three-State Implementation
39
Binary Tree Style
40
Demultiplexer
  • Takes one input
  • Out to one of 2n possible outputs

41
Demux is a Decoder
  • With an enable

42
Change Topics
  • Verilog
  • First a couple of syntax styles
  • Verilog test programs

43
Verilog 2001 Formals (P.42)
  • New style for module formals
  • 2001 calling style input and output in fcn
    declr.
  • module name(output B, input A)

44
Instance Port Names (P.49)
  • Module
  • module modp(output C, input A)
  • Ports referenced as
  • modp i_name(conC, conA)
  • Also as
  • modp i_name(.A(conA), .C(conC))

45
Parameter (P. 19)
  • Can set constant
  • Like define
  • parameter SIZE 16

46
Verilog for Simulation
  • Code more convenient than the GUI testbench
  • Also more complex conditions
  • Can test for expected result

47
ISE
  • Make Verilog Test Fixture
  • Will create a wrapper (a module)
  • Instantiating your circuit
  • Itll be called UUT (unit under test)
  • You then add your test code
  • Example on next slides

48
Module and Instance UUT
  • module syn_adder_for_example_v_tf()
  • // DATE 212220 01/25/2004
  • // ...Bunch of comments...
  • ...
  • // Instantiate the UUT
  • syn_adder uut (
  • .B(B),
  • .A(A),
  • .C0(C0),
  • .S(S),
  • .C4(C4)
  • )
  • ...
  • endmodule

49
Reg
  • It will create storage for the inputs to the UUT
  • // Inputs
  • reg 30 B
  • reg 30 A
  • reg C0
  • Well talk more about reg next week

50
Wires for Outputs
  • That specifies bus sizes
  • // Outputs
  • wire 30 S
  • wire C4

51
Begin/End
  • Verilog uses begin and end for block
  • instead of curly braces

52
Initial
  • Initial statement runs when simulation begins
  • initial
  • begin
  • B 0
  • A 0
  • C0 0
  • end

53
Procedural assignment
  • Why no assign
  • Because its not a continuous assignment
  • Explain more next week when we look at
    storage/clocking

54
Initialize in Default Test File
  • Theres one in ISE generated file, but dont
    think auto_init is defined
  • // Initialize Inputs
  • ifdef auto_init
  • initial begin
  • B 0
  • A 0
  • C0 0
  • end
  • endif

55
What to Add?
  • Need to make time pass
  • Use command for skipping time
  • Example (note no semicolon after 50)
  • initial
  • begin
  • B 0
  • 50 B 1
  • end

56
For (P. 109)
  • Can use for loop in initial statement block
  • initial
  • begin
  • for(i0 i lt 5 i i 1)
  • begin
  • 50 B i
  • end
  • end

57
Integers (P. 22)
  • Can declare for loop control variables
  • Will not synthesize, as far as I know
  • integer i
  • integer j
  • Can copy to input regs
  • There may be problems with negative values

58
There are also
  • While
  • Repeat
  • Forever

59
Timescale (P. 222)
  • Need to tell simulator what time scale to use
  • Place top of test fixture
  • timescale 1ns/10ps

60
System Tasks (Appendix D)
  • Tasks for the simulator
  • stop end the simulation
  • display like C printf
  • monitor prints when arguments change (example
    next)
  • time Provides value of simulated time

61
Monitor
  • // set up monitoring
  • initial
  • begin
  • monitor(time, " Ab ,Bb\n", A, B)
  • end
  • // These statements conduct the actual test
  • initial
  • begin
  • Code...
  • end

62
Today
  • Common functions should know these
  • Decoder
  • Priority encoder
  • Multiplexer (mux)
  • Demultiplexer
  • Verilog test programs

63
Next
  • Adders
  • Ripple Carry adder
  • Verilog for adder
  • Hierarchical design
  • Subtraction
  • Signed arithmetic
  • Multiplication
Write a Comment
User Comments (0)
About PowerShow.com