使用Quartus-II 9.1SP2 + ModelSim 6.5b-Aletra + Altera DE2-115 FPGA開發平台,設計 組合邏輯 (1 ) 為例(FPGA開發平台)
module DE2_115 (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;
// input [3:0] IN;
// output Y;
P77_gate_level( SW[3:0],LEDR[0] );
P77_dataflow (SW[3:0],LEDR[1]);
P77_BehaviorLevel(SW[3:0],LEDR[2]);
endmodule
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;
// input [3:0] IN;
// output Y;
P77_gate_level( SW[3:0],LEDR[0] );
P77_dataflow (SW[3:0],LEDR[1]);
P77_BehaviorLevel(SW[3:0],LEDR[2]);
endmodule
module P77_gate_level( IN,Y );
input [3:0] IN;
output Y;
wire W1, W2;
nand ( W1, IN[3],IN[2]);
or ( W2, IN[1],IN[0]);
or ( Y, W2, W1 );
endmodule
module P77_dataflow (IN,Y );
input [3:0] IN;
output Y;
wire W1, W2;
assign W1 = ~(IN[3]&IN[2]);
assign W2 = (IN[1]|IN[0]);
assign Y = W2|W1;
endmodule
module P77_BehaviorLevel(IN,Y );
input [3:0] IN;
output reg Y;
wire W1, W2;
always @( IN ) begin
Y = (~(IN[3]&IN[2])) | (IN[1]|IN[0]);
end
endmodule
沒有留言:
張貼留言