修改 2x1 MUX 成為8組 2x1 MUX
並送至2個7段顯示器上顯示結果
並送至2個7段顯示器上顯示結果
並下載到DE2-70 板子
¡Input x SW[0-7]
¡Input y SW[8-15]
¡Input SW17 select X or Y
¡Output LEDG0-7
module mux8_2x1disp
(SW,LEDR,LEDG,HEX0,HEX1,HEX2,HEX3,HEX4,HEX5,HEX6,HEX7);
input [17:0] SW;
output [17:0] LEDR;
output [7:0] LEDG;
output [6:0]
HEX0,HEX1,HEX2,HEX3,HEX4,HEX5,HEX6,HEX7;
assign HEX2=7'b111_1111; //off 7-segment Display
assign HEX3=7'b111_1111;
assign HEX4=7'b111_1111;
assign HEX5=7'b111_1111;
assign HEX6=7'b111_1111;
assign HEX7=7'b111_1111;
wire [7:0]T1;
mux8_2x1
c 0 (SW[16],SW[7:0],SW[15:8],T1);
assign LEDR[7:0] = T1;
hex_7seg c1(T1[3:0],HEX0);
hex_7seg c2(T1[7:4],HEX1);
endmodule
//===============================
module mux8_2x1(sel,a,b,z);
parameter
WIDTH=8;
input
[WIDTH-1:0] a,b;
output
[WIDTH-1:0]z;
input sel;
assign z =
sel ? a : b;
endmodule
//===============================
module hex_7seg (hex,seg_out);
input [3:0] hex;
output reg [6:0] seg_out;
always@ (hex)
begin
case (hex)
// gfe_dcba 7-segment
4'b0000 : seg_out = 7'b100_0000;
4'b0001 : seg_out = 7'b111_1001;
4'b0010 : seg_out = 7'b010_0100;
4'b0011 : seg_out = 7'b011_0000;
4'b0100 : seg_out = 7'b001_1001;
4'b0101 : seg_out = 7'b001_0010;
4'b0110 : seg_out = 7'b000_0010;
4'b0111 : seg_out = 7'b111_1000;
4'b1000 : seg_out = 7'b000_0000;
4'b1001 : seg_out = 7'b001_0000;
4'b1010 : seg_out = 7'b000_1000;
4'b1011 : seg_out = 7'b000_0011;
4'b1100 : seg_out = 7'b100_0110;
4'b1101 : seg_out = 7'b010_0001;
4'b1110 : seg_out = 7'b000_0110;
default : seg_out = 7'b000_1110;
endcase
end
endmodule
//===============================
/*
4'b0001 : seg = 8'b11111001; //1 = F9H
4'b0010 : seg = 8'b10100100; //2 = A4H
4'b0011 : seg = 8'b10110000; //3 = B0H
4'b0100 : seg = 8'b10011001; //4 = 99H
4'b0101 : seg = 8'b10010010; //5 = 92H
4'b0110 : seg = 8'b10000010; //6 = 82H
4'b0111 : seg = 8'b11111000; //7 = F8H
4'b1000 : seg = 8'b10000000; //8 = 80H
4'b1001 : seg = 8'b10010000; //9 = 90H
4'b1010 : seg = 8'b10001000; //A = 88H
4'b1011 : seg = 8'b10000011; //b = 83H
4'b1100 : seg = 8'b11000110; //C = C6H
4'b1101 : seg = 8'b10100001; //d = A1H
4'b1110 : seg = 8'b10000110; //E = 86H
4'b1111 : seg = 8'b10001110; //F = 8EH
default : seg = 8'b11000000; //0 = C0H */
4'b0010 : seg = 8'b10100100; //2 = A4H
4'b0011 : seg = 8'b10110000; //3 = B0H
4'b0100 : seg = 8'b10011001; //4 = 99H
4'b0101 : seg = 8'b10010010; //5 = 92H
4'b0110 : seg = 8'b10000010; //6 = 82H
4'b0111 : seg = 8'b11111000; //7 = F8H
4'b1000 : seg = 8'b10000000; //8 = 80H
4'b1001 : seg = 8'b10010000; //9 = 90H
4'b1010 : seg = 8'b10001000; //A = 88H
4'b1011 : seg = 8'b10000011; //b = 83H
4'b1100 : seg = 8'b11000110; //C = C6H
4'b1101 : seg = 8'b10100001; //d = A1H
4'b1110 : seg = 8'b10000110; //E = 86H
4'b1111 : seg = 8'b10001110; //F = 8EH
default : seg = 8'b11000000; //0 = C0H */
沒有留言:
張貼留言