Verilog for Behavioral Modeling
|
|
|
- Abraham Briggs
- 9 years ago
- Views:
Transcription
1 Verilog for Behavioral Modeling Dept. of Electrical Engineering-Systems University of Southern California 1
2 Objective of the Lecture To address those features of Verilog that are required for the class project discussion will be limited to behavioral modeling features will be briefly presented emphasis will be given to the examples 2
3 Warning This lecture includes features supported by and tested with the Cadence Verilog-XL simulator The primary source of the presented material is the Cadence Verilog-XL Reference Manual 3
4 Outline Introduction Data types Expressions Assignments Behavioral modeling Hierarchical structures (modules) System (built-in) functions Example 4
5 Verilog Features Verilog can simulate models at the following levels: algorithmic RTL gate switch Verilog offers: behavioral language structural language 5
6 Verilog Behavioral Language Structures procedures for sequential or concurrent execution Explicit control of the time of procedure activation specified by both delay expressions and by value changes called event expressions Explicitly named events to trigger the enabling and disabling of actions in their procedures Procedural constructs for conditional, if-else, case, and looping operations Arithmetic, logical, bit-wise, and reduction operators for expressions Procedures called tasks that can have parameters and non-zero time durations (not covered in today s lecture) Procedures called functions that allow the definition of new operators (not covered in today s lecture) 6
7 Outline Introduction ========> Data types Expressions Assignments Behavioral modeling Hierarchical structures System (built-in) functions Example 7
8 Data Types Value sets: 0: logic zero or false condition 1: logic one or true condition x: unknown logic value z: high-impedance state Registers Nets Memories Integers and times integer type declaration example: integer n, k[1:64]; Reals 8
9 Data Types: Registers Abstractions of data storage elements They store a value from one assignment to the other Register type declaration examples: reg a; // a scalar register reg [3:0] b; // a 4-bit vector register reg [2:5] c; 9
10 Data Types: Nets Physical connections They do not store a value They must be driven by a driver (i.e., gate or continuous assignment) Their value is z, if not driven Net type declaration examples: wire d; // a scalar wire wire [3:0] e, f; // 4-bit vector wires Warning: There are more types of nets than wires, but they are not needed for behavioral modeling 10
11 Data Types: Memories Memories are modeled as arrays of registers Each register in the array (i.e., an element or word) is addressed by a single array index Memories are declared in register declaration statements: reg [31:0] Imem[0:255]; // a 256-word, 32-bit memory 11
12 Parameters Parameters are not variables they are constants Parameter declaration examples parameter size = 8; // defines size as a constant with value 16 12
13 Outline Introduction Data types ========> Expressions Assignments Behavioral modeling Hierarchical structures System (built-in) functions Example 13
14 Expressions The following operator types are supported: binary arithmetic relational equality logical bit-wise reduction shift concatenation conditional 14
15 Number Representation Constant numbers can be: decimal, hexadecimal, octal, or binary Two forms of representation are available: simple decimal number (e.g., 45, 507, 234, etc.) <size><base_format><number> <size>: number of bits that the constant contains <base_format>: a letter specifying the number s base (d, h, o, or b), followed by the single quote character (') <number>: digits that are legal for the specified <base_format> Examples: 4'b 'ha04f 4'b01x0 12'hx // a 4-bit binary number // a 16-bit hexadecimal number // a 4-bit binary number // a 12-bit unknown number 15
16 Arithmetic Operators Binary: +, -, *, /, % (the modulus operator) Unary: +, - Integer division truncates any fractional part The result of a modulus operation takes the sign of the first operand If any operand bit value is the unknown value x, then the entire result value is x Register data types are used as unsigned values negative numbers are stored in two s complement form 16
17 Relational Operators a < b a less than b a > b a greater than b a <= b a less than or equal to b a >= b a greater than or equal to b The result is a scalar value: 0 if the relation is false 1 if the relation is true x if any of the operands has unknown x bits Note: If a value is x or z, then the result of that test is false 17
18 Equality Operators a === b a equal to b, including x and z a!== b a not equal to b, including x and z a == b a equal to b, result may be unknown a!= b a not equal to b, result may be unknown Operands are compared bit by bit, with zero filling if the two operands do not have the same length Result is 0 (false) or 1 (true) For the == and!= operators the result is x, if either operand contains an x or a z For the === and!== operators bits with x and z are included in the comparison and must match for the result to be true the result is always 0 or 1 18
19 Logical Operators! logical negation && logical and logical or Expressions connected by && and are evaluated from left to right Evaluation stops as soon as the result is known The result is a scalar value: 0 if the relation is false 1 if the relation is true x if any of the operands has unknown x bits 19
20 Bit-wise Operators ~ negation & and inclusive or ^ exclusive or ^~ or ~^ exclusive nor (equivalence) Computations include unknown bits, in the following way: ~x = x, 0&x = 0, 1&x = x&x = x, 1 x = 1, 0 x = x x = x 0^x = 1^x = x^x = x, 0^~x = 1^~x = x^~x = x When operands are of unequal bit length, the shorter operand is zero-filled in the most significant bit positions 20
21 Reduction Operators & and ~& nand or ~ nor ^ xor ^~ or ~^ xnor Reduction operators are unary They perform a bit-wise operation on a single operand to produce a single bit result Reduction unary NAND and NOR operators operate as AND and OR respectively, but with their outputs negated Unknown bits are treated as described before 21
22 Shift Operators << left shift >> right shift The left operand is shifted by the number of bit positions given by the right operand The vacated bit positions are filled with zeroes 22
23 Concatenation Operator Concatenations are expressed using the brace characters { and }, with commas separating the expressions within Examples {a, b[3:0], c, 4'b1001} // if a and c are 8-bit numbers, the results has 24 bits Unsized constant numbers are not allowed in concatenations Repetition multipliers that must be constants can be used: {3{a}} // this is equivalent to {a, a, a} Nested concatenations are possible: {b, {3{c, d}}} // this is equivalent to {b, c, d, c, d, c, d} 23
24 Conditional Operator The conditional operator has the following C-like format: cond_expr? true_expr : false_expr The true_expr or the false_expr is evaluated and used as a result depending on whether cond_expr evaluates to true or false 24
25 Operator Precedence Rules!, ~ highest precedence, /, % +, - <<, >> <, <=, >, >= ==,!=, ===,!== & ^, ^~ &&?: lowest precedence 25
26 Issues about Operands Parts or single bits of registers and nets can be used as operands: reg [7:0] a; // a is declared as an 8-bit register a[4] could be used as a single-bit operand in an expression a[6:3] could be used as a 4-bit operand in an expression There is no mechanism to express bit-selects or pert-selects of memory elements directly (only entire memory words) reg [7:0] mema[0:255] // mema is declared as a 8-bit, 256 word register mema[15] is a valid operand which includes the 16th memory word 26
27 Outline Introduction Data types Expressions ========> Assignments Behavioral modeling Hierarchical structures System (built-in) functions Example 27
28 Assignments Continuous assignments, which assigns values to nets Procedural assignments, which assigns values to registers 28
29 Continuous Assignments Continuous assignments drive values onto nets (vector and scalar) The assignment occurs whenever simulation causes the value of the right-hand side to change They provide a way to model combinational logic specifying the logical expression that drives the net instead of an interconnection of gates The right-hand side expression is not restricted in any way Whenever an operand in the right hand side changes value during simulation, the whole right-hand side expression is evaluated and assigned to the left-hand side Modeling a 16-bit adder with a continuous assignment wire [15:0] sum, a, b; // declaration of 16-bit vector nets wire cin, cout; // declaration of 1-bit (scalar) nets assign // assign is a keyword {cout, sum} = a + b + cin; 29
30 Procedural Assignments Procedural assignments drive values onto registers (vector and scalar) They do not have duration (the register data type holds the value of the assignment until the next procedural assignment to the register) They occur within procedures such as always and initial (described right after) They are triggered when the flow of execution in the simulation reaches them 30
31 Outline Introduction Data types Expressions Assignments ========> Behavioral modeling Hierarchical structures System (built-in) functions Example 31
32 Behavioral Modeling Introduction Procedural assignments Conditional statement Case statement Looping statements Timing controls Block statements Structured procedures 32
33 33 Introduction to Behavioral Modeling Activity starts at the control constructs initial and always Each initial and always statement starts a new concurrent activity flow Time units are used to represent simulation time A simple example: module behave; reg [1:0] a,b; // a and b are 2-bit register data types initial // this statement is executed only once begin a = 2'b01; // a is initialized to 01 b = 2'b00; // b is initialized to 00 end always // this statement is repetitively executed until begin // simulation is completed #50 a = ~a; // register a inverts every 50 time units end always // this statement is repetitively executed begin // simulation is completed end endmodule #100 b = ~b; // register b inverts every 100 time units
34 More on Procedural Assignments Blocking procedural assignments: <lvalue>=<timing_control> <expression> must be executed before the execution of the statements that follow them in a sequential block does not prevent the execution of statements that follow them in a parallel block Non-blocking procedural assignments: <lvalue><=<timing_control> <expression> allow to schedule assignments without blocking the procedural flow used whenever you want to make several register assignments within the same time step without regard to order or dependance upon each other (e.g., register swap) they are executed in two steps: (a) the simulator evaluates the right-hand side, (b) the assignment occurs at the end of the time step indicated by the <timing_control> <timing_control> is optional in both cases It is possible to complete your project by using blocking only statements 34
35 Procedural Assignment Example module block; reg a, b, c, d, e, f; initial begin a = #10 1; // a is assigned at simulation time 10 b = #2 0; // b is assigned at simulation time 12 c = #4 1; // c is assigned at simulation time 16 end initial begin d <= #10 1; // d is assigned at simulation time 10 e <= #2 0; // e is assigned at simulation time 2 f <= #4 1; // f is assigned at simulation time 4 end endmodule 35
36 Procedural Assignment Example (cond) module block; reg a, b, c, d, e, f; initial begin #10 a = 1; // a is assigned at simulation time 10 #2 b = 0; // b is assigned at simulation time 12 #4 c = 1; // c is assigned at simulation time 16 end initial begin #10 d <= 1; // d is assigned at simulation time 10 #2 e <= 0; // e is assigned at simulation time 12 $4 f <= 1; // f is assigned at simulation time 16 end endmodule 36
37 Conditional Statement if (<expression>) <statement> else <statement> Equivalent to: if (<expression>!= 0) <statement> else <statement> else-clause is optional and is always associated with the closest previous if that lacks an else Example if (index > 0) if (rega > regb) result = rega; else // else applies to preceding if result = regb; 37
38 Case Statement Case statement is a special multi-way decision statement: reg [1:0] sel; reg [15:0] in0, in1, in2, in3, out; case (sel) 2'b00: out = in0; 2'b01: out = in1; 2'b10: out = in2; 2'b11: out = in3; default out = 16'bx; endcase The default statement is optional If all comparisons fail and the default is not given, none of the case statements is executed 38
39 Case Statement (cond) Case statement used to trap x and z values: reg [1:0] sel, flag; reg [15:0] in0, in1, in2, in3, out; case (sel) 2'b00: out = in0; 2'b01: out = in1; 2'b0x, 2'b0z: out = flag? 16'bx : 16'b0; 2'b10: out = in2; 2'b11: out = in3; 2'bx0, 2'bz0: out = flag? 16'bx : 16'b0; default out = 16'bx; endcase 39
40 Case Statement with Don t-cares casez: high-impedance (z) values are treated as don t-cares casex: high-impedance (z) and unknown (x) values are treated as don t-cares reg [31:0] instruction; reg [2:0] aluop; casez (instruction[31:26]) 6'b00????: aluop = 3'b000; //? indicates a don t-care bit position 6'b100???: aluop = 3'b001; 6'b101???: aluop = 3'b010; 6'b1100??: aluop = 3'b001; 6'b11010?: aluop = 3'b100; 6'b110110: aluop = 3'b101; endcase 40
41 Looping Statements forever repeat while for 41
42 Forever Statement Continuously executes a statement Should be used in conjunction with the timing controls (to be presented later) 42
43 Repeat Statement Executes a statement a fixed number of times parameter size = 8, longsize = 16; reg [size:1] opa, opb; reg [longsize:1] result; begin: mult // begin-end statements could optionally be named reg [longsize:1] shift_opa, shift_opb; shift_opa = opa; shift_opb = opb; result = 0; repeat (size) begin if (shift_opb[1]) result = result + shift_opa; shift_opa = shift_opa << 1; shift_opb = shift_opb >> 1; end end 43
44 While Statement Executes a statement until an expression becomes false begin: count1s reg [7:0] tempreg; count = 0; tempreg = rega; while (tempreg) begin if (tempreg[0]) count = count + 1; tempreg = tempreg >> 1; end end 44
45 For Statement Similar to C for-statement for (initial_assignment; condition; step_assignment) statement Using a for-loop to initialize a memory: begin :init_mem reg [7:0] tempi; for (tempi = 0; tempi < memsize; tempi = tempi + 1) memory[tempi] = 0; end 45
46 Procedural Timing Controls delay control, which is introduced by the number symbol (#) event control, which is introduced by the at symbol wait statement, which operates like a combination of the event control and the while loop 46
47 Delay Control Examples #10 rega = regb; #d rega = regb; // d is defined as a parameter #((d+e)/2) rega = regb; #regr regr = regr + 1; // delay is the value in regr 47
48 Event Control Synchronizes execution of a procedural statement with a value change on a net or register, or the occurrence of a declared event rega = regb; // controlled by any value changes in the register clock) rega = regb; // controlled by positive edge on clock clock) rega = regb; // controlled by negative or enable) rega = regb; // controlled by trig or clock_a or posedge clock_b) rega = regb; 48
49 Wait Statement The execution of a statement can be delayed until a condition becomes true The wait statement checks a condition: if it is false, causes the procedure to pause until that condition becomes true before continuing Example: wait (condition_expression) statement reg enable, a, b; initial begin wait (!enable) #10 a = 1; // a becomes 1 at #110 #10 b = 1; // b becomes 1 at #120 end initial #100 enable = 0; 49
50 Intra-Assignment Timing Controls Can be delay or event controls The right-hand side expression is evaluate before the delay or the event, but the assignment happens when the delay expires or the event happens: a = #5 b; equivalent to: begin temp = b; #5 a = temp; end a clk) b; equivalent to: begin temp = clk) a = temp; end 50
51 Block Statements Sequential blocks delimited by the keywords begin and end statements execute in sequence, one after another delays are cumulative; each statement executes after all the delays preceding it have elapsed control passes out of the block after the last statement executes Parallel blocks delimited by the keywords fork and join statements execute concurrently delay values for each statement are relative to the simulation time when control enters the block delay control is used to provide time-ordering for assignments control passes out of the block when the last time-ordered statement executes or a disable statement executes 51
52 Sequential Block Examples begin #10 a = 1; // a becomes 1 at #10 #20 a = 0; // a becomes 0 at #30 end r = 1; // r becomes 1 when trig changes value #250 r = 0; // r becomes time units after r changes value end clock) q = clock) q = 1; end // q becomes 0 at the posedge of clock // q becomes 1 at the next posedge of clock 52
53 Parallel Block Examples fork join #30 a = 0; // a becomes 0 at #30 #10 a = 1; // a becomes 1 at #10 fork clock) q = clock) w = 1; // q becomes 0 at the posedge of clock // w becomes 1 at the same posedge of clock begin join areg = breg; // this statement is executed after both Aevent and // Bevent have occurred regardless their order 53
54 Structured Procedures initial statement always statement task (not discussed) function (not discussed) 54
55 Initial Statement Activated at the beginning of simulation Executed once initial begin areg = 0; // initialize a register for (index = 0; index < size; index = index + 1) memory[index] = 0; // initialize a memory end initial begin inputs = 6'b000000; #10 inputs = 6'b001011; #10 inputs = 6'b110001; end 55
56 Always Statement Activated at the beginning of simulation Repeats continuously throughout the whole simulation run always #100 clock = ~clock // creates a clock signal with #200 period time clock) // the block below starts execution at posedge of clock begin #10 a = 0; // #10 after the posedge of clock, a becomes 0 #20 b = 1; // #30 after the posedge of clock, b becomes 1 #40 b = 0; // #70 after the posedge of clock, b becomes 1 end 56
57 Outline Introduction Data types Expressions Assignments Behavioral modeling ========> Hierarchical structures System (built-in) functions Example 57
58 Hierarchical Structures Hierarchy consists of modules High-level modules create instances of lower-level modules Modules communicate through input, output, and bidirectional ports Each module definition stands alone; the definitions are not nested 58
59 Syntax of Module Definitions module mname (port1, port2, port3, port4,...); // keywords are in italics output port1; input port2, port3; inout port4; reg port1; // output ports are usually defined as registers reg variable1, variable2; // definitions of local variables wire variable3; initial statements // any of the behavioral modeling statements always statements // any of the behavioral modeling statements assign continuous-assign-statements // required for nets mod1 mod1instance (variable1, variable2,...) // instantiating lowerlevel modules endmodule 59
60 Module Ports Used to connect modules Can be thought as procedure parameters Could be input, output, or inout Input and inout ports can be only net data type My advice is: define all the output ports as registers works fine with input ports because, in module connections, input ports are driven by output ports that are registers define all the inout ports as wires and use assign statements for them 60
61 Example module m; reg clk; wire [1:10] out_a, in_a; wire [1:5] out_b, in_b; // create an instance and set parameters vddf #(10, 15) mod_a (out_a, in_a, clk); // create an instance leaving default values vddf mod_b (out_b, in_b, clk); endmodule module vdff (out, in, clk); parameter size = 1, delay = 1; input [0:size-1] in; input clk; output [0:size-1] out; reg [0:size-1] out; clk) #delay out = in; endmodule 61
62 Outline Introduction Data types Expressions Assignments Behavioral modeling Hierarchical structures ========> System (built-in) functions Example 62
63 $display and $write They display information They are identical, except that $display automatically adds a newline character to the end of the output Similar to the C printf statement $display("rval = %h hex %d decimal", rval, rval) $display("rval = %o octal %b binary", rval, rval) $write("simulation time is $t \n", $time); //$time is a function that returns the current simulation time 63
64 Format Specifications %h or %H display in hexadecimal format %d or %D display in decimal format %o or %O display in octal format %b or %B display in binary format %c or %C display in ASCII character format %m or %M display hierarchical name (doesn t need a parameter) %s or %S display as a string %t or %T display in current time format 64
65 Continuous Monitoring $monitor, $monitoron, $monitoroff $monitor displays a list of variables any time one of them changes $monitoron and $monitoroff enable and disable the monitor statement respectively $monitor($time, "rxb=%b txb=%b", rxb, txb); 65
66 Strobed Monitoring The $strobe system task displays the specified information at the end of the time unit Same format as $display clock) $strobe("at time %d, data is %h", $time, data); 66
67 File Output $fopen opens a file: integer out_file; // out_file is a file descriptor (declared as integer) out_file = $fopen("cpu.data"); // cpu.data is the file opened $fdisplay, $fwrite, $fstrobe, $fmonitor are used to write data into the file: $fdisplay(out_file, "rval = %h hex %d decimal", rval, rval); $fclose closes a file: $fclose(out_file); 67
68 $finish $finish causes the simulator to exit and pass control back to the host operating system Example: if the simulation time is #800, then use the following statement at the beginning of the top-level module initial #800 $finish; 68
69 Loading Memories from Text Files $readmemb and $readmemh read and load (binary and hexadecimal respectively) data from a specified text file into a specified memory reg [7:0] mem[1:256] // a 8-bit, 256-word memory is declared To load the memory at simulation time 0 starting at address 1 from file mem.data: initial $readmemh("mem.data", mem) To load the memory at simulation time 0 starting at address 16 and continuing on towards address 256 from file mem.data: initial $readmemh("mem.data", mem, 16) To load the memory at simulation time 0 starting at address 128 and continuing down towards address 1 from file mem.data: initial $readmemh("mem.data", mem, 128, 1) 69
70 Displaying Signals as Graphical Waveforms Used with cwaves graphical interface $shm_open opens a database $shm_probe specifies signals whose waveform can be displayed with cwaves $shm_close terminates the simulation s connection to the database initial $shm_open("signals.shm"); // default database name is waves.shm $shm_probe(clk, opa, opb); // $shm_probe("as"); would probe all signals #800 $shm_close(); $finish; 70
71 Outline Introduction Data types Expressions Assignments Behavioral modeling Hierarchical structures System (built-in) functions ========> Example 71
72 Simulating a Simple Instruction Set Architecture A baby-instruction set: Imm R d MV: R d sign_ext(imm) R sr R d ADD: R d R d +R sr R sr R d XOR: R d R d R sr No memory instructions No control transfer instructions If the operand of an instruction is written by the previous one, the old value is read 72
73 Block Diagram Data Path I-Memory PC Counter ALU CPU Register File Reset Instruction Decoder 73
74 A Data-Memory Example Test Module Accessing the Memory D-Memory Address Data Rd/Wr An example where a module port should be declared as inout (i.e., the data bus) Assuming a single phase clocking scheme, the data bus is actively driven by the test module during the first half cycle and by the memory during the second half cycle Temporary register data type variables are required from both sides The assign-statement should be used 74
Life Cycle of a Memory Request. Ring Example: 2 requests for lock 17
Life Cycle of a Memory Request (1) Use AQR or AQW to place address in AQ (2) If A[31]==0, check for hit in DCache Ring (3) Read Hit: place cache word in RQ; Write Hit: replace cache word with WQ RDDest/RDreturn
ECE 3401 Lecture 7. Concurrent Statements & Sequential Statements (Process)
ECE 3401 Lecture 7 Concurrent Statements & Sequential Statements (Process) Concurrent Statements VHDL provides four different types of concurrent statements namely: Signal Assignment Statement Simple Assignment
Understanding Verilog Blocking and Non-blocking Assignments
Understanding Verilog Blocking and Non-blocking Assignments International Cadence User Group Conference September 11, 1996 presented by Stuart HDL Consulting About the Presenter Stuart has over 8 years
ECE232: Hardware Organization and Design. Part 3: Verilog Tutorial. http://www.ecs.umass.edu/ece/ece232/ Basic Verilog
ECE232: Hardware Organization and Design Part 3: Verilog Tutorial http://www.ecs.umass.edu/ece/ece232/ Basic Verilog module ();
Chapter 4 Register Transfer and Microoperations. Section 4.1 Register Transfer Language
Chapter 4 Register Transfer and Microoperations Section 4.1 Register Transfer Language Digital systems are composed of modules that are constructed from digital components, such as registers, decoders,
Modeling Sequential Elements with Verilog. Prof. Chien-Nan Liu TEL: 03-4227151 ext:34534 Email: [email protected]. Sequential Circuit
Modeling Sequential Elements with Verilog Prof. Chien-Nan Liu TEL: 03-4227151 ext:34534 Email: [email protected] 4-1 Sequential Circuit Outputs are functions of inputs and present states of storage elements
A Verilog HDL Test Bench Primer Application Note
A Verilog HDL Test Bench Primer Application Note Table of Contents Introduction...1 Overview...1 The Device Under Test (D.U.T.)...1 The Test Bench...1 Instantiations...2 Figure 1- DUT Instantiation...2
Let s put together a Manual Processor
Lecture 14 Let s put together a Manual Processor Hardware Lecture 14 Slide 1 The processor Inside every computer there is at least one processor which can take an instruction, some operands and produce
Registers & Counters
Objectives This section deals with some simple and useful sequential circuits. Its objectives are to: Introduce registers as multi-bit storage devices. Introduce counters by adding logic to registers implementing
VHDL Test Bench Tutorial
University of Pennsylvania Department of Electrical and Systems Engineering ESE171 - Digital Design Laboratory VHDL Test Bench Tutorial Purpose The goal of this tutorial is to demonstrate how to automate
Chapter 7: Advanced Modeling Techniques
Chapter 7: Advanced Modeling Techniques Prof. Ming-Bo Lin Department of Electronic Engineering National Taiwan University of Science and Technology Digital System Designs and Practices Using Verilog HDL
More Verilog. 8-bit Register with Synchronous Reset. Shift Register Example. N-bit Register with Asynchronous Reset.
More Verilog 8-bit Register with Synchronous Reset module reg8 (reset, CLK, D, Q); input reset; input [7:0] D; output [7:0] Q; reg [7:0] Q; if (reset) Q = 0; else Q = D; module // reg8 Verilog - 1 Verilog
ECE 451 Verilog Exercises. Sept 14, 2007. James Barnes ([email protected])
ECE 451 Verilog Exercises Sept 14, 2007 James Barnes ([email protected]) Organization These slides give a series of self-paced exercises. Read the specification of each exercise and write your
Name: Class: Date: 9. The compiler ignores all comments they are there strictly for the convenience of anyone reading the program.
Name: Class: Date: Exam #1 - Prep True/False Indicate whether the statement is true or false. 1. Programming is the process of writing a computer program in a language that the computer can respond to
6. Control Structures
- 35 - Control Structures: 6. Control Structures A program is usually not limited to a linear sequence of instructions. During its process it may bifurcate, repeat code or take decisions. For that purpose,
Module 3: Floyd, Digital Fundamental
Module 3: Lecturer : Yongsheng Gao Room : Tech - 3.25 Email : [email protected] Structure : 6 lectures 1 Tutorial Assessment: 1 Laboratory (5%) 1 Test (20%) Textbook : Floyd, Digital Fundamental
The string of digits 101101 in the binary number system represents the quantity
Data Representation Section 3.1 Data Types Registers contain either data or control information Control information is a bit or group of bits used to specify the sequence of command signals needed for
Informatica e Sistemi in Tempo Reale
Informatica e Sistemi in Tempo Reale Introduction to C programming Giuseppe Lipari http://retis.sssup.it/~lipari Scuola Superiore Sant Anna Pisa October 25, 2010 G. Lipari (Scuola Superiore Sant Anna)
A New Paradigm for Synchronous State Machine Design in Verilog
A New Paradigm for Synchronous State Machine Design in Verilog Randy Nuss Copyright 1999 Idea Consulting Introduction Synchronous State Machines are one of the most common building blocks in modern digital
3. VERILOG HARDWARE DESCRIPTION LANGUAGE
3. VERILOG HARDWARE DESCRIPTION LANGUAGE The previous chapter describes how a designer may manually use ASM charts (to describe behavior) and block diagrams (to describe structure) in top-down hardware
Chapter One Introduction to Programming
Chapter One Introduction to Programming 1-1 Algorithm and Flowchart Algorithm is a step-by-step procedure for calculation. More precisely, algorithm is an effective method expressed as a finite list of
Keywords are identifiers having predefined meanings in C programming language. The list of keywords used in standard C are : unsigned void
1. Explain C tokens Tokens are basic building blocks of a C program. A token is the smallest element of a C program that is meaningful to the compiler. The C compiler recognizes the following kinds of
CHAPTER 11: Flip Flops
CHAPTER 11: Flip Flops In this chapter, you will be building the part of the circuit that controls the command sequencing. The required circuit must operate the counter and the memory chip. When the teach
Object Oriented Software Design
Object Oriented Software Design Introduction to Java - II Giuseppe Lipari http://retis.sssup.it/~lipari Scuola Superiore Sant Anna Pisa September 14, 2011 G. Lipari (Scuola Superiore Sant Anna) Introduction
BINARY CODED DECIMAL: B.C.D.
BINARY CODED DECIMAL: B.C.D. ANOTHER METHOD TO REPRESENT DECIMAL NUMBERS USEFUL BECAUSE MANY DIGITAL DEVICES PROCESS + DISPLAY NUMBERS IN TENS IN BCD EACH NUMBER IS DEFINED BY A BINARY CODE OF 4 BITS.
Chapter 13: Verification
Chapter 13: Verification Prof. Ming-Bo Lin Department of Electronic Engineering National Taiwan University of Science and Technology Digital System Designs and Practices Using Verilog HDL and FPGAs @ 2008-2010,
Sources: On the Web: Slides will be available on:
C programming Introduction The basics of algorithms Structure of a C code, compilation step Constant, variable type, variable scope Expression and operators: assignment, arithmetic operators, comparison,
Lab #5: Design Example: Keypad Scanner and Encoder - Part 1 (120 pts)
Dr. Greg Tumbush, [email protected] Lab #5: Design Example: Keypad Scanner and Encoder - Part 1 (120 pts) Objective The objective of lab assignments 5 through 9 are to systematically design and implement
Verilog - Representation of Number Literals
Verilog - Representation of Number Literals... And here there be monsters! (Capt. Barbossa) Numbers are represented as: value ( indicates optional part) size The number of binary
Systems I: Computer Organization and Architecture
Systems I: Computer Organization and Architecture Lecture 9 - Register Transfer and Microoperations Microoperations Digital systems are modular in nature, with modules containing registers, decoders, arithmetic
I PUC - Computer Science. Practical s Syllabus. Contents
I PUC - Computer Science Practical s Syllabus Contents Topics 1 Overview Of a Computer 1.1 Introduction 1.2 Functional Components of a computer (Working of each unit) 1.3 Evolution Of Computers 1.4 Generations
Memory Elements. Combinational logic cannot remember
Memory Elements Combinational logic cannot remember Output logic values are function of inputs only Feedback is needed to be able to remember a logic value Memory elements are needed in most digital logic
Lab1 : 2-1 MUX. 1. Change to Lab1 directory. It contains the mux.v and mux_text.v files. use this command : cd Lab1
Please design a 2-1MUX Specifications Module name : mux Input pins : a, b, sel Output pins : out Function : Lab1 : 2-1 MUX 1. Change to Lab1 directory. It contains the mux.v and mux_text.v files. use this
(Refer Slide Time: 00:01:16 min)
Digital Computer Organization Prof. P. K. Biswas Department of Electronic & Electrical Communication Engineering Indian Institute of Technology, Kharagpur Lecture No. # 04 CPU Design: Tirning & Control
1. True or False? A voltage level in the range 0 to 2 volts is interpreted as a binary 1.
File: chap04, Chapter 04 1. True or False? A voltage level in the range 0 to 2 volts is interpreted as a binary 1. 2. True or False? A gate is a device that accepts a single input signal and produces one
Coding Guidelines for Datapath Synthesis
Coding Guidelines for Datapath Synthesis Reto Zimmermann Synopsys July 2005 Abstract This document summarizes two classes of RTL coding guidelines for the synthesis of datapaths: Guidelines that help achieve
Digital Electronics Detailed Outline
Digital Electronics Detailed Outline Unit 1: Fundamentals of Analog and Digital Electronics (32 Total Days) Lesson 1.1: Foundations and the Board Game Counter (9 days) 1. Safety is an important concept
1. Convert the following base 10 numbers into 8-bit 2 s complement notation 0, -1, -12
C5 Solutions 1. Convert the following base 10 numbers into 8-bit 2 s complement notation 0, -1, -12 To Compute 0 0 = 00000000 To Compute 1 Step 1. Convert 1 to binary 00000001 Step 2. Flip the bits 11111110
ECE410 Design Project Spring 2008 Design and Characterization of a CMOS 8-bit Microprocessor Data Path
ECE410 Design Project Spring 2008 Design and Characterization of a CMOS 8-bit Microprocessor Data Path Project Summary This project involves the schematic and layout design of an 8-bit microprocessor data
EE 261 Introduction to Logic Circuits. Module #2 Number Systems
EE 261 Introduction to Logic Circuits Module #2 Number Systems Topics A. Number System Formation B. Base Conversions C. Binary Arithmetic D. Signed Numbers E. Signed Arithmetic F. Binary Codes Textbook
150127-Microprocessor & Assembly Language
Chapter 3 Z80 Microprocessor Architecture The Z 80 is one of the most talented 8 bit microprocessors, and many microprocessor-based systems are designed around the Z80. The Z80 microprocessor needs an
Modeling Registers and Counters
Lab Workbook Introduction When several flip-flops are grouped together, with a common clock, to hold related information the resulting circuit is called a register. Just like flip-flops, registers may
COMP 250 Fall 2012 lecture 2 binary representations Sept. 11, 2012
Binary numbers The reason humans represent numbers using decimal (the ten digits from 0,1,... 9) is that we have ten fingers. There is no other reason than that. There is nothing special otherwise about
Counters and Decoders
Physics 3330 Experiment #10 Fall 1999 Purpose Counters and Decoders In this experiment, you will design and construct a 4-bit ripple-through decade counter with a decimal read-out display. Such a counter
An Integer Square Root Algorithm
An Integer Square Root Algorithm 71 Example 24 An Integer Square Root Algorithm The C algorithm shown in Fig. 2.8 performs an integer square root of the input a as shown in Table 2.1. Note from Table 2.1
Lecture 2. Binary and Hexadecimal Numbers
Lecture 2 Binary and Hexadecimal Numbers Purpose: Review binary and hexadecimal number representations Convert directly from one base to another base Review addition and subtraction in binary representations
Chapter 2 Verilog HDL for Design and Test
Chapter 2 Verilog HDL for Design and Test In Chapter 1, we discussed the basics of test and presented ways in which hardware description languages (HDLs) could be used to improve various aspects of digital
The 104 Duke_ACC Machine
The 104 Duke_ACC Machine The goal of the next two lessons is to design and simulate a simple accumulator-based processor. The specifications for this processor and some of the QuartusII design components
Computer organization
Computer organization Computer design an application of digital logic design procedures Computer = processing unit + memory system Processing unit = control + datapath Control = finite state machine inputs
Digital Logic Design. Basics Combinational Circuits Sequential Circuits. Pu-Jen Cheng
Digital Logic Design Basics Combinational Circuits Sequential Circuits Pu-Jen Cheng Adapted from the slides prepared by S. Dandamudi for the book, Fundamentals of Computer Organization and Design. Introduction
Embedded Systems. Review of ANSI C Topics. A Review of ANSI C and Considerations for Embedded C Programming. Basic features of C
Embedded Systems A Review of ANSI C and Considerations for Embedded C Programming Dr. Jeff Jackson Lecture 2-1 Review of ANSI C Topics Basic features of C C fundamentals Basic data types Expressions Selection
ETEC 2301 Programmable Logic Devices. Chapter 10 Counters. Shawnee State University Department of Industrial and Engineering Technologies
ETEC 2301 Programmable Logic Devices Chapter 10 Counters Shawnee State University Department of Industrial and Engineering Technologies Copyright 2007 by Janna B. Gallaher Asynchronous Counter Operation
Digital System Design Prof. D Roychoudhry Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur
Digital System Design Prof. D Roychoudhry Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur Lecture - 04 Digital Logic II May, I before starting the today s lecture
LAB #4 Sequential Logic, Latches, Flip-Flops, Shift Registers, and Counters
LAB #4 Sequential Logic, Latches, Flip-Flops, Shift Registers, and Counters LAB OBJECTIVES 1. Introduction to latches and the D type flip-flop 2. Use of actual flip-flops to help you understand sequential
Decimal Number (base 10) Binary Number (base 2)
LECTURE 5. BINARY COUNTER Before starting with counters there is some vital information that needs to be understood. The most important is the fact that since the outputs of a digital chip can only be
Programmable Logic Design Grzegorz Budzyń Lecture. 12: VHDL vs Verilog
Programmable Logic Design Grzegorz Budzyń Lecture 12: VHDL vs Verilog Plan Introduction Veriloginbrief VHDL/Verilog comparison Examples Summary Introduction Introduction At presenttherearetwo industry
Lecture 2 Notes: Flow of Control
6.096 Introduction to C++ January, 2011 Massachusetts Institute of Technology John Marrero Lecture 2 Notes: Flow of Control 1 Motivation Normally, a program executes statements from first to last. The
CS101 Lecture 26: Low Level Programming. John Magee 30 July 2013 Some material copyright Jones and Bartlett. Overview/Questions
CS101 Lecture 26: Low Level Programming John Magee 30 July 2013 Some material copyright Jones and Bartlett 1 Overview/Questions What did we do last time? How can we control the computer s circuits? How
CHAPTER 3 Boolean Algebra and Digital Logic
CHAPTER 3 Boolean Algebra and Digital Logic 3.1 Introduction 121 3.2 Boolean Algebra 122 3.2.1 Boolean Expressions 123 3.2.2 Boolean Identities 124 3.2.3 Simplification of Boolean Expressions 126 3.2.4
Gates, Circuits, and Boolean Algebra
Gates, Circuits, and Boolean Algebra Computers and Electricity A gate is a device that performs a basic operation on electrical signals Gates are combined into circuits to perform more complicated tasks
Upon completion of unit 1.1, students will be able to
Upon completion of unit 1.1, students will be able to 1. Demonstrate safety of the individual, class, and overall environment of the classroom/laboratory, and understand that electricity, even at the nominal
Chapter Binary, Octal, Decimal, and Hexadecimal Calculations
Chapter 5 Binary, Octal, Decimal, and Hexadecimal Calculations This calculator is capable of performing the following operations involving different number systems. Number system conversion Arithmetic
DEPARTMENT OF INFORMATION TECHNLOGY
DRONACHARYA GROUP OF INSTITUTIONS, GREATER NOIDA Affiliated to Mahamaya Technical University, Noida Approved by AICTE DEPARTMENT OF INFORMATION TECHNLOGY Lab Manual for Computer Organization Lab ECS-453
Oct: 50 8 = 6 (r = 2) 6 8 = 0 (r = 6) Writing the remainders in reverse order we get: (50) 10 = (62) 8
ECE Department Summer LECTURE #5: Number Systems EEL : Digital Logic and Computer Systems Based on lecture notes by Dr. Eric M. Schwartz Decimal Number System: -Our standard number system is base, also
JAVA - QUICK GUIDE. Java SE is freely available from the link Download Java. So you download a version based on your operating system.
http://www.tutorialspoint.com/java/java_quick_guide.htm JAVA - QUICK GUIDE Copyright tutorialspoint.com What is Java? Java is: Object Oriented Platform independent: Simple Secure Architectural- neutral
Flip-Flops, Registers, Counters, and a Simple Processor
June 8, 22 5:56 vra235_ch7 Sheet number Page number 349 black chapter 7 Flip-Flops, Registers, Counters, and a Simple Processor 7. Ng f3, h7 h6 349 June 8, 22 5:56 vra235_ch7 Sheet number 2 Page number
Contents COUNTER. Unit III- Counters
COUNTER Contents COUNTER...1 Frequency Division...2 Divide-by-2 Counter... 3 Toggle Flip-Flop...3 Frequency Division using Toggle Flip-flops...5 Truth Table for a 3-bit Asynchronous Up Counter...6 Modulo
9 Control Statements. 9.1 Introduction. 9.2 Objectives. 9.3 Statements
9 Control Statements 9.1 Introduction The normal flow of execution in a high level language is sequential, i.e., each statement is executed in the order of its appearance in the program. However, depending
Computer Science 281 Binary and Hexadecimal Review
Computer Science 281 Binary and Hexadecimal Review 1 The Binary Number System Computers store everything, both instructions and data, by using many, many transistors, each of which can be in one of two
Jianjian Song LogicWorks 4 Tutorials (5/15/03) Page 1 of 14
LogicWorks 4 Tutorials Jianjian Song Department of Electrical and Computer Engineering Rose-Hulman Institute of Technology March 23 Table of Contents LogicWorks 4 Installation and update...2 2 Tutorial
Numeral Systems. The number twenty-five can be represented in many ways: Decimal system (base 10): 25 Roman numerals:
Numeral Systems Which number is larger? 25 8 We need to distinguish between numbers and the symbols that represent them, called numerals. The number 25 is larger than 8, but the numeral 8 above is larger
Digital Systems Based on Principles and Applications of Electrical Engineering/Rizzoni (McGraw Hill
Digital Systems Based on Principles and Applications of Electrical Engineering/Rizzoni (McGraw Hill Objectives: Analyze the operation of sequential logic circuits. Understand the operation of digital counters.
UIL Computer Science for Dummies by Jake Warren and works from Mr. Fleming
UIL Computer Science for Dummies by Jake Warren and works from Mr. Fleming 1 2 Foreword First of all, this book isn t really for dummies. I wrote it for myself and other kids who are on the team. Everything
Today. Binary addition Representing negative numbers. Andrew H. Fagg: Embedded Real- Time Systems: Binary Arithmetic
Today Binary addition Representing negative numbers 2 Binary Addition Consider the following binary numbers: 0 0 1 0 0 1 1 0 0 0 1 0 1 0 1 1 How do we add these numbers? 3 Binary Addition 0 0 1 0 0 1 1
Sequential Logic. (Materials taken from: Principles of Computer Hardware by Alan Clements )
Sequential Logic (Materials taken from: Principles of Computer Hardware by Alan Clements ) Sequential vs. Combinational Circuits Combinatorial circuits: their outputs are computed entirely from their present
13 Classes & Objects with Constructors/Destructors
13 Classes & Objects with Constructors/Destructors 13.1 Introduction In object oriented programming, the emphasis is on data rather than function. Class is a way that binds the data & function together.
CSE140 Homework #7 - Solution
CSE140 Spring2013 CSE140 Homework #7 - Solution You must SHOW ALL STEPS for obtaining the solution. Reporting the correct answer, without showing the work performed at each step will result in getting
C Programming. for Embedded Microcontrollers. Warwick A. Smith. Postbus 11. Elektor International Media BV. 6114ZG Susteren The Netherlands
C Programming for Embedded Microcontrollers Warwick A. Smith Elektor International Media BV Postbus 11 6114ZG Susteren The Netherlands 3 the Table of Contents Introduction 11 Target Audience 11 What is
COMBINATIONAL CIRCUITS
COMBINATIONAL CIRCUITS http://www.tutorialspoint.com/computer_logical_organization/combinational_circuits.htm Copyright tutorialspoint.com Combinational circuit is a circuit in which we combine the different
MACHINE ARCHITECTURE & LANGUAGE
in the name of God the compassionate, the merciful notes on MACHINE ARCHITECTURE & LANGUAGE compiled by Jumong Chap. 9 Microprocessor Fundamentals A system designer should consider a microprocessor-based
CSI 333 Lecture 1 Number Systems
CSI 333 Lecture 1 Number Systems 1 1 / 23 Basics of Number Systems Ref: Appendix C of Deitel & Deitel. Weighted Positional Notation: 192 = 2 10 0 + 9 10 1 + 1 10 2 General: Digit sequence : d n 1 d n 2...
Designing Digital Circuits a modern approach. Jonathan Turner
Designing Digital Circuits a modern approach Jonathan Turner 2 Contents I First Half 5 1 Introduction to Designing Digital Circuits 7 1.1 Getting Started.......................... 7 1.2 Gates and Flip
Chapter 5 Programming Statements. Chapter Table of Contents
Chapter 5 Programming Statements Chapter Table of Contents OVERVIEW... 57 IF-THEN/ELSE STATEMENTS... 57 DO GROUPS... 58 IterativeExecution... 59 JUMPING... 61 MODULES... 62 Defining and Executing a Module....
Take-Home Exercise. z y x. Erik Jonsson School of Engineering and Computer Science. The University of Texas at Dallas
Take-Home Exercise Assume you want the counter below to count mod-6 backward. That is, it would count 0-5-4-3-2-1-0, etc. Assume it is reset on startup, and design the wiring to make the counter count
A single register, called the accumulator, stores the. operand before the operation, and stores the result. Add y # add y from memory to the acc
Other architectures Example. Accumulator-based machines A single register, called the accumulator, stores the operand before the operation, and stores the result after the operation. Load x # into acc
Keil C51 Cross Compiler
Keil C51 Cross Compiler ANSI C Compiler Generates fast compact code for the 8051 and it s derivatives Advantages of C over Assembler Do not need to know the microcontroller instruction set Register allocation
MICROPROCESSOR AND MICROCOMPUTER BASICS
Introduction MICROPROCESSOR AND MICROCOMPUTER BASICS At present there are many types and sizes of computers available. These computers are designed and constructed based on digital and Integrated Circuit
Chapter 7. Registers & Register Transfers. J.J. Shann. J. J. Shann
Chapter 7 Registers & Register Transfers J. J. Shann J.J. Shann Chapter Overview 7- Registers and Load Enable 7-2 Register Transfers 7-3 Register Transfer Operations 7-4 A Note for VHDL and Verilog Users
SIM-PL: Software for teaching computer hardware at secondary schools in the Netherlands
SIM-PL: Software for teaching computer hardware at secondary schools in the Netherlands Ben Bruidegom, [email protected] AMSTEL Instituut Universiteit van Amsterdam Kruislaan 404 NL-1098 SM Amsterdam
E158 Intro to CMOS VLSI Design. Alarm Clock
E158 Intro to CMOS VLSI Design Alarm Clock Sarah Yi & Samuel (Tae) Lee 4/19/2010 Introduction The Alarm Clock chip includes the basic functions of an alarm clock such as a running clock time and alarm
COMBINATIONAL and SEQUENTIAL LOGIC CIRCUITS Hardware implementation and software design
PH-315 COMINATIONAL and SEUENTIAL LOGIC CIRCUITS Hardware implementation and software design A La Rosa I PURPOSE: To familiarize with combinational and sequential logic circuits Combinational circuits
3.Basic Gate Combinations
3.Basic Gate Combinations 3.1 TTL NAND Gate In logic circuits transistors play the role of switches. For those in the TTL gate the conducting state (on) occurs when the baseemmiter signal is high, and
Central Processing Unit (CPU)
Central Processing Unit (CPU) CPU is the heart and brain It interprets and executes machine level instructions Controls data transfer from/to Main Memory (MM) and CPU Detects any errors In the following
16-bit ALU, Register File and Memory Write Interface
CS M152B Fall 2002 Project 2 16-bit ALU, Register File and Memory Write Interface Suggested Due Date: Monday, October 21, 2002 Actual Due Date determined by your Lab TA This project will take much longer
Multiplexers Two Types + Verilog
Multiplexers Two Types + Verilog ENEE 245: Digital Circuits and ystems Laboratory Lab 7 Objectives The objectives of this laboratory are the following: To become familiar with continuous ments and procedural
Lesson 12 Sequential Circuits: Flip-Flops
Lesson 12 Sequential Circuits: Flip-Flops 1. Overview of a Synchronous Sequential Circuit We saw from last lesson that the level sensitive latches could cause instability in a sequential system. This instability
What is a Loop? Pretest Loops in C++ Types of Loop Testing. Count-controlled loops. Loops can be...
What is a Loop? CSC Intermediate Programming Looping A loop is a repetition control structure It causes a single statement or a group of statements to be executed repeatedly It uses a condition to control
The programming language C. sws1 1
The programming language C sws1 1 The programming language C invented by Dennis Ritchie in early 1970s who used it to write the first Hello World program C was used to write UNIX Standardised as K&C (Kernighan
Outline. Conditional Statements. Logical Data in C. Logical Expressions. Relational Examples. Relational Operators
Conditional Statements For computer to make decisions, must be able to test CONDITIONS IF it is raining THEN I will not go outside IF Count is not zero THEN the Average is Sum divided by Count Conditions
