1
我想逐位读取8位寄存器。即首先读数为0:3,然后是1:4,然后是2:5。一次读取4位。 下面的代码在使用整数访问寄存器位时会出错。Verilog - 动态读取寄存器位或使用某些变量
module First_Module(
clock,
reset,
enable,
counter_out
);
// input ports
input clock;
input reset;
input enable;
output [3:0] counter_out;
wire clock;
wire reset;
wire enable=1'b1;
reg[3:0] counter_out=0001;
reg[9:0] line=1101101101;
reg[3:0] testPattern=1101;
reg[3:0] temp=0000;
integer IndexStart,IndexEnd;
initial
begin
IndexStart=0;
IndexEnd=3;
end
initial
#20 $finish; //finish after 20 time units
always
begin:COUNTER
\#1
$monitor ("counter Out = %d Reset = %d",counter_out,reset);
$monitor ("Temp = %d ",temp);
if(reset==1'b1)
begin
counter_out <= 4'b0000;
end// if-end
else if (enable==1'b1)
begin
counter_out= counter_out+1;
IndexEnd=IndexEnd+1;
temp=line[IndexEnd:IndexStart]; // Error at this line
end
end// always end
endmodule
帮助需要帮助。
23页!非常感谢。 –