本文转载自:<span id="profileBt"><a href="https://mp.weixin.qq.com/s/PxvN5fKXXCI0m01UbXJ5BA"> 无界逻辑(微信号:wujieluoji)微信公众号</a></span>
我们开发FPGA,需要使用硬件描述语言(Hardware Description Language),简称HDL。当前使用最广泛的硬件描述逻辑功能语言是verilog,VHDL和是ystemverilg也有部分工程师在坚持使用。
HDL会涉及到标识符,标识符适用于定义常数,变量,信号,端口,子模块或者参数宏的名称。如何给标识符起名字,特别关键,至关重要,看到标识符,就应该知道这个标识符的内在含义。方便后来者或者以后对代码的阅读理解。
针对参数,推荐采用P_PARAMETER的命名方式,大写,P_前缀。
针对宏定义,推荐采用M_MCRO的命名方式,大写,M_前缀。
而对信号命名和模块命名,三字经法和驼峰法比较常用。
驼峰法,又分为小驼峰和大驼峰,比较常用。
如下图所示小驼峰命名法。
<center><img src="https://cdn.eetrend.com/files/2023-08/%E5%8D%9A%E5%AE%A2/100573416-3130…; alt=""></center>
此处推荐”三字经“的写法,即利用三个左右的字母缩写加下划线级联的方式命名。
如:dma_len,atr_din_rdy
常用的缩写如下表:
<table border="1" cellpadding="0" cellspacing="0">
<colgroup>
<col width="145" />
<col width="153" />
</colgroup>
<tbody>
<tr height="19">
<td width="231" height="14" bgcolor="#33CCFF"><strong>全拼</strong></td>
<td width="81" bgcolor="#33CCFF"><strong>缩写</strong></td>
</tr>
<tr height="19">
<td height="14" width="166">acknowledge </td>
<td width="81">ack </td>
</tr>
<tr height="19">
<td height="14" width="166">addition </td>
<td width="81">add </td>
</tr>
<tr height="19">
<td height="14" width="166">address </td>
<td width="81">addr </td>
</tr>
<tr height="19">
<td height="14" width="166">almost empty </td>
<td width="81">aempty </td>
</tr>
<tr height="19">
<td height="14" width="166">almost full </td>
<td width="81">afull </td>
</tr>
<tr height="19">
<td height="14" width="166">answer </td>
<td width="81">ans </td>
</tr>
<tr height="19">
<td height="14" width="166">argument </td>
<td width="81">arg </td>
</tr>
<tr height="19">
<td height="14" width="166">array </td>
<td width="81">arr </td>
</tr>
<tr height="19">
<td height="14" width="166">asynchrounus </td>
<td width="81">async </td>
</tr>
<tr height="19">
<td height="14" width="166">audio </td>
<td width="81">aud </td>
</tr>
<tr height="19">
<td height="14" width="166">average </td>
<td width="81">avg </td>
</tr>
<tr height="19">
<td height="14" width="166">back </td>
<td width="81">bk </td>
</tr>
<tr height="19">
<td height="14" width="166">block </td>
<td width="81">blk </td>
</tr>
<tr height="19">
<td height="14" width="166">blue </td>
<td width="81">blu </td>
</tr>
<tr height="19">
<td height="14" width="166">bottom </td>
<td width="81">bot </td>
</tr>
<tr height="19">
<td height="14" width="166">buffer </td>
<td width="81">buff </td>
</tr>
<tr height="19">
<td height="14" width="166">calculate </td>
<td width="81">calc </td>
</tr>
<tr height="19">
<td height="14" width="166">capture </td>
<td width="81">capt </td>
</tr>
<tr height="19">
<td height="14" width="166">change </td>
<td width="81">chg </td>
</tr>
<tr height="19">
<td height="14" width="166">channel </td>
<td width="81">ch </td>
</tr>
<tr height="19">
<td height="14" width="166">character </td>
<td width="81">char </td>
</tr>
<tr height="19">
<td height="14" width="166">check </td>
<td width="81">chk </td>
</tr>
<tr height="19">
<td height="14" width="166">chip select </td>
<td width="81">cs </td>
</tr>
<tr height="19">
<td height="14" width="166">clock </td>
<td width="81">clk </td>
</tr>
<tr height="19">
<td height="14" width="166">clear </td>
<td width="81">clr </td>
</tr>
<tr height="19">
<td height="14" width="166">column </td>
<td width="81">col </td>
</tr>
<tr height="19">
<td height="14" width="166">combine </td>
<td width="81">cmb </td>
</tr>
<tr height="19">
<td height="14" width="166">command </td>
<td width="81">cmd </td>
</tr>
<tr height="19">
<td height="14" width="166">compare </td>
<td width="81">cmp </td>
</tr>
<tr height="19">
<td height="14" width="166">configure </td>
<td width="81">cfg</td>
</tr>
<tr height="19">
<td height="14" width="166">consume </td>
<td width="81">csm</td>
</tr>
<tr height="19">
<td height="14" width="166">control </td>
<td width="81">ctrl</td>
</tr>
<tr height="19">
<td height="14" width="166">count </td>
<td width="81">cnt </td>
</tr>
<tr height="19">
<td height="14" width="166">current </td>
<td width="81">curr </td>
</tr>
<tr height="19">
<td height="14" width="166">data </td>
<td width="81">dat</td>
</tr>
<tr height="19">
<td height="14" width="166">debug </td>
<td width="81">dbg</td>
</tr>
<tr height="19">
<td height="14" width="166">decode/decoder</td>
<td width="81">dec </td>
</tr>
<tr height="19">
<td height="14" width="166">define </td>
<td width="81">def </td>
</tr>
<tr height="19">
<td height="14" width="166">delay </td>
<td width="81">dly </td>
</tr>
<tr height="19">
<td height="14" width="166">delay1cycle </td>
<td width="81">_d1</td>
</tr>
<tr height="19">
<td height="14" width="166">delay2cycle </td>
<td width="81">_d2 </td>
</tr>
<tr height="19">
<td height="14" width="166">delay3cycle </td>
<td width="81">_d3 </td>
</tr>
<tr height="19">
<td height="14" width="166">delete </td>
<td width="81">del </td>
</tr>
<tr height="19">
<td height="14" width="166">destination </td>
<td width="81">dst </td>
</tr>
<tr height="19">
<td height="14" width="166">detect </td>
<td width="81">det </td>
</tr>
<tr height="19">
<td height="14" width="166">device </td>
<td width="81">dev </td>
</tr>
<tr height="19">
<td height="14" width="166">different </td>
<td width="81">diff </td>
</tr>
<tr height="19">
<td height="14" width="166">directory </td>
<td width="81">dir </td>
</tr>
<tr height="19">
<td height="14" width="166">display </td>
<td width="81">disp </td>
</tr>
<tr height="19">
<td height="14" width="166">division/divide </td>
<td width="81">div </td>
</tr>
<tr height="19">
<td height="14" width="166">document </td>
<td width="81">doc </td>
</tr>
<tr height="19">
<td height="14" width="166">double </td>
<td width="81">dbl </td>
</tr>
<tr height="19">
<td height="14" width="166">double buffer</td>
<td width="81">drop </td>
</tr>
<tr height="19">
<td height="14" width="166">dynamic </td>
<td width="81">dyna </td>
</tr>
<tr height="19">
<td height="14" width="166">empty </td>
<td width="81">ept </td>
</tr>
<tr height="19">
<td height="14" width="166">enable </td>
<td width="81">en </td>
</tr>
<tr height="19">
<td height="14" width="166">encode/eoncoder </td>
<td width="81">enc </td>
</tr>
<tr height="19">
<td height="14" width="166">environment</td>
<td width="81">env </td>
</tr>
<tr height="19">
<td height="14" width="166">error </td>
<td width="81">err </td>
</tr>
<tr height="19">
<td height="14" width="166">ethernet </td>
<td width="81">eth </td>
</tr>
<tr height="19">
<td height="14" width="166">execute </td>
<td width="81">exec</td>
</tr>
<tr height="19">
<td height="14" width="166">extend </td>
<td width="81">ext </td>
</tr>
<tr height="19">
<td height="14" width="166">feed back </td>
<td width="81">fb </td>
</tr>
<tr height="19">
<td height="14" width="166">filter </td>
<td width="81">flt </td>
</tr>
<tr height="19">
<td height="14" width="166">finish </td>
<td width="81">fin</td>
</tr>
<tr height="19">
<td height="14" width="166">finite state machine</td>
<td width="81">fsm </td>
</tr>
<tr height="19">
<td height="14" width="166">first </td>
<td width="81">1st </td>
</tr>
<tr height="19">
<td height="14" width="166">flag </td>
<td width="81">flg </td>
</tr>
<tr height="19">
<td height="14" width="166">frame </td>
<td width="81">frm </td>
</tr>
<tr height="19">
<td height="14" width="166">frame per second</td>
<td width="81">fps </td>
</tr>
<tr height="19">
<td height="14" width="166">frequency </td>
<td width="81">freq </td>
</tr>
<tr height="19">
<td height="14" width="166">full </td>
<td width="81">ful </td>
</tr>
<tr height="19">
<td height="14" width="166">function </td>
<td width="81">fun </td>
</tr>
<tr height="19">
<td height="14" width="166">generate </td>
<td width="81">gen </td>
</tr>
<tr height="19">
<td height="14" width="166">global </td>
<td width="81">glb </td>
</tr>
<tr height="19">
<td height="14" width="166">green </td>
<td width="81">gre </td>
</tr>
<tr height="19">
<td height="14" width="166">ground </td>
<td width="81">gnd </td>
</tr>
<tr height="19">
<td height="14" width="166">group </td>
<td width="81">grp </td>
</tr>
<tr height="19">
<td height="14" width="166">header </td>
<td width="81">hdr </td>
</tr>
<tr height="19">
<td height="14" width="166">heartbeat </td>
<td width="81">htbt</td>
</tr>
<tr height="19">
<td height="14" width="166">height </td>
<td width="81">ht </td>
</tr>
<tr height="19">
<td height="14" width="166">high </td>
<td width="81">_h </td>
</tr>
<tr height="19">
<td height="14" width="166">identification </td>
<td width="81">id </td>
</tr>
<tr height="19">
<td height="14" width="166">image </td>
<td width="81">img</td>
</tr>
<tr height="19">
<td height="14" width="166">implement </td>
<td width="81">impl</td>
</tr>
<tr height="19">
<td height="14" width="166">increment </td>
<td width="81">inc </td>
</tr>
<tr height="19">
<td height="14" width="166">index </td>
<td width="81">idx </td>
</tr>
<tr height="19">
<td height="14" width="166">information </td>
<td width="81">info </td>
</tr>
<tr height="19">
<td height="14" width="166">initalize </td>
<td width="81">init </td>
</tr>
<tr height="19">
<td height="14" width="166">inout </td>
<td width="81">io_ </td>
</tr>
<tr height="19">
<td height="14" width="166">input </td>
<td width="81">i_ </td>
</tr>
<tr height="19">
<td height="14" width="166">input & output</td>
<td width="81">io </td>
</tr>
<tr height="19">
<td height="14" width="166">insert </td>
<td width="81">ins </td>
</tr>
<tr height="19">
<td height="14" width="166">interface </td>
<td width="81">if </td>
</tr>
<tr height="19">
<td height="14" width="166">interrupt </td>
<td width="81">int </td>
</tr>
<tr height="19">
<td height="14" width="166">iteration </td>
<td width="81">itr </td>
</tr>
<tr height="19">
<td height="14" width="166">layer </td>
<td width="81">lay </td>
</tr>
<tr height="19">
<td height="14" width="166">length </td>
<td width="81">len</td>
</tr>
<tr height="19">
<td height="14" width="166">level </td>
<td width="81">lev </td>
</tr>
<tr height="19">
<td height="14" width="166">library </td>
<td width="81">lib</td>
</tr>
<tr height="19">
<td height="14" width="166">line </td>
<td width="81">ln </td>
</tr>
<tr height="19">
<td height="14" width="166">link </td>
<td width="81">lnk </td>
</tr>
<tr height="19">
<td height="14" width="166">list </td>
<td width="81">lst </td>
</tr>
<tr height="19">
<td height="14" width="166">local </td>
<td width="81">loc </td>
</tr>
<tr height="19">
<td height="14" width="166">logical </td>
<td width="81">log </td>
</tr>
<tr height="19">
<td height="14" width="166">low </td>
<td width="81">_l </td>
</tr>
<tr height="19">
<td height="14" width="166">make </td>
<td width="81">mk </td>
</tr>
<tr height="19">
<td height="14" width="166">manager </td>
<td width="81">mgr </td>
</tr>
<tr height="19">
<td height="14" width="166">master </td>
<td width="81">mst </td>
</tr>
<tr height="19">
<td height="14" width="166">match </td>
<td width="81">mat </td>
</tr>
<tr height="19">
<td height="14" width="166">maximum </td>
<td width="81">max </td>
</tr>
<tr height="19">
<td height="14" width="166">memory </td>
<td width="81">mem </td>
</tr>
<tr height="19">
<td height="14" width="166">message </td>
<td width="81">msg </td>
</tr>
<tr height="19">
<td height="14" width="166">micro block </td>
<td width="81">mb </td>
</tr>
<tr height="19">
<td height="14" width="166">middle </td>
<td width="81">mid</td>
</tr>
<tr height="19">
<td height="14" width="166">minimum </td>
<td width="81">min </td>
</tr>
<tr height="19">
<td height="14" width="166">mouse & keyboard</td>
<td width="81">mk </td>
</tr>
<tr height="19">
<td height="14" width="166">multiplication </td>
<td width="81">mul</td>
</tr>
<tr height="19">
<td height="14" width="166">negedge/falling </td>
<td width="81">neg</td>
</tr>
<tr height="19">
<td height="14" width="166">negitivt </td>
<td width="81">_n</td>
</tr>
<tr height="19">
<td height="14" width="166">next </td>
<td width="81">nxt</td>
</tr>
<tr height="19">
<td height="14" width="166">number </td>
<td width="81">num</td>
</tr>
<tr height="19">
<td height="14" width="166">object </td>
<td width="81">obj </td>
</tr>
<tr height="19">
<td height="14" width="166">operand </td>
<td width="81">op </td>
</tr>
<tr height="19">
<td height="14" width="166">operator </td>
<td width="81">optr </td>
</tr>
<tr height="19">
<td height="14" width="166">optimization </td>
<td width="81">opt</td>
</tr>
<tr height="19">
<td height="14" width="166">origin/original </td>
<td width="81">org </td>
</tr>
<tr height="19">
<td height="14" width="166">output </td>
<td width="81">o_ </td>
</tr>
<tr height="19">
<td height="14" width="166">over flow </td>
<td width="81">of </td>
</tr>
<tr height="19">
<td height="14" width="166">package </td>
<td width="81">pkg </td>
</tr>
<tr height="19">
<td height="14" width="166">packet </td>
<td width="81">pkt</td>
</tr>
<tr height="19">
<td height="14" width="166">padding </td>
<td width="81">pad </td>
</tr>
<tr height="19">
<td height="14" width="166">parameter </td>
<td width="81">para </td>
</tr>
<tr height="19">
<td height="14" width="166">password </td>
<td width="81">psw </td>
</tr>
<tr height="19">
<td height="14" width="166">payload type</td>
<td width="81">pt </td>
</tr>
<tr height="19">
<td height="14" width="166">physical </td>
<td width="81">phy </td>
</tr>
<tr height="19">
<td height="14" width="166">picture </td>
<td width="81">pic </td>
</tr>
<tr height="19">
<td height="14" width="166">point </td>
<td width="81">pnt</td>
</tr>
<tr height="19">
<td height="14" width="166">pointer </td>
<td width="81">ptr </td>
</tr>
<tr height="19">
<td height="14" width="166">posedge/raising </td>
<td width="81">pos</td>
</tr>
<tr height="19">
<td height="14" width="166">position </td>
<td width="81">pos </td>
</tr>
<tr height="19">
<td height="14" width="166">positive </td>
<td width="81">_p </td>
</tr>
<tr height="19">
<td height="14" width="166">power </td>
<td width="81">pwr </td>
</tr>
<tr height="19">
<td height="14" width="166">previous </td>
<td width="81">pre</td>
</tr>
<tr height="19">
<td height="14" width="166">process/procedure</td>
<td width="81">proc </td>
</tr>
<tr height="19">
<td height="14" width="166">public </td>
<td width="81">pub </td>
</tr>
<tr height="19">
<td height="14" width="166">read </td>
<td width="81">rd</td>
</tr>
<tr height="19">
<td height="14" width="166">read only </td>
<td width="81">ro </td>
</tr>
<tr height="19">
<td height="14" width="166">read write </td>
<td width="81">rw </td>
</tr>
<tr height="19">
<td height="14" width="166">ready </td>
<td width="81">rdy</td>
</tr>
<tr height="19">
<td height="14" width="166">receive </td>
<td width="81">rx</td>
</tr>
<tr height="19">
<td height="14" width="166">record </td>
<td width="81">rcd </td>
</tr>
<tr height="19">
<td height="14" width="166">red </td>
<td width="81">r </td>
</tr>
<tr height="19">
<td height="14" width="166">region </td>
<td width="81">rgn </td>
</tr>
<tr height="19">
<td height="14" width="166">register </td>
<td width="81">reg </td>
</tr>
<tr height="19">
<td height="14" width="166">release </td>
<td width="81">rls </td>
</tr>
<tr height="19">
<td height="14" width="166">request </td>
<td width="81">req </td>
</tr>
<tr height="19">
<td height="14" width="166">reset </td>
<td width="81">rst </td>
</tr>
<tr height="19">
<td height="14" width="166">result </td>
<td width="81">res </td>
</tr>
<tr height="19">
<td height="14" width="166">return </td>
<td width="81">ret </td>
</tr>
<tr height="19">
<td height="14" width="166">screen </td>
<td width="81">srcn </td>
</tr>
<tr height="19">
<td height="14" width="166">second </td>
<td width="81">2nd </td>
</tr>
<tr height="19">
<td height="14" width="166">segment </td>
<td width="81">seg </td>
</tr>
<tr height="19">
<td height="14" width="166">select </td>
<td width="81">sel </td>
</tr>
<tr height="19">
<td height="14" width="166">server </td>
<td width="81">svr </td>
</tr>
<tr height="19">
<td height="14" width="166">signaling </td>
<td width="81">sig </td>
</tr>
<tr height="19">
<td height="14" width="166">slave </td>
<td width="81">slv </td>
</tr>
<tr height="19">
<td height="14" width="166">slice </td>
<td width="81">slc </td>
</tr>
<tr height="19">
<td height="14" width="166">source </td>
<td width="81">src </td>
</tr>
<tr height="19">
<td height="14" width="166">stack </td>
<td width="81">stk </td>
</tr>
<tr height="19">
<td height="14" width="166">standard </td>
<td width="81">std </td>
</tr>
<tr height="19">
<td height="14" width="166">start </td>
<td width="81">st </td>
</tr>
<tr height="19">
<td height="14" width="166">state </td>
<td width="81">s_ </td>
</tr>
<tr height="19">
<td height="14" width="166">status </td>
<td width="81">stat </td>
</tr>
<tr height="19">
<td height="14" width="166">stream </td>
<td width="81">strm </td>
</tr>
<tr height="19">
<td height="14" width="166">string </td>
<td width="81">str </td>
</tr>
<tr height="19">
<td height="14" width="166">subtraction </td>
<td width="81">sub </td>
</tr>
<tr height="19">
<td height="14" width="166">summation </td>
<td width="81">sum </td>
</tr>
<tr height="19">
<td height="14" width="166">synchronization </td>
<td width="81">syn </td>
</tr>
<tr height="19">
<td height="14" width="166">system </td>
<td width="81">sys </td>
</tr>
<tr height="19">
<td height="14" width="166">table </td>
<td width="81">tbl</td>
</tr>
<tr height="19">
<td height="14" width="166">temporary </td>
<td width="81">tmp</td>
</tr>
<tr height="19">
<td height="14" width="166">test </td>
<td width="81">tst </td>
</tr>
<tr height="19">
<td height="14" width="166">text </td>
<td width="81">txt </td>
</tr>
<tr height="19">
<td height="14" width="166">third </td>
<td width="81">3rd </td>
</tr>
<tr height="19">
<td height="14" width="166">threshold </td>
<td width="81">th </td>
</tr>
<tr height="19">
<td height="14" width="166">time stamp </td>
<td width="81">ts </td>
</tr>
<tr height="19">
<td height="14" width="166">total </td>
<td width="81">tot </td>
</tr>
<tr height="19">
<td height="14" width="166">transmitter </td>
<td width="81">tx </td>
</tr>
<tr height="19">
<td height="14" width="166">triple </td>
<td width="81">tri </td>
</tr>
<tr height="19">
<td height="14" width="166">tristate </td>
<td width="81">t_ </td>
</tr>
<tr height="19">
<td height="14" width="166">update </td>
<td width="81">upd </td>
</tr>
<tr height="19">
<td height="14" width="166">upgrade </td>
<td width="81">upg</td>
</tr>
<tr height="19">
<td height="14" width="166">user interface </td>
<td width="81">ui </td>
</tr>
<tr height="19">
<td height="14" width="166">utility </td>
<td width="81">util </td>
</tr>
<tr height="19">
<td height="14" width="166">valid </td>
<td width="81">vld </td>
</tr>
<tr height="19">
<td height="14" width="166">value </td>
<td width="81">val </td>
</tr>
<tr height="19">
<td height="14" width="166">variable </td>
<td width="81">var </td>
</tr>
<tr height="19">
<td height="14" width="166">variable length code</td>
<td width="81">vlc </td>
</tr>
<tr height="19">
<td height="14" width="166">version </td>
<td width="81">ver </td>
</tr>
<tr height="19">
<td height="14" width="166">vertical synchronous </td>
<td width="81">vsync</td>
</tr>
<tr height="19">
<td height="14" width="166">video </td>
<td width="81">vid </td>
</tr>
<tr height="19">
<td height="14" width="166">wide/width </td>
<td width="81">wd </td>
</tr>
<tr height="19">
<td height="14" width="166">window </td>
<td width="81">wnd </td>
</tr>
<tr height="19">
<td height="14" width="166">wire </td>
<td width="81">w_ </td>
</tr>
<tr height="19">
<td height="14" width="166">write </td>
<td width="81">wr </td>
</tr>
<tr height="19">
<td height="14" width="166">cyclic redundancy check</td>
<td width="81">crc</td>
</tr>
</tbody>
</table>
需要特别注意的是,命名一定要避免使用verilog,systemverilog的保留字。
还有哪些常用的缩略语,请推荐给作者。