博文

目前显示的是标签为“register”的博文

How to access register in FPGA Verilog?

图片
 In Verilog, “registers” are just flip-flops you create with sequential logic and then expose/read through signals or a bus. Below is a practical cheat-sheet covering declaring , writing , reading , memory-mapped access , register files/BRAM , and best practices . 1) A register = flip-flop updated on a clock module simple_reg ( input wire clk, input wire rst_n, // active-low reset input wire we, // write enable input wire [7:0] d, output wire [7:0] q ); reg [7:0] r; // Verilog “reg” -> storage (flip-flop) assign q = r; // read: just wire it out always @(posedge clk or negedge rst_n) begin if (!rst_n) r <= 8'h00; // reset value else if (we) r <= d; // write on enable end endmodule Key rules Use non-blocking <= in sequential always @(posedge ...) blocks. Reading a register is just using its signal ( q=r ). Sys...