Discussion 2: More to discuss

Slides:



Advertisements
Similar presentations
Verilog HDL -Introduction
Advertisements

Verilog.
Simulation executable (simv)
The Verilog Hardware Description Language
Verilog Overview. University of Jordan Computer Engineering Department CPE 439: Computer Design Lab.
CPEN Digital System Design
Verilog Intro: Part 1.
16/04/20151 Hardware Descriptive Languages these notes are taken from Mano’s book It can represent: Truth Table Boolean Expression Diagrams of gates and.
SYEN 3330 Digital SystemsJung H. Kim Chapter SYEN 3330 Digital Systems Chapters 4 – Part3: Verilog – Part 1.
1 Brief Introduction to Verilog Weiping Shi. 2 What is Verilog? It is a hardware description language Originally designed to model and verify a design.
CSE 341 Verilog HDL An Introduction. Hardware Specification Languages Verilog  Similar syntax to C  Commonly used in  Industry (USA & Japan) VHDL 
The Multicycle Processor II CPSC 321 Andreas Klappenecker.
ENEE 408C Lab Capstone Project: Digital System Design Verilog Tutorial Class Web Site:
ECE 353 Computer Systems Lab I Verilog Hardware Description Language.
CSE241 R1 Verilog.1Kahng & Cichy, UCSD ©2003 CSE241 VLSI Digital Circuits Winter 2003 Recitation 1: Verilog Introduction.
Reconfigurable Computing (EN2911X, Fall07) Lecture 05: Verilog (1/3) Prof. Sherief Reda Division of Engineering, Brown University
Computer Organization Lecture Set – 03 Introduction to Verilog Huei-Yung Lin.
University of Jordan Computer Engineering Department CPE 439: Computer Design Lab.
Lecture Note on Verilog, Course # , EE, NTU, C.H Tsai Basic Logic Design with Verilog TA: Chen-han Tsai.
ECE 2372 Modern Digital System Design
Introduction Verilog is a HARDWARE DESCRIPTION LANGUAGE (HDL) A hardware description language is a language or means used to describe or model a digital.
CS 3850 Lecture 3 The Verilog Language. 3.1 Lexical Conventions The lexical conventions are close to the programming language C++. Comments are designated.
1 An Update on Verilog Ξ – Computer Architecture Lab 28/06/2005 Kypros Constantinides.
Module 1.2 Introduction to Verilog
1 CSE-308 Digital System Design (DSD) N-W.F.P. University of Engineering & Technology, Peshawar.
COE 202 Introduction to Verilog Computer Engineering Department College of Computer Sciences and Engineering King Fahd University of Petroleum and Minerals.
Anurag Dwivedi. Basic Block - Gates Gates -> Flip Flops.
Introduction to Combinational Verilog EECS270 rev 9/25/12.
ELEE 4303 Digital II Introduction to Verilog. ELEE 4303 Digital II Learning Objectives Get familiar with background of HDLs Basic concepts of Verilog.
CSCE 211: Digital Logic Design Chin-Tser Huang University of South Carolina.
CSCI-365 Computer Organization Lecture Note: Some slides and/or pictures in the following are adapted from: Computer Organization and Design, Patterson.
Introduction to ASIC flow and Verilog HDL
Introduction to Verilog. Data Types A wire specifies a combinational signal. – Think of it as an actual wire. A reg (register) holds a value. – A reg.
Introduction to Verilog
COE 202 Introduction to Verilog Computer Engineering Department College of Computer Sciences and Engineering King Fahd University of Petroleum and Minerals.
Verilog Intro: Part 1. Hardware Description Languages A Hardware Description Language (HDL) is a language used to describe a digital system, for example,
Introduction to Verilog. Structure of a Verilog Program A Verilog program is structured as a set of modules, which may represent anything from a collection.
1 University of Jordan Computer Engineering Department CPE 439: Computer Design Lab.
1 A hardware description language is a computer language that is used to describe hardware. Two HDLs are widely used Verilog HDL VHDL (Very High Speed.
Introduction to Verilog COE 202 Digital Logic Design Dr. Muhamed Mudawar King Fahd University of Petroleum and Minerals.
Structural Description
Overview Logistics Last lecture Today HW5 due today
Hardware Description Languages: Verilog
An Introduction to Verilog: Transitioning from VHDL
Reg and Wire:.
University of Maryland Baltimore County Department of Computer Science and Electrical Engineering   CMPE 212 Laboratory (Discussion 2) Hasibul Hasan
Introduction to Verilog
Verilog Introduction Fall
Verilog-HDL-1 by Dr. Amin Danial Asham.
KARTHIK.S Lecturer/ECE S.N.G.C.E
‘if-else’ & ‘case’ Statements
Lecture 2 Supplement Verilog-01
Verilog-HDL-3 by Dr. Amin Danial Asham.
Hardware Description Languages: Verilog
Introduction to DIGITAL CIRCUITS MODELING & VERIFICATION using VERILOG [Part-I]
Introduction to Verilog
Behavioral Modeling in Verilog
Introduction to Verilog
Levels in computer design
102-1 Under-Graduate Project Verilog
Introduction to Digital System and Microprocessor Design
Introduction to Verilog
Introduction to Verilog, ModelSim, and Xilinx Vivado
Supplement on Verilog adder examples
Introduction to Verilog
The Verilog Hardware Description Language
Introduction to Verilog
COE 202 Introduction to Verilog
Reconfigurable Computing (EN2911X, Fall07)
Presentation transcript:

Discussion 2: More to discuss CMPE212 Fall 2015

Introduction In discussion, we will go over the Verilog language These slides are meant to be a basic reference, I don’t expect you to absorb all of the material in discussion In lab, you will download some code that I have written to get a basic example of Verilog code and how to compile it

Verilog Instruction Verilog is a Hardware Description Language. Modular implementation of circuit components: Modules form the building blocks of circuit components. Bigger modules are made up of smaller modules. 2 different ways to program (“Levels of Abstraction”): Behavioral Structural …more on these later

Hardware Descriptor Language HDL: Programming language used to describe the behavior of an electronic circuit. Uses simulations to test and verify a circuit’s functionality. Difference between HDL’s and other programming languages: HDL’s include a notion of time.

Syntax White spaces are ignored. Commenting: Variables: // single line /* multiple line */ Variables: Must start with an alphabet char, or an underscore followed by an alphabet char. Case sensitive.

Keywords: ‘reg’ and ‘wire’ Register Represents storage elements (memory). Holds value until next assignment. reg [7:0] test; // a 8-bit register vector // individual bits: test[7], ..., test[0] Wire Represents physical wires that connect modules. Does not store values, must be continuously driven. wire [15:0] net1; // a 16-bit wire vector (aka ‘net’) // individual bits: net1[15], ..., net1[0]

Keywords: ‘input’ and ‘output’ Understood as a special ‘wire’ that brings input values into a module. Can be read from, unlike normal wires. input [7:0] in1; Output Understood as a special ‘wire’ that drives output values from a module. Even though it is a wire by default, it can be assigned like a register under certain circumstances. output [7:0] out1;

Modules Most basic unit of hierarchy in Verilog Can be a single circuit element, or a collection of lower level modules connected together. Contained in 1 Verilog file. Multiple modules can reside in 1 file, but this is not recommended. Module name should match the file name. So the module ‘adder’ would reside in the file named ‘adder.v’.

Modules continued Defining a module: module <module_name>(<module_terminal_list>); ... <module internals> endmodule We can describe the functionality of a module with either Structural code or Behavioral code. 9

2 Levels of Abstraction Structural code Behavioral code Represents circuit components. Gates Lower level modules May use Verilog’s Gate Primitives: and u1(y, a, b); Instantiates an AND gate called u1 with inputs a and b, and output y. No direct mapping to circuit components. Loops if-else statements May use Verilog’s Boolean operators: assign y = a && b; Performs the AND operator on a and b, and assigns the result to y.

2 Levels of Abstraction Structural: Gate Primitives Behavioral: Operators Predefined in Verilog. Can have multiple inputs. and and_1 (out, in0, in1); nand nand_1 (out, in0, in1,in2);  or or_1 (out, in0, in1); nor nor_1 (out, in0, in1, in2, in3); xor xor_1 (out, in0, in1, in2); xnor xnor_1 (out, in0, in1); Bitwise: ~, &, |, ^ Logical: !, &&, || Reduction: &, |, ^ Arithmetic: +, -,*, /, ** Relational: >, >=, ==, != Shift: >>, <<

Module Example – Structural module fred(O,A,B,C); input A,B,C; output O; wire W; or (W,B,C); and (O,A,W); endmodule

Module Example – Behavioral module fred(O,A,B,C); input A,B,C; output O; wire W; assign W = B | C; assign O = A & W; endmodule

Testbench A testbench tests the functionality of a module. Always contains behavioral code. Controls the inputs to a module, and examines the outputs of a module. A testbench for the Fred module: Instantiates a Fred module, and gives this instance a name. Applies all the different possible combinations of A, B, and C to the module’s inputs. Displays the output values so that you can see if the Fred module is working as expected.

Module Example – Test Bench module testbench4Fred(); reg [2:0] switches; wire y; fred f1(y,switches[2], switches[1], switches[0]); initial begin switches = 000; $display(“switches=ABC\n”); #80 $finish; end always switches = switches + 001; #10 $display(“switches=%b, y=%b”, switches, y); endmodule

How to Compile / Run Verilog files Log onto a computer with linux. In a command window, enter: verilog <testbench name> <module name> Make sure you are in the same folder as the files which you wish to run. If you’re not in the same folder, specify the file paths in front of the testbench name and module name. You can append as many modules to this command as you wish, but use one testbench at a time.

Running testbench4Fred.v Output from the test bench for the Fred module. Verilog compile / run command

Parallel Operation Remember that these operations may not necessarily operate in sequence. There is a way to control this: begin...end block of code that will perform in order. fork...join block of code that will perform in parallel. With combinational logic, use sequential programming. Later on when we deal with timing, you may need to use parallel blocks.

Time Delays Remember earlier when we said there is a notion of time in HDL. We can specify an amount of time delay using the #x operator. Let x be some integer, that will be the number of time steps delayed. BEWARE: This operator works differently under sequential and parallel blocks.

Time Delay Example Sequential: Parallel: #1 a = b; #10 b = a; Sequential: Instructions occur after the 1st and 11th time steps. Parallel: Instructions occur after the 1st and 10th time steps.