Reconfigurable Computing S. Reda, Brown University Reconfigurable Computing (EN2911X, Fall07) Lecture 06: Verilog (2/3) Prof. Sherief Reda Division of.

Slides:



Advertisements
Similar presentations
Verilog HDL -Introduction
Advertisements

Simulation executable (simv)
Supplement on Verilog adder examples
Chap. 6 Dataflow Modeling
Reconfigurable Computing S. Reda, Brown University Reconfigurable Computing (EN2911X, Fall07) Lecture 07: Verilog (3/3) Prof. Sherief Reda Division of.
CPEN Digital System Design
Reconfigurable Computing (EN2911X, Fall07) Lecture 04: Programmable Logic Technology (2/3) Prof. Sherief Reda Division of Engineering, Brown University.
Hardware Description Language (HDL)
SYEN 3330 Digital SystemsJung H. Kim Chapter SYEN 3330 Digital Systems Chapters 4 – Part3: Verilog – Part 1.
1 Workshop Topics - Outline Workshop 1 - Introduction Workshop 2 - module instantiation Workshop 3 - Lexical conventions Workshop 4 - Value Logic System.
Reconfigurable Computing S. Reda, Brown University Reconfigurable Computing (EN2911X, Fall07) Lecture 10: RC Principles: Software (3/4) Prof. Sherief Reda.
Data Types in Java Data is the information that a program has to work with. Data is of different types. The type of a piece of data tells Java what can.
ELEN 468 Lecture 151 ELEN 468 Advanced Logic Design Lecture 15 Synthesis of Language Construct I.
S. Reda EN1600 SP’08 Design and Implementation of VLSI Systems (EN1600S08) Lecture12: Logical Effort (1/2) Prof. Sherief Reda Division of Engineering,
S. Reda EN160 SP’07 Design and Implementation of VLSI Systems (EN0160) Lecture 11: Logical Effort (1/2) Prof. Sherief Reda Division of Engineering, Brown.
Reconfigurable Computing S. Reda, Brown University Reconfigurable Computing (EN2911X, Fall07) Lecture 09: RC Principles: Software (2/4) Prof. Sherief Reda.
1 CS150 Introduction to Computer Science 1 Arithmetic Operators.
Reconfigurable Computing S. Reda, Brown University Reconfigurable Computing (EN2911X, Fall07) Lecture 16: Application-Driven Hardware Acceleration (1/4)
Reconfigurable Computing (EN2911X, Fall07) Lecture 05: Verilog (1/3) Prof. Sherief Reda Division of Engineering, Brown University
Reconfigurable Computing S. Reda, Brown University Reconfigurable Computing (EN2911X, Fall07) Lab 2 presentations Prof. Sherief Reda Division of Engineering,
S. Reda EN160 SP’07 Design and Implementation of VLSI Systems (EN0160) Lecture 30: Design Methodologies using Tanner Tools Prof. Sherief Reda Division.
Fall 2006AE6382 Design Computing1 Relational and Logical Operators Use relational operators to test two values Work with values of true and false Compare.
1 Expressions, Operators Expressions Operators and Precedence Reading for this class: L&L, 2.4.
Digital System Design EEE344 Lecture 3 Introduction to Verilog HDL Prepared by: Engr. Qazi Zia, Assistant Professor EED, COMSATS Attock1.
Today’s Lecture Process model –initial & always statements Assignments –Continuous & procedural assignments Timing Control System tasks.
Lecture 12: Computer Arithmetic Today’s topic –Numerical representations –Addition / Subtraction –Multiplication / Division 1.
Chapter 6. Dataflow Modeling. Continuous Assignments The left hand side always be a scalar or vector net or a concatenation of scalar and vector nets.
Workshop Topics - Outline
Unit 3 Lesson 2: Rational Expressions
C ONTINUOUS A SSIGNMENTS. C OMBINATIONAL L OGIC C IRCUITS each output of a Combinational Logic Circuit  A function of the inputs - Mapping functions.
Assignment Statements Operator Precedence. ICS111-Java Programming Blanca Polo 2 Assignment, not Equals  An assignment statement changes the value of.
CP104 Introduction to Programming Overview of C Lecture 4__ 1 Assignment Statements An assignment statement is to store a value in a variable variable.
COE 202 Introduction to Verilog Computer Engineering Department College of Computer Sciences and Engineering King Fahd University of Petroleum and Minerals.
LOOP & Type Conversion. do – while Loop In the while loop, the test expression is evaluated at the beginning of the loop. If the test condition is false.
1 Workshop Topics - Outline Workshop 1 - Introduction Workshop 2 - module instantiation Workshop 3 - Lexical conventions Workshop 4 - Value Logic System.
3/4/20031 ECE 551: Digital System Design * & Synthesis Lecture Set 3 3.1: Verilog - User-Defined Primitives (UDPs) (In separate file) 3.2: Verilog – Operators,
1 Verilog Digital System Design Z. Navabi, 2006 Verilog Language Concepts.
1 Expressions. 2 Variables and constants linked with operators  Arithmetic expressions Uses arithmetic operators Can evaluate to any value  Logical.
CEC 220 Digital Circuit Design Introduction to VHDL Wed, February 25 CEC 220 Digital Circuit Design Slide 1 of 19.
Programming in Java (COP 2250) Lecture 4 Chengyong Yang Fall, 2005.
Arithmetic Expressions in C++. CSCE 1062 Outline Data declaration {section 2.3} Arithmetic operators in C++ {section 2.6} Mixed data type arithmetic in.
Arithmetic OperatorOperationExample +additionx + y -subtractionx - y *multiplicationx * y /divisionx / y Mathematical FormulaC Expressions b 2 – 4acb *
M.Mohajjel. Continuous Assignments Continuously Drive a value onto a net Left hand side must be net Right hand side registers nets function calls Keyword.
Arithmetic Expressions Addition (+) Subtraction (-) Multiplication (*) Division (/) –Integer –Real Number Mod Operator (%) Same as regular Depends on the.
Doing math In java.
Multiplexers Section Topics Multiplexers – Definition – Examples – Verilog Modeling.
COE 202 Introduction to Verilog Computer Engineering Department College of Computer Sciences and Engineering King Fahd University of Petroleum and Minerals.
Chapter 3: Dataflow Modeling Digital System Designs and Practices Using Verilog HDL and 2008~2010, John Wiley 3-1 Chapter 3: Dataflow Modeling.
CEC 220 Digital Circuit Design Introduction to VHDL Wed, Oct 14 CEC 220 Digital Circuit Design Slide 1 of 19.
CSCI 1100/1202 January 18, Arithmetic Expressions An expression is a combination of operators and operands Arithmetic expressions compute numeric.
Structural Description
Subtracting Integers #41.
1.3 ARITHMETIC OPERATIONS WITH SCALARS
CSE 220 – C Programming Expressions.
Reg and Wire:.
Lecture 2 Supplement Verilog-01
Expressions An expression is a portion of a C++ statement that performs an evaluation of some kind Generally requires that a computation or data manipulation.
Arithmetic operations & assignment statement
Assignment statement and Arithmetic operation 2
Computer Programming: C language
Arithmetic Operator Operation Example + addition x + y
Chapter 3: Dataflow Modeling
OUTLINE Introduction Basics of the Verilog Language
With Assignment Operator
Expressions An expression is a portion of a C++ statement that performs an evaluation of some kind Generally requires that a computation or data manipulation.
DATA TYPES AND OPERATIONS
COE 202 Introduction to Verilog
Reconfigurable Computing (EN2911X, Fall07)
Reconfigurable Computing (EN2911X, Fall07)
Reconfigurable Computing (EN2911X, Fall07)
Presentation transcript:

Reconfigurable Computing S. Reda, Brown University Reconfigurable Computing (EN2911X, Fall07) Lecture 06: Verilog (2/3) Prof. Sherief Reda Division of Engineering, Brown University

Reconfigurable Computing S. Reda, Brown University Dataflow modeling Module is designed by specifying the data flow, where the designer is aware of how data flows between hardware registers and how the data is processed in the design The continuous assignment is one of the main constructs used in dataflow modeling assign out = i1 & i2; assign addr[15:0] = addr1[15:0] ^ addr2[15:0]; assign {c_out, sum[3:0]}=a[3:0]+b[3:0]+c_in; A continuous assignment is always active and the assignment expression is evaluated as soon as one of the right-hand-side variables change Left-hand side must be a scalar or vector net. Right-hand side operands can be registers, nets, integers, real, …

Reconfigurable Computing S. Reda, Brown University Operator types in dataflow expressions Operators are similar to C except that there are no ++ or – Arithmetic: *, /, +, -, % and ** Logical: !, && and || Relational: >, = and <= Equality: ==, !=, === and !== Bitwise: ~, &, |, ^ and ^~ Reduction: &, ~&, |, ~|, ^ and ^~ Shift: >, >>> and <<< Concatenation: { } Replication: {{}} Conditional: ?:

Reconfigurable Computing S. Reda, Brown University Example module mux4(out, i0, i1, i2, i3, s1, s0); output out; input i0, i1, i2, i3; output s1, s0; assign out = (~s1 & ~s0 & i0) | (~s1 & s0 & i1) | (s1 & ~s0 & i2) | (s1 & s0 & i3); // OR THIS WAY assign out = s1 ? (s0 ? i3:i2) : (s0 ? i1:i0); endmodule

Reconfigurable Computing S. Reda, Brown University Behavioral or algorithmic modeling Design is expressed in algorithmic level, which frees designers from thinking in terms of logic gates or data flow. Designing at this model is very similar to programming in C. All algorithmic statements in Verilog can appear only inside two statements: always and initial. Each always and initial statement represents a separate activity flow in Verilog. Remember that activity flows in Verilog run in parallel. You can have multiple initial and always statements but you can’t nest them.. reg a, b, c; initial a=1’b0;. always begin b = a ^ 1’b1; c = a + b; end.

Reconfigurable Computing S. Reda, Brown University initial statements An initial block start at time 0, executes exactly once and then never again. If there are multiple initial blocks, each blocks starts to execute concurrently at time 0 and each blocks finish execution independently of the others. Multiple behavioral statements must be grouped using begin and end. If there is one statement then grouping is not necessary. reg x, y, m; initial m=1’b0; initial begin x=1’b0; y=1’b1; end

Reconfigurable Computing S. Reda, Brown University always statement The always statement starts at time 0 and executes the statements in the always block continuously in a looping fashion. It models a block of activity that is repeated continuously in a digital circuit. Multiple behavioral statements must be grouped using begin and end. If there is one statement then grouping is not necessary. integer count; count=0; always begin count=count+1; end

Reconfigurable Computing S. Reda, Brown University Events-based timing control An event is the change in the value on a register or a net. Events can be utilized to trigger the execution of a statement of a block of statements. symbol is used to specify an event control. Statements can be executed on changes in signal value or at a positive ( posedge ) or negative ( negedge ) transition of the signal. input clock; integer count; count=0; begin count=count+1; end input clock; integer count; count=0; begin count=count+1; end input clock1, clock 2; integer count; count=0; or clock2) begin count=count+1; end

Reconfigurable Computing S. Reda, Brown University Procedural assignments Procedural assignments update values of reg, integer, or real variables. The value will remain unchanged until another procedural assignment updates the variable with a different value → different from dataflow continuous assignments. Two types of procedural assignments: blocking and nonblocking. Blocking statements, specified using the = operator, are executed in the order they are specified in a sequential block. Nonblocking statements, specified using the <= operator, are executed without blocking the statements that flow in a sequential block. reg x, y; initial begin x=1’b1; y=1’b0; end reg x, y; initial begin x<=1’b1; y<=1’b0; end

Reconfigurable Computing S. Reda, Brown University Uses of nonblocking assignments clock) begin a = b; b = a; end clock) begin a <= b; b <= a; end If the intention is to swap the contents of and b, which one of these will work? Nonblocking assignments eliminate the race conditions. At the positive edge of clock, the values of all the RHS variables are “read”, expressions evaluated and then assigned to the LHS.

Reconfigurable Computing S. Reda, Brown University Conditional statements Very similar to C Can always appear inside always and initial blocks. if(x) begin y= 1’b1; z= 1’b0; end. if (count < 10) count = count+1; else count = 0;. expression. if(alu_control == 0) y = x + z; else if (alu_control == 1) y = x – z; else if (alu_control == 2) y = x * z; else y = x;. reg [1:0] alu_control;.. case (alu_control) 2’d0 : y = x + z; 2’d1 : y = x – z; 2’d2 : y = x * z; default: y=x; endcase

Reconfigurable Computing S. Reda, Brown University Loops integer count; integer y=1; integer x=2; initial for (count = 0; count < 128; count = count + 1) begin x <= x + y; y <= x; end initial count = 0; while (count < 128) begin. count = count +1; end initial count = 0; repeat(128) begin. count = count +1; end Must contain a number or a signal value; only evaluated once at the beginning

Reconfigurable Computing S. Reda, Brown University Example: Mux4x1 module mux4x1(out, i0, i1, i2, i3, s1, s0); output out; input i0, i1, i2, i3; input s1, s0; reg out; or s0 or i0 or i1 or i2 or i3) begin case({s1, s0}) 2’d0: out = i0; 2’d1: out = i1; 2’d2: out = i2; 2’d3: out = i3; endcase endmodule

Reconfigurable Computing S. Reda, Brown University DE2 board overview SW[0] … SW[17] HEX0[6:0] … HEX7[6:0] KEY[0] … KEY[3] LEDG[0] … LEDG[8] LEDR[0] … LEDR[17] CLOCK_50 Import the given pin assignment file to make things easy for you!

Reconfigurable Computing S. Reda, Brown University D2 example: A 1 second blinking light module sec (input CLOCK_50, output reg [8:0] LEDG); integer count=0; initial LEDG[0]=1'b0; CLOCK_50) begin count=count+1; if(count == 50_000_000) begin count=0; if(LEDG[0]) LEDG[0]=1'b0; else LEDG[0]=1'b1; end endmodule

Reconfigurable Computing S. Reda, Brown University Lab 1 Please go through the lab0 tutorial to get familiar with the tool and the synthesis environment Please check the class webpage for helpful resources You are required to form teams (2 students per team). Since there are 11 students enrolled in the class, one team has to be composed of either 3 students or just 1 student. Deliverables (1 st game Oct 4 th and 2 nd game Oct 9 th ) include –Working design which will be tested –Quartus II project files –Written documentation includes Verilog source code with comments Report the amount of logic and routing area utilized in the FPGA Snapshot of the final layout of the FPGA as produced by the synthesis tool Simple documentations on any additions you volunteered to add to the game

Reconfigurable Computing S. Reda, Brown University Game 1: Secret Code Grabber AKA Simon The objective of this game to memorize a “random” pattern of lights that is displayed to you on the DE2 board LEDs, and input it back using the available push buttons or switches. At the beginning, the board should display the user a pattern by lighting one LED at a time for a “short” period, and then the gamer should input back the pattern in the same sequence. After that, the board should display some sign on the 7 segment display to tell the gamer whether his/her input is correct or not, and replay with another “random pattern.” There are two knobs that you can use to make the game harder: the period where each LED is ON and the length of the pattern. You can either fix those in advance, or make change them as the user progresses in playing.

Reconfigurable Computing S. Reda, Brown University Game 2: Catch the ant In this game we have an ant that continuously traverses the board from left to right and then from right to left. The position of the ant is indicated by the LED that is lightened up. The ant is quick and stops at each position for a “short” period. The ant also sometimes “randomly” changes its direction which makes it hard to predict its next location. Your objective is to catch the ant as many times as you could. Each position corresponds to a push button and you want to press the push button that corresponds to the ant position. Every time you correctly get the ant, you score 1 point and every time you miss you lose 1 point. The score should be displayed on the seven segments.

Reconfigurable Computing S. Reda, Brown University Game 3: Match the alien symbol In this game the DE2 board is possessed by some alien. It displays some alien symbol on one of the 7 segment displays and then displays four symbols on four other 7 segment displays. Your objective is to choose (via the push buttons) the number (or location) of the symbol that matches the alien symbol. You have to be quick because the board will allow you only very “short” time to make your choice. A green LED should lighten up if you match successfully; otherwise, a red LED should lighten up.