Q1: write Verilog code to generate below waveform:
Q2: write Verilog code to generate below waveform:
Since there is one delay after the rising edge of data in, three delays after the negedge of din, I write a moore FSM.
module delay_reg(rst,clk,d_in,d_out);
input rst,clk, d_in;
output reg d_out;
reg [1:0] c_s, n_s;
parameter s0=2'b00, s1=2'b01,s2=2'b10,s3=2'b11;
always @(posedge clk)begin
if(rst)
c_s<=s0;
else
c_s<= n_s;end
always@(*)begin
case(c_s)
s0: begin
if(d_in)
n_s=s1;
else
n_s