DE2-115 開發 以 D Filp-Folp with CLR PreSET 7474 為例(Verilog behavioral modeling )
module D_FF_wirh_clr_pset(SW, LEDR, LEDG , CLOCK_50 ,KEY,HEX0 ,HEX1 ,HEX2,HEX3 ,HEX4 ,HEX5 ,HEX6 ,HEX7 );
input [17:0] SW; // toggle switches
input [3: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,HEX4,HEX5,HEX6,HEX7 ; //7-segment display
assign HEX0=7'b111_1111; //off 7-segment Display
assign HEX1=7'b111_1111;
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;
d_flip_flop(CLOCK_50,SW[0],KEY[0],KEY[1],LEDR[0]);
endmodule
module d_flip_flop (clk, d, clr,preset, q);
input clk, d, clr,preset;
output q;
reg q;
always @(negedge clk or negedge clr or negedge preset)
begin
if (!clr)
q <= 1'b0;
else if (!preset)
q <= 1'b1;
else
q <= d;
end
endmodule
沒有留言:
張貼留言