From cb0be9e2039569ee7d18657e8f675d1f8369b407 Mon Sep 17 00:00:00 2001 From: Flavian Kaufmann Date: Tue, 21 May 2024 13:50:28 +0200 Subject: restructured project --- rtl/src/io.v | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 rtl/src/io.v (limited to 'rtl/src/io.v') diff --git a/rtl/src/io.v b/rtl/src/io.v new file mode 100644 index 0000000..f53062b --- /dev/null +++ b/rtl/src/io.v @@ -0,0 +1,30 @@ +module io ( + input clk, + input rstn, + + input we, + input [31:0] addr, + input [31:0] wd, + + output reg [31:0] rd, + + input [31:0] io_in, + output reg [31:0] io_out +); + +`include "include/consts.vh" + +always @ (posedge clk or negedge rstn) begin + if (!rstn) begin + io_out <= 32'b0; + end else if (we && addr == 32'h0000_0004) begin + io_out <= wd; + end +end + +always @ (posedge clk) begin + if (addr == 32'h0000_0000) rd <= io_in; + else if (addr == 32'h0000_0004) rd <= io_out; + else rd <= 32'b0; +end +endmodule \ No newline at end of file -- cgit v1.2.3