用verilog寫8位迴圈移位器

時間 2021-09-04 07:42:48

1樓:

module barrel_org(s,a_p,b_p);

input [2:0] s;

input [7:0] a_p;

input [7:] b_p;

reg [7:0] b_p;

always@(a_p or s)

begin

case(s)

3'b000:

begin

b_p <= a_p;

end3'b001:

begin

b_p[7] <= a_p[0];

b_p[6:0] <= a_p[7:1];

end3'b010:

begin

b_p[7:6] <= a_p[1:0];

b_p[5:0] <= a_p[7:2];

end3'b011:

begin

b_p[7:5] <= a_p[2:0];

b_p[4:0] <= a_p[7:3];

end3'b100:

begin

b_p[7:4] <= a_p[3:0];

b_p[3:0] <= a_p[7:4];

end3'b101:

begin

b_p[7:3] <= a_p[4:0];

b_p[2:0] <= a_p[7:5];

end3'b110:

begin

b_p[7:2] <= a_p[5:0];

b_p[1:0] <= a_p[7:6];

end3'b111:

begin

b_p[7:1] <= a_p[6:0];

b_p[0] <= a_p[7];

enddefault:

begin

b_p = a_p;

endendcase

endendmodule

2樓:匿名使用者

always @(posedge clk)begin

data<=;//迴圈左移

//data<=;//迴圈右移end

用verilog hdl程式設計設計8位左右移移位暫存器電路。

3樓:匿名使用者

module verilog1(clk,ldn,k,d,q);

input clk,ldn,k;

input [7:0] d;

output [7:0] q;

reg[7:0] d_reg,q_reg;

always@(negedge ldn)

if(!ldn)

d_reg <= d;

always@(posedge clk )begin

if(k)

begin//right

q_reg[7:0] <= ;

endelse q_reg[7:0] <= ;

endassign q = q_reg;

endmodule

用vfp中的for迴圈語句寫階乘

zifu 設定空字串 for i 1 to 10 if i 2 1 for j 2 to i stip 1 k str j zifu zifu k endforelse for j i to 1 stip 1 k str j zifu zifu k endforendifjishu ctod i j...

在vb中n 用for迴圈怎麼寫

風華正茂 dim n as long dim s as double n inputbox 請輸入n的值 s 1 s初值設為1for i 1 to n step 1 s s i next i print s 最後輸出 dim n as long dim i as long dim s as long...

求1 2 3n 的和,用C語言巢狀迴圈格式寫

include void main while n 1 for i 1 i n i printf ld n sum 此程式已在vc 6.0下除錯通過 輸入 1 輸出 1 輸入 2 輸出 3 輸入 3 輸出 9 輸入 4 輸出 33 輸入資料不能過大,因為long型最大隻有2的32次方 1這麼大 ma...