我正在尝试将 FPGA 用作带有 pwm 的某些 LED 的移位寄存器,但在尝试分配包含移入输出变量的值的 reg 时遇到错误。当我将它上传到 FPGA 时(我正在使用嵌入式 micro 的 mojo),它什么也不做。当我使用模拟器时,它报告所有输出变量都没有被分配并且具有 X 的值,而模块内的所有其他变量都可以正常工作。这是我的移位模块代码:
module shifting(
input clk,
input shiftingpin,//data to be shifted in
input rst,
output done,
output [3:0]data//pwm compare value output
);
reg [2: 0] ctr_d, ctr_q;
reg don;
reg [3:0]datas;
always @(*) begin
if(ctr_q == 3'b100) begin
ctr_d[2:0] = 3'b0;
don = 1'b1;
end else begin
ctr_d = ctr_q + 1'b1;
don = 1'b0;
end
end
always @(posedge clk) begin
datas[ctr_q] = shiftingpin;// assign value to the output
if (rst) begin
ctr_q <= 1'b0;
end else begin
ctr_q <= ctr_d;
end
end
assign data = datas;
assign done = don;
endmodule
done 告诉包含模块何时更新并将值分配给 pwm。