2012年10月16日 星期二

a 1MHz clock, and you want to toggle the led once per secon


reg [31:0] count;
reg        led_state;
wire count_max = 32'd1_000_000;


assign count_nxt = (count >= count_max) ? 32'd0 : count + 32'd1;
assign led_state_nxt = (count == count_max) ? ~led_state : led_state;

always @(posedge clk)
begin
    count <= count_nxt;
    led_state <= led_state_nxt;
end

沒有留言:

張貼留言

邊緣快篩與生成式 AI 智慧環境哨兵(Edge-Cloud AI EnvSentinel)

邊緣快篩與生成式 AI 智慧環境哨兵(Edge-Cloud AI EnvSentinel) 這套系統結合了 Wokwi ESP32 遙測 、 MQTT 傳輸 、 本地 LightGBM 異常快篩 、 SQLite 歷史存檔 、 Gemini 生成式 AI 診斷 與 Telegr...