The Designer's Guide Community
Forum
Welcome, Guest. Please Login or Register. Please follow the Forum guidelines.
Jul 17th, 2024, 4:35pm
Pages: 1
Send Topic Print
verilogA digital code shifter (Read 15496 times)
newic
Senior Member
****
Offline



Posts: 138

verilogA digital code shifter
May 07th, 2011, 8:38am
 
try to model a digital code shifter in verilogA. It got syntax error.
"result[0:<<--? 7] = {1 0 0 1 1 1 0 1};"

Looks like I could not define the content of the array.

       integer result[0:7] ;

       analog begin
               @( initial_step) begin
                       result[0:7] = {1, 0, 0, 1, 1, 1, 0, 1};
               end

               @( cross( V(clk)-vth, 1)) begin
                       temp = result[i];
                       i = i + 1;
                       if( i >=8)
                               i=0;
               end

Back to top
 
 
View Profile   IP Logged
rfidea
Senior Member
****
Offline



Posts: 159
Europe
Re: verilogA digital code shifter
Reply #1 - May 8th, 2011, 11:10pm
 
I'm not sure that you can set the value of all elements in results[0:7] as you try to do. Sometimes verilogA is limited in this kind of operations. You can try something like results[0] = 1; results[1] = 0; ...

It is not beatiful but I think it will work...
Back to top
 
 
View Profile   IP Logged
newic
Senior Member
****
Offline



Posts: 138

Re: verilogA digital code shifter
Reply #2 - May 8th, 2011, 11:31pm
 
I am aware of doing that. Is there a better way?
Because i need to create a long patterns for different cases.

That shift register is to do a simple test case only
Back to top
 
 
View Profile   IP Logged
boe
Community Fellow
*****
Offline



Posts: 615

Re: verilogA digital code shifter
Reply #3 - May 9th, 2011, 10:29am
 
Newic,

According to Cadence V-A Language reference (Sept 2010) you can use `{} to initialize parameter/localparam arrays. However, I don't know if that works elsewhere.

B O E

PS: Did you try result = ....?
Back to top
 
 
View Profile   IP Logged
newic
Senior Member
****
Offline



Posts: 138

Re: verilogA digital code shifter
Reply #4 - May 20th, 2011, 5:56pm
 
seems like i got to assign the bit one by one.
Back to top
 
 
View Profile   IP Logged
Geoffrey_Coram
Senior Fellow
******
Offline



Posts: 1999
Massachusetts, USA
Re: verilogA digital code shifter
Reply #5 - May 23rd, 2011, 10:43am
 
Following boe's tip, perhaps you could:

 `define MYMAX 7
 localparam integer startval[`MYMAX:0] = `{1, 0, 0, 1, 1, 1, 0, 1};

 integer result[`MYMAX:0] ;
 integer k;

 @(initial_step) begin
   for (k=0; k<=`MYMAX; k=k+1) result[k] = startval[k];
 end
Back to top
 
 

If at first you do succeed, STOP, raise your standards, and stop wasting your time.
View Profile WWW   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.