Programmable Devices
CPLDs, FPGAs, SoC FPGAs, Configuration, and Transceivers
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.
21615 Discussions

about verilog code" while"

Altera_Forum
Honored Contributor II
1,142 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
416 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