不知道有没有用的数码管消影

This commit is contained in:
iridiumR 2022-04-05 17:27:13 +08:00
parent 453edfb17a
commit 65009ea748
2 changed files with 24 additions and 9 deletions

View file

@ -26,6 +26,7 @@ quit -f
</modelsim_script> </modelsim_script>
<modelsim_script_timing>onerror {exit -code 1} <modelsim_script_timing>onerror {exit -code 1}
vlib work vlib work
@ -50,6 +51,7 @@ quit -f
</modelsim_script_timing> </modelsim_script_timing>
<hdl_lang>verilog</hdl_lang> <hdl_lang>verilog</hdl_lang>
</simulation_settings>*/ </simulation_settings>*/
@ -684,9 +686,9 @@ TRANSITION_LIST("clk2")
REPEAT = 1; REPEAT = 1;
NODE NODE
{ {
REPEAT = 100; REPEAT = 200;
LEVEL 0 FOR 5.0; LEVEL 0 FOR 2.5;
LEVEL 1 FOR 5.0; LEVEL 1 FOR 2.5;
} }
} }
} }

View file

@ -7,30 +7,40 @@ output reg [6:0] codeout; //型码
//当前位置数字 //当前位置数字
reg [6:0] code_loc=2'B01; reg [6:0] code_loc=2'b01;
reg isEnable;
reg [1:0] loc; reg [1:0] loc;
//循环移位 //循环移位
always @(posedge clk) always @(posedge clk)
begin begin
if(loc==2'b01) if(isEnable)
loc=2'b10; isEnable<=0;
else else
loc=2'b01; begin
isEnable<=1;
if(loc==2'b01)
loc=2'b10;
else
loc=2'b01;
end
end end
always @(*) always @(*)
begin begin
sel = 4'b0000; if(isEnable)
begin
case (loc) case (loc)
2'b01: begin code_loc = d1; sel = 4'b10; end 2'b01: begin code_loc = d1; sel = 4'b10; end
2'b10: begin code_loc = d2; sel = 4'b01; end 2'b10: begin code_loc = d2; sel = 4'b01; end
endcase endcase
end
end end
always @(*) always @(*)
begin begin
if(isEnable)
begin
case (code_loc) case (code_loc)
4'd0: codeout<=7'b1111110; 4'd0: codeout<=7'b1111110;
4'd1: codeout<=7'b0110000; 4'd1: codeout<=7'b0110000;
@ -44,6 +54,9 @@ begin
4'd9: codeout<=7'b1111011; 4'd9: codeout<=7'b1111011;
default: codeout<=7'bx; default: codeout<=7'bx;
endcase endcase
end
else
codeout=7'b0;
end end
endmodule endmodule