Programmable Devices
CPLDs, FPGAs, SoC FPGAs, Configuration, and Transceivers
20781 Discussions

about verilog code" while"

Altera_Forum
Honored Contributor II
979 Views

hi all: 

One of my books says that we can compile "while" if there is some thing control it (eg:@(posedge Clock)).I don't know whether my book is right. 

Is there some one have do it .
0 Kudos
1 Reply
Altera_Forum
Honored Contributor II
253 Views

reg MyRegBit; 

always @ ( posedge MyClock ) 

MyRegBit <= MyAssignedValue; 

 

this is like a  

while ( 1 )  

MyRegBit = MyAssignedValue; 

 

if you want dependencies based upon a signal then 

while ( EnableAssignment )  

MyRegBit = MyAssignedValue; 

 

would be 

reg MyRegBit; 

always @ ( posedge MyClock ) 

if ( EnableAssignment ) 

MyRegBit <= MyAssignedValue; 

else 

MyRegBit <= MyRegBit; 

 

or write it like 

reg MyRegBit; 

always @ ( posedge MyClock ) 

MyRegBit <= ( EnableAssignment ) ? MyAssignedValue : MyRegBit;
0 Kudos
Reply