I have an HDL Block in which the output follows the input in such a way that when input signal is binary 0, output remains 0 but when input turns 1, output turns 1 for a preset number of clock cycles (signal_length). i.e. input may remain high for suppose 65 or 66 clock cycles but output should remain high for preset number of clock cycles. I tried to accomplish the task with Verilog. But I am having an error and I don’t know how to rectify. Hope someone can help.
This piece of code looks like it should give syntax error during compile.
Code Verilog - [expand]
1
assign cnt <= cnt +1'b1;
assign is continuous assignment; whenever RHS changes it'll be assigned to LHS. So there's no concept of non-blocking assignment ( <= ).
If the idea is to count the clocks, cnt should be inside an always block with posedge clk in its sensitivity list.
Another thing is probably you should initialize the parameter signal_length to some default value.
It'll be a useful practice if you can visualize the circuit you want to implement before starting to code. Hardware comes first and verilog is only a tool describe that hardware.