For help-verilog design of a calculator

D

davidbarby

Guest
Hi,

I am a new student majoring in LSI. Now I have to design a calculator
using verilog. It is the homework of a course.
I am looking for some reference code about it as I have very little
experience to program in Verilog. I would be very appreciated with your
help.
BTW, the functions I have to realize include Add, Subtract, Multiply,
Division, N!, C, Shift, MC, MS, MR, M+, M-.

Thank you...
 
davidbarby <danyangqu@suou.waseda.jp> wrote in message
news:6eb3db6ca7f5485d9d696440776471c6@localhost.talkaboutprogramming.com...
Hi,

I am a new student majoring in LSI. Now I have to design a calculator
using verilog. It is the homework of a course.
I am looking for some reference code about it as I have very little
experience to program in Verilog. I would be very appreciated with your
help.
BTW, the functions I have to realize include Add, Subtract, Multiply,
Division, N!, C, Shift, MC, MS, MR, M+, M-.

Thank you...
why don't you tell us how you think it should be approached? I'm not being
awkward, in fact I wouldn't quite know where to start without giving it some
thought - perhaps if you did just that and then published what you think, it
may kick start an interesting discussion :)
 
I dont know but i think u havent been studying Verilog as much as
required to even make a calculator! Anyway, would be great if u can
tell what kind of adder would you like! How precise it should be in
each case (upto what float point values). Also how do you plan to
implement in the end? Do you need to simulate it or burn it on a chip?
Salaams :)
UJMi


"davidbarby" <danyangqu@suou.waseda.jp> wrote in message news:<0361cf501e78f24c366efa482c411e62@localhost.talkaboutprogramming.com>...
thanks a lot for your reply, but I think I don't catch your meaning.
Frankly, I lack experience about it and looking for some helps. Could you
please advise me something? I need some completed code for reference.
//
 
-
Dave Wooff
dave@dmwooff.freeserve.co.uk
davidbarby <danyangqu@suou.waseda.jp> wrote in message
news:0361cf501e78f24c366efa482c411e62@localhost.talkaboutprogramming.com...
thanks a lot for your reply, but I think I don't catch your meaning.
Frankly, I lack experience about it and looking for some helps. Could you
please advise me something? I need some completed code for reference.
//
well if its the completed code you're after, then you may try asking your
tutor although I can guess what kind of resposne you might get. I'm not
going to write any "completed" code for you but I will try to give you some
direction (hopefuly not misdirected):

This is a two sided problem. a) you need to solve the hardware design
problem and b) you need to express it in Verilog. As far as b) is concerned
all I can do really is point you to www.vol.webnexus.com This is an
excellent on-line Verilog tutorial which I have been using and have managed
to pick up the language in a very short time.

Regarding a). You need to look at your calculator and examine what it is
and what it does. It has a display and some buttons. The system is all
event driven in the sense that everything it does is in response to a button
press. (Therefore you might expect a Verilog construct similar to:
@ (posedge( button_0 or button_1.....or button_add etc) or you may split it
up into several such constructs.)

In any case, some of the operators (add, subtract, multiply, divide) are
binary operators requiring 2 operands lets say a and b. Other operators are
unary and require only one operand (n! for example). Operands need to be
stored between button presses and so you would expect to require a register
or two to hold these while entering other operands. You also need a
register to act as a memory store (for the MS, MC, M+ and M- buttons).

You need to draw a diagram and figure out how to connect all these things
together to make a working calculator. Your original post does not specify
whether the operands can be real or integer or indeed positive only.
Verilog does support the real data type in 64 bit IEEE format so you should
be able to support real numbers. I think the hardest part will be parsing
the numeric button presses in this case.

You should implement the calculator as a Verilog module with an interface
something like:

module calculator( button_1, button_2, ..., button_MS, button_MC, button_eq,
display_output) etc
....
endmodule

this is all I can offer and I hope it is of some assistance. Perhaps
someone out there will offer you a completed module but if they do I do not
see what you will be getting out of it other than a pass mark.

Good Luck,
DW.
 
couldnt agree anymore Wooff

"David Wooff" <dave@dmwooff.freeserve.co.uk> wrote in message news:<c9ir7v$87o$1@newsg2.svr.pol.co.uk>...
-
Dave Wooff
dave@dmwooff.freeserve.co.uk
davidbarby <danyangqu@suou.waseda.jp> wrote in message
news:0361cf501e78f24c366efa482c411e62@localhost.talkaboutprogramming.com...
thanks a lot for your reply, but I think I don't catch your meaning.
Frankly, I lack experience about it and looking for some helps. Could you
please advise me something? I need some completed code for reference.
//


well if its the completed code you're after, then you may try asking your
tutor although I can guess what kind of resposne you might get. I'm not
going to write any "completed" code for you but I will try to give you some
direction (hopefuly not misdirected):

This is a two sided problem. a) you need to solve the hardware design
problem and b) you need to express it in Verilog. As far as b) is concerned
all I can do really is point you to www.vol.webnexus.com This is an
excellent on-line Verilog tutorial which I have been using and have managed
to pick up the language in a very short time.

Regarding a). You need to look at your calculator and examine what it is
and what it does. It has a display and some buttons. The system is all
event driven in the sense that everything it does is in response to a button
press. (Therefore you might expect a Verilog construct similar to:
@ (posedge( button_0 or button_1.....or button_add etc) or you may split it
up into several such constructs.)

In any case, some of the operators (add, subtract, multiply, divide) are
binary operators requiring 2 operands lets say a and b. Other operators are
unary and require only one operand (n! for example). Operands need to be
stored between button presses and so you would expect to require a register
or two to hold these while entering other operands. You also need a
register to act as a memory store (for the MS, MC, M+ and M- buttons).

You need to draw a diagram and figure out how to connect all these things
together to make a working calculator. Your original post does not specify
whether the operands can be real or integer or indeed positive only.
Verilog does support the real data type in 64 bit IEEE format so you should
be able to support real numbers. I think the hardest part will be parsing
the numeric button presses in this case.

You should implement the calculator as a Verilog module with an interface
something like:

module calculator( button_1, button_2, ..., button_MS, button_MC, button_eq,
display_output) etc
...
endmodule

this is all I can offer and I hope it is of some assistance. Perhaps
someone out there will offer you a completed module but if they do I do not
see what you will be getting out of it other than a pass mark.

Good Luck,
DW.
 
"davidbarby" <danyangqu@suou.waseda.jp> wrote in message news:<6eb3db6ca7f5485d9d696440776471c6@localhost.talkaboutprogramming.com>...
Hi,

I am a new student majoring in LSI. Now I have to design a calculator
using verilog. It is the homework of a course.
I am looking for some reference code about it as I have very little
experience to program in Verilog. I would be very appreciated with your
help.
BTW, the functions I have to realize include Add, Subtract, Multiply,
Division, N!, C, Shift, MC, MS, MR, M+, M-.

Thank you...
Although you did not say real/floating point I would forget about
verilog real as that will lead you into endless complexity and
potentially dead end.

You did not not include dec pt key in your list, if its not there then
its all integer. If its implied (see spec/tutor), then you are still
dealing with integer but with an exponent for simple floating point.
As far as I know, pocket calculators don't do floating point by
converting the input to IEEE anyway. They do digit by digit
arithmetic. The dec pt is just a separate little state bit that tracks
where .. well you know how to do it on paper right.

Wish I had this sort of asignment in school too, but HDL didn't really
exist back then, only TTL.

Think in terms of FSMs. You can collect the key strokes into buffers
or regs. If the key is a digit, push down. If its an operator then do
that operator on whats in the buff. It up to you to make it work
though.

regards

johnjakson_usa_com
 
On 7 Jun 2004 07:21:48 -0700, johnjakson@yahoo.com (john jakson)
wrote:

"davidbarby" <danyangqu@suou.waseda.jp> wrote in message news:<6eb3db6ca7f5485d9d696440776471c6@localhost.talkaboutprogramming.com>...
Hi,

I am a new student majoring in LSI. Now I have to design a calculator
using verilog. It is the homework of a course.
I am looking for some reference code about it as I have very little
experience to program in Verilog. I would be very appreciated with your
help.
BTW, the functions I have to realize include Add, Subtract, Multiply,
Division, N!, C, Shift, MC, MS, MR, M+, M-.

Thank you...

Although you did not say real/floating point I would forget about
verilog real as that will lead you into endless complexity and
potentially dead end.

You did not not include dec pt key in your list, if its not there then
its all integer. If its implied (see spec/tutor), then you are still
dealing with integer but with an exponent for simple floating point.
As far as I know, pocket calculators don't do floating point by
converting the input to IEEE anyway. They do digit by digit
arithmetic. The dec pt is just a separate little state bit that tracks
where .. well you know how to do it on paper right.

Wish I had this sort of asignment in school too, but HDL didn't really
exist back then, only TTL.
We had a similar assignment, but we had to make it work in TTL.

Think in terms of FSMs. You can collect the key strokes into buffers
or regs. If the key is a digit, push down. If its an operator then do
that operator on whats in the buff. It up to you to make it work
though.
Why not do what real calculators do?

Design a small 4 or 8 bit microcontroller and code it in Verilog.

Write the calculator application in assembly language.

Regards,
Allan.
 
UJMi plz tell me the hardware of calculator and vending machine(using FSM) . what will be tha hardware how can we show it on hardware
 

Welcome to EDABoard.com

Sponsor

Back
Top