Skip to main content

For each bit in a 32-bit vector, capture when the input signal changes from 1 in one clock cycle to 0 the next. "Capture" means that the output will remain 1 until the register is reset (synchronous reset). Each output bit behaves like a SR flip-flop: The output bit should be set (to 1) the cycle after a 1 to 0 transition occurs. The output bit should be reset (to 0) at the positive clock edge when reset is high. If both of the above events occur at the same time, reset has precedence. In the last 4 cycles of the example waveform below, the 'reset' event occurs one cycle earlier than the 'set' event, so there is no conflict here. In the example waveform below, reset, in1 and out1 are shown again separately for clarity.   

enter image description hereenter image description here

my code:

module top_module ( input clk, input reset, input [31:0] in, output [31:0] out ); integer i; reg [31:0] in_del; reg [31:0] out_del; always @ (posedge clk) begin in_del<=in; out_del<=~in & in_del; if (reset) out=0; else begin for (i=0; i<32;i=i+1) begin if (out_del[i]) out[i]=out_del[i]; end end end endmodule 

my output

enter image description hereenter image description here

For each bit in a 32-bit vector, capture when the input signal changes from 1 in one clock cycle to 0 the next. "Capture" means that the output will remain 1 until the register is reset (synchronous reset). Each output bit behaves like a SR flip-flop: The output bit should be set (to 1) the cycle after a 1 to 0 transition occurs. The output bit should be reset (to 0) at the positive clock edge when reset is high. If both of the above events occur at the same time, reset has precedence. In the last 4 cycles of the example waveform below, the 'reset' event occurs one cycle earlier than the 'set' event, so there is no conflict here. In the example waveform below, reset, in1 and out1 are shown again separately for clarity.  enter image description here

my code:

module top_module ( input clk, input reset, input [31:0] in, output [31:0] out ); integer i; reg [31:0] in_del; reg [31:0] out_del; always @ (posedge clk) begin in_del<=in; out_del<=~in & in_del; if (reset) out=0; else begin for (i=0; i<32;i=i+1) begin if (out_del[i]) out[i]=out_del[i]; end end end endmodule 

my output

enter image description here

For each bit in a 32-bit vector, capture when the input signal changes from 1 in one clock cycle to 0 the next. "Capture" means that the output will remain 1 until the register is reset (synchronous reset). Each output bit behaves like a SR flip-flop: The output bit should be set (to 1) the cycle after a 1 to 0 transition occurs. The output bit should be reset (to 0) at the positive clock edge when reset is high. If both of the above events occur at the same time, reset has precedence. In the last 4 cycles of the example waveform below, the 'reset' event occurs one cycle earlier than the 'set' event, so there is no conflict here. In the example waveform below, reset, in1 and out1 are shown again separately for clarity. 

enter image description here

my code:

module top_module ( input clk, input reset, input [31:0] in, output [31:0] out ); integer i; reg [31:0] in_del; reg [31:0] out_del; always @ (posedge clk) begin in_del<=in; out_del<=~in & in_del; if (reset) out=0; else begin for (i=0; i<32;i=i+1) begin if (out_del[i]) out[i]=out_del[i]; end end end endmodule 

my output

enter image description here

Edited mistake in the title.
Source Link
dave_59
  • 43.3k
  • 3
  • 29
  • 66
< module top_module ( input clk, input reset, input [31:0] in, output [31:0] out ); integer i; reg [31:0] in_del; reg [31:0] out_del; always @ (posedge clk) begin in_del<=in; out_del<=~in & in_del; if (reset) out=0; else begin for (i=0; i<32;i=i+1) begin if (out_del[i]) out[i]=out_del[i]; end end end 

endmodule

module top_module ( input clk, input reset, input [31:0] in, output [31:0] out ); integer i; reg [31:0] in_del; reg [31:0] out_del; always @ (posedge clk) begin in_del<=in; out_del<=~in & in_del; if (reset) out=0; else begin for (i=0; i<32;i=i+1) begin if (out_del[i]) out[i]=out_del[i]; end end end endmodule 
< module top_module ( input clk, input reset, input [31:0] in, output [31:0] out ); integer i; reg [31:0] in_del; reg [31:0] out_del; always @ (posedge clk) begin in_del<=in; out_del<=~in & in_del; if (reset) out=0; else begin for (i=0; i<32;i=i+1) begin if (out_del[i]) out[i]=out_del[i]; end end end 

endmodule

module top_module ( input clk, input reset, input [31:0] in, output [31:0] out ); integer i; reg [31:0] in_del; reg [31:0] out_del; always @ (posedge clk) begin in_del<=in; out_del<=~in & in_del; if (reset) out=0; else begin for (i=0; i<32;i=i+1) begin if (out_del[i]) out[i]=out_del[i]; end end end endmodule 

why does my output signal hashave 2 clock cycles delay?

Source Link
Loading