Примеры кода для A-C4E6E10.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

80 lines
1.5 KiB

module seg7x8_dp(
input [31:0]num,
input [7:0] dp,
input CLK,
output [7:0] HEX,
output [0:7] HEX_S
);
reg y;
reg [31:0] i;
always @(posedge CLK)
begin
i<=i+1;
if (i == 10_000)
begin
y <= 1;
i <= 0;
end
else y <= 0;
end
reg [6:0] h;
reg [3:0] n;
always @(*)
begin
case (n) //ABCD_EFG
4'h0 : h = 7'b1111_110;
4'h1 : h = 7'b0110_000;
4'h2 : h = 7'b1101_101;
4'h3 : h = 7'b1111_001;
4'h4 : h = 7'b0110_011;
4'h5 : h = 7'b1011_011;
4'h6 : h = 7'b1011_111;
4'h7 : h = 7'b1110_000;
4'h8 : h = 7'b1111_111;
4'h9 : h = 7'b1111_011;
4'hA : h = 7'b1110_111;
4'hB : h = 7'b0011_111;
4'hC : h = 7'b1001_110;
4'hD : h = 7'b0111_101;
4'hE : h = 7'b1001_111;
4'hF : h = 7'b1000_111;
endcase
end
reg DP = 0;
assign HEX_S = {~h[6:0],~DP};
reg [7:0]j=8'b0000_0001;
always @(posedge y)
begin
j<=j<<1;
if (j == 8'b1000_0000) j <= 8'b0000_0001;
case (j)
8'b1000_0000 : n <= num[3:0];
8'b0100_0000 : n <= num[31:28];
8'b0010_0000 : n <= num[27:24];
8'b0001_0000 : n <= num[23:20];
8'b0000_1000 : n <= num[19:16];
8'b0000_0100 : n <= num[15:12];
8'b0000_0010 : n <= num[11:8];
8'b0000_0001 : n <= num[7:4];
endcase
case (j)
8'b1000_0000 : DP <= dp[0];
8'b0100_0000 : DP <= dp[1];
8'b0010_0000 : DP <= dp[2];
8'b0001_0000 : DP <= dp[3];
8'b0000_1000 : DP <= dp[4];
8'b0000_0100 : DP <= dp[5];
8'b0000_0010 : DP <= dp[6];
8'b0000_0001 : DP <= dp[7];
endcase
end
assign HEX = ~ j;
endmodule