CS189A/172 - Winter 2008 Lecture 7: Software Specification, Architecture Specification.

Slides:



Advertisements
Similar presentations
Compilers Course 379K, TTH 9:30-11:00 Instructor: Dr. Doron A. Peled Office Hours: Mon 11:00-12:00.
Advertisements

Software & Services Group, Developer Products Division Copyright© 2010, Intel Corporation. All rights reserved. *Other brands and names are the property.
CS 31003: Compilers Introduction to Phases of Compiler.
Compilers and Language Translation
The Functions and Purposes of Translators Code Generation (Intermediate Code, Optimisation, Final Code), Linkers & Loaders.
Compiler Construction by Muhammad Bilal Zafar (AP)
UNIT-III By Mr. M. V. Nikum (B.E.I.T). Programming Language Lexical and Syntactic features of a programming Language are specified by its grammar Language:-
CPSC Compiler Tutorial 9 Review of Compiler.
Software Requirements
From Cooper & Torczon1 Implications Must recognize legal (and illegal) programs Must generate correct code Must manage storage of all variables (and code)
MCA –Software Engineering Kantipur City College. Topics include  Formal Methods Concept  Formal Specification Language Test plan creation Test-case.
1.3 Executing Programs. How is Computer Code Transformed into an Executable? Interpreters Compilers Hybrid systems.
Lecture 2 Phases of Compiler. Preprocessors, Compilers, Assemblers, and Linkers Preprocessor Compiler Assembler Linker Skeletal Source Program Source.
Basic Concepts The Unified Modeling Language (UML) SYSC System Analysis and Design.
Invitation to Computer Science 5th Edition
Chapter 1 Introduction Dr. Frank Lee. 1.1 Why Study Compiler? To write more efficient code in a high-level language To provide solid foundation in parsing.
Parser-Driven Games Tool programming © Allan C. Milne Abertay University v
Chapter 10: Compilers and Language Translation Invitation to Computer Science, Java Version, Third Edition.
1 History of compiler development 1953 IBM develops the 701 EDPM (Electronic Data Processing Machine), the first general purpose computer, built as a “defense.
TMF1013 : Introduction To Computing Lecture 1 : Fundamental of Computer ComputerFoudamentals.
Compiler course 1. Introduction. Outline Scope of the course Disciplines involved in it Abstract view for a compiler Front-end and back-end tasks Modules.
CS 326 Programming Languages, Concepts and Implementation Instructor: Mircea Nicolescu Lecture 2.
Object Management Group (OMG) Specifies open standards for every aspect of distributed computing Multiplatform Model Driven Architecture (MDA)
CST320 - Lec 11 Why study compilers? n n Ties lots of things you know together: –Theory (finite automata, grammars) –Data structures –Modularization –Utilization.
1 COMP 3438 – Part II-Lecture 1: Overview of Compiler Design Dr. Zili Shao Department of Computing The Hong Kong Polytechnic Univ.
CSC 230: C and Software Tools Rudra Dutta Computer Science Department Course Introduction.
Problem Solving Techniques. Compiler n Is a computer program whose purpose is to take a description of a desired program coded in a programming language.
C++ Programming Language Lecture 2 Problem Analysis and Solution Representation By Ghada Al-Mashaqbeh The Hashemite University Computer Engineering Department.
Unit-1 Introduction Prepared by: Prof. Harish I Rathod
Documenting Software Architectures 1.Uses and Audiences for Architecture Documentation Architecture documentation serves as a means of education Architecture.
1.  10% Assignments/ class participation  10% Pop Quizzes  05% Attendance  25% Mid Term  50% Final Term 2.
Review: Compiler Phases: Source program Lexical analyzer Syntax analyzer Semantic analyzer Intermediate code generator Code optimizer Code generator Symbol.
Chapter 1 Introduction. Chapter 1 - Introduction 2 The Goal of Chapter 1 Introduce different forms of language translators Give a high level overview.
CS 460/660 Compiler Construction. Class 01 2 Why Study Compilers? Compilers are important – –Responsible for many aspects of system performance Compilers.
Introduction to Compilers. Related Area Programming languages Machine architecture Language theory Algorithms Data structures Operating systems Software.
Overview of Previous Lesson(s) Over View  A program must be translated into a form in which it can be executed by a computer.  The software systems.
1 Compiler Design (40-414)  Main Text Book: Compilers: Principles, Techniques & Tools, 2 nd ed., Aho, Lam, Sethi, and Ullman, 2007  Evaluation:  Midterm.
Chapter 1 Introduction Study Goals: Master: the phases of a compiler Understand: what is a compiler Know: interpreter,compiler structure.
1 Compiler Construction (CS-636) Muhammad Bilal Bashir UIIT, Rawalpindi.
Chapter# 6 Code generation.  The final phase in our compiler model is the code generator.  It takes as input the intermediate representation(IR) produced.
Compiler Introduction 1 Kavita Patel. Outlines 2  1.1 What Do Compilers Do?  1.2 The Structure of a Compiler  1.3 Compilation Process  1.4 Phases.
Chapter 1: Introduction 1 Compiler Designs and Constructions Chapter 1: Introduction Objectives: Course Objectives Introduction Dr. Mohsen Chitsaz.
Compiler Construction Dr. Naveed Ejaz Lecture 4. 2 The Back End Register Allocation:  Have each value in a register when it is used. Instruction selection.
Compiler Construction Composed By, Muhammad Bilal Qureshi.
The Hashemite University Computer Engineering Department
What is a compiler? –A program that reads a program written in one language (source language) and translates it into an equivalent program in another language.
CS223: Software Engineering
Dr. Mohamed Ramadan Saady 314ALL CH1.1 Chapter 1: Introduction to Compiling.
Compiler Construction CPCS302 Dr. Manal Abdulaziz.
1 Asstt. Prof Navjot Kaur Computer Dept PRESENTED BY.
ICS312 Introduction to Compilers Set 23. What is a Compiler? A compiler is software (a program) that translates a high-level programming language to machine.
Evolution of C and C++ n C was developed by Dennis Ritchie at Bell Labs (early 1970s) as a systems programming language n C later evolved into a general-purpose.
Presented by : A best website designer company. Chapter 1 Introduction Prof Chung. 1.
Defects of UML Yang Yichuan. For the Presentation Something you know Instead of lots of new stuff. Cases Instead of Concepts. Methodology instead of the.
Chapter 1 Introduction Samuel College of Computer Science & Technology Harbin Engineering University.
CHAPTER 1 INTRODUCTION TO COMPILER SUNG-DONG KIM, DEPT. OF COMPUTER ENGINEERING, HANSUNG UNIVERSITY.
Advanced Computer Systems
Compiler Design (40-414) Main Text Book:
PRINCIPLES OF COMPILER DESIGN
Chapter 1 Introduction.
Introduction to Compiler Construction
Compiler Construction (CS-636)
SOFTWARE DESIGN AND ARCHITECTURE
Chapter 1 Introduction.
课程名 编译原理 Compiling Techniques
Compiler Lecture 1 CS510.
Compiler Construction
System Programming and administration
Compiler Construction
Chapter 10: Compilers and Language Translation
Presentation transcript:

CS189A/172 - Winter 2008 Lecture 7: Software Specification, Architecture Specification

Software Specification In different phases of the software process we need ways to specify the deliverable for that phase –Need to specify the requirements Which is what you are doing in SRS –Need to specify the design We need to document and communicate the design –Need to specify the implementation Comments Assertions

Specification Languages Main issue: When you write code you write it in a programming language –How do you write the requirements? –How do you write the design? Specification languages –Used to specify the requirements or the design –As we have seen parts of SRS are necessarily in English (customer has to understand). To bring some structure to the SRS you can use semi-formal techniques such as use-case diagrams. Depending on the application you maybe able to use formal techniques too –For design you can use UML class diagrams, sequence diagrams, state diagrams, activity diagrams –Some specification languages (such as UML class diagrams are supported with code generation tools)

Specification Specifications can be –Informal No formal syntax or semantics –for example in English Informal specifications can be ambiguous and imprecise –Semiformal Syntax is precise but does not have formal semantics UML (Universal Modeling Language) class diagrams, sequence diagrams –Formal Both syntax and semantics are formal Z, Statecharts, SDL (Specification and Design Language), Message Sequence Charts (MSC), Petri nets, CSP, SCR, RSML

Ambiguities in Informal Specifications The input will be a string or a number –The input will be a string or a number or both –The input will be a string or a number but not both The number of songs selected should be less than 10 –strictly less than? less than or equal? The user has to select the options A and B or C –“(A and B) or C”, “A and (B or C)”

Formal Specifications: A Success Story Requirements State Machine Language (RSML) –A formal specification language based on hierarchical state machines (statecharts) The developers of RSML applied it to the specification of Traffic Collision Avoidance System (TCAS) to demonstrate benefits of using RSML [Leveson et al. 1994] –TCAS: the specification of a software system which is required on all aircraft in USA carrying more than 30 passengers During the specification of TCAS in RSML ambiguities were discovered in the original English specification of TCAS –Eventually FAA decided to use the RSML versions of the TCAS specification

Example Formal Specification Formal specifications avoid ambiguity –However, they could be hard to understand –And it is not easy to write formal specifications Let’s try to specify a sorting procedure formally (mathematically) I will just use basic Math concepts: functions, integers, arithmetic –Input: I : An array of size n of integers How do we formally specify what an array is? I : Z  Z (a function from integers to integers) I : 1... n  Z n  1

Example: Sorting –Output: O : 1... n  Z  i, O(i)  O(i+1)  i, 1  i  n  O(i)  O(i+1)  i, 1  i  n  O(i)  O(i+1) (  i, 1  i  n  O(i)  O(i+1))  (  i, 1  i  n  (  j, 1  j  n  O(i) = I(j))) (  i, 1  i  n  O(i)  O(i+1))  (  i, 1  i  n  (  j, 1  j  n  O(i) = I(j)))  (  i, 1  i  n  (  j, 1  j  n  I(i) = O(j))) (  i, 1  i  n  O(i)  O(i+1))  (  f : 1... n  1... n, (  i, j, (1  i  n  1  j  n  i  j)  f(i)  f(j))  (  i, 1  i  n  O(i) = I(f(i))))

Architecture Specification There are several Architecture Description Languages (ADLs) that have been proposed –See “A Classification and Comparison Framework for Software Architecture Description Languages,” N. Medvidovic, R. N. Taylor, IEEE Transactions of Software Engineering, vol. 26, no. 1, pp , The basic concepts in specification of software architecture are: –Components: Components represent either major computational elements or data stores. They are usually represented with boxes in visual representation of architectures. –Connectors: Connectors represent interactions among components. They are usually represented as lines in visual representations –Systems: Systems correspond to different configurations of components and connectors.

Architecture Specification Most architecture specification languages support –hierarchical specification where one component contains a sub- architecture that is specified separately –specification of component interfaces which consist of ports ports are the points where the connections are made ports can be classified as input and output ports –specification of connector roles when a connector is connected to a port, it assumes a role such as source, sink, reader, writer, caller, readee, writee, callee, etc. –both graphical and textual specification of systems that consist of components and connectors –specification of additional constraints on components and connectors

Client Server Architecture ClientServer request Components Connector In addition to this diagram, the architecture specification should Explain the basic functionality of the Server and the Client –What do they do? What do they compute? What do they store? Explain the type of the connector –Is it an RPC connection or is it a socket connection, etc.? Explain the contents of the data (messages) exchanged between the Client and the Server Ports

A Case Study: Compiler I will use several block diagrams to explain the architecture of a compiler Although compilers are complicated software applications their basic architecture can be explained –using block diagrams that consist of components and connectors –listing key functionality of each component Even if you have not taken a course on compilers, after going through the following several slides you should have a good idea about the typical compiler architecture

A diagram showing the compiler as a single component with three ports (input, output, and error) A compiler recognizes legal (and illegal) source programs and translates them to the target language A Case Study: Compiler Source code Machine code Compiler Errors

A Higher Level View of a Compiler Compiler Preprocessor AssemblerLoader/Linker skeletal source program target assembly program relocatable machine code library routines, relocatable object files generates machine code from the assembly code collects the source program which may be divided into separate files macro expansion links the library routines and other object modules generates absolute addresses source program absolute machine code

Compiler Architecture Compiler uses an intermediate representation ( IR ) Front end maps legal source code into IR Back end maps IR into target machine code The middle end optimizes the generated code by analyzing and transforming the IR Different phases of compiler also interact through the symbol table Symbol Table Errors Middle End Source code Front End Machine code Back End IR

Architecture of the Front End The front end Recognizes legal programs Reports errors for the illegal programs in a useful way Produces IR and construct the symbol table Source code Scanner IR Parser tokens IR Type Checker Errors

Architecture of the Back End The back end Translates IR into target machine code Chooses instructions to implement each IR operation Decides which values to keep in registers Schedules the instructions for instruction pipeline Errors IR Instruction Scheduling Instruction Selection Machine code Register Allocation IR

Architecture of the Middle End The middle end is organized as a series of phases where each phase transforms the IR to optimize the generated code Typical optimization transformations include Discover and propagate constant values Move a computation to a less frequently executed place Discover a redundant computation and remove it Remove unreachable code Errors Opt 1 Opt 3 Opt 2 Opt n... IR