本帖最后由 jlgcumt 于 2010-5-27 15:46 编辑
module sw_led(clk, rst, sw0, sw1, sw2, sw3, led0, led1, led2, led3, led4,
led5, led6, led7);
input clk;
input rst;
input sw0;
input sw1;
input sw2;
input sw3;
output led0;
output led1;
output led2;
output led3;
output led4;
output led5;
output led6;
output led7;
wire led0;
wire led1;
wire led2;
wire led3;
wire led4;
wire led5;
wire led6;
wire led7;
wire [3 :0] sw;
reg [7 :0] led;
assign sw = {sw0,sw1,sw2,sw3};
assign {led0,led1,led2,led3,led4,led5,led6,led7} = led;
always @ ( posedge clk or negedge rst)
begin
if(!rst)
led<='b0;
else
case ( sw )
4'b0001: led <= 8'b0000_0001;
4'b0010: led <= 8'b0000_0010;
4'b0100: led <= 8'b0000_0100;
4'b1000: led <= 8'b0000_1000;
4'b0011: led <= 8'b0001_0000;
4'b0110: led <= 8'b0010_0000;
4'b1100: led <= 8'b0100_0000;
4'b1001: led <= 8'b1000_0000;
default: led <= 8'b0000_0000;
endcase
end
endmodule
小弟问一下那个CLK是从哪得到的,是从内部得到还是从配置是连一个外部引脚,引脚上加一个晶振,一般怎么处理这个CLK |