?? second_count.v
字號:
module second_count(
// Clock Input
input clkin, // 20MHz晶振
// Reset Button
input reset_n, // 低電平復(fù)位
// Push Button
input [8:0] key, //9個按鍵(9~1)。按下為0,松開為1。
// Toggle Switch
input [0:3] switch, //按實驗箱的位序標識,SW0在最左邊。撥向上為0,撥向下為1。
// LED
output [0:7] led, //LED0~3在上面一排,LED4~7在下面一排;左上角是LED0,右下角LED7
// 7-SEG Dispaly
output [7:0] seven,
output [0:3] seven_sel, //按實驗箱的位序標識,DIGITAL0在最左邊。為0時點亮對應(yīng)位。
// Address Bus
output [20:0] mem_addr, // SRAM 18 bits; Flash memory 21 bits
// Data Bus
inout [15:0] mem_data, // SRAM 16 bits; Flash memory 8 bits
// SRAM Interface
output [1:0] sram_be,
output sram_rd,
output sram_wr,
output sram_sel,
// Flash Memory Interface
output flash_oe,
output flash_we,
output flash_cs,
// LCD Interface
inout [7:0] lcd_data,
output lcd_cs1,
output lcd_cs2,
output lcd_di,
output lcd_e,
output lcd_reset,
output lcd_rw,
// PS2 Interface
output ps2_clk,
output ps2_data,
output ps2_2_clk,
output ps2_2_data,
// RS232 Interface
input rxd,
output txd,
input rxd_2,
output txd_2,
// Motor Interface
input motor_counter,
output motor_pwm,
// DA Interface
output da_a0,
output da_a1,
output [7:0] da_data,
output da_ldac_n,
output da_wr_n,
// AD Interface
output ad_convst_n,
output ad_sclk,
output ad_din,
input ad_dout,
output ad_rfs,
output ad_tfs,
// USB Interface
output [7:0] usb_addr,
inout [15:0] usb_data,
input usb_int,
input usb_rdy,
output usb_rst_n,
output usb_cs_n,
output usb_rd_n,
output usb_wr_n
);
////////////////////////////////////////////////////////////////
wire clk_enable = ~switch[0]; //撥動開關(guān)控制時鐘計數(shù)
wire [3:0] sel; //片選信號
wire clkl;
wire to_8_16;
wire [15:0] to_mux_4_1;
wire [3:0] to_decode_7;
wire reset = ~reset_n;
assign seven_sel = ~sel;
//assign led = 8'b11111111; // 點亮所有指示燈
//assign seven = 8'hFF;
//assign seven_sel = 4'b0000; // 點亮所有數(shù)碼管
// SRAM
assign mem_data = 16'hzzzz;
assign sel_sram = 1'b1;
// Flash Memory
assign flash_cs = 1'b1;
assign flash_oe = 1'b1;
// LCD
assign lcd_data = 8'hzz;
// USB
assign usb_data = 16'hzzzz;
///////////////////////////////////////////////////////////////////////
//分頻器實例化
LPM_fp LPM_fp_inst(
.clock(clkin),
.cout(clkl),
.q()
);
///////////////////////////////////////////////////////////////////////
//七段數(shù)碼顯示實例化
decode_7 decode_7_inst(
.data_out(seven),
.data_in(to_decode_7)
);
///////////////////////////////////////////////////////////////////////
//四選一選擇器實例化
mux_4_1 mux_4_1_inst(
.sel(sel),
.dataout(to_decode_7),
.datain(to_mux_4_1)
);
////////////////////////////////////////////////////////////////////////
//移位寄存器實例化
RLSifter_4 #(4) RLSifter_4_inst(
.clk(clkl),
.reset(reset),
.q(sel)
);
////////////////////////////////////////////////////////////////////////
//八位計數(shù)器實例化
count_8 count_8_inst(
.clk(clkl),
.reset(reset),
.temp(to_8_16),
.q()
);
////////////////////////////////////////////////////////////////////////
//十六位計數(shù)器實例化
count_16 count_16_inst(
.clk(to_8_16),
.reset(reset),
.enable(clk_enable),
.q(to_mux_4_1)
);
endmodule
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -