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

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

Last Lecture: Divide by 3 FSM

Example Best and Median Results

ECE 2300 Digital Logic & Computer Organization. More Sequential Logic Verilog

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

Quick Introduction to SystemVerilog: Sequental Logic

CSE 502: Computer Architecture

Testbenches for Sequential Circuits... also, Components

Laboratory Exercise 3 Davide Rossi DEI University of Bologna AA

Synthesizable Verilog

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>

SystemVerilog HDL - a programming language

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

Lecture 32: SystemVerilog

Digital Design with SystemVerilog

Blocking(=) vs Nonblocking (<=) Assignment. Lecture 3: Modeling Sequential Logic in Verilog HDL. Procedural assignments

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

EECS 470 Lab 1. Verilog: Hardware Description Language

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

EECS 470 Lab 1. Verilog: Hardware Description Language

Online Verilog Resources

Digital Design using HDLs EE 4755 Midterm Examination

HDLs and SystemVerilog. Digital Computer Design

Verilog Execution Semantics

Digital Design with FPGAs. By Neeraj Kulkarni

Verilog Fundamentals. Shubham Singh. Junior Undergrad. Electrical Engineering

ECEN 468 Advanced Logic Design

Problem Set 2 Solutions

Verilog 1 - Fundamentals

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

ECE 353 Lab 3 (Verilog Design Approach)

Nikhil Gupta. FPGA Challenge Takneek 2012

EN164: Design of Computing Systems Lecture 07: Lab Foundations / Verilog 3

Verilog Nonblocking Assignments with Delays - Myths & Mysteries

FPGA: FIELD PROGRAMMABLE GATE ARRAY Verilog: a hardware description language. Reference: [1]

FSM and Efficient Synthesizable FSM Design using Verilog

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

ARM 64-bit Register File

Modeling Sequential Circuits in Verilog

ECE 4514 Digital Design II. Spring Lecture 13: Logic Synthesis

271/469 Verilog Tutorial

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

EPC6055 Digital Integrated Circuits EXAM 1 Fall Semester 2013

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

ECE331: Hardware Organization and Design

271/471 Verilog Tutorial

EN2911X: Reconfigurable Computing Topic 02: Hardware Definition Languages

- 1 of 18 - The Verilog Hardware Description Language - A Behavioural View Overview. The Behavioural Model

MCMASTER UNIVERSITY EMBEDDED SYSTEMS

Introduction To HDL. Verilog HDL. Debdeep Mukhopadhyay Dept of CSE, IIT Madras 1

ECE 353 Lab 4. Verilog Review. Professor Daniel Holcomb With material by Professor Moritz and Kundu UMass Amherst Fall 2016

Lecture 8: More SystemVerilog Features

Digital Design with SystemVerilog

ENGN1640: Design of Computing Systems Topic 02: Lab Foundations

ECEN 468 Advanced Digital System Design

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

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

Synthesis of Combinational and Sequential Circuits with Verilog

Digital System Design Verilog-Part III. Amir Masoud Gharehbaghi

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

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

VERILOG. Deepjyoti Borah, Diwahar Jawahar

University of Toronto Faculty of Applied Science and Engineering Edward S. Rogers Sr. Department of Electrical and Computer Engineering

(System)Verilog Tutorial Aleksandar Milenković

Digital Design Using Verilog EE Final Examination

Verilog Overview. The Verilog Hardware Description Language. Simulation of Digital Systems. Simulation of Digital Systems. Don Thomas, 1998, Page 1

ECE 4514 Digital Design II. Spring Lecture 2: Hierarchical Design

Chap 4 Connecting the Testbench and. Design. Interfaces Clocking blocks Program blocks The end of simulation Top level scope Assertions

CSE140L: Components and Design Techniques for Digital Systems Lab

VHDL VS VERILOG.

CS6710 Tool Suite. Verilog is the Key Tool

Introduction to Verilog/System Verilog

Laboratory Exercise 3

Post-Synthesis Simulation. VITAL Models, SDF Files, Timing Simulation

Introduction to Verilog

EECS150 - Digital Design Lecture 5 - Verilog Logic Synthesis

CSE140L: Components and Design

Lecture #2: Verilog HDL

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

Verilog Overview. The Verilog Hardware Description Language. Simulation of Digital Systems. Simulation of Digital Systems. Don Thomas, 1998, Page 1

Chap 6 Introduction to HDL (d)

EEL 4783: HDL in Digital System Design

EECS150 - Digital Design Lecture 10 Logic Synthesis

EECS150 - Digital Design Lecture 10 Logic Synthesis

yamin/

Verilog Lecture Gandhi Puvvada, USC always statements, Coding a Flip-Flop. blocking and non-blocking assignments. Copyright 2008 Gandhi Puvvada 1

Techniques for Digital Systems Lab. Verilog HDL. Tajana Simunic Rosing. Source: Eric Crabill, Xilinx

CSE140L: Components and Design Techniques for Digital Systems Lab. Verilog HDL. Instructor: Mohsen Imani UC San Diego. Source: Eric Crabill, Xilinx

What is Verilog HDL? Lecture 1: Verilog HDL Introduction. Basic Design Methodology. What is VHDL? Requirements

Building Bigger Systems: Hardware Threads

Verilog Overview. The Verilog Hardware Description Language. Simulation of Digital Systems. Simulation of Digital Systems. Don Thomas, 1998, Page 1

Lab 6 : Introduction to Verilog

EECS150 - Digital Design Lecture 8 - Hardware Description Languages

ECE 4514 Digital Design II. Spring Lecture 9: Review of Key Ideas, System Commands and Testbenches

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

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

EE 231 Fall EE 231 Homework 8 Due October 20, 2010

Nonblocking Assignments in Verilog Synthesis; Coding Styles That Kill!

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

Transcription:

!== vs.!= and === vs. == In SystemVerilog, logic is a 4-state signal type with values 0, 1, X, Z. If a signal is never assigned to, ModelSim will assume that has an xxx xxx value. This means if you do something like if (hash!= 160 d0) it will return false even if hash is undefined. It sort of treats x s as wildcards. In SystemVerilog,!== comparator will return true because the x s don t match the 0 s. Similarly, === treats x s different than 0 s and 1 s. However, synthesis will produce same logic. 1

Blocking vs. Nonblocking Assignment For always_ff statements, use nonblocking assignments (<=) All nonblocking assignments happen together at the end after next clock tick. e.g., always_ff@(posedge clk) begin q <= q + 1; end a flip-flop gets created for q, RHS (q + 1) is current value of the q flip-flop, and LHS (q <= ) means the q flip-flop gets updated on next clock tick. For always_comb statements, use blocking assignment (=) All blocking assignments happen in order of appearance. e.g., always_comb begin t = a & b; f = t & c; end a wire gets generated for t as output of the AND-gate a & b. Using or mixing blocking assignment (=) in always_ff or nonblocking assignment (<=) in always_comb possible, but not recommended. 2

Using Functions You can use a function to encapsulate a large chunk of logic statements using blocking assignments (=). Then you can instantiate the function from within an always_ff statement using nonblocking assignments (<=). function logic [159:0] add4(input logic [31:0] a, b, c, d);... endfunction always_ff @(posedge clk, negedge reset_n) begin end if (!reset_n) begin... end else begin end... f <= add4(a, b, c, d);... 3

Project 2: Byte Rotation The goal of this project is to learn about the memory model that we will be using for our remaining projects. 4

Byte Rotation Suppose each memory word is 32-bits, comprising of 4 bytes. Write back to memory with each memory word left-rotated by one byte. Example (word shown in hexadecimal): M[0] = 32 h01234567 M[1] = 32 h02468ace Each hexadecimal digit is 4 bits. e.g., 67 means 0110_0111 (8 bits) Write back to memory with most significant byte left-rotated to the least significant byte position. M[100] = 32 h23456701 M[111] = 32 h468ace02 5

Module Interface Wait in idle state for start, read message starting at message_addr, left-rotate each word by one byte, and write output to memory starting at output_addr. The message_addr and output_addr are word addresses. The size is given in number of bytes (guaranteed to be multiple of 4 for this project). Set done to 1 when finished. Memory (provided by testbench) mem_clk mem_addr[15:0] mem_we mem_write_data [31:0] mem_read_data[31:0] memory interface message_addr[31:0] size[31:0] output_addr[31:0] start done byte_rotation clk reset_n 6

Module Interface Your assignment is to design the yellow box: module byte_rotation(input logic clk, reset_n, start, input logic [31:0] message_addr, size, output_addr, output logic done, mem_clk, mem_we, output logic [15:0] mem_addr, output logic [31:0] mem_write_data, input logic [31:0] mem_read_data);... endmodule mem_clk message_addr[31:0] size[31:0] output_addr[31:0] start done Memory (provided by testbench) mem_addr[15:0] mem_we mem_write_data [31:0] mem_read_data[31:0] memory interface byte_rotation clk reset_n 7

Memory Model To read from the memory: Set mem_addr = 0x0000, mem_we = 0 At next clock cycle, read data from mem_read_data To write to the memory: Set mem_addr = 0x0004, mem_we = 1, mem_write_data = data that you wish to write mem_clk message_addr[31:0] size[31:0] output_addr[31:0] start done Memory (provided by testbench) mem_addr[15:0] mem_we mem_write_data [31:0] mem_read_data[31:0] memory interface byte_rotation clk reset_n 8

Memory Model You can issue a new read or write command every cycle, but you have to wait for next cycle for data to be available on mem_read_data for a read command. Be careful that if you set mem_addr and mem_we inside always_ff block, compiler will produce flip-flops for them, which means external memory will not see the address and write-enable until another cycle later. 9

Byte Rotation Use this function function logic [31:0] byte_rotate(input logic [31:0] value); byte_rotate = {value[23:16], value[15:8], value[7:0], value[31:24]}; endfunction In your SystemVerilog code, you can do something like this: mem_write_data <= byte_rotate(mem_read_data); 10

Project 2 Use the provided tb_byte_rotation.sv testbench. Name your file byte_rotation.sv. 11

Your Design Should Produce This Testbench will internally generate a 16-word message: This is shown in hexidecimal where 01 is a byte These are not shown as ASCii characters starting message 01234567 02468ace 048d159c 091a2b38 12345670 2468ace0 48d159c0 91a2b380 23456701 468ace02 8d159c04 1a2b3809 34567012 68ace024 d159c048 a2b38091 converted message 23456701 468ace02 8d159c04 1a2b3809 34567012 68ace024 d159c048 a2b38091 45670123 8ace0246 159c048d 2b38091a 56701234 ace02468 59c048d1 b38091a2 12