简单流水灯循环左移
- 格式:docx
- 大小:13.55 KB
- 文档页数:8
简单流水灯循环左移
#include<stdio.h> #include<reg52.h>
#include<intrins.h>
#define uint unsigned int
#define uchar unsigned char
uchar temp;
void delay();
void main()
{ temp=0xfe;
P1=temp;
while(1)
{
delay();
temp=_crol_(temp,1);
P1=temp;
}
}
void delay()
{
uint x;
for(x=12000;x>0;x--);
}
`default_nettype none
module my_usb(
// Clock Input
input wire clkin, // 20MHz晶振
// Reset Button
input wire reset_n, // 低电平复位
// Push Button
input wire [8:0] key, //9个按键(9~1)。
按下为0,松开为1。
// Toggle Switch
input wire [0:3] switch, //按实验箱的位序标识,SW0在最左边。
拨向上为0,拨向下为1。
// LED
output wire [0:7] led, //LED0~3在上面一排,LED4~7在下面一排;左上角是LED0,右下角LED7
// 7-SEG Dispaly
output wire [7:0] seven,
output wire [0:3] seven_sel, //按实验箱的位序标识,DIGITAL0在最左边。
为0时点亮对应位。
// Address Bus
output wire [22:0] mem_addr, // SRAM 18 bits; Flash memory 23 bits
// Data Bus
inout wire [15:0] mem_data, // SRAM 16 bits; Flash memory 8 bits
// SRAM Interface
output wire [1:0] sram_be_n,
output wire sram_rd_n,
output wire sram_wr_n,
output wire sram_cs_n,
// Flash Memory Interface
output wire flash_oe_n,
output wire flash_we_n,
output wire flash_cs_n,
output wire flash_reset_n,
// LCD Interface
inout wire [7:0] lcd_data,
output wire lcd_cs1_n,
output wire lcd_cs2_n,
output wire lcd_di,
output wire lcd_e,
output wire lcd_reset_n, output wire lcd_rw,
// PS2 Interface
output wire ps2_clk, output wire ps2_data, output wire ps2_2_clk, output wire ps2_2_data, // RS232 Interface
input wire rxd,
output wire txd,
input wire rxd_2, output wire txd_2,
// Motor Interface output wire motor_pwm, input wire motor_sensor, // DA Interface
output wire da_a0, output wire da_a1, output wire [7:0] da_data, output wire da_ldac_n, output wire da_wr_n,
// AD Interface
output wire ad_convst_n,
output wire ad_sclk,
output wire ad_din,
input wire ad_dout,
output wire ad_rfs,
output wire ad_tfs,
// USB Interface
output wire [7:0] usb_addr,
inout wire [15:0] usb_data,
input wire usb_int,
input wire usb_rdy, //READY
output wire usb_rst_n, //RESET
output wire usb_cs_n,
output wire usb_rd_n,
output wire usb_wr_n
// 请不要改变上面的端口名称!否则不能与引脚约束匹配。
);
/************** 重要说明*****************************/ // 如果自己的设计用到下面的器件,请删除相应的赋值代码。
// 否则,不要删除这些赋值代码!!尤其是flash器件!!!
assign flash_reset_n = 1'b1;
assign flash_cs_n = 1'b1;
assign flash_oe_n = 1'b1;
// 自己设计的代码中用到LCD
时,需要删除这里的赋值语句
assign lcd_data = 8'hzz;
// 自己设计的代码中用到USB时,需要删除这里的赋值语句
//assign usb_data = 16'hzzzz;
// 自己设计的代码中用到外部SRAM时,需要删除这里的赋值语句//assign mem_data = 16'hzzzz;
//assign sram_cs_n = 1'b1;
// 自己设计的代码中用到LED指示灯时,需要删除这里的赋值语句//assign led = 8'b11111111; // 点亮所有指示灯
// 自己设计的代码中用到七段数码管时,需要删除这里的赋值语句assign seven = 8'hFF; // 数码管的每一段都亮assign seven_sel = 4'b0000; // 4个数码管同时点亮
/******************************************************/ wire reset = ~reset_n;
// 在下面添加自己的设计代码
my_usb_component my_usb_component_inst
(
.clk_0 (iCLK_50),
.coe_USB_ADDR_from_the_ISP1581 (oOTG_A),
.coe_USB_CS_N_from_the_ISP1581 (oOTG_CS_N),
.coe_USB_DATA_to_and_from_the_ISP1581 (OTG_D),
.coe_USB_INT_to_the_ISP1581 (iOTG_INT0),
.coe_USB_RDY_to_the_ISP1581 (iOTG_INT1),
.coe_USB_RD_N_from_the_ISP1581 (oOTG_OE_N),
.coe_USB_RST_N_from_the_ISP1581 (oOTG_RESET_N),
.coe_USB_WR_N_from_the_ISP1581 (oOTG_WE_N),
.coe_addr_from_the_sram_0 (oSRAM_A),
.coe_be_n_from_the_sram_0 (oSRAM_BE_N),
.coe_cs_n_from_the_sram_0 (oOTG_CS_N),
.coe_data_to_and_from_the_sram_0 (SRAM_DQ),
.coe_rd_n_from_the_sram_0 (oSRAM_OE_N), .coe_wr_n_from_the_sram_0 (oSRAM_WE_N), .out_port_from_the_led_pio (oLEDG),
.reset_n (DLY0)
);
endmodule。