The Designer's Guide Community
Forum
Welcome, Guest. Please Login or Register. Please follow the Forum guidelines.
Jul 16th, 2024, 11:36am
Pages: 1
Send Topic Print
adder in verilog-ams (Read 4929 times)
vp1953
Senior Member
****
Offline



Posts: 172

adder in verilog-ams
Feb 14th, 2011, 11:03am
 
I wanted to know if verilog-ams supports register addition like in standard verilog. For instance would the following code work in verilog-ams, if not what changes might be needed?

reg [7:0] A,B,C;

assign A=B+C;

Back to top
 
 
View Profile   IP Logged
Geoffrey_Coram
Senior Fellow
******
Offline



Posts: 1999
Massachusetts, USA
Re: adder in verilog-ams
Reply #1 - Feb 14th, 2011, 12:44pm
 
Verilog-AMS is a super-set of Verilog, so it should work.  I have a vague impression you can't use reg in the analog block, but it should be OK in a digital section (always, initial).
Back to top
 
 

If at first you do succeed, STOP, raise your standards, and stop wasting your time.
View Profile WWW   IP Logged
vp1953
Senior Member
****
Offline



Posts: 172

Re: adder in verilog-ams
Reply #2 - Feb 15th, 2011, 9:20am
 
Hi Geoffrey,

Thank you very much. I meant to ask if it was possible to implement such an adder in VerilogA. What I want to do is to add two 8 bit numbers and get the sum and carry. However none of the verilogA examples that i have gone through has anything similar (including the models available at designers-guide). Is it even possible to do this in VerilogA?

Back to top
 
 
View Profile   IP Logged
Geoffrey_Coram
Senior Fellow
******
Offline



Posts: 1999
Massachusetts, USA
Re: adder in verilog-ams
Reply #3 - Feb 15th, 2011, 1:16pm
 
Two simulators I tried wouldn't let me have "reg" in a Verilog-A module.

Certainly, it is possible to add two integers together; I guess it comes down to: how do you intend to set B and C, and what do you want to do with A once you've gotten the sum?
Back to top
 
 

If at first you do succeed, STOP, raise your standards, and stop wasting your time.
View Profile WWW   IP Logged
vp1953
Senior Member
****
Offline



Posts: 172

Re: adder in verilog-ams
Reply #4 - Feb 15th, 2011, 2:30pm
 
Hi Geoffrey,

Many thanks. I was also not able to get reg to work. What i want to do is to add A+B and store this in C which is 8 bits and the 9th bit of C i want to use as carry.

Seems like the following is one way

C=A+B;
carry = C & 9'b100000000;
carry = carry >> 8;
C= C & 8'b11111111;
Back to top
 
 
View Profile   IP Logged
Marq Kole
Senior Member
****
Offline

Hmmm. That's
weird...

Posts: 122
Eindhoven, The Netherlands
Re: adder in verilog-ams
Reply #5 - Feb 16th, 2011, 5:58am
 
Hi,

If you recode it in integer arithmetic it should work fine. working with regs works only well from the digital side. Assignment to regs (procedural assignment) should be done in an always block, not in an analog block. Always blocks are not supported in Verilog-A. Field widths do not have a meaning in Verilog-A as everything is mapped onto integers that have a fixed width of 32 bits.

Your code indeed can be readily used in a Verilog-A analog block. You can leave out the field widths for the literals as they're not honored anyway.

Cheers,
Marq
Back to top
 
 
View Profile   IP Logged
Pages: 1
Send Topic Print
Copyright 2002-2024 Designer’s Guide Consulting, Inc. Designer’s Guide® is a registered trademark of Designer’s Guide Consulting, Inc. All rights reserved. Send comments or questions to editor@designers-guide.org. Consider submitting a paper or model.