Handel-C Language Reference Manual
Total Page:16
File Type:pdf, Size:1020Kb
Handel-C Language Reference Manual Version 3.1 Celoxica, the Celoxica logo and Handel-C are trademarks of Celoxica Limited. Xilinx, Virtex and Spartan are trademarks of Xilinx Corp. Altera, Apex, ApexII, FLEX, FLEX 10K, MAX+PLUS II, Mercury and Quartus, are trademarks and/or service marks of Altera Corp. Actel, Actel Designer Series FPGA Development Suite, eX, SX, ProASIC and VariCore are trademarks and/or service marks of Actel Corp. Microsoft and Windows are trademarks of Microsoft Corporation. ModelSim is a trademark of Model Technologies Inc. FPGAExpress is a trademark of Synopsys Inc. Synplify is a trademark of Synplicity Inc. LeonardoSpectrum is a trademark of Exemplar Logic Inc. All other products or services mentioned herein may be trademarks of their respective owners. Neither the whole nor any part of the information contained in, or the product described in, this document may be adapted or reproduced in any material form except with the prior written permission of the copyright holder. The product described in this document is subject to continuous development and improvement. All particulars of the product and its use contained in this document are given by Celoxica Limited in good faith. However, all warranties implied or express, including but not limited to implied warranties of merchantability, or fitness for purpose, are excluded. This document is intended only to assist the reader in the use of the product. Celoxica Limited shall not be liable for any loss or damage arising from the use of any information in this document, or any incorrect use of the product. The information contained herein is subject to change without notice and is for general guidance only. Copyright © 2002 Celoxica Limited. All rights reserved. Authors: RG, SB Document number: RM-1003-3.0 Handel-C Language Reference Manual >: Table of contents Table of contents TABLE OF CONTENTS ..................................................................................................... 3 CONVENTIONS ............................................................................................................. 10 ASSUMPTIONS ............................................................................................................. 11 OMISSIONS............................................................................................................... 11 >: 1 INTRODUCTION ..................................................................................................... 12 1.1 REFERENCES ..................................................................................................... 12 >: 2 GETTING STARTED WITH HANDEL-C....................................................................... 13 2.1 LANGUAGE CHANGES IN DK1.1 ........................................................................... 13 2.2 NOTES FOR C PROGRAMMERS............................................................................. 13 2.2.1 How Handel-C differs from ANSI-C ...................................................................... 14 2.2.2 Statements in C and Handel-C............................................................................. 15 2.2.3 C and Handel-C types, type operators and objects............................................... 16 2.3 EXPRESSIONS IN C AND HANDEL-C STATEMENTS ................................................. 17 2.4 NOTES FOR HARDWARE ENGINEERS ..................................................................... 18 2.5 BASIC CONCEPTS ............................................................................................... 18 2.5.1 Handel-C programs .............................................................................................. 18 2.5.2 Parallel programs ................................................................................................. 19 2.5.3 Channel communications: overview ..................................................................... 20 2.5.4 Scope and variable sharing .................................................................................. 20 2.6 LANGUAGE BASICS ............................................................................................. 22 2.6.1 Program structure................................................................................................. 22 2.6.2 Comments............................................................................................................ 23 >: 3 LANGUAGE SUMMARY ........................................................................................... 24 3.1 STATEMENT SUMMARY ........................................................................................ 24 3.2 OPERATOR SUMMARY ......................................................................................... 25 3.3 TYPE SUMMARY .................................................................................................. 27 >: 4 DECLARATIONS .................................................................................................... 29 4.1 INTRODUCTION TO TYPES..................................................................................... 29 4.1.1 Handel-C values and widths................................................................................. 29 4.1.2 String constants ................................................................................................... 30 4.1.3 Constants............................................................................................................. 30 4.2 LOGIC TYPES...................................................................................................... 31 4.2.1 int ......................................................................................................................... 31 4.2.2 Inferring widths..................................................................................................... 33 4.3 COMPLEX TYPES................................................................................................. 34 4.3.1 Arrays................................................................................................................... 34 Handel-C Language Reference Manual >: Table of contents 4.3.2 Array indices ........................................................................................................ 35 4.3.3 Struct....................................................................................................................35 4.3.4 enum.................................................................................................................... 36 4.3.5 Bit field .................................................................................................................37 4.4 POINTERS .......................................................................................................... 38 4.4.1 Pointers and addresses........................................................................................ 39 4.4.2 Pointers to functions............................................................................................. 40 4.4.3 Pointers to interfaces............................................................................................ 40 4.4.4 Structure pointers................................................................................................. 40 4.4.5 * operator / & operator.......................................................................................... 42 4.5 ARCHITECTURAL TYPES ...................................................................................... 43 4.6 CHANNELS ......................................................................................................... 43 4.6.1 Arrays of channels................................................................................................ 43 4.7 INTERFACES: OVERVIEW ..................................................................................... 44 4.7.1 Interface definition................................................................................................ 45 4.7.2 Interface declaration............................................................................................. 46 4.7.3 Example interface to external code ...................................................................... 47 4.7.4 Interface specifications......................................................................................... 48 4.8 RAMS AND ROMS ............................................................................................. 49 4.8.1 Multidimensional memory arrays .......................................................................... 51 4.9 MPRAM (MULTI-PORTED RAMS)........................................................................... 52 4.9.1 Initialization of mprams......................................................................................... 53 4.9.2 Mapping of different width mpram ports................................................................ 54 4.9.3 mprams example.................................................................................................. 55 4.9.4 WOM (write-only memory).................................................................................... 56 4.10 OTHER ARCHITECTURAL TYPES.......................................................................... 57 4.10.1 sema .................................................................................................................. 57 4.10.2 signal.................................................................................................................