Main Void

@voidmain

I'm a newbie at coding..

Joined on Mar 8, 2025

  • // 腳位定義(使用 L/R 命名更直觀) #define L_SPEED 3 // D3:左馬達速度(原 ENA) #define R_SPEED 11 // D11:右馬達速度(原 ENB) #define L_IN1 5 // D5:左馬達 IN1 #define L_IN2 6 // D6:左馬達 IN2 #define R_IN1 9 // D9:右馬達 IN3 #define R_IN2 10 // D10:右馬達 IN4 char command; int speedValue = 150; // 初始速度值(範圍 0~255)
     Like  Bookmark
  • module SimpleGPU ( input [5:0] opcode, // 操作碼 input [31:0] A, B, // 輸入數據 output [31:0] Result, // 計算結果 output [31:0] MemDataOut // 記憶體讀取數據 ); wire ALUOp, MemRead, MemWrite, MemToReg; wire [31:0] ALUResult, MemoryData; ​​​​// 實例化控制單元
     Like  Bookmark
  • 當然可以,這是整理好的一鍵複製版文章: Verilog HDL 中的資料流模型(Dataflow)與行為模型(Behavioral)比較 在 Verilog HDL 中,硬體描述可以透過多種方式進行建模,其中最常見的兩種是: 資料流模型(Dataflow Modeling) 行為模型(Behavioral Modeling) 這兩種模型各有其特點與適用情境,以下針對兩者進行詳細比較與範例說明。
     Like  Bookmark
  • /* D 锁存器(D Latch)Verilog */ module DLatch ( input wire en, // 使能信号 input wire d, output reg q ); always @(*) begin if (en) q = d;
     Like  Bookmark
  • /* D 触发器(D Flip-Flop) Verilog */ module DFF ( input wire clk, input wire rst_n, // 低电平复位 input wire d, output reg q ); always @(posedge clk or negedge rst_n) begin if (!rst_n)
     Like  Bookmark
  • // Verilog 代碼:Mars Rover 走 500 米 module mars_rover( input wire clk, // 時鐘信號,每秒觸發一次 input wire reset, // 重置信號,將 Rover 設為初始狀態 input wire FS, // 前方感測器 (1 = 偵測到障礙物, 0 = 無障礙物) input wire LS, // 左側感測器 (1 = 偵測到障礙物, 0 = 無障礙物) input wire RS, // 右側感測器 (1 = 偵測到障礙物, 0 = 無障礙物) output reg MF, // 前進 (1 = 前進, 0 = 停止) output reg TL, // 左轉 (1 = 左轉, 0 = 不左轉)
     Like  Bookmark
  • module Generator_Test ( input clk, // 時鐘信號 input rst_n, // 重置信號,低有效 input [7:0] voltage_in, // 輸入電壓(0~255) input [7:0] current_in, // 輸入電流(0~255) output reg [7:0] voltage_out, // 測試後的電壓 output reg [7:0] current_out, // 測試後的電流 output reg voltage_alarm, // 電壓警報 output reg current_alarm, // 電流警報 output reg test_active // 測試啟動標誌
     Like  Bookmark
  • module abs_system ( input wire [3:0] wheel_speed_left, // 左車輪速度(4位元,範圍0-15) input wire [3:0] wheel_speed_right, // 右車輪速度(4位元,範圍0-15) input wire sensor_trigger, // 感應器觸發信號(1位元) output wire abs_active // ABS 系統啟動信號 ); ​​​​// 使用 NAND 和 NOT 實現 XOR(比較車輪速率差異) ​​​​wire speed_difference; ​​​​wire nand_1, nand_2, nand_3, nand_4, xor_temp;
     Like  Bookmark
  • // D Latch 模組 // 用於保存警報狀態 module d_latch ( input wire D, // D 輸入信號 input wire enable, // 使能信號 output reg Q // Q 輸出信號 ); ​​​​always @ (D or enable) begin ​​​​ if (enable) begin
     Like  Bookmark
  • // ===【火星無人車狀態機模組】=== module mars_rover_fsm ( input wire clk, // 時脈信號 input wire reset, // 重置信號 input wire wake_signal, // 遙控「醒來」信號(從太空人手錶發來) output reg [4:0] state // 火星無人車狀態 ); ​​​​// ===【狀態定義】=== ​​​​parameter S0 = 5'b00001; // 停止
     Like  Bookmark
  • module mars_rover_fsm ( input wire clk, // FPGA 時脈訊號 input wire reset, // 重置訊號 input wire obstacle, // 是否有障礙物 (1=有, 0=無) input wire right_blocked, // 右側是否被擋住 (1=有, 0=無) input wire left_blocked, // 左側是否被擋住 (1=有, 0=無) output reg [4:0] state // FSM 狀態變數 (One-Hot 編碼) ); ​​​​// 定義 One-Hot 狀態
     Like  Bookmark
  • module rock_paper_scissors_fsm ( input clk, // 時鐘信號 input reset, // 重置信號 input [1:0] player1_choice, // 角色1的選擇(00 = 石頭, 01 = 剪刀, 10 = 布) input [1:0] player2_choice, // 角色2的選擇(00 = 石頭, 01 = 剪刀, 10 = 布) output reg [1:0] player1_state, // 角色1狀態 output reg [1:0] player2_state, // 角色2狀態 output reg [7:0] round_counter // 回合計數器 );
     Like  Bookmark
  • module knight_rider_led ( input wire clk, // 時脈訊號 input wire rst_n, // 非同步重置訊號 (低有效) output reg [9:0] leds // 10 顆 LED 控制輸出 ); reg [3:0] position; // 當前亮燈的位置 (範圍 0~9) reg direction; // 方向 (0: 向右, 1: 向左) reg [23:0] counter; // 降頻計數器 (調整 LED 變化速度)
     Like  Bookmark
  • // 檔名:丐幫幫主選拔.java import java.util.Random; public class 丐幫幫主選拔 { ​​​​// *== 角色類別模組 ==* ​​​​static class Fighter { ​​​​ String mName; // 角色姓名 ​​​​ int mHealth; // 生命值
     Like  Bookmark
  • // 檔名:Tetsujin28.java import java.util.Scanner; public class Tetsujin28 { ​​​​// *== 機器人類別模組 ==* ​​​​static class Robot { ​​​​ private String mName; // 機器人名稱 ​​​​ private String mState; // 當前狀態
     Like  Bookmark
  • // 檔名:霹靂狂刀.java // 網中人 vs 無人座 模擬對決 public class 霹靂狂刀 { ​​​​// 定義角色類別 ​​​​static class Character { ​​​​ String mName; // 名字 ​​​​ int mHealth; // 血量 ​​​​ int mAttackPower; // 攻擊力
     Like  Bookmark
  • // 定義無人駕駛車輛的類別 class AutonomousVehicle { // 物件屬性 private String model; // 車型 private double speed; // 當前速度 (km/h) private String direction; // 方向 (e.g., "北", "南", "東", "西") ​​​​// 建構子 (Constructor) ​​​​public AutonomousVehicle(String m) { ​​​​ this.model = m; // 使用 this 指定物件屬性
     Like  Bookmark
  • // 檔名:PZ.java // === 常數與主要設定 === public class PZ { private static final int SAFE_DISTANCE = 15; // 安全距離 (單位:公分) ​​​​public static void main(String[] args) { ​​​​ PZ car = new PZ(); ​​​​ car.run(); ​​​​}
     Like  Bookmark
  • // 檔名:PZ.java public class PZ { private static final int SAFE_DISTANCE = 15; // 安全距離 (單位:公分) ​​​​public static void main(String[] args) { ​​​​ PZ car = new PZ(); ​​​​ car.run(); ​​​​}
     Like  Bookmark
  • Today 生成一個自走車 的arduino程式 當然可以!以下是一個簡單的 Arduino 程式,用於控制一輛自走車。這個程式假設您的自走車使用了兩個直流馬達和一個超聲波傳感器來進行避障。馬達由 L298N 驅動板控制,超聲波傳感器是 HC-SR04。 cpp = #define trigPin 9 #define echoPin 10 #define motorLeftForward 3
     Like  Bookmark