用Verilog设计一位十进制可逆计数器?
发布网友
发布时间:2022-05-07 13:51
我来回答
共1个回答
热心网友
时间:2023-11-04 00:30
mole test (
input cp,
input asclr,
input preset,
input [3:0] psdata,
input up,
output reg [3:0] cntvalue,
output reg cout
);
always @(posedge cp or negedge asclr)
if ( !asclr) begin
cntvalue <= 4'h0;
cout <= 1'b0;
end
else if (preset==1) begin
cntvalue <= psdata;
cout <= 1'b0;
end
else if ( up ==1) begin
if ( cntvalue < 4'h9) begin
cntvalue <= cntvalue +1;
end
else begin
cntvalue <= 4'h0;
cout <= 1'b1;
end
end
else if ( !up) begin
if (cntvalue == 4'h0) begin
cntvalue <= 4'h9;
cout <= 1'b1;
end
else begin
cntvalue <= cntvalue -1;
end
end
endmole
热心网友
时间:2023-11-04 00:30
mole test (
input cp,
input asclr,
input preset,
input [3:0] psdata,
input up,
output reg [3:0] cntvalue,
output reg cout
);
always @(posedge cp or negedge asclr)
if ( !asclr) begin
cntvalue <= 4'h0;
cout <= 1'b0;
end
else if (preset==1) begin
cntvalue <= psdata;
cout <= 1'b0;
end
else if ( up ==1) begin
if ( cntvalue < 4'h9) begin
cntvalue <= cntvalue +1;
end
else begin
cntvalue <= 4'h0;
cout <= 1'b1;
end
end
else if ( !up) begin
if (cntvalue == 4'h0) begin
cntvalue <= 4'h9;
cout <= 1'b1;
end
else begin
cntvalue <= cntvalue -1;
end
end
endmole
热心网友
时间:2023-11-04 00:30
mole test (
input cp,
input asclr,
input preset,
input [3:0] psdata,
input up,
output reg [3:0] cntvalue,
output reg cout
);
always @(posedge cp or negedge asclr)
if ( !asclr) begin
cntvalue <= 4'h0;
cout <= 1'b0;
end
else if (preset==1) begin
cntvalue <= psdata;
cout <= 1'b0;
end
else if ( up ==1) begin
if ( cntvalue < 4'h9) begin
cntvalue <= cntvalue +1;
end
else begin
cntvalue <= 4'h0;
cout <= 1'b1;
end
end
else if ( !up) begin
if (cntvalue == 4'h0) begin
cntvalue <= 4'h9;
cout <= 1'b1;
end
else begin
cntvalue <= cntvalue -1;
end
end
endmole
热心网友
时间:2023-11-04 00:30
mole test (
input cp,
input asclr,
input preset,
input [3:0] psdata,
input up,
output reg [3:0] cntvalue,
output reg cout
);
always @(posedge cp or negedge asclr)
if ( !asclr) begin
cntvalue <= 4'h0;
cout <= 1'b0;
end
else if (preset==1) begin
cntvalue <= psdata;
cout <= 1'b0;
end
else if ( up ==1) begin
if ( cntvalue < 4'h9) begin
cntvalue <= cntvalue +1;
end
else begin
cntvalue <= 4'h0;
cout <= 1'b1;
end
end
else if ( !up) begin
if (cntvalue == 4'h0) begin
cntvalue <= 4'h9;
cout <= 1'b1;
end
else begin
cntvalue <= cntvalue -1;
end
end
endmole
热心网友
时间:2023-11-04 00:30
mole test (
input cp,
input asclr,
input preset,
input [3:0] psdata,
input up,
output reg [3:0] cntvalue,
output reg cout
);
always @(posedge cp or negedge asclr)
if ( !asclr) begin
cntvalue <= 4'h0;
cout <= 1'b0;
end
else if (preset==1) begin
cntvalue <= psdata;
cout <= 1'b0;
end
else if ( up ==1) begin
if ( cntvalue < 4'h9) begin
cntvalue <= cntvalue +1;
end
else begin
cntvalue <= 4'h0;
cout <= 1'b1;
end
end
else if ( !up) begin
if (cntvalue == 4'h0) begin
cntvalue <= 4'h9;
cout <= 1'b1;
end
else begin
cntvalue <= cntvalue -1;
end
end
endmole
热心网友
时间:2023-11-04 00:30
mole test (
input cp,
input asclr,
input preset,
input [3:0] psdata,
input up,
output reg [3:0] cntvalue,
output reg cout
);
always @(posedge cp or negedge asclr)
if ( !asclr) begin
cntvalue <= 4'h0;
cout <= 1'b0;
end
else if (preset==1) begin
cntvalue <= psdata;
cout <= 1'b0;
end
else if ( up ==1) begin
if ( cntvalue < 4'h9) begin
cntvalue <= cntvalue +1;
end
else begin
cntvalue <= 4'h0;
cout <= 1'b1;
end
end
else if ( !up) begin
if (cntvalue == 4'h0) begin
cntvalue <= 4'h9;
cout <= 1'b1;
end
else begin
cntvalue <= cntvalue -1;
end
end
endmole
热心网友
时间:2023-11-04 00:30
mole test (
input cp,
input asclr,
input preset,
input [3:0] psdata,
input up,
output reg [3:0] cntvalue,
output reg cout
);
always @(posedge cp or negedge asclr)
if ( !asclr) begin
cntvalue <= 4'h0;
cout <= 1'b0;
end
else if (preset==1) begin
cntvalue <= psdata;
cout <= 1'b0;
end
else if ( up ==1) begin
if ( cntvalue < 4'h9) begin
cntvalue <= cntvalue +1;
end
else begin
cntvalue <= 4'h0;
cout <= 1'b1;
end
end
else if ( !up) begin
if (cntvalue == 4'h0) begin
cntvalue <= 4'h9;
cout <= 1'b1;
end
else begin
cntvalue <= cntvalue -1;
end
end
endmole
热心网友
时间:2023-11-04 00:30
mole test (
input cp,
input asclr,
input preset,
input [3:0] psdata,
input up,
output reg [3:0] cntvalue,
output reg cout
);
always @(posedge cp or negedge asclr)
if ( !asclr) begin
cntvalue <= 4'h0;
cout <= 1'b0;
end
else if (preset==1) begin
cntvalue <= psdata;
cout <= 1'b0;
end
else if ( up ==1) begin
if ( cntvalue < 4'h9) begin
cntvalue <= cntvalue +1;
end
else begin
cntvalue <= 4'h0;
cout <= 1'b1;
end
end
else if ( !up) begin
if (cntvalue == 4'h0) begin
cntvalue <= 4'h9;
cout <= 1'b1;
end
else begin
cntvalue <= cntvalue -1;
end
end
endmole
热心网友
时间:2023-11-04 00:31
mole test (
input cp,
input asclr,
input preset,
input [3:0] psdata,
input up,
output reg [3:0] cntvalue,
output reg cout
);
always @(posedge cp or negedge asclr)
if ( !asclr) begin
cntvalue <= 4'h0;
cout <= 1'b0;
end
else if (preset==1) begin
cntvalue <= psdata;
cout <= 1'b0;
end
else if ( up ==1) begin
if ( cntvalue < 4'h9) begin
cntvalue <= cntvalue +1;
end
else begin
cntvalue <= 4'h0;
cout <= 1'b1;
end
end
else if ( !up) begin
if (cntvalue == 4'h0) begin
cntvalue <= 4'h9;
cout <= 1'b1;
end
else begin
cntvalue <= cntvalue -1;
end
end
endmole