1 of 37

COA Lab Project (2016-17) �The LNMIIT, Jaipur�

Smart Home

Kartik Agrawal (15UCS060)

Harsh Bhambhani (15UCS045)

Mrinal Malik(15UCS075)

Kartikey Pohani (15UCS062)

2 of 37

Introduction

  • Any device in your home that uses electricity can be put on your home network and at your command. Whether you give that command by voice, remote control, tablet or smartphone, the home reacts. Most applications relate to lighting, home security, home theatre and entertainment, and thermostat regulation.
  • With a smart home, you could quiet all of these worries with a quick glance at your smartphone or tablet. You could connect the devices and appliances in your home so they can communicate with each other and with you.

3 of 37

Functions

  • Access Control – Check for pin code and alerts security system when incorrect tries > 3.

  • Fire Alarm – Monitors the temp. and gas concentration and alerts security system when faulty.

  • Security System – Sounds an alarm in case of any uneventuality.

  • Temperature Monitoring – Maintains an optimum temperature inside the home.

  • Energy efficiency – Turns tubelights on and off depending of no. of people present.

4 of 37

  • Lighting Control – Controls the lighting power depending on time slot of the day.

  • Music Control – Plays different types of music depending on user’s preferences.

  • Appliances Control – User can control appliances with the touch of a single button.

  • Air Purifier – Monitors the O2 level and infuses more if it falls below a desired level.

  • Sprinkler System – Automatically waters the lawn and activates itself depending on season.

5 of 37

Memory Model

  • Since the ISA we are designing is for a 32-bit machine therefore word length becomes 32-bit or 4 bytes.

  • We are using byte addressing and ALIGNED memory model because memories operate efficiently because of alignment.

6 of 37

Registers

29 General Purpose Registers which are used for storing permanent values for comparison as well as temporary values and memory addresses. These can be represented by using numbers through 00000-11100, eg. R0 = 00000, R1 = 00001, R2 = 000010….

Permanent values to be stored:

R0 – Password

R1 – Break down Temp

R2 – Gas conc.

R3 – Persons / tubelight

R4 – Current Time

R5 – Time slot

R6– Music 1

R7 – Music 2

R8 – Music 3

R9 – Music 4

R10 – Desired O2 level

R11 – Current Season

R12 – Max. Tubelights

Registers R13 – R28 will be used to store temporary values as well as memory addresses.�These general purpose registers are completely interchangeable, i.e. the compiler can use R2 to store a temporary / permanent value, but it can equally well use R28.�But use of some registers is pre-defined to avoid any confusion and loss of data by the CPU.

7 of 37

Registers

3 Special Purpose Registers are also available that hold various miscellaneous bits that are needed by the CPU.

  • PC (11101) – Program Counter
  • IR (11110) – Instruction Register
  • FR (11111) – Flag Register

The flag register (Program Status Word Register) has the following typical condition code bits -

  1. N: Negative result
  2. Z: Result is zero
  3. V: When result caused an overflow
  4. C: Result caused a carry out of the leftmost bit
  5. A: When there was an Auxiliary Carry
  6. P: When the result had an even Parity

8 of 37

Instruction Format

Instruction Format

Description

MOV R1, R2

Copies content of R1 into R2

LDB @R1, R2

Load value stored at memory address indicated by R1 into R2

STB @R1, R2

Store the value contained in R2 at memory address indicated by R1

CMP R1, R2

Compares the values in R1 and R2 and sets the flag register correspondingly

SWP R1, R2

Swaps the values in the R1 and R2

ADD R1, R2

Adds the values stored in R1 and R2 and stores the result in R1

AND R1, R2

Logical AND of R1 and R2

OR R1, R2

Logical OR of R1 and R2

LDBI @R1, R2

Loads value stored at address indicated by R1 into R2 and increments R1 by 1.

1. Two Address instructions

9 of 37

Instruction Format

Instruction Format

Addresses

INC R1

Increments value in R1 by 1

DEC R1

Decrements value in R1 by 1

JGE $L1

Jumps if greater than 0

JMP $L1

Jumps unconditionally

JLE $L1

Jumps if less than 0

JZR $L1

Jumps if Z flag is set

CAL $L1

Calls subroutine

CLR R1

Clears the contents of R1

2. One Address instructions

10 of 37

Instruction Format

3. Zero Address instructions

Instruction

Description

HLT

Halts the program

PSH

Pushes the value to the top of the stack

POP

Pops out the value from the top of the stack.

11 of 37

Instruction Design

  • Reduced Instruction Set Computer (RISC) is used as it can be executed in a single clock cycle and it’s a system that uses a small, highly optimized set of instructions, rather than a more versatile set of instructions often found in other types of architectures.

  • Fixed Length Instructions, which can be easily decoded as length of each instruction is exactly equal to 1 word, and hence easy to decode.

12 of 37

Instruction Types

  1. Data movement instructions : These must somehow indicate the amount of data to be moved. On fixed-word-length machines, the amount to be moved is often exactly one word, i.e here 16 bits.
  2. Register to Register – MOV
  3. Memory to Register – LDB
  4. Register to Memory – STB
  5. Constant to register – MOV

2. Dyadic Operations : These combine two operands to produce a result.

ADD, SUB, MUL, DIV, CMP, AND, OR etc.

3. Monadic Operations: Monadic operations have one operand and produce one result.

CLR, INC, DEC, PSH, POP etc.

13 of 37

Instruction Types

4. Comparisons and Conditional Branching:

JMP , JNQ , JEQ ,JNZ ,JGT ,JLT , CMP

5. Procedure Call Instructions: These are nothing but used for calling subroutines, which are otherwise known as procedures.

14 of 37

Data Types

  • Unsigned Integers – Range 0 to 65535
  • ASCII Code – 7 bit characters
  • Bitmap – 16 bit word can hold 16 Boolean values.

1

1

0

1

0

1

1

1

1

0

1

0

1

0

0

1

1

1

0

1

0

1

1

1

1

0

1

0

1

0

0

1

15 of 37

Addressing Modes

  1. Immediate Addressing – MOV #4, R1

  • Direct Addressing – MOV LOCA, R5

  • Register Addressing – MOV R1, R2

  • Register Indirect Addressing – STB @R1, R2

  • Implied mode – ADD R1

16 of 37

Flow of Control Handling

  • Flow of control handling refers to the sequence in which the instructions are executed dynamically, that is, during program execution.

  • In general, in absence of branches and procedure calls, it is sequential.

  • But when there is presence of branches and labels, the flow transfers to the address where the label lies. This can be achieved through various comparison and conditional branching statements like JMP, JNE etc. in our ISA.

17 of 37

Datapath- Single Bus Architecture

Datapath is a

collection of functional

units, such as

arithmetic logic units

or multipliers, that

perform data

processing operations,

registers, and buses.

Along with the control

unit it composes the

central processing unit

(CPU).

18 of 37

Arithmetic Logical�Unit (ALU)

Value of X (X2 X1 X0)

Operation

000

Addition

001

Subtraction

010

Multiplication

011

Division

100

Modulo

An arithmetic logic unit (ALU) is a digital circuit used to perform arithmetic and logic operations. It represents the fundamental building block of the central processing unit (CPU) of a computer.

19 of 37

ADDI R1, R2, Im

  • PCout, MARin, Read, Select4, Add, Zin
  • Zout, PCin, Yin, WMFC
  • MDRout, IRin
  • R2out, Yin, SelectY
  • DCout, Add, Zin
  • Zout, R1in, END

PCin

PCout

MARin

READ

SELECT4

ADD

Zin

Zout

WMFC

IRin

R1in

R2out

DCout

Yin

SelectY

MDRout

0

1

1

1

1

1

1

0

0

0

0

0

0

0

0

0

1

0

0

0

0

0

0

0

1

0

0

0

0

0

0

0

0

0

0

0

0

0

0

0

0

1

0

0

0

0

0

1

0

0

0

0

0

0

0

0

0

0

0

1

0

1

1

0

0

0

0

0

0

1

1

0

0

0

0

0

1

0

0

0

0

0

0

0

0

0

0

1

0

0

1

0

0

0

0

0

20 of 37

SUBI R1, R2, Im

  • PCout, MARin, Read, Select4, Add, Zin
  • Zout, PCin, Yin, WMFC
  • MDRout, IRin
  • R2out, Yin, SelectY
  • DCout, Sub, Zin
  • Zout, R1in, END

PCin

PCout

MARin

READ

SELECT4

ADD

Zin

Zout

WMFC

IRin

R1in

R2out

DCout

Yin

SelectY

MDRout

0

1

1

1

1

1

1

0

0

0

0

0

0

0

0

0

1

0

0

0

0

0

0

0

1

0

0

0

0

0

0

0

0

0

0

0

0

0

0

0

0

1

0

0

0

0

0

1

0

0

0

0

0

0

0

0

0

0

0

1

0

1

1

0

0

0

0

0

0

0

1

0

0

0

0

0

1

0

0

0

0

0

0

0

0

0

0

1

0

0

1

0

0

0

0

0

SUB

0

0

0

0

1

0

21 of 37

MULI R1, R2, Im

  • PCout, MARin, Read, Select4, Add, Zin
  • Zout, PCin, Yin, WMFC
  • MDRout, IRin
  • R2out, Yin, SelectY
  • DCout, Mul, Zin
  • Zout, R1in, END

PCin

PCout

MARin

READ

SELECT4

ADD

Zin

Zout

WMFC

IRin

R1in

R2out

DCout

Yin

SelectY

MDRout

0

1

1

1

1

1

1

0

0

0

0

0

0

0

0

0

1

0

0

0

0

0

0

0

1

0

0

0

0

0

0

0

0

0

0

0

0

0

0

0

0

1

0

0

0

0

0

1

0

0

0

0

0

0

0

0

0

0

0

1

0

1

1

0

0

0

0

0

0

1

1

0

0

0

0

0

1

0

0

0

0

0

0

0

0

0

0

1

0

0

1

0

0

0

0

0

MUL

0

0

0

0

1

0

22 of 37

DIVI R1, R2, Im

  • PCout, MARin, Read, Select4, Add, Zin
  • Zout, PCin, Yin, WMFC
  • MDRout, IRin
  • R2out, Yin, SelectY
  • DCout, Div, Zin
  • Zout, R1in, END

PCin

PCout

MARin

READ

SELECT4

ADD

Zin

Zout

WMFC

IRin

R1in

R2out

DCout

Yin

SelectY

MDRout

0

1

1

1

1

1

1

0

0

0

0

0

0

0

0

0

1

0

0

0

0

0

0

0

1

0

0

0

0

0

0

0

0

0

0

0

0

0

0

0

0

1

0

0

0

0

0

1

0

0

0

0

0

0

0

0

0

0

0

1

0

1

1

0

0

0

0

0

0

1

1

0

0

0

0

0

1

0

0

0

0

0

0

0

0

0

0

1

0

0

1

0

0

0

0

0

DIV

0

0

0

0

1

0

23 of 37

MODI R1, R2, Im

  • PCout, MARin, Read, Select4, Add, Zin
  • Zout, PCin, Yin, WMFC
  • MDRout, IRin
  • R2out, Yin, SelectY
  • DCout, Mod, Zin
  • Zout, R1in, END

PCin

PCout

MARin

READ

SELECT4

ADD

Zin

Zout

WMFC

IRin

R1in

R2out

DCout

Yin

SelectY

MDRout

0

1

1

1

1

1

1

0

0

0

0

0

0

0

0

0

1

0

0

0

0

0

0

0

1

0

0

0

0

0

0

0

0

0

0

0

0

0

0

0

0

1

0

0

0

0

0

1

0

0

0

0

0

0

0

0

0

0

0

1

0

1

1

0

0

0

0

0

0

1

1

0

0

0

0

0

1

0

0

0

0

0

0

0

0

0

0

1

0

0

1

0

0

0

0

0

MOD

0

0

0

0

1

0

24 of 37

COMPI R1, Im

  • PCout, MARin, Read, Select4, Add, Zin
  • Zout, PCin, Yin, WMFC
  • MDRout, IRin
  • R1out, Yin, SelectY
  • DCout, Sub, Zin
  • If Z = 0, Z flag is set, END
  • If Z < 0, N flag is set, END
  • END

25 of 37

MOVI R1, Im

  • PCout, MARin, Read, Select4, Add, Zin
  • Zout, PCin, Yin, WMFC
  • MDRout, IRin
  • DCout, R1in, END

26 of 37

ADD R1, R2

  • PCout, MARin, Read, Select4, Add, Zin
  • Zout, PCin, Yin, WMFC
  • MDRout, IRin
  • R2out, Yin, SelectY
  • R1out, Add, Zin
  • Zout, R1in, END

27 of 37

MUL R1, R2

  • PCout, MARin, Read, Select4, Add, Zin
  • Zout, PCin, Yin, WMFC
  • MDRout, IRin
  • R2out, Yin, SelectY
  • R1out, Mul, Zin
  • Zout, R1in, END

28 of 37

COMP R1, R2

  • PCout, MARin, Read, Select4, Add, Zin
  • Zout, PCin, Yin, WMFC
  • MDRout, IRin
  • R1out, Yin, SelectY
  • R2out, Sub, Zin
  • If Z = 0, Z flag is set, END
  • If Z < 0, N flag is set, END
  • END

29 of 37

MOV R1, R2

  • PCout, MARin, Read, Select4, Add, Zin
  • Zout, PCin, Yin, WMFC
  • MDRout, IRin
  • R2, R1in, END

30 of 37

JMP L1

  • PCout, MARin, Read, Select4, Add, Zin
  • Zout, PCin, Yin, WMFC
  • MDRout, IRin
  • OFFSET-FIELD-OF-IRout, Add, Zin
  • Zout, PCin, END

31 of 37

JEQ L1

  • PCout, MARin, Read, Select4, Add, Zin
  • Zout, PCin, Yin, WMFC
  • MDRout, IRin
  • OFFSET-FIELD-OF-IRout, Add, Zin
  • If Z flag is not set, END
  • Zout, PCin, END

32 of 37

JLT L1

  • PCout, MARin, Read, Select4, Add, Zin
  • Zout, PCin, Yin, WMFC
  • MDRout, IRin
  • OFFSET-FIELD-OF-IRout, Add, Zin
  • If N flag is not set, END
  • Zout, PCin, END

33 of 37

JGT L1

  • PCout, MARin, Read, Select4, Add, Zin
  • Zout, PCin, Yin, WMFC
  • MDRout, IRin
  • OFFSET-FIELD-OF-IRout, Add, Zin
  • If Z flag is set or N flag is set, END
  • Zout, PCin, END

34 of 37

INC R1

  • PCout, MARin, Read, Select4, Add, Zin
  • Zout, PCin, Yin, WMFC
  • MDRout, IRin
  • R1out, Select1, Add, Zin
  • Zout, R1in, END

35 of 37

DEC R1

  • PCout, MARin, Read, Select4, Add, Zin
  • Zout, PCin, Yin, WMFC
  • MDRout, IRin
  • R1out, Select1, Sub, Zin
  • Zout, R1in, END

36 of 37

37 of 37

THE END