CS 150 - Fall 2000 - Hardware Description Languages - 1 Hardware Description Languages zDescribe hardware at varying levels of abstraction zStructural.

Slides:



Advertisements
Similar presentations
Recap : Always block module and_gate (out, in1, in2); inputin1, in2; outputout; regout; or in2) begin out = in1 & in2; end endmodule zAlways.
Advertisements

Hardware Description Languages (HDL): Verilog
Hardware Description Languages: Verilog
Sequential logic examples
Chapter #10: Finite State Machine Implementation
Implementation Strategies
Simulation executable (simv)
Verilog Overview. University of Jordan Computer Engineering Department CPE 439: Computer Design Lab.
Synchronous Sequential Logic
Combinational Logic.
Table 7.1 Verilog Operators.
Verilog Intro: Part 1.
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.
 HDLs – Verilog and Very High Speed Integrated Circuit (VHSIC) HDL  „ Widely used in logic design  „ Describe hardware  „ Document logic functions.
Verilog - 1 Writing Hardware Programs in Abstract Verilog  Abstract Verilog is a language with special semantics  Allows fine-grained parallelism to.
CSE Spring Verilog for Sequential Systems - 1 Today: Verilog and Sequential Logic zFlip-flops yrepresentation of clocks - timing of state.
III - Working with Combinational Logic © Copyright 2004, Gaetano Borriello and Randy H. Katz 1 Working with combinational logic Simplification  two-level.
OUTLINE Introduction Basics of the Verilog Language Gate-level modeling Data-flow modeling Behavioral modeling Task and function.
CS Fall Lecture #4: Verilog - 1 Hardware Description Languages: Verilog zVerilog yStructural Models y(Combinational) Behavioral Models ySyntax.
Verilog Sequential Circuits Ibrahim Korpeoglu. Verilog can be used to describe storage elements and sequential circuits as well. So far continuous assignment.
ELEN 468 Lecture 161 ELEN 468 Advanced Logic Design Lecture 16 Synthesis of Language Construct II.
VII - Finite State Machines © Copyright 2004, Gaetano Borriello and Randy H. Katz 1 Finite State Machines Sequential circuits  primitive sequential elements.
Advanced Verilog EECS 270 v10/23/06.
Lecture 7 Verilog Additional references Structural constructs
FPGA-Based System Design: Chapter 5 Copyright  2004 Prentice Hall PTR Verilog for sequential machines.
Overview Logistics Last lecture Today HW5 due today
Sequential Logic in Verilog
CSET 4650 Field Programmable Logic Devices
FPGA-Based System Design: Chapter 5 Copyright  2004 Prentice Hall PTR Topics n Verilog styles for sequential machines. n Flip-flops and latches.
CSE 370 – Winter Hardware Description Languages - 1 Overview zLast lecture yRipple and Carry-Lookahead Adders zToday yALU yAn Introduction to Hardware.
ECE 551 Digital System Design & Synthesis Fall 2011 Midterm Exam Overview.
CS 61C L4.2.2 Verilog II (1) K. Meinz, Summer 2004 © UCB CS61C : Machine Structures Lecture Verilog II Kurt Meinz inst.eecs.berkeley.edu/~cs61c.
Chapter 11: System Design Methodology Digital System Designs and Practices Using Verilog HDL and 2008, John Wiley11-1 Ders 8: FSM Gerçekleme ve.
Lab7-1 Lab 6: FSM Description Separate combinational and memory circuits –State memory uses FFs –Others are combinational circuits.
1 Workshop Topics - Outline Workshop 1 - Introduction Workshop 2 - module instantiation Workshop 3 - Lexical conventions Workshop 4 - Value Logic System.
ECE/CS 352 Digital System Fundamentals© 2001 C. Kime 1 ECE/CS 352 Digital Systems Fundamentals Spring 2001 Chapters 3 and 4: Verilog – Part 2 Charles R.
Register Transfer Level & Design with ASM
1 CSE-308 Digital System Design (DSD) N-W.F.P. University of Engineering & Technology, Peshawar.
Module 1.2 Introduction to Verilog
1 COMP541 Sequential Circuits Montek Singh Feb 1, 2012.
Verilog for Synthesis Ing. Pullini Antonio
Anurag Dwivedi. Basic Block - Gates Gates -> Flip Flops.
1 Hardware description languages: introduction intellectual property (IP) introduction to VHDL and Verilog entities and architectural bodies behavioral,
Behavioral Modelling - 1. Verilog Behavioral Modelling Behavioral Models represent functionality of the digital hardware. It describes how the circuit.
Verilog A Hardware Description Language (HDL ) is a machine readable and human readable language for describing hardware. Verilog and VHDL are HDLs.
Introduction to ASIC flow and Verilog HDL
Chapter 11: System Design Methodology Digital System Designs and Practices Using Verilog HDL and 2008, John Wiley11-1 Chapter 11: System Design.
ACCESS IC LAB Graduate Institute of Electronics Engineering, NTU 99-1 Under-Graduate Project Design of Datapath Controllers Speaker: Shao-Wei Feng Adviser:
1 University of Jordan Computer Engineering Department CPE 439: Computer Design Lab.
SYEN 3330 Digital SystemsJung H. Kim Chapter SYEN 3330 Digital Systems Chapters 4 – Part4: Verilog – Part 2.
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.
CSE Winter Hardware Description Languages - 1 Hardware description languages zDescribe hardware at varying levels of abstraction zStructural.
Overview Logistics Last lecture Today HW5 due today
Hardware Description Languages: Verilog
© Copyright 2004, Gaetano Borriello and Randy H. Katz
Discussion 2: More to discuss
Hardware Description Languages: Verilog
Sequential logic examples
FSM MODELING MOORE FSM MELAY FSM. Introduction to DIGITAL CIRCUITS MODELING & VERIFICATION using VERILOG [Part-2]
332:437 Lecture 8 Verilog and Finite State Machines
COE 202 Introduction to Verilog
Topics Verilog styles for sequential machines. Flip-flops and latches.
The Verilog Hardware Description Language
Verilog Synthesis & FSMs
332:437 Lecture 8 Verilog and Finite State Machines
Implementation Strategies
Lecture 7: Verilog Part II
Presentation transcript:

CS Fall Hardware Description Languages - 1 Hardware Description Languages zDescribe hardware at varying levels of abstraction zStructural description yTextual replacement for schematic yHierarchical composition of modules from primitives zBehavioral/functional description yDescribe what module does, not how ySynthesis generates circuit for module zSimulation semantics

CS Fall Hardware Description Languages - 2 HDLs zAbel (circa 1983) - developed by Data-I/O yTargeted to programmable logic devices yNot good for much more than state machines zISP (circa 1977) - research project at CMU ySimulation, but no synthesis zVerilog (circa 1985) - developed by Gateway (absorbed by Cadence) ySimilar to Pascal and C yDelays is only interaction with simulator yFairly efficient and easy to write yIEEE standard zVHDL (circa 1987) - DoD sponsored standard ySimilar to Ada (emphasis on re-use and maintainability) ySimulation semantics visible yVery general but verbose yIEEE standard

CS Fall Hardware Description Languages - 3 Verilog zSupports structural and behavioral descriptions zStructural yExplicit structure of the circuit yE.g., each logic gate instantiated and connected to others zBehavioral yProgram describes input/output behavior of circuit yMany structural implementations could have same behavior yE.g., different implementation of one Boolean function zWe’ll only be using behavioral Verilog in DesignWorks yRely on schematic when we want structural descriptions

CS Fall Hardware Description Languages - 4 module xor_gate (out, a, b); input a, b; output out; wire abar, bbar, t1, t2; inverter invA (abar, a); inverter invB (bbar, b); and_gate and1 (t1, a, bbar); and_gate and2 (t2, b, abar); or_gate or1 (out, t1, t2); endmodule Structural Model

CS Fall Hardware Description Languages - 5 module xor_gate (out, a, b); input a, b; output out; reg out; assign #6 out = a ^ b; endmodule Simple behavioral model zContinuous assignment delay from input change to output change simulation register - keeps track of value of signal

CS Fall Hardware Description Languages - 6 module xor_gate (out, a, b); input a, b; output out; reg out; or b) begin #6 out = a ^ b; end endmodule Simple Behavioral Model zalways block specifies when block is executed I.e., triggered by which signals

CS Fall Hardware Description Languages - 7 module stimulus (x, y); output x, y; reg [1:0] cnt; initial begin cnt = 0; repeat (4) begin #10 cnt = cnt + 1; $display time=%d, x=%b, y=%b, cnt=%b", $time, x, y, cnt); end #10 $finish; end assign x = cnt[1]; assign y = cnt[0]; endmodule Driving a Simulation 2-bit vector initial block executed only once at start of simulation directive to stop simulation print to a console

CS Fall Hardware Description Languages - 8 Complete Simulation zInstantiate stimulus component and device to test in a schematic x y a b z

CS Fall Hardware Description Languages - 9 module Compare1 (A, B, Equal, Alarger, Blarger); input A, B; output Equal, Alarger, Blarger; assign #5 Equal = (A & B) | (~A & ~B); assign #3 Alarger = (A & ~B); assign #3 Blarger = (~A & B); endmodule Comparator Example

CS Fall Hardware Description Languages - 10 module life (n0, n1, n2, n3, n4, n5, n6, n7, self, out); input n0, n1, n2, n3, n4, n5, n6, n7, self; output out; reg out; reg [7:0] neighbors; reg [3:0] count; reg [3:0] i; assign neighbors = {n7, n6, n5, n4, n3, n2, n1, n0}; or self) begin count = 0; for (i = 0; i < 8; i = i+1) count = count + neighbors[i]; out = (count == 3); out = out | ((self == 1) & (count == 2)); end endmodule More Complex Behavioral Model

CS Fall Hardware Description Languages - 11 Hardware Description Languages vs. Programming Languages zProgram Structure yInstantiation of multiple components of the same type ySpecify interconnections between modules via schematic yHierarchy of modules zAssignment yContinuous assignment (logic always computes) yPropagation delay (computation takes time) yTiming of signals is important (when does computation have its effect) zData structures ySize explicitly spelled out - no dynamic structures yNo pointers zParallelism yHardware is naturally parallel (must support multiple threads) yAssignments can occur in parallel (not just sequentially)

CS Fall Hardware Description Languages - 12 Hardware Description Languages and Combinational Logic zModules: specification of inputs, outputs, bidirectional, and internal signals zContinuous assignment: a gate's output is a function of its inputs at all times (doesn't need to wait to be "called") zPropagation delay: concept of time and delay in input affecting gate output zComposition: connecting modules together with wires zHierarchy: modules encapsulate functional blocks zSpecification of don't care conditions (accomplished by setting output to “x”)

CS Fall Hardware Description Languages - 13 Hardware Description Languages and Sequential Logic zFlip-Flops yRepresentation of clocks - timing of state changes yAsynchronous vs. synchronous zFSMs yStructural view (FFs separate from combinational logic) yBehavioral view (synthesis of sequencers) zData-paths = ALUs + registers yUse of arithmetic/logical operators yControl of storage elements zParallelism yMultiple state machines running in parallel zSequential don't cares

CS Fall Hardware Description Languages - 14 module dff (clk, d, q); input clk, d; output q; reg q; clk) q = d; endmodule Flip-flop in Verilog zUse always block's sensitivity list to wait for clock edge

CS Fall Hardware Description Languages - 15 module dff (clk, s, r, d, q); input clk, s, r, d; output q; reg q; clk) if (reset) q = 1'b0; else if (set) q = 1'b1; else q = d; endmodule module dff (clk, s, r, d, q); input clk, s, r, d; output q; reg q; reset) q = 1'b0; set) q = 1'b1; clk) q = d; endmodule More Flip-flops zSynchronous/asynchronous reset/set ySingle thread that waits for the clock yThree parallel threads – only one of which waits for the clock

CS Fall Hardware Description Languages - 16 module FSM (HL, FL, ST, clk, C, TS, TL); output [2:0] HL, FL; reg [2:0] HL, FL; output ST; reg ST; input clk; input C, TS, TL; reg [1:0] present_state; reg [1:0] next_state; initial begin HL = 3'b001; FL = 3'b100; present_state = 2'b00; end clk) // registers present_state = next_state; or C or TS or TL) // compute next-state and output logic whenever state or inputs change // put equations here for next_state[1:0], HL[2:0], FL[2:0], and ST // as functions of C, TS, TL, and present_state[1:0] endmodule Structural View of an FSM zTraffic light controller: two always blocks - flip-flops separate from logic

CS Fall Hardware Description Languages - 17 module FSM(HR, HY, HG, FR, FY, FG, ST, TS, TL, C, reset, Clk); outputHR; outputHY; outputHG; outputFR; outputFY; outputFG; outputST; inputTS; inputTL; inputC; inputreset; inputClk; reg [6:1]state; regST; `define highwaygreen 6'b `define highwayyellow 6'b `define farmroadgreen 6'b `define farmroadyellow 6'b assign HR = state[6]; assign HY = state[5]; assign HG = state[4]; assign FR = state[3]; assign FY = state[2]; assign FG = state[1]; specify state bits and codes for each state as well as connections to outputs Behavioral View of an FSM zSpecification of inputs, outputs, and state elements

CS Fall Hardware Description Languages - 18 initial begin state = `highwaygreen; ST = 0; end Clk) begin if (reset) begin state = `highwaygreen; ST = 1; end else begin ST = 0; case (state) `highwaygreen: if (TL & C) begin state = `highwayyellow; ST = 1; end `highwayyellow: if (TS) begin state = `farmroadgreen; ST = 1; end `farmroadgreen: if (TL | !C) begin state = `farmroadyellow; ST = 1; end `farmroadyellow: if (TS) begin state = `highwaygreen; ST = 1; end endcase end end endmodule Behavioral View of an FSM (cont’d) case statement triggerred by clock edge

CS Fall Hardware Description Languages - 19 module Timer(TS, TL, ST, Clk); outputTS; outputTL; input ST; input Clk; integer value; assign TS = (value >= 4); // 5 cycles after reset assign TL = (value >= 14); // 15 cycles after reset ST) value = 0; // async reset Clk) value = value + 1; endmodule Timer for Traffic Light Controller zAnother FSM

CS Fall Hardware Description Languages - 20 module main(HR, HY, HG, FR, FY, FG, reset, C, Clk); output HR, HY, HG, FR, FY, FG; input reset, C, Clk; Timer part1(TS, TL, ST, Clk); FSM part2(HR, HY, HG, FR, FY, FG, ST, TS, TL, C, reset, Clk); endmodule Complete Traffic Light Controller zTying it all together (FSM + timer)

CS Fall Hardware Description Languages - 21 `define zero 0 `define one1 1 `define two1s 2 module reduce (clk, reset, in, out); input clk, reset, in; output out; reg out; reg [2:1] state;// state variables reg [2:1] next_state; clk) if (reset) state = `zero; else state = next_state; state assignment Verilog FSM - Reduce 1s example zMoore machine zero [0] one1 [0] two1s [1]

CS Fall Hardware Description Languages or state) case (state) `zero: // last input was a zero begin if (in) next_state = `one1; else next_state = `zero; end `one1: // we've seen one 1 begin if (in) next_state = `two1s; else next_state = `zero; end `two1s: // we've seen at least 2 ones begin if (in) next_state = `two1s; else next_state = `zero; end endcase crucial to include all signals that are input to state and output equations Moore Verilog FSM (cont’d) note that output only depends on state case (state) `zero: out = 0; `one1: out = 0; `two1s: out = 1; endcase endmodule

CS Fall Hardware Description Languages module reduce (clk, reset, in, out); input clk, reset, in; output out; reg out; `register state;// state variables reg next_state; clk) if (reset) state = `zero; else state = next_state; or state) case (state) `zero:// last input was a zero begin out = 0; if (in) next_state = `one; else next_state = `zero; end `one:// we've seen one 1 if (in) begin next_state = `one; out = 1; end else begin next_state = `zero; out = 0; end endcase endmodule Mealy Verilog FSM 1/0 0/0 1/1 zero [0] one1 [0]

CS Fall Hardware Description Languages - 24 module reduce (clk, reset, in, out); input clk, reset, in; output out; reg out; reg state;// state variables clk) if (reset) state = `zero; else case (state) `zero:// last input was a zero begin out = 0; if (in) state = `one; else state = `zero; end `one:// we've seen one 1 if (in) begin state = `one; out = 1; end else begin state = `zero; out = 0; end endcase endmodule Synchronous Mealy Machine