Altera_Forum
Honored Contributor
16 years agoHow can I neaten this up?
I have writte some code that works, but its long and looks primitive. Any tips how to rewrite this short and more elegant without change the function of it? I am reading serial bits from a Copernicus GPS module, then displaying them on a LCD for further decoding.
The code works, but it would be hard for someone else to read if I try to get a patent or use snippets of this as portfolio meterial to get a job in this field. Example 1. //This is where I read the serial pin from the GPS chip into a FIFO structure begin if (bittimer!=bitlength) bittimer=bittimer+1; if (bittimer==bitlength) begin bitstreamin[300]<=bitstreamin[299]; bitstreamin[299]<=bitstreamin[298]; bitstreamin[298]<=bitstreamin[297]; bitstreamin[297]<=bitstreamin[296]; bitstreamin[296]<=bitstreamin[295]; bitstreamin[295]<=bitstreamin[294]; bitstreamin[294]<=bitstreamin[293]; bitstreamin[293]<=bitstreamin[292]; bitstreamin[292]<=bitstreamin[291]; bitstreamin[291]<=bitstreamin[290]; bitstreamin[290]<=bitstreamin[289]; bitstreamin[289]<=bitstreamin[288]; bitstreamin[288]<=bitstreamin[287]; bitstreamin[287]<=bitstreamin[286]; bitstreamin[286]<=bitstreamin[285]; bitstreamin[285]<=bitstreamin[284]; bitstreamin[284]<=bitstreamin[283]; bitstreamin[283]<=bitstreamin[282]; bitstreamin[282]<=bitstreamin[281]; bitstreamin[281]<=bitstreamin[280]; bitstreamin[280]<=bitstreamin[279]; bitstreamin[279]<=bitstreamin[278]; bitstreamin[278]<=bitstreamin[277]; bitstreamin[277]<=bitstreamin[276]; bitstreamin[276]<=bitstreamin[275]; bitstreamin[275]<=bitstreamin[274]; bitstreamin[274]<=bitstreamin[273]; bitstreamin[273]<=bitstreamin[272]; bitstreamin[272]<=bitstreamin[271]; bitstreamin[271]<=bitstreamin[270]; bitstreamin[270]<=bitstreamin[269]; bitstreamin[269]<=bitstreamin[268]; bitstreamin[268]<=GPSIN; bittimer<=0; end /// Example 2, the ASCII byte from the GPS has to sent to the LCD if (state==7) begin twire[7]=gpsasci[229]; twire[6]=gpsasci[228]; twire[5]=gpsasci[227]; twire[4]=gpsasci[226]; twire[3]=gpsasci[225]; twire[2]=gpsasci[224]; twire[1]=gpsasci[223]; twire[0]=gpsasci[221]; end