/* 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)
q <= 0;
else
q <= d;
end
endmodule
// 腳位定義(使用 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)
Apr 11, 2025module 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; // 實例化控制單元
Apr 8, 2025當然可以,這是整理好的一鍵複製版文章:
Apr 8, 2025module DLatch (input wire en, // 使能信号input wire d,output reg q);always @(*) beginif (en)q = d;endendmodule
Mar 19, 2025or
By clicking below, you agree to our terms of service.
New to HackMD? Sign up