1 Arithmetic, ALUs Lecture 9 Digital Design and Computer Architecture Harris & Harris Morgan Kaufmann / Elsevier, 2007.

Slides:



Advertisements
Similar presentations
VHDL Lecture 1 Megan Peck EECS 443 Spring 08.
Advertisements

CDA 3100 Recitation Week 11.
Simulation executable (simv)
The Verilog Hardware Description Language
Verilog Overview. University of Jordan Computer Engineering Department CPE 439: Computer Design Lab.
Sequential Logic in Verilog
Synchronous Sequential Logic
Prof. John Nestor ECE Department Lafayette College Easton, Pennsylvania ECE Computer Organization Lecture 13 - A Verilog.
Multiplication and Division
Verilog Modules for Common Digital Functions
Table 7.1 Verilog Operators.
ECE 551 Digital System Design & Synthesis Lecture 06 Loops Non-synthesizable Constructs File I/O.
CSE 201 Computer Logic Design * * * * * * * Verilog Modeling
Verilog. 2 Behavioral Description initial:  is executed once at the beginning. always:  is repeated until the end of simulation.
Chapter 9 Computer Design Basics. 9-2 Datapaths Reminding A digital system (or a simple computer) contains datapath unit and control unit. Datapath: A.
//HDL Example 6-1 // //Behavioral description of //Universal shift register // Fig. 6-7 and Table 6-3 module shftreg.
FSM examples.
ELEN 468 Lecture 151 ELEN 468 Advanced Logic Design Lecture 15 Synthesis of Language Construct I.
Pulse-Width Modulated DAC
1 CS 140 Lecture 14 Standard Combinational Modules Professor CK Cheng CSE Dept. UC San Diego Some slides from Harris and Harris.
Copyright © 2007 Elsevier4- Chapter 4 :: Hardware Description Languages Digital Design and Computer Architecture David Money Harris and Sarah L. Harris.
ENEE 408C Lab Capstone Project: Digital System Design Verilog Tutorial Class Web Site:
Ring Counter Discussion 11.3 Example 32.
Arbitrary Waveform Discussion 12.2 Example 34. Recall Divide-by-8 Counter Use q2, q1, q0 as inputs to a combinational circuit to produce an arbitrary.
2-to-1 Multiplexer: if Statement Discussion D7.1 Example 4.
Registers and Shift Registers Discussion D8.2. D Flip-Flop X 0 Q 0 ~Q 0 D CLK Q ~Q D gets latched to Q on the rising edge of the clock. Positive.
University of Jordan Computer Engineering Department CPE 439: Computer Design Lab.
Verilog Descriptions of Digital Systems. Electronic Lock // // Electronic combinational lock // module lock(seg7,key, valid_key, col, row, mclk, resetL)
Computer Architecture and Design – ECEN 350
Sequential Logic in Verilog
Verilog Digital System Design Z. Navabi, 2006
Programmable Logic Architecture Verilog HDL FPGA Design Jason Tseng Week 5.
Lecture 4. Verilog HDL 1 (Combinational Logic Design)
Registers CPE 49 RMUTI KOTAT.
Week Four Design & Simulation Example slides. Agenda Review the tiny example (Minako “logic”)from last week – look at the detailed static timing report.
Lecture 6. Verilog HDL – Sequential Logic
ECE 551 Digital System Design & Synthesis Fall 2011 Midterm Exam Overview.
Lecture 9. MIPS Processor Design – Instruction Fetch Prof. Taeweon Suh Computer Science Education Korea University 2010 R&E Computer System Education &
1 Workshop Topics - Outline Workshop 1 - Introduction Workshop 2 - module instantiation Workshop 3 - Lexical conventions Workshop 4 - Value Logic System.
Digital Design Lectures 11 & 12 Shift Registers and Counters.
Designing an ALU Taken from various sources Primary source: Digital Design and Computer Architecture by Harris &Harris.
Spring 2009W. Rhett DavisNC State UniversityECE 406Slide 1 ECE 406 – Design of Complex Digital Systems Lecture 7: Design Example, Modeling Flip-Flops Spring.
Anurag Dwivedi. Basic Block - Gates Gates -> Flip Flops.
Final Project. System Overview Description of Inputs reset: When LOW, a power on reset is performed. mode: When LOW, NORMal mode selected When HIGH,
CSCE 211: Digital Logic Design Chin-Tser Huang University of South Carolina.
 A test bench is an HDL program used for applying stimulus to an HDL design in order to test it and observe its response during simulation.  In addition.
Chapter 4 Computer System Architectures Chapter 4 Based on Digital Design and Computer Architecture, 2 nd Edition David Money Harris and Sarah L. Harris.
Lecture 5. Verilog HDL #1 Prof. Taeweon Suh Computer Science & Engineering Korea University COSE221, COMP211 Logic Design.
Lecture 8. ALU, Shifter, Counter,
Lecture 5. Verilog HDL #3 Prof. Taeweon Suh Computer Science & Engineering Korea University COSE221, COMP211 Logic Design.
1 Lecture 3: Modeling Sequential Logic in Verilog HDL.
Figure Implementation of an FSM in a CPLD..
Chapter 4 Digital Design and Computer Architecture: ARM® Edition
Supplement on Verilog FF circuit examples
Supplement on Verilog for Algorithm State Machine Chart
Timing and Verification
Chapter 4 Digital Design and Computer Architecture, 2nd Edition
COMP211 Computer Logic Design
Testbenches HDL that tests another module: device under test (dut)
Chapter 4 Digital Design and Computer Architecture, 2nd Edition
Lecture 9: Testbench and Division
Testbenches HDL that tests another module: device under test (dut)
Verilog.
Register-Transfer Level Components in Verilog
Lecture 9: Testbench and Division
The Verilog Hardware Description Language
The Verilog Hardware Description Language
Chapter 4 Digital Design and Computer Architecture: ARM® Edition
Introduction to Digital IC Design
Lecture 7: Verilog Part II
Presentation transcript:

1 Arithmetic, ALUs Lecture 9 Digital Design and Computer Architecture Harris & Harris Morgan Kaufmann / Elsevier, 2007

2 1-Bit Adders

3 Multi-bit Adder

4 Ripple-carry Adder

5 Subtractor

6 Comparator: Equality

7 Comparator: Less Than

8 Arithmetic Logic Unit (ALU) F 2:0 Function 000A & B 001A | B 010A + B 011not used 100A & B 101A | ~B 110A - B 111SLT

9 ALU Design

10 ALU Function F 2:0 Function 000A & B 001A | B 010A + B 011not used 100A & B 101A | ~B 110A - B 111SLT

11 Set Less Than (SLT)

12 Shifters Logical shifter: shifts value to left or right and fills empty spaces with 0’s Arithmetic shifter: same as logical shifter, but on right shift, fills empty spaces with the old most significant bit (msb). Rotator: rotates bits in a circle, such that bits shifted off one end are shifted into the other end

13 Shifter Design

14 Example Write verilog code to implement the following function in hardware: y = b’c’ + ab’ Name the module “sillyfunction”.

15 Testbenches Verilog code written to test other verilog modules Not synthesizeable

16 Simple Testbench module testbench1(); reg a, b, c; wire y; // instantiate device under test sillyfunction dut(a, b, c, y); // apply inputs one at a time initial begin a = 0; b = 0; c = 0; #10; c = 1; #10; b = 1; c = 0; #10; c = 1; #10; a = 1; b = 0; c = 0; #10; c = 1; #10; b = 1; c = 0; #10; c = 1; #10; end endmodule

17 Self-checking Testbench module testbench2(); reg a, b, c; wire y; // instantiate device under test sillyfunction dut(a, b, c, y); // apply inputs one at a time // checking results initial begin a = 0; b = 0; c = 0; #10; if (y !== 1) $display("000 failed."); c = 1; #10; if (y !== 0) $display("001 failed."); b = 1; c = 0; #10; if (y !== 0) $display("010 failed."); c = 1; #10; if (y !== 0) $display("011 failed.");

18 Self-checking Testbench (cont.) a = 1; b = 0; c = 0; #10; if (y !== 1) $display("100 failed."); c = 1; #10; if (y !== 1) $display("101 failed."); b = 1; c = 0; #10; if (y !== 0) $display("110 failed."); c = 1; #10; if (y !== 0) $display("111 failed."); end endmodule

19 Testbench with Testvectors Write testvectors file Testbench: 1.Generates clock for assigning inputs, reading outputs 2.Reads testvectors file into array 3.Assigns inputs, expected outputs 4.Compares outputs to expected outputs and reports errors

20 Testvectors File File: example.tv 000_1 001_0 010_0 011_0 100_1 101_1 110_0 111_0

21 Testbench: 1. Generate Clock module testbench3(); reg clk, reset; reg a, b, c, yexpected; wire y; reg [31:0] vectornum, errors; reg [3:0] testvectors[10000:0]; // instantiate device under test sillyfunction dut(a, b, c, y); // generate clock always begin clk = 1; #5; clk = 0; #5; end

22 2. Read Testvectors into Array // at start of test, load vectors // and pulse reset initial begin $readmemb("example.tv", testvectors); vectornum = 0; errors = 0; reset = 1; #27; reset = 0; end

23 3. Assign Inputs, Expected Outputs // apply test vectors on rising edge of clk clk) begin #1; {a, b, c, yexpected} = testvectors[vectornum]; end

24 4. Compare Outputs with Expected // check results on falling edge of clk clk) if (~reset) begin // skip during reset if (y !== yexpected) begin $display("Error: inputs = %b", {a, b, c}); $display(" outputs = %b (%b expected)", y, yexpected); errors = errors + 1; end vectornum = vectornum + 1; if (testvectors[vectornum] === 4'bx) begin $display("%d tests completed with %d errors", vectornum, errors); $finish; end endmodule

25 Next Time Number systems +