CIGAL Workshop Programming Jim Voyvodic August 11, 2008.

Slides:



Advertisements
Similar presentations
Introduction to C Programming
Advertisements

Instruction Set Design
Review of the MIPS Instruction Set Architecture. RISC Instruction Set Basics All operations on data apply to data in registers and typically change the.
INSTRUCTION SET ARCHITECTURES
SPIM and MIPS programming
Computer Architecture CSCE 350
COSC 120 Computer Programming
CSCE 121, Sec 200, 507, 508 Fall 2010 Prof. Jennifer L. Welch.
1 Lab Session-IV CSIT-120 Spring 2001 Lab 3 Revision and Exercises Rev: Precedence Rules Lab Exercise 4-A Machine Language Programming The “Micro” Machine.
1 Chapter 4 The Fundamentals of VBA, Macros, and Command Bars.
Visual Basic: An Object Oriented Approach 4: Simple Programming in VB.
Guide To UNIX Using Linux Third Edition
Software Development and Software Loading in Embedded Systems.
Introduction to Array The fundamental unit of data in any MATLAB program is the array. 1. An array is a collection of data values organized into rows and.
MIPS Instruction Set Advantages
Alternate Version of STARTING OUT WITH C++ 4 th Edition Chapter 1 Introduction to Computers and Programming.
System Calls 1.
 2003 Prentice Hall, Inc. All rights reserved. 1 Introduction to C++ Programming Outline Introduction to C++ Programming A Simple Program: Printing a.
Introduction to FORTRAN
Topics Introduction Hardware and Software How Computers Store Data
Fortran 1- Basics Chapters 1-2 in your Fortran book.
A Level Computing#BristolMet Session Objectives U2#S6 MUST identify different data types used in programming aka variable types SHOULD describe each data.
Learning Targets Identify the external parts of the computer Identify examples of input devices Identify examples of output devices Define basic computer.
Practical PC, 7th Edition Chapter 17: Looking Under the Hood
DELTA TAU Data Systems, Inc. 1 UMAC TurboTurbo PMAC PCIGeo Drive Single Source Machine Control motion logic data Power PMAC Project Management November.
Dr. José M. Reyes Álamo 1.  The 80x86 memory addressing modes provide flexible access to memory, allowing you to easily access ◦ Variables ◦ Arrays ◦
Introduction to Python
Machine Instruction Characteristics
IT253: Computer Organization Lecture 4: Instruction Set Architecture Tonga Institute of Higher Education.
CISC105 General Computer Science Class 1 – 6/5/2006.
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley C H A P T E R 1 Introduction to Computers and Programming.
CIGAL Workshop I Jim Voyvodic Sept 17, 2009 CIGAL.
Computer Systems Organization CS 1428 Foundations of Computer Science.
Pascal Programming Strings, Arithmetic operators and output formatting National Certificate – Unit 4 Carl Smith.
Computational Methods of Scientific Programming Lecturers Thomas A Herring, Room A, Chris Hill, Room ,
Memory Layout and SLC500™ System Addresses. Processor Memory Division An SLC 500 processor's memory is divided into two storage areas. Like two drawers.
Memory Layout and SLC500™ System Addresses. Processor Memory Division An SLC 500 processor's memory is divided into two storage areas. Like two drawers.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 3: Operating-System Structures System Components Operating System Services.
Hello.java Program Output 1 public class Hello { 2 public static void main( String [] args ) 3 { 4 System.out.println( “Hello!" ); 5 } // end method main.
CIS-165 C++ Programming I CIS-165 C++ Programming I Bergen Community College Prof. Faisal Aljamal.
Fundamentals of C and C++ Programming. EEL 3801 – Lotzi Bölöni Sub-Topics  Basic Program Structure  Variables - Types and Declarations  Basic Program.
Term 2, 2011 Week 1. CONTENTS Problem-solving methodology Programming and scripting languages – Programming languages Programming languages – Scripting.
© Janice Regan, CMPT 300, May CMPT 300 Introduction to Operating Systems Memory: Relocation.
Integration of behavioral and physiological data with imaging data James Voyvodic, Ph.D. Brain Imaging and Analysis Center Duke University June 30, 2008.
Introduction to Python Dr. José M. Reyes Álamo. 2 Three Rules of Programming Rule 1: Think before you program Rule 2: A program is a human-readable set.
Postgraduate Computing Lectures PAW 1 PAW: Physicist Analysis Workstation What is PAW? –A tool to display and manipulate data. Learning PAW –See ref. in.
What is a program? A sequence of steps
CHAPTER THREE Representing Data: Constants and Variables.
Arrays in MIPS Assembly Computer Organization and Assembly Language: Module 6.
C++ Programming Lecture 14 Arrays – Part I The Hashemite University Computer Engineering Department (Adapted from the textbook slides)
DELTA TAU Data Systems, Inc. 1 UMAC TurboTurbo PMAC PCIGeo Drive Single Source Machine Control motion logic data Power PMAC Shared Memory December 2013.
1 Asstt. Prof Navjot Kaur Computer Dept PRESENTED BY.
1 Types of Programming Language (1) Three types of programming languages 1.Machine languages Strings of numbers giving machine specific instructions Example:
LECTURE 3 Translation. PROCESS MEMORY There are four general areas of memory in a process. The text area contains the instructions for the application.
Hello world !!! ASCII representation of hello.c.
LECTURE 19 Subroutines and Parameter Passing. ABSTRACTION Recall: Abstraction is the process by which we can hide larger or more complex code fragments.
F453 Module 8: Low Level Languages 8.1: Use of Computer Architecture.
Information Technology (IT). Information Technology – technology used to create, store, exchange, and use information in its various forms (business data,
Lecture 3 Translation.
Unit 2 Technology Systems
MIPS Instruction Set Advantages
Topics Introduction Hardware and Software How Computers Store Data
Microsoft Office Access 2010 Lab 2
1-1 Logic and Syntax A computer program is a solution to a problem.
DBW - PHP DBW2017.
Topics Introduction Hardware and Software How Computers Store Data
CS285 Introduction - Visual Basic
Computer Architecture and Assembly Language
Course Overview PART I: overview material PART II: inside a compiler
Presentation transcript:

CIGAL Workshop Programming Jim Voyvodic August 11, 2008

CIGAL Programming Main CIGAL scripting language Vaguely C-like syntax Operate on whole variable in single instruction Commands (e.g. “read”, “write”, “initialize”) Functions (e.g. “sqrt()”, “random()”) Arithmetic (e.g. “a = (b + c)/d”) Structured language (If/else, while, subroutines) Real-time processor language Assembly language-like syntax Simple command repertoire Fast, accurate execution timing Asynchronous & parallel processing Showplay programming Limited event repertoire

CIGAL Variables Number formats bit1-bit integer nibble2-bit integer quad4-bit integer byte8-bit integer integer16-bit integer long32-bit integer real32 bit floating point Variables Number single value (#) Array1-D number list (^) Matrix2-D number matrix (^^) Solid3-D number matrix (^^^) Image2-D pixel number matrix (%) Stringnull-terminated text (~) String listarray of text strings (~~) Pointerpointer to another variable

Register variables There are 10 “register” real number variables that are always defined locally: r0-r9 R1-R9 are typically used for storing R0 is used to return error status for some commands. For example, “read” and “write” will return with the number of records successfully transferred in R0, or a negative number if there was an error. The “initialize” command will return a negative value if there was a problem initializing a device. e.g.read fname mm1 if(r0 <= 0) type “error reading file:” fname

Declaring variables DECLARE – create a new variable Variable names are limited to 12 characters UNDECLARE – destroy a data variable Allocating memory -- ARRAY(), MATRIX(), SOLID() e.g.aa1 = matrix(20,400) bbb1 = solid(100,200,50) aa1 = matrix(400,20) RELEASE – deallocate memory without undeclaring Local versus global Global – values available to any subroutine Local – values only available in this routine Declare in command window is global Declare in script defaults to local DEFINE – preprocessor alias (like in C)

Standard pre-defined variables The standard CIGAL startup script (sysstart.imp) declares several variables of each type, which can be used as handy general-purpose data variables. declare global string s1 s2 s3 s4 fname declare global string list slist declare global byte array b1 b2 b3 b4 declare global integer array i1 i2 i3 i4 declare global array a1 a2 a3 a4 declare global integer solid iii1 iii2 iii3 iii4 declare global long image mm1 mm2 mm3 mm4 ; standard shared memory variables declare global byte array bbuf(512) declare global integer array ibuf(256) = bbuf declare global long array lbuf(128) = bbuf declare global real array rbuf(128) = bbuf The scripts “pdigminit.imp” and “showplay.imp” also declare many commonly used variables.

Variables – Data storage locations User-defined variables Explicitly declared variables e.g.declare real x y z declare integer array jdata(4,200) declare byte matrix bmatrix Stack – Automatically allocated (800 Kb) High stack – User allocated (RAM limited) Intrinsic pseudo-variables Provide access to status and control variables See Hardware device pseudo-variables Number variables associated with data channels e.g.adc0, adc1, digio, lpt100, lpt101 cursx, cursy Variables assigned automatically by Initialize Disk files can be used as implicit variables e.g.^^junk.txt ~~names.txt

Data variable subsets In general, CIGAL commands or functions can operate on whole variables, or subsets of variables. Examples: aa2(3,4)A single element of matrix aa2 aa2(3)A single row of matrix aa2 aa2(,4)A single column of matrix aa2 aa2(2:5,4:99)A 3x96 matrix subset of aa2 Assigning data to a variable without explicitly declared dimensions automatically allocates memory. aa3 = aa2(100:199,200:249);Create 100x50 aa3 Assigning data to a subset only affects those elements. aa2(50:149,100:149) = aa3

Limited stack memory When performing complex arithmetic, CIGAL automatically allocates temporary stack storage space for intermediate results. e.g.y = -b + sqrt(b**2-4*a*c)/2*a Because stack storage space is limited, it is safer to break up calculations using large variables into separate steps, to avoid the need for temporary data storage. So if A, B, C, and Y are arrays, try: a1 = b**2 a2 = a * c a2 = 4 * a2 a1 = a1 – a2 a1 = sqrt(a1) a2 = 2 * a a1 = a1 / a2 y = a1 - b

Common CIGAL commands CIGAL has over 300 commands and functions. The most commonly used are: declare- declare a data variable define- define a preprocessor alias show- show the status of a variable read- read a file write- write a file type- print data values ftype- formatted print format- formatted print into a text string execute- execute a command string map- use data values as index to lookup table menu- load a GUI menu accept- request user input if- test condition while- loop condition default- assign default program arguments return- return from a CIGAL program realtime- run a real-time program and arithmetic expressions

Real-time programming The REALTIME command reads, compiles, and executes a real-time program. There are over 100 real-time commands in CIGAL. They all start with “r_”. Example: s1 = “Press a button” l1 = { 0ff0000h 0ff00h 0ffh 0ffff00h 0ffffh 0ffffffh 0 } i1 = { scrwid/2 100 } ii1= { } realtime { r_erase ff00h; green screen r_text0 0 0 i1 s1 1; put text r_uwait0 0 0 stemp; wait for response r_ifeq0 0 0stemp 113 r_quit r_endif r_erase b3b3b3h; gray screen r_repeat r_bfill0 0 0l1++ ii1; color in box r_end r_wait r_quit }

Combining Showplay real-time modules ; select default module files file_rtrig = dir_rtcode // "rt_trigger.txt" file_raread = dir_rtcode // "rt_aread.txt" file_ruread = dir_rtcode // "rt_uwait.txt" file_rdread = dir_rtcode // "rt_dwait.txt" file_rresp = dir_rtcode // "rt_response.txt" file_rmain = dir_rtcode // "rt_stimon.txt" file_rmain2 = dir_rtcode // "rt_stimoff.txt" file_rquit = dir_rtcode // "rt_finish.txt" ; create the realtime program RTIME.TMP if(?file_rtrig > 0) list file_rtrig 0 > rtime.tmp if(?file_raread > 0) list file_raread 0 >> rtime.tmp if(?file_ruread > 0) list file_ruread 0 >> rtime.tmp if(?file_rdread > 0) list file_rdread 0 >> rtime.tmp if(?file_rresp > 0) list file_rresp 0 >> rtime.tmp if(?file_rmain > 0) list file_rmain 0 >> rtime.tmp if(?file_rumain > 0) list file_rumain 0 >> rtime.tmp if(?file_rmain2 > 0) list file_rmain2 0 >> rtime.tmp if(?file_rquit > 0) list file_rquit 0 >> rtime.tmp if(?file_ruser > 0) list file_ruser 0 >> rtime.tmp ; run the realtime program realtime rtime.tmp runlog pdflg

Programming examples The PDIGM and IMP subfolders in the CIGAL system directory are full of examples of simple CIGAL programs. The CODEBLOCKS subfolder contains all of the preprocessing and postprocessing subroutines (.IMP) as well as the default real-time modules (RT_*.txt) used to create the RTIME.TMP real-time program. There is an example Showplay PPF in the DEMO folder and also on the Wiki.

Showplay event programming Currently limited to stimulus files, text, and a few commands: font - change the text font fix- draw a fiixation cross erase - fill the screen with back_color reset- reset the clock to 0 rwait- wait for a subject response owait – wait for an operator response Will soon add ability to jump between multiple stimulus lists and to step through preset lists of stimuli.