这算是第二个硬件试验了吧
很简单的代码
一个按键驱动8个LED 的亮灭
按键按下为低电平 LED高电平点亮
(附件为一个LED 流水灯实例和一个数码管显示实例)
引脚分配如下
# Copyright (C) 1991-2007 Altera Corporation
# Your use of Altera Corporation's design tools, logic functions
# and other software and tools, and its AMPP partner logic
# functions, and any output files from any of the foregoing
# (including device programming or simulation files), and any
# associated documentation or information are expressly subject
# to the terms and conditions of the Altera Program License
# Subscription Agreement, Altera MegaCore Function License
# Agreement, or other applicable license agreement, including,
# without limitation, that your use is for the sole purpose of
# programming logic devices manufactured by Altera and sold by
# Altera or its authorized distributors. Please refer to the
# applicable agreement for further details.
# The default values for assignments are stored in the file
# KeyToLed_assignment_defaults.qdf
# If this file doesn't exist, and for assignments not listed, see file
# assignment_defaults.qdf
# Altera recommends that you do not modify this file. This
# file is updated automatically by the Quartus II software
# and any changes you make may be lost or overwritten.
set_global_assignment -name FAMILY "Cyclone II"
set_global_assignment -name DEVICE EP2C5T144C8
set_global_assignment -name TOP_LEVEL_ENTITY KeyToLED
set_global_assignment -name ORIGINAL_QUARTUS_VERSION 7.2
set_global_assignment -name PROJECT_CREATION_TIME_DATE "15:59:45 OCTOBER 18, 2009"
set_global_assignment -name LAST_QUARTUS_VERSION 11.0
set_global_assignment -name USE_GENERATED_PHYSICAL_CONSTRAINTS OFF -section_id eda_palace
set_global_assignment -name CYCLONEII_OPTIMIZATION_TECHNIQUE AREA
set_global_assignment -name PARTITION_NETLIST_TYPE SOURCE -section_id Top
set_global_assignment -name PARTITION_COLOR 2147039 -section_id Top
set_global_assignment -name LL_ROOT_REGION ON -section_id "Root Region"
set_global_assignment -name LL_MEMBER_STATE LOCKED -section_id "Root Region"
set_location_assignment PIN_25 -to key[0]
set_location_assignment PIN_24 -to key[1]
set_location_assignment PIN_9 -to key[2]
set_location_assignment PIN_8 -to key[3]
set_location_assignment PIN_27 -to LED[0]
set_location_assignment PIN_26 -to LED[1]
set_location_assignment PIN_7 -to LED[2]
set_location_assignment PIN_4 -to LED[3]
set_location_assignment PIN_3 -to LED[4]
set_location_assignment PIN_144 -to LED[5]
set_location_assignment PIN_143 -to LED[6]
set_location_assignment PIN_142 -to LED[7]
set_global_assignment -name VERILOG_FILE RTL/KeyToLED.v
set_instance_assignment -name PARTITION_HIERARCHY root_partition -to | -section_id Top
set_global_assignment -name PARTITION_FITTER_PRESERVATION_LEVEL PLACEMENT_AND_ROUTING -section_id Top
set_global_assignment -name STRATIX_DEVICE_IO_STANDARD "3.3-V LVTTL"
verilog源代码如下
module KeyToLED(
input [3:0] key ,
output wire [7:0] LED
);
// key 0 ctrl LED 0-7
// when key is pressed , key input low level, else key input high level
assign LED = ~{ 8{key[0]}} ; //key value display in beep
endmodule
这里主要巧的是拼接符号{}的妙用 来完成对LED的驱动
全编译
下载代码到fpga
默认8个led全不亮
按下按键0后 8个led全部点亮
sead_cn_562752139 2015-2-25 10:46
用户1550903 2015-2-10 09:46
用户421074 2013-9-14 14:43
谢谢分享!