160 likes | 179 Views
Expression Evaluating Calculator Jagadish Rath(2003cs10164) Dhanshree Nimje(2003cs10160) Group 4 Instructor: Prof. M.Balakrishnan. Specifications:. Output Data corresponding to the input expression and evaluated value. Input data sequence. LCD Display. Digital Calculator.
E N D
Expression Evaluating Calculator Jagadish Rath(2003cs10164) Dhanshree Nimje(2003cs10160) Group 4 Instructor: Prof. M.Balakrishnan
Specifications: Output Data corresponding to the input expression and evaluated value Input data sequence LCD Display Digital Calculator KeyBoard Interface Restart evaluation Reset Block Diagram of the model The Digital Calculator takes as input an expression containing constants(Integer and boolean) ,variables and operators,and evaluates the expression.While evaluating the expression if it finds a variable which is not assigned a value, it asks for the value and then gives as output the evaluated value of the expression.
User Interface: The user can give the input expression as a sequence of pre-decided characters from the FPGA keyboard and can see the input expression,the variable assignment prompt and the evaluated value of the expression on the LCD Display in FPGA board. The concrete syntax for the language is given in the next page. All the expressions involving operators has to be given in postfix notation with the operands represented as tuples followed by the operator e.g. The concrete syntax for 123+ 45 is (123,45)+; And input sequence is #*0*1*2*3#*2*4*5#*1#*#0#*3 There will be two inputs from the pushbutton 1.evaluate or re-evaluate an already input expression 2.reset the whole calculator
Main-Macros of the Digital Calculator: 1.Keyboard Interface 2.Writer: State Machine which writes into a RAM 3.RAM : It stores the data of the expression 4.Interpreter: State Machine which reads the RAM and generates corresponding opcodes (for operators),binary number (for integers which are stored in BCD format in RAM),binary digit(1,0 for boolean constants true,false respectively).While reading the RAM if it finds a variable it looks for its value in the TABLE. If it does not find a value for the variable,then it asks for it(which is displayed on the LCD screen) and then takes the input through Writer and updates the TABLE.If it finds a value then it generates the binary of the value.
5.TABLE:it is a RAM which stores the value corresponding to the variable(numbered n) in the nth row. 6.STACK: It is a RAM which has the values corresponding to the expression evaluated till now. What ever value is generated by the Interpreter is stored in the stack.When an opcode is produced by the Interpreter,according to the arity of the operator corresponding to the opcode those many values are taken from the STACK and passed on to the MINI-PROCESSOR . 7.MINI-PROCESSOR:It evaluates the values and operator given to it and returns back the result to the STACK which is then pushed into the STACK. 8.OUTPUT UNIT: uptill the evaluation continues it outputs the data corresponding to the Input expression to the LCD Display.After completion of evaluation the result from top of STACK is output to the LCD display.
Data Part: Give variable value Value of variable Input from keyboard interface Data to be written Writer RAM Interpreter Data to be written Write Variable to be read Wr value opcode value1 TABLE MINI-PROCESSOR value2 STACK Evaluated value Value of variable OUTPUTUNIT
Writer: state diagram Inputs:star,hash,clk,clear outputs:clstar,clhash,write,ds(6) States:s0(intial),s1,s2,s3,s4,s5 DefaultOutputs:clstar=1,ds=000001,clhash=0,write=0 s0 *All the transitions are at rising clk edge star hash clear clear clear S1 ds=000010, clstar, write S3 ds=001000, clhash, write clear clear star hash S5 ds=100000, clstar, write S2 ds=000100, clhash, write S4 ds=010000, clhash, write hash
RAM: The RAM has a word length of 6 and depth 256.Hence the maximum number of characters that can be stored or evaluated is 256. Format of storing data: The 1st two columns say either the data stored is a digit,boolean , operator,variable,or special characters Nature of data R5 R4 R(3-0) Digit 0 0 value of digit Variable 0 1 no of the variable Operators 1 0 value of the input key ( 1 0 1 0 1 0 ) 1 0 1 0 1 1 , 1 0 1 1 0 0 ; 1 0 1 1 0 1 Boolean 1 1 value of the input key
MINI-PROCESSOR: The opcodes of any operator is same as the value stored in the RAM at locations R(3-0) .any other value of the operator is considered as a nop. When the opcode corresponds to multiplication or division or mod the complete signal becomes 1 after the operation is complete. Else the complete is always 1.
Components of the MINI PROCESSOR: • DECODER decodes the opcodes • ---loader-loads the argument values into the input regesters of • Multiplier and divider • ADDER/SUBTRACTOR does the addition and subtraction • MULTIPLIER does the multiplication • DIVIDER/MOD does the division and mod operation • COMPARATER does the equality and greaterthan check • AND ,OR,NOT • Output multiplexer:outputs the output of appropriate block to output depending on the opcode • Complete generator : generates the complete signal
Components in the MINI-PROCESSOR: Add/sub decoder multiplier Divider/mod loader comparator
Select signal for output mux completegenerator Output multiplexer
possible extensions: Possible extension: 1.The model can be extended to operate for sequencing of expressions. 2.The current model is for fixed no of variables it can be extended for any number of variables. 3. conditional operations like ifthenelse,while,case operations like exponentiaton,logarithm,trigonometric functions,real number operations can be included in the language. 4.The model can be made more user friendly by taking input from the keyboard of PC.