Triangle waveform verilog -


I'm trying to get a triangle wave, but my code does not work! I think that "if conditions" are wrong, but I can not find fault. My wave has increased so much that it should happen and it comes down to 90 degrees after achieving the top level

  Module PLA clk, race, out2); Input clack, ridge Output [0: 7] out 2; Reg [0: 7] Out 2; Always @ (Pause CLK) starts if (RAS) starts (out2> = 8'b11111111) out2 = out2 + 1; And if (out 2> = 8'b 00000000) out2 = out2-1; And out 2 = 8'b 00000000; End and out 2 = 8'b000000; End-end module module testbench; Reg clk, res; Wire [0: 7] out 2; Pilla Sevro (CLK, Race, Out 2); Always # 2 clk = ~ clk; Initial start clk = 0; Res = 0; # 2 race = 1; The initial $ 5000 finishes; Endmile  

To indicate the direction you are currently counting, you get some signal needed. Non-intercept assignment operator instead of blocking assignment operator = & lt; = also use

  module pellea (CLK, RSA, out 2); Input clack, ridge Output [0: 7] out 2; Reg [0: 7] out2 = 8'h00; Reg count_down = 1'b0; Always start @ (Pause CLK) if (count_down == 1'b0) starts (if out2 == 8'b11111111) // count_down starts for the top of the check count & lt; = 1'b1; Out2 & lt; = Out2-1; End by 2 & lt; = Out2 + 1; Finally starts if (out2 == 8'b00000000) // Check countdown check count_down below & lt; = 1'b0; Out2 & lt; = Out2 + 1; End by 2 & lt; = Out2-1; End and end module  

Comments