當前位置:編程學習大全網 - 編程軟體 - Verilong編程

Verilong編程

二分法,用按位或判斷是否全零。

比如5bit的結果,如果輸入高16bit全為零,則結果的最高位設置為0,否則設置為1,依次分為兩點。

-附壹個1找高位,低位也差不多。

reg [31:0]數據;

reg [ 4:0]位置;

reg[15:0]sel 1;

reg[7:0]sel 2;

reg[3:0]sel 3;

reg[2:0]sel 4;

總是@(*)開始

if(|data[31:16] == 0)開始

位置[4]= 0;

sel 1 = data[15:0];

結束

否則開始

position[4]= 1;

sel 1 = data[31:16];

結束

結束

總是@(*)開始

if(| sel 1[15:8]= = 1 ' B0)開始

位置[3]= 0;

sel 2 = sel 1[7:0];

結束

否則開始

position[3]= 1;

sel 2 = sel 1[15:8];

結束

結束

總是@(*)開始

if(|sel2[7:4] == 1'b0)開始

位置[2]= 0;

sel 3 = sel 2[3:0];

結束

否則開始

position[2]= 1;

sel 3 = sel 2[7:4];

結束

結束

總是@(*)開始

if(|sel3[3:2] == 1'b0)開始

position[1]= 0;

sel 4 = sel 3[1:0];

結束

否則開始

位置[1]= 1;

sel 4 = sel 3[3:2];

結束

結束

總是@(*)開始

if(sel4[1] == 1'b0)開始

位置[0]= 0;

結束

否則開始

position[0]= 1;

結束

結束

  • 上一篇:銀行科技部,試營業,數據中心哪個好?
  • 下一篇:微機原理題中的源操作數00FFH怎麽得來的?
  • copyright 2024編程學習大全網