Lecturer: Simon Winberg Lecture 20 C  HDL Automatic Conversion.

Slides:



Advertisements
Similar presentations
Verilog Intro: Part 1.
Advertisements

Ch. 7 Process Synchronization (1/2) I Background F Producer - Consumer process :  Compiler, Assembler, Loader, · · · · · · F Bounded buffer.
Processor Technology and Architecture
1 Homework Turn in HW2 at start of next class. Starting Chapter 2 K&R. Read ahead. HW3 is on line. –Due: class 9, but a lot to do! –You may want to get.
1 Lecture 6 Performance Measurement and Improvement.
Aug. 24, 2007ELEC 5200/6200 Project1 Computer Design Project ELEC 5200/6200-Computer Architecture and Design Fall 2007 Vishwani D. Agrawal James J.Danaher.
Kazi Fall 2006 EEGN 4941 EEGN-494 HDL Design Principles for VLSI/FPGAs Khurram Kazi Some of the slides were taken from K Gaj’s lecture slides from GMU’s.
Chapter 4 Processor Technology and Architecture. Chapter goals Describe CPU instruction and execution cycles Explain how primitive CPU instructions are.
Computer ArchitectureFall 2008 © August 25, CS 447 – Computer Architecture Lecture 3 Computer Arithmetic (1)
Kazi Fall 2006 EEGN 4941 EEGN-494 HDL Design Principles for VLSI/FPGAs Khurram Kazi Some of the slides were taken from K Gaj’s lecture slides from GMU’s.
George Mason University ECE 448 – FPGA and ASIC Design with VHDL Finite State Machines State Diagrams, State Tables, Algorithmic State Machine (ASM) Charts,
VHDL. What is VHDL? VHDL: VHSIC Hardware Description Language  VHSIC: Very High Speed Integrated Circuit 7/2/ R.H.Khade.
Railway Foundation Electronic, Electrical and Processor Engineering.
Reduced Instruction Set Computers (RISC) Computer Organization and Architecture.
Introduction to VHDL (part 2)
An Introduction Chapter Chapter 1 Introduction2 Computer Systems  Programmable machines  Hardware + Software (program) HardwareProgram.
CIS Computer Programming Logic
Introduction to FPGA AVI SINGH. Prerequisites Digital Circuit Design - Logic Gates, FlipFlops, Counters, Mux-Demux Familiarity with a procedural programming.
ECE 2372 Modern Digital System Design
IT253: Computer Organization Lecture 4: Instruction Set Architecture Tonga Institute of Higher Education.
Synthesis Presented by: Ms. Sangeeta L. Mahaddalkar ME(Microelectronics) Sem II Subject: Subject:ASIC Design and FPGA.
Lecturer: Simon Winberg Lecture 20 C  HDL Automatic Conversion Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
A VHDL Tutorial ENG2410. ENG241/VHDL Tutorial2 Goals Introduce the students to the following: –VHDL as Hardware description language. –How to describe.
VHDL IE- CSE. What do you understand by VHDL??  VHDL stands for VHSIC (Very High Speed Integrated Circuits) Hardware Description Language.
CS 320 Assignment 1 Rewriting the MISC Osystem class to support loading machine language programs at addresses other than 0 1.
Your Own Digital Accelerator Topics & Selection Lecturer: Simon Winberg Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
1 Workshop Topics - Outline Workshop 1 - Introduction Workshop 2 - module instantiation Workshop 3 - Lexical conventions Workshop 4 - Value Logic System.
Language Concepts Ver 1.1, Copyright 1997 TS, Inc. VHDL L a n g u a g e C o n c e p t s Page 1.
EEE2243 Digital System Design Chapter 4: Verilog HDL (Sequential) by Muhazam Mustapha, January 2011.
1 Workshop Topics - Outline Workshop 1 - Introduction Workshop 2 - module instantiation Workshop 3 - Lexical conventions Workshop 4 - Value Logic System.
ENG241 Digital Design Week #8 Registers and Counters.
Fall 2004EE 3563 Digital Systems Design EE 3563 VHDL – Basic Language Elements  Identifiers: –basic identifier: composed of a sequence of one or more.
Fall 2004EE 3563 Digital Systems Design EE 3563 VHSIC Hardware Description Language  Required Reading: –These Slides –VHDL Tutorial  Very High Speed.
Anurag Dwivedi. Basic Block - Gates Gates -> Flip Flops.
Design Methodology Based on VHDL Instructors: Fu-Chiung Cheng ( 鄭福炯 ) Associate Professor Computer Science & Engineering Tatung University.
Discussed in class and on Fridays n FSMs (only synchronous, with asynchronous reset) –Moore –Mealy –Rabin-Scott n Generalized register: –With D FFs, –With.
1 Hardware description languages: introduction intellectual property (IP) introduction to VHDL and Verilog entities and architectural bodies behavioral,
Introduction to VHDL Simulation … Synthesis …. The digital design process… Initial specification Block diagram Final product Circuit equations Logic design.
Lab 2 Parallel processing using NIOS II processors
 Lecture 2 Processor Organization  Control needs to have the  Ability to fetch instructions from memory  Logic and means to control instruction sequencing.
ALU (Continued) Computer Architecture (Fall 2006).
VHDL Discussion Sequential Sytems. Memory Elements. Registers. Counters IAY 0600 Digital Systems Design Alexander Sudnitson Tallinn University of Technology.
1 Part III: VHDL CODING. 2 Design StructureData TypesOperators and AttributesConcurrent DesignSequential DesignSignals and VariablesState Machines A VHDL.
Introduction to ASIC flow and Verilog HDL
04/26/20031 ECE 551: Digital System Design & Synthesis Lecture Set : Introduction to VHDL 12.2: VHDL versus Verilog (Separate File)
5-1 Logic System Design I VHDL Design Principles ECGR2181 Reading: Chapter 5.0, 5.1, 5.3 port ( I: in STD_LOGIC_VECTOR (1 to 9); EVEN, ODD: out STD_LOGIC.
EE121 John Wakerly Lecture #17
Teaching Digital Logic courses with Altera Technology
1 Introduction to Engineering Spring 2007 Lecture 18: Digital Tools 2.
1 Introduction to Engineering Spring 2007 Lecture 19: Digital Tools 3.
Introduction to the FPGA and Labs
Overview Logistics Last lecture Today HW5 due today
Lecture 26 C  HDL Automatic Conversion
Discussion 2: More to discuss
Introduction Introduction to VHDL Entities Signals Data & Scalar Types
‘if-else’ & ‘case’ Statements
ECE 4110–5110 Digital System Design
ECE 434 Advanced Digital System L08
HDL Programming Fundamentals
RTL Style در RTL مدار ترتيبي به دو بخش (تركيبي و عناصر حافظه) تقسيم مي شود. مي توان براي هر بخش يك پروسس نوشت يا براي هر دو فقط يك پروسس نوشت. مرتضي صاحب.
IAS 0600 Digital Systems Design
VHDL (VHSIC Hardware Description Language)
Programming in JavaScript
IAS 0600 Digital Systems Design
Figure 8.1. The general form of a sequential circuit.
Programming in JavaScript
Introduction to Microprocessor Programming
ECE 448 Lecture 6 Finite State Machines State Diagrams, State Tables, Algorithmic State Machine (ASM) Charts, and VHDL code ECE 448 – FPGA and ASIC Design.
Sequntial-Circuit Building Blocks
EEL4712 Digital Design (VHDL Tutorial).
Presentation transcript:

Lecturer: Simon Winberg Lecture 20 C  HDL Automatic Conversion

 Reminders  C  HDL automatic conversion  Overview of conversion process  Limitations  Scenario  Mapping C to VHDL behavioural  Some tools

 Quiz 4 to be held next Thursday (9 May)  Lecture 16 (slide 13)  Lecture 20  CH24 (pages: ; 473; )

YODA Groups and their managers Design reviews: May 9, 10 See wiki for your ‘group manager’ assignment (copied to next slide too) Make contact with your group manager

#Name and LinkTeamATeamB 01 SF - Smoothing Filter P01?Smoothing Filter P01? 02 TLUA – Table Look-up Accelerator P02? P*Table Look-up Accelerator P02? 03 IF – Interpolation Filter P03?Interpolation Filter P03?LQLTUM001 HNGDAN001 (OH) 04 PRNG – Parallel Random Number Generator P04?Parallel Random Number Generator P04? 05 DM - Delta modulator P05?Delta modulator P05? 06 ASG - Arithmetic series generator P06?Arithmetic series generator P06? MTKMOO001 NSKCHR001 ATMLOR001 (JE) BSXLAS001 DLLMIK001 (JE) 07 SALG – Selection Address List Generator P07? P*Selection Address List Generator P07? 08 FSG – Function Samples Generator P08? P*Function Samples Generator P08?MTBMOR002 XMBSAN001 (OH) 09 BCDC - Binary Coded Decimal Convertor P09?Binary Coded Decimal Convertor P09? CHPDAV005 VVNJON001 RSHNIK001 (KR) YGMPEN001 NDHNYI002 (KR) 10 NCSM - Nonlinear Check Sum Module P10? P*Nonlinear Check Sum Module P10? 11 CRCC - Cyclic Redundancy Check Calculator P11?Cyclic Redundancy Check Calculator P11? GWNJAM001 RTFFRA004 (IT) 12 MMA - Matrix Multiplier Accelerator P12?Matrix Multiplier Accelerator P12?MNYPAU005 MPNALF001 (JE) JKXGEO001 OPNWIL001 CDRNEL001 (JE) 13 IMA - Image Masking Accelerator P13?Image Masking Accelerator P13?CTSJUS001 MSSDAN004 (OH) 14 PSA - Pattern Seek Accelerator P14? P*Pattern Seek Accelerator P14? 15 DE - Data encryption accelerator P15?Data encryption accelerator P15?CWDMAT001 TNGOLO001 (IT) 16 DEA - TBD 17 O - Digital Encryption Recovery Accelerator P17? P*Digital Encryption Recovery Accelerator P17? BRMGRE003 LRNFED001 (IT) 18 AA - Audio Accelerator P18?Audio Accelerator P18? 19 SPA - Shortest Path Accelerator P19NCLAND004NCLAND004 (KR) InitialsName (KR) Karthik Rajeswaran (OH) Ojonav Hazarika (IT) Israel Tshililo (JE) Jason Esselaar

 Some teams not yet booked  Please me your requested slot (see announcement sent earlier)  Demos are still 15 and 16 May  Final report and code hand in: 20 May  Heavy penalties for late demo

 Every heard of DMIPS?  In relation to a VAX?  How bizarre… how is that possibly of any relevance to HPCE?...

 DMIPS =  Dhrystone MIPS (Million Instructions Per Second). Shows number of iterations of the Dhrystone loop repeated per second.  MIPS along are not all that meaningful for benchmarking because 1 CISC instruction may be worth many RISC instructions (but the CISC might still complete the task faster)  DMIPS = Dhrystone_score / 1,757  The value 1,757 is the number of Dhrystones per second obtained on the VAX 11/780, nominally a 1 MIPS machine

 Whetstone is a collection of commonly used computation tasks, repeated in a loop, and the time the loop takes to complete equates to the Whetstone rating. For further details see:

 The Dhrystone benchmark contains no floating point operations; it is works similarly to the Whetstone, but uses computations appropriate for fixed-point or integer based applications. further details see:

 CoreMark is a smaller benchmark  Developed by the Embedded Microprocessor Benchmark Consortium (EEMBC)  Focuses on the CPU core, similar to Dhrystone.  CoreMark is intended to  Execute on any processor, incl. small micro-controllers.  Avoid issues such as the compiler computing the work during compile time  Use real algorithms rather than being mostly synthetic.  CoreMark has established rules for running the benchmark and for reporting the results. further details see:

C to HDL Automatic Conversion EEE4084F

C to VHDL Converters  C program: functions; variables;  based on sequence (start to end) and the use of memory/registers operations  VHDL:  Implements an entity for the procedure C code converted to VHDL

 Standard C  Memory-based  Variables (registers) used in performing computation  Normal C and C programs are sequential  Specialized C flavours for parallel description & FPGA programming:  Mitrion-C, SystemC, pC (IBM Parallel C) System Crafter, Impulse C  FpgaC Open-source ( – does generate VHDL/Verilog but directly to bit filehttp://fpgac.sourceforge.net/

 Input  Often one C module at a time, no C libraries (operations like sqrt hardcoded as VHDL and H file interface, e.g. math.h)  More complete versions could use multiple user- developed modules and libraries  Output  VHDL code describing a top-level element with ports that can be hooked-up to other elements (e.g. using Altera Quartus II or LabView FPGA*) such as memory (e.g. BRAM, SDRAM), multipliers and dividers – similar to what you’ve done in Prac3 *

 No global variables  Forced to use additional parameters  E.g. to lines to control/arbitrate memory accesses, which you may need to manually account for in your code of things don’t work  Limited arguments  E.g. limited to 4  Does not support all C constructs  E.g. struct  One function at a time

 Looking at the steps a translation tool would take  Program requirements:  Implement a 4-bit up-counter in C that counts from an initial value (default of 0) and sets a reset_alarm variable once the target has been reached  Also want a reset operation and ability to set the count value

 Let’s write it as we’d naturally write in C 1. Set up a few global variables 2. Set up a few functions 3. Write a main() function as starting point of the program Please refer to the Handle-C handout that describes the style & syntax (note this handout is a simplification of the official Handle-C syntax) See handlec.c in: resources / class activities / handlec-example.zip

/** upcount (attempt 1): 4-bit up-counter with reset alert. This is a C program that we want to translate into VHDL. */ /* Global variables */ int count = 0; // our global counter int target = 5; // the targer value // Reset function sets count to 0 void reset () { count = 0; } /** Our upcount function. Return nonzero when target reached. */ int upcount () { count=(count + 1)%7; if (count==target) return 1; else return 0; } int main () { reset(); // reset the counter // wait a bit... while (!upcount()); // override with another value count = 2; return 0; } Program continues here

 VHDL program doesn’t really have a starting point  Usually more a data flows, sending signals to a port and getting signals back  We’re essentially wanting the program to become a VHDL entity  Need to make account for other entities wanting to control this one (e.g., telling this program to “reset”)  What about the clock?

 Design around “lines” (shown as variable parameters) that control the upcount function (to become the upcount entity)  Parameters  Reset = reset the counter  Loadcnt = request value to load  Data = input value to load into count  Target = target to up to

C Interface  VHDL Port H file for C program /* 4-bit up-counter with reset alert. */ void upcount ( _in int data, _in int target, _in bit loadcnt, _in bit reset ); /* Increments count until it reaches target. Returns 1 if target reached else returns 0 */ VHDL Code Port ENTITY counter_4 IS PORT( clock, reset, loadcnt: IN BIT; data: IN BIT_VECTOR( 3 DOWNTO 0 ); reset_alert: OUT BIT; count: BUFFER BIT_VECTOR(3 DOWNTO 0) ); END counter_4;

 The translation needs to map C variable types into VHDL signals…  VHDL standard types…  Scalar (single valued) signal types:  bit, boolean, integer  Examples:  A: in bit;  G: out boolean;  K: out integer range -2**4 to 2**4-1;

 Aggregate (collection) signal types:  bit_vector – array of bits representing an unsigned binary number  signed – array of bits representing a signed binary number  Examples:  D: in bit_vector(0 to 7);  E: in bit_vector(7 downto 0);  M: in signed (4 downto 0); -- signed 5-bit vector for a binary number

 C implementation  Initialization of global variables  Operation of the functions  The entry point (main) and sequencing of program (i.e. main calls upcount)  VHDL translation  Initialization of registers  Clocks (to synchronize operations)  Architecture/behaviour descriptions describing what the entities do

ENTITY upcount IS PORT( clock : IN BIT; data : IN BIT_VECTOR (3 DOWNTO 0); target: IN BIT_VECTOR (3 DOWNTO 0); loadcnt, reset : IN BIT; reset_alert: OUT BIT ); END counter_4; ARCHITECTURE behavioral OF counter_4 IS BEGIN upcount: PROCESS( clock ) VARIABLE count: BIT_VECTOR(3 DOWNTO 0); BEGIN IF (clock= '1') THEN IF (reset = '1') THEN count <= "0000"; ELSIF (loadcnt='1') THEN count <= data; ELSE -- … adder here (see next slide) … END PROCESS upcount; END behavioral; C to HDL: Large part is converting C into a VHDL behaviour description… C Code /* 4-bit up-counter with reset alert. */ int count = 0; // this function runs // all the time: int upcount ( _in int 4 data, _in int 4 target, _in bit loadcnt, _in bit reset, _out bit reset_alert) { if (reset) count=0; if (loadcnt) { count=data; return 0; } count=(count + 1)%15; if (count==target) reset_alert=1; else reset_alert=0; } VHDL Code

-- full adder -- count(0) <= NOT count(0); count(1) <= count(0) XOR count(1); count(2) <= ( count(0) AND count(1) ) XOR count(2); count(3) <= ( count(0) AND count(1) AND count(2) ) XOR count(3); IF count = target THEN reset_alert <= '1'; ELSE reset_alert <= '0'; END IF; -- IF count = target END IF; -- IF reset = ‘1’ END IF; -- IF clock = '1’ VHDL Code Continuation of last slide (for completeness sake)…

 Handles the basic C data types  ints, arrays / pointers, reference variables (e.g., int& ref)  Handles basic C constructs such as:  arithmetic operations  if-then-else and switch  Loops: for, while-do, do-while General rule of practice: avoid using loops (esp. for) unless it’s really needed as better and more efficient code is generally produced if you keep in mind that the whole function restarts after a return / reaches the end.

 if-then-elseif-then-else  while-doif-then, while-do  do-whilefirst iteration, while-do  for-dofor-do  Arithmetic Arithmetic operationsoperations

 Mutual recursion not supported  Hardware to hardware communication generally not supported  For some convertors, The return statement at the end of code should return only void or integer (e.g., DimeC)  Declarative limitations for variables and procedures (e.g., not more than 4 parameters – depends on interconnect limitations of FPGA)

 Implement a pattern counter:  Send a starting address (byte addressing used)  Send an ending address  Send a 2-byte (16-bit) sequence to search for (this can be a 16-bit input)  Send an enable pulse to read all the inputs and start searching (note the inputs may change later during the execution)  Returns a 16-bit integer showing the number found, and raises done to high See lecture 20 handout on pattern counter exercise (and sample solution)

C  VHDL Tools Commercial Conversion Tools

SystemC Example (an alternative) #include "systemc.h" SC_MODULE(adder) // module declaration (like class) { sc_in a, b; // ports sc_out sum; void do_add () // define a process... { sum = a + b; } SC_CTOR(adder) // constructor { SC_METHOD(do_add); // register do_add with kernel sensitive << a << b; // sensitivity list for ‘do_add’ } }; (lecturers comment: as the code shows, it is not easy; I recommend starting with something like handleC and delve into SystemC if you need its expressivity and additional features.)

ImpulseC Write FPGA processing applications in (fairly standard) C Provides a sophisticated IDE Include tools for profiling and to help you optimize your code Generates both hardware bit files for the FPGA (s) used and an FPGA interface for custom PC-based programs

ImpulseC Screenshot

 Many of the C  VHDL also support C  Verilog as well  Free online C to Verilog translator 

Example Run C CODE (6 lines) #define ITEMS 256 // of each word of B[] in A[] void my_main(unsigned int* A, unsigned int* B) { for (int i=0; i<ITEMS; i++) A[i] = A[i] + B[i]; } module _Z7my_mainPjS_ ( clk, reset, rdy,// control // memport for: A mem_A_out0, mem_A_in0, mem_A_addr0, mem_A_mode0, // memport for B: mem_B_out0, mem_B_in0, mem_B_addr0, mem_B_mode0, // 2 nd mem port for A for parallel proc mem_A_out1, mem_A_in1, mem_A_addr1, mem_A_mode1, …); // params input wire clk; input wire reset; // output rdy; reg rdy; output return_value; reg return_value; input [7:0] p_A; input [7:0] p_B;input wire [31:0] mem_A_out0;output reg [31:0] … Verilog (281 lines of code A,B 8-bit)