首页 > 试题广场 >

Please write verilog code to r

[问答题]

Please write verilog code to represent a single bit DFF of synchronized reset and asynchronized reset.

module dff(input clk,input rst,input d,out q1,out q2) 
always@(posedge clk) 
begin    
     if(rst==1'b1)     
        q1 <= 0;     
else         
    q1 <= d; 
end  
always@(posedge clk or negedge rst
begin     
    if(rst==1'b1)     
    q2 <= 0;     
else     
    q2 <= d; 
end
发表于 2019-09-16 16:36:58 回复(0)
module DFF1( output reg q,
             input  d,
             input  clk,rst
           );
always @(posedge clk)  //synchronization
    begin
      if(!rst)
          q<=0;
      else 
          q<=d;
    end
endmodule 



module DFF2( output reg q,
             input  d,
             input  clk,rst
           );
always @(posedge clk or negedge rst)  //asynchronization
    begin
      if(!rst)
          q<=0;
      else 
          q<=d;
    end
endmodule 

编辑于 2019-12-19 20:42:15 回复(3)
module DFF(
    input wire D,  
    input wire areset,    
    input wire reset,     
    input wire clk,
    output reg Q);
    always @(posedge clk or posedge areset)
        begin
            if(areset)    
                Q <= 1'b0;
            else if(reset)
                Q <= 1'b0;
            else 
                Q <= D;
        end


endmodule
发表于 2020-02-18 23:44:53 回复(3)
所以同步复位的含义是复位信号不是敏感信号,模块只对时钟信号上升沿敏感,只有时钟上升沿来到时才会有相应动作;而在异步复位中,复位信号也是敏感信号,而且是下降沿敏感,当复位信号出现下降沿时,模块也会有相应动作。
发表于 2020-06-14 17:16:49 回复(0)
module sync_dff(sync_out,async_out,din,clk,rst_n);
    input din;
    input clk;
    input rst_n;
    output reg sync_out;
    output reg async_out;
    always@(posedge clk)begin
        if(!rst_n)
            sync_out<=1'b0;
        else 
            sync_out<=din;
    end
    always@(posedge clk or negedge rst_n)begin
        if(!rst_n)
            async_out<=1'b0;
        else 
            async_out<=din;
    end
    
endmodule
发表于 2022-05-24 22:46:18 回复(0)
module dff_syn(
    input clk,
    input reset,
    input d,
    output q
);
    always@(posedge clk)begin
        if(reset)
            q <= 0;
        else
            q <= d;
    end
endmodule
module dff_asyn(
    input clk,
    input areset,
    input d,
    output q
);
    always@(posedge clk&nbs***bsp;posedge arest)begin
        if(areset)
            q <= 0;
        else
            q <= d;
    end
endmodule



发表于 2021-04-07 16:31:29 回复(0)
always @(posedge clk&nbs***bsp;negedge rst_n) // 异步复位
always @(posedge clk) // 同步复位

发表于 2021-03-13 20:06:24 回复(0)
`include "type_mux.v"
module #(
parameter TYPE = 0
)(
input    i_data    ,
input    rst_n    ,
output   o_data    
);

reg data;
`ifdef ASYNC_RST
always@(posedge clk)
    if(!rst_n)
        data <= 'd0;
    else
        data <= i_data;
`endif
`ifdef SNYC_RST
always@(posedge clk&nbs***bsp;negedge rst_n)
    if(!rst_n)
        data <= 'd0;
    else 
        data <= i_data;
`endif

assign o_data = data;



发表于 2020-08-20 21:36:01 回复(0)
module sDFF(clk,D,Q,rest);
input clk,rest;
input D;
output Q;
always @(posedge clk)
begin
if(!rest)
Q<=1'b0;
else
Q<=D;
end
endmodule
module aDFF(clk,D,Q,rest);
input clk,rest;
input D;
output Q;
always @(posedge clk ,negedge rest)
begin
if(!rest)
Q<=1'b0;
else
Q<=D;
end
endmodule
发表于 2020-04-28 16:56:10 回复(0)
module rst_module(
input a_rst_n,
input clk,
output s_rst_n
)
reg temp1;
reg temp2;
assign s_rst_n=temp2;
always@(posedge clk or negedge rst_n)
begin
if(!rst_n)
begin
temp1<=0;
temp2<=0;
end
else 
begin
temp1<=1;
temp2<=temp1;
end
end

endmodule


看错题目,以为是要写个产生复位信号的逻辑
发表于 2019-08-18 10:50:51 回复(1)
module reset(
            input clk,
            input rst_n,
            input a,
            output b,
            output c
);
    always @(posedge clk)
            b <= a;
    always @(posedge clk or negedge rst_n)
            c <=a;
endmodule
发表于 2019-07-24 09:46:52 回复(1)
module Syn_DFF(clk, rst_n,Din,Dout);
input clk,rst_n,Din;
output Dout;
reg Dout;
always@(posedge clk)
  begin
    if(!rst_n)
      Dout <= 1'b0;
    else
      Dout <= Din;
  end
endmodule


module Asyn_DFF(clk, rst_n,Din,Dout);
input clk,rst_n,Din;
output Dout;
reg Dout;
always@(posedge clk or negedge rst_n)
  begin
    if(!rst_n)
      Dout <= 1'b0;
    else
      Dout <= Din;
  end
endmodule

发表于 2019-06-03 20:14:16 回复(1)