我想要得到一个三角形波形,但我的代码不起作用!我认为,“如果条件”是有组织错了,但我无法找到我的波上升像它应该是错误的,它实现了顶级三角形波形verilog
module pila(clk,res,out2);
input clk,res;
output [0:7]out2;
reg [0:7]out2;
always @(posedge clk)
begin
if (res)
begin
if(out2<=8'b11111111)
out2=out2+1;
else if(out2>=8'b00000000)
out2=out2-1;
else out2=8'b00000000;
end
else out2=8'b00000000;
end
endmodule
module testbench;
reg clk,res;
wire [0:7]out2;
pila Sevo(clk,res,out2);
always #2 clk=~clk;
initial
begin
clk=0;res=0;
#2 res=1;
end
initial #5000 $finish;
endmodule
详细阐述“不起作用”。 – toolic
你看到'out2'后面有'00-> 01-> ...-> FE-> FF-> 00-> 01 - > ..'模式,但期待00-> 01 - > ...-> FE-> FF-> FE - > .. 01-> 00-> 01 - > ..,对吗? – Greg
@Greg - 是的你是对的 – PYPL