Zynq學習筆記(1)

Craftor發表於2014-11-23

做硬體的第一個例項,一般當然是LED點燈啦~

 

硬體:ZedBoard

軟體:ISE 14.7

 

1、新建工程

image

2、選擇平臺

image

3、新建完成後,輸入如下程式碼:

 

`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
// Company: 
// Engineer: 
// 
// Create Date:    16:49:10 11/23/2014 
// Design Name: 
// Module Name:    main 
// Project Name: 
// Target Devices: 
// Tool versions: 
// Description: 
//
// Dependencies: 
//
// Revision: 
// Revision 0.01 - File Created
// Additional Comments: 
//
//////////////////////////////////////////////////////////////////////////////////
module main(

	input clk,
	output reg [7:0] led = 8'h01

    );

reg[31:0] cnt = 0;
reg clk_buf = 0;
reg direction = 0;

always@(posedge clk) begin
	if (cnt==32'd10000000) begin
		clk_buf <= !clk_buf;
		cnt <= 0;
	end
	else begin
		cnt <= cnt + 1;
	end
end

always@(posedge clk_buf) begin

	// direction control
	if (led==8'h80) begin
		direction = 1'b1;
	end else if (led==8'h01) begin
		direction = 1'b0;
	end	

	// shift
	if (direction==1'b0) begin
		led <= {led[6:0], 1'b0}; // shift left
	end	else if (direction==1'b1) begin
		led <= {1'b0,led[7:1]};  // shift right
	end

end

endmodule

4、新增如下的UCF檔案:

# "LD0"
NET "led[0]" LOC = T22;
NET "led[0]" IOSTANDARD = LVCMOS33;
# "LD1"
NET "led[1]" LOC = T21;
NET "led[1]" IOSTANDARD = LVCMOS33;
# "LD2"
NET "led[2]" LOC = U22;
NET "led[2]" IOSTANDARD = LVCMOS33;
# "LD3"
NET "led[3]" LOC = U21;
NET "led[3]" IOSTANDARD = LVCMOS33;
# "LD4"
NET "led[4]" LOC = V22;
NET "led[4]" IOSTANDARD = LVCMOS33;
# "LD5"
NET "led[5]" LOC = W22;
NET "led[5]" IOSTANDARD = LVCMOS33;
# "LD6"
NET "led[6]" LOC = U19;
NET "led[6]" IOSTANDARD = LVCMOS33;
# "LD7"
NET "led[7]" LOC = U14;
NET "led[7]" IOSTANDARD = LVCMOS33;
# "GCLK"
NET "clk" LOC = Y9;
NET "clk" IOSTANDARD = LVCMOS33;

5、編譯,下載

image

相關文章