DE2-115 開發 以 4 TO 10 Decoder 74145 為例
module x74145_4x10_deocder(SW, LEDR, LEDG , CLOCK_50 ,KEY ,HEX0 ,HEX1 ,HEX2,HEX3,HEX4 ,HEX5 ,HEX6,HEX7, GPIO );
input [17:0] SW; // toggle switches
input [7:0] KEY; // Push bottom
input CLOCK_50; //Clock 27MHz , 50Mhz
output [17:0] LEDR; // red LEDS
output [8:0] LEDG; // green LEDs
output [6:0] HEX0,HEX1,HEX2,HEX3; //7-segment display
output [6:0] HEX4,HEX5,HEX6,HEX7; //7-segment display
inout [35:0] GPIO;
assign HEX0=7'b111_1111;
assign HEX1=7'b111_1111;
assign HEX2=7'b111_1111;
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;
//decoder2to4_Behavioral (i, d) ;
decoder4to10_Behavioral(SW[3:0],LEDR[9:0]);
endmodule
//Behavioral Modeling
module decoder4to10_Behavioral (i, d) ;
input [3:0]i;
output [9:0]d;
reg [9:0] d;
always @ (i )
case (i)
0: d = 10'b11_1111_1110;
1: d = 10'b11_1111_1101;
2: d = 10'b11_1111_1011;
3: d = 10'b11_1111_0111;
4: d = 10'b11_1110_1111;
5: d = 10'b11_1101_1111;
6: d = 10'b11_1011_1111;
7: d = 10'b11_0111_1111;
8: d = 10'b10_1111_1111;
9: d = 10'b01_1111_1111;
default d = 10'b11_1111_1111;
endcase
endmodule
input [17:0] SW; // toggle switches
input [7:0] KEY; // Push bottom
input CLOCK_50; //Clock 27MHz , 50Mhz
output [17:0] LEDR; // red LEDS
output [8:0] LEDG; // green LEDs
output [6:0] HEX0,HEX1,HEX2,HEX3; //7-segment display
output [6:0] HEX4,HEX5,HEX6,HEX7; //7-segment display
inout [35:0] GPIO;
assign HEX0=7'b111_1111;
assign HEX1=7'b111_1111;
assign HEX2=7'b111_1111;
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;
//decoder2to4_Behavioral (i, d) ;
decoder4to10_Behavioral(SW[3:0],LEDR[9:0]);
endmodule
//Behavioral Modeling
module decoder4to10_Behavioral (i, d) ;
input [3:0]i;
output [9:0]d;
reg [9:0] d;
always @ (i )
case (i)
0: d = 10'b11_1111_1110;
1: d = 10'b11_1111_1101;
2: d = 10'b11_1111_1011;
3: d = 10'b11_1111_0111;
4: d = 10'b11_1110_1111;
5: d = 10'b11_1101_1111;
6: d = 10'b11_1011_1111;
7: d = 10'b11_0111_1111;
8: d = 10'b10_1111_1111;
9: d = 10'b01_1111_1111;
default d = 10'b11_1111_1111;
endcase
endmodule
沒有留言:
張貼留言