請問各位,小弟有一題是做用六顆七段顯示器顯示000000~999999 然後從最暗到最亮,6個0是最暗,逐漸亮到6個9,用四顆DATA SW去控制0000~1001現在問題是要如何配置腳位?? 以下是編譯後的程式(無誤) module example(clk, rst, sw, seg1, seg2, seg3, seg4, seg5, seg6); input clk, rst; //If clk = 1MHz, 1us input [ 3: 0] sw; output [ 7: 0] seg1, seg2, seg3, seg4, seg5, seg6; wire [ 7: 0] seg1, seg2, seg3, seg4, seg5, seg6; reg [31: 0] lightcnt, darkcnt; always @(sw) case(sw) 4'b0000: begin lightcnt = 32'd100000; //100ms = 1us x 100000 darkcnt = 32'd500000; //500ms = 1us x 500000 end 4'b0001: begin lightcnt = 32'd150000; //150ms darkcnt = 32'd450000; //450ms end 4'b0010: begin lightcnt = 32'd200000; //200ms darkcnt = 32'd400000; //400ms end 4'b0011: begin lightcnt = 32'd250000; //250ms darkcnt = 32'd350000; //350ms end 4'b0100: begin lightcnt = 32'd300000; //300ms darkcnt = 32'd300000; //300ms end 4'b0101: begin lightcnt = 32'd350000; //350ms darkcnt = 32'd250000; //250ms end 4'b0110: begin lightcnt = 32'd400000; //400ms darkcnt = 32'd200000; //200ms end 4'b0111: begin lightcnt = 32'd450000; //450ms darkcnt = 32'd150000; //150ms end 4'b1000: begin lightcnt = 32'd500000; //500ms darkcnt = 32'd100000; //100ms end 4'b1001: begin lightcnt = 32'd550000; //550ms darkcnt = 32'd50000; //50ms end endcase timer timer(clk, rst, lightcnt, darkcnt, out); wire [ 7: 0] seg; sevenseg_case sevenseg_case(sw,seg); assign seg1 = out ? seg : 8'h0, seg2 = out ? seg : 8'h0, seg3 = out ? seg : 8'h0, seg4 = out ? seg : 8'h0, seg5 = out ? seg : 8'h0, seg6 = out ? seg : 8'h0; endmodule module timer(clk, rst, lightcnt, darkcnt, out); input clk, rst; input [31: 0] lightcnt, darkcnt; output out; reg out; reg [31: 0] cnt; always @(posedge clk) if(rst) begin cnt <=#1 32'h0; out <=#1 1'b0; end else if( out & cnt == lightcnt | ~out & cnt == darkcnt) begin cnt <=#1 32'h0; out <=#1 ~out; end else cnt <=#1 cnt + 32'h1; endmodule 我是用MAX+plus II 10.2 BASELINE這套軟體,Device是EPF10K10TC144-4 |