题目理解错误 以为都是在同一个代码中实现 。。。
阴错阳差的实现了循环 好家伙。。。
用移位运算符需要加一个循环代码
位拼接则不用
`timescale 1ns/1ns module tb_net7(); reg clk; reg rst; wire [7:0]po_a; initial clk=0; always #5 clk=~clk; initial begin rst=0; #100 rst=1; #10 rst=0; #100 rst=1; end net7 tb_net7_inst( .clk(clk), .rst(rst), .po_a(po_a)); endmodule
module net7( input wire clk, input wire rst, output reg [7:0]po_a=1); always @(posedge clk or posedge rst) begin if (rst) begin po_a=1'd1; end else begin po_a<=po_a<<1'b1; po_a<={po_a[6:0],po_a[7]}; end end endmodule