A short introduction to SystemVerilog. For those who know VHDL We aim for synthesis

Similar documents
A short introduction to SystemVerilog. For those who know VHDL We aim for synthesis

TSEA44: Computer hardware a system on a chip

Digital Design with SystemVerilog

Quick Introduction to SystemVerilog: Sequental Logic

A Brief Introduction to Verilog Hardware Definition Language (HDL)

SystemVerilog 3.1: It s What The DAVEs In Your Company Asked For

Last Lecture. Talked about combinational logic always statements. e.g., module ex2(input logic a, b, c, output logic f); logic t; // internal signal

Testbenches for Sequential Circuits... also, Components

Chapter 4 :: Topics. Introduction. SystemVerilog. Hardware description language (HDL): allows designer to specify logic function only.

EECS150 - Digital Design Lecture 10 Logic Synthesis

EECS150 - Digital Design Lecture 10 Logic Synthesis

CAD for VLSI Design - I. Lecture 21 V. Kamakoti and Shankar Balachandran

Chapter 4. Digital Design and Computer Architecture, 2 nd Edition. David Money Harris and Sarah L. Harris. Chapter 4 <1>

Chapter 4. Digital Design and Computer Architecture, 2 nd Edition. David Money Harris and Sarah L. Harris. Chapter 4 <1>

CSE140L: Components and Design Techniques for Digital Systems Lab

Synthesis vs. Compilation Descriptions mapped to hardware Verilog design patterns for best synthesis. Spring 2007 Lec #8 -- HW Synthesis 1

Lecture 32: SystemVerilog

CSE140L: Components and Design

Verilog: The Next Generation Accellera s SystemVerilog Standard

Logic Synthesis. EECS150 - Digital Design Lecture 6 - Synthesis

Verilog introduction. Embedded and Ambient Systems Lab

ECE 574: Modeling and Synthesis of Digital Systems using Verilog and VHDL. Fall 2017 Final Exam (6.00 to 8.30pm) Verilog SOLUTIONS

EECS150 - Digital Design Lecture 5 - Verilog Logic Synthesis

Synthesis of Language Constructs. 5/10/04 & 5/13/04 Hardware Description Languages and Synthesis

EECS 470 Lab 1. Verilog: Hardware Description Language

FPGA Design Challenge :Techkriti 14 Digital Design using Verilog Part 1

Last Lecture: Divide by 3 FSM

CSE 502: Computer Architecture

CMPE 415 Parameterized Modules and Simulation

Date Performed: Marks Obtained: /10. Group Members (ID):. Experiment # 11. Introduction to Verilog II Sequential Circuits

Synthesizable Verilog

!== vs.!= and === vs. ==

EEL 4783: HDL in Digital System Design

HDLs and SystemVerilog. Digital Computer Design

Online Verilog Resources

EECS 470 Lab 1. Verilog: Hardware Description Language

VERILOG 2: LANGUAGE BASICS

Introduction to Verilog/System Verilog

Spiral 1 / Unit 4 Verilog HDL. Digital Circuit Design Steps. Digital Circuit Design OVERVIEW. Mark Redekopp. Description. Verification.

What, If Anything, In SystemVerilog Will Help Me With FPGA-based Design. Stuart Sutherland, Consultant and Trainer, Sutherland HDL, Inc.

Computer Aided Design Basic Syntax Gate Level Modeling Behavioral Modeling. Verilog

Graduate Institute of Electronics Engineering, NTU Design of Datapath Controllers

Behavioral Modeling and Timing Constraints

Hardware Description Language (HDL)

Lab 7 (All Sections) Prelab: Introduction to Verilog

Digital Design (VIMIAA01) Introduction to the Verilog HDL

IP Core Design. Lecture 6 Introduction to Verilog-2001

Digital Design with SystemVerilog

EN164: Design of Computing Systems Lecture 06: Lab Foundations / Verilog 2

M A S S A C H U S E T T S I N S T I T U T E O F T E C H N O L O G Y DEPARTMENT OF ELECTRICAL ENGINEERING AND COMPUTER SCIENCE

Synthesis of Combinational and Sequential Circuits with Verilog

Digital Integrated Circuits

ECEN : Microprocessor System Design Department of Electrical and Computer Engineering Texas A&M University. Homework #1 Solutions

Department of Computer Science and Electrical Engineering. Intro to Verilog II

Lab 7 (Sections 300, 301 and 302) Prelab: Introduction to Verilog

271/469 Verilog Tutorial

MCMASTER UNIVERSITY EMBEDDED SYSTEMS

EECS 470 Lab 3. SystemVerilog Style Guide. Department of Electrical Engineering and Computer Science College of Engineering University of Michigan

VHDL: RTL Synthesis Basics. 1 of 59

Logic Circuits II ECE 2411 Thursday 4:45pm-7:20pm. Lecture 3

Modeling Sequential Circuits in Verilog

EN2911X: Reconfigurable Computing Topic 02: Hardware Definition Languages

ENGN1640: Design of Computing Systems Topic 02: Design/Lab Foundations

Course Topics - Outline

Chapter 2 Using Hardware Description Language Verilog. Overview

The Verilog Language COMS W Prof. Stephen A. Edwards Fall 2002 Columbia University Department of Computer Science

Verilog Execution Semantics

Example Best and Median Results

Verilog for Synthesis Ing. Pullini Antonio

ENGN1640: Design of Computing Systems Topic 02: Design/Lab Foundations

Building Bigger Systems: Interfacing

Note: Closed book no notes or other material allowed, no calculators or other electronic devices.

SystemVerilog Design: User Experience Defines Multi-Tool, Multi-Vendor Language Working Set Experience from Four Years of SVD Adoption

PINE TRAINING ACADEMY

Schematic design. Gate level design. 0 EDA (Electronic Design Assistance) 0 Classical design. 0 Computer based language

Recommended Design Techniques for ECE241 Project Franjo Plavec Department of Electrical and Computer Engineering University of Toronto

Verilog. What is Verilog? VHDL vs. Verilog. Hardware description language: Two major languages. Many EDA tools support HDL-based design

Digital Design with FPGAs. By Neeraj Kulkarni

VHDL. VHDL History. Why VHDL? Introduction to Structured VLSI Design. Very High Speed Integrated Circuit (VHSIC) Hardware Description Language

Veriolog Overview. CS/EE 3710 Fall 2010

EECS 470 Lab 6. SystemVerilog. Department of Electrical Engineering and Computer Science College of Engineering. (University of Michigan)

Course Topics - Outline

DIGITAL SYSTEM DESIGN

Digital Circuit Design and Language. Datapath Design. Chang, Ik Joon Kyunghee University

CSE 591: Advanced Hardware Design and Verification (2012 Spring) LAB #0

Verilog for Modeling - Module 9

Intro to HW Design & Externs for P4àNetFPGA. CS344 Lecture 5

Verilog for High Performance

EECS 427 Lecture 14: Verilog HDL Reading: Many handouts/references. EECS 427 W07 Lecture 14 1

In our case Dr. Johnson is setting the best practices

N-input EX-NOR gate. N-output inverter. N-input NOR gate

CS6710 Tool Suite. Verilog is the Key Tool

In this lecture, we will go beyond the basic Verilog syntax and examine how flipflops and other clocked circuits are specified.

A Verilog Primer. An Overview of Verilog for Digital Design and Simulation

Two HDLs used today VHDL. Why VHDL? Introduction to Structured VLSI Design

(System)Verilog Tutorial Aleksandar Milenković

Lab 1.5 (Warmup): Synthesis Workflow and SystemVerilog Register File Not Due

OVERVIEW: ============================================================ REPLACE

Department of Computer Science and Electrical Engineering. CMPE 415 Verilog Events Timing and Testbenches Prof. Ryan Robucci

Yet Another Latch and Gotchas Paper

Transcription:

A short introduction to SystemVerilog For those who know VHDL We aim for synthesis 1

Verilog & SystemVerilog 1984 Verilog invented, C-like syntax First standard Verilog 95 Extra features Verilog 2001 A super set - SystemVerilog VHDL www.vhdl.org/sv/systemverilog_3.1a. pdf 2

Verilog vs VHDL VHDL 2001 95 3

SystemVerilog 4

SystemVerilog constructs Flip-flop Register Adder Multiplier (signed, unsigned) Concatenation Priority decoder Memory (sync and async)

Synch and Single Pulse reg x,y; // variable type (0,1,Z,X) wire button; // net type (0,1,Z,X) // SSP always @(posedge clk) begin x <= stb; y <= x; assign button = x & ~y; // procedural block //continuous assignment stb x y button & 6

Is this the same thing? reg x,y; // variable type (0,1,Z,X) wire button; // net type (0,1,Z,X) // SSP always @(posedge clk) begin x <= stb; always @(posedge clk) begin y <= x; assign button = x & ~y; // procedural block // procedural block stb x y button & 7

One more thing // This is OK always @(posedge clk) begin x <= stb; if (rst) x <= 0; // same as always @(posedge clk) begin if (rst) x <= 0; else x <= stb; // This is not OK (synth) // multiple assignment always @(posedge clk) begin x <= stb; always @(posedge clk) begin if (rst) x <= 0; 8

SV: always_{comb, ff, latch} a 1 0 b c // forgot else branch // a synthesis warning always @(a or b) if (b) c = a; // compilation warning always_comb if (b) c = a; // yes always_comb if (b) c = a; else c = d; 9

reg or wire in Verilog 1) 2) always a <= b & c; reg both wire both assign a = b & c; both wire 3) wire both module 10

SV relaxes variable use A variable can receive a value from one of these : any number of always/initial-blocks one always_ff/always_comb-block one continuous assignment one module instance We can skip wire If you don t like reg, use logic instead 11

Signed/unsigned Numbers in verilog (95) are unsigned. If you write assign d3 = s + d2; s and d2 get zero-exted wire signed [4:0] d3; reg signed [3:0] s; wire signed [3:0] d2; assign d3 = s + d2; s and d2 get sign-exted 12

Blocking vs Non-Blocking Blocking assignment (=) Assignments are blocked when executing The statements will be executed in sequence, one after one always_ff @(posedge clk) begin B = A; C = B; Non-blocking assignment (<=) Assignments are not blocked The statements will be executed concurrently always_ff @(posedge clk) begin B <= A; C <= B; Use <= for sequential logic 13

Blocking vs Non-Blocking always_comb begin C = A & B; E = C D; always_comb begin C <= A & B; E <= C D; Same result Use = for combinatorial logic 14

Verilog constructs for synthesis Construct type Keyword Notes ports input, inout, output parameters module definition parameter module signals and variables wire, reg Vectors are allowed instantiation module instances E.g., mymux ml(out, io, il, s); Functions and tasks function, task Timing constructs ignored procedural always, if, then, else, case initial is not supported data flow assign Delay information is ignored loops for, while, forever procedural blocks begin,, named blocks, disable Disabling of named blocks allowed 15

Operators Replication {3{a}} same as {a,a,a} 16

Parameters module w(x,y); input x; output y; parameter z=16; localparam s=3 h1;... w w0(a,b); w #(8) w1(a,b); w #(.z(32)) w2(.x(a),.y(b)); module 17

Constants... `include myconstants.v `define PKMC `define S0 1 b0 `define S1 1 b1 `ifdef PKMC... `else... `if 18

Comment: FSM1 x NEXT s OUT u 1(1) 0 1 0(1) 0(0) 1(0) //NEXT always_ff @(posedge clk) begin if (rst) s <= `S0; else case (s) `S0: if (x) s <= `S1; default: if (x) s <= `S0; //OUT always_comb begin case (s) `S0: if (x) u = 1 b1; else u = 1 b0; default: if (x) u = 1 b0; else u = 1 b1; 19

Comment: FSM2 x COMB ns s u 1(1) 0(1) 0 1 // COMB always_comb begin ns = `S0; // defaults u = 1 b0; case (s) `S0: if (x) begin ns = `S1; u = 1 b1; default: if (~x) begin u = 1 b1; ns = `S1; 0(0) 1(0) // state register always_ff @(posedge clk) begin if (rst) s <= `S0; else s <= ns; 20

Good to have typedef logic [3:0] nibble; nibble nibblea, nibbleb; typedef enum {WAIT, LOAD, STORE} state_t; state_t state, next_state; typedef struct { logic [4:0] alu_ctrl; logic stb,ack; state_t state } control_t; control_t control; assign control.ack = 1 b0; 21

System tasks Initialize memory from file module test; reg [31:0] mem[0:511]; // 512x32 memory integer i; initial begin $readmemh( init.dat, mem); for (i=0; i<512; i=i+1) $display( mem %0d: %h, i, mem[i]); // with CR... module 22

initial begin uart1.putstr( s 0 ); Do you want a nicer test bench? => Try a task or two! my_test_bench cl k compute r rs t uart t x r x uart_task s getch putch cl k putstr computer 1 uart1 23

Tasks module uart_tasks(input clk, uart_tx, output logic uart_rx); initial begin uart_rx = 1'b1; task getch(); reg [7:0] char; begin @(negedge uart_tx); #4340; #8680; for (int i=0; i<8; i++) begin char[i] = uart_tx; #8680; $fwrite(32'h1,"%c", char); task // getch task putch(input byte char); begin uart_rx = 1'b0; for (int i=0; i<8; i++) #8680 uart_rx = char[i]; #8680 uart_rx = 1'b1; #8680; task // putch task putstr(input string str); byte ch; begin for (int i=0; i<str.len; i++) begin ch = str[i]; if (ch) putch(ch); putch(8'h0d); task // putstr module // uart_tb 24

In the testbench wire tx,rx;... // s a command initial begin #100000 // wait 100 us uart1.putstr( s 0 ); // instantiate the test UART uart_tasks uart1(.*); // instantiate the computer computer computer1(.*); 25

Lab 0 : Build a UART in Verilog USB clk = 40 MHz baud rate = 115200 8.68 us full duplex Start 1 0 0 0 0 0 1 0 stop 26

UCF = User constraint file CONFIG PART = XC2V4000-FF1152-4 ; NET "clk" LOC = "AK19"; # SWx buttons NET "stb" LOC = "B3" ; NET "rst" LOC = "C2" ; # LEDs NET "u<0>" LOC = "N9"; //leftmost NET "u<1>" LOC = "P8"; NET "u<2>" LOC = "N8"; NET "u<3>" LOC = "N7"; # DIP switches NET "kb<0>" LOC = "AL3"; //leftmost NET "kb<1>" LOC = "AK3"; NET "kb<2>" LOC = "AJ5"; NET "kb<3>" LOC = "AH6"; 27

Lab0: Testbench s rst DIP switch 0x41 kb tx LEDs 0x41 u rx clk 28

Arrays-packed/unpacked wire [31:0] bus; reg [3:0][7:0] mem; // a packed array // so is this // both are contiguous assign bus = mem; assign bus[31:16] = mem[3:2]; 31 23 15 7 0 mem[3][7:0] mem[2][7:0] mem[1][7:0] mem[0][7:0] 31 bus[31:0] 0 29

Arrays-packed/unpacked wire [31:0] bus; reg [7:0] mem [0:3]; // 4 bytes assign bus[31:24] = mem[3]; 7 0 mem[0][7:0] mem[1][7:0] mem[2][7:0] mem[3][7:0] 31 bus[31:0] 0 30

Case study Two square wave generators driven by an FSM reading from an 8 bit wide ROM The 8 bit wide ROM is divided into 8 word packets Addr 0: LSB of number of clock cycles for this packet Addr 1: MSB of number of clock cycles for this packet Addr 2,3: LSB, MSB of square wave period, channel 1 Addr 4,5: LSB, MSB of square wave period, channel 2 Addr 6,7: Unused