Signed-off-by: Michael Walle <mich...@walle.cc> --- cores/lm32/rtl/lm32_dp_ram.v | 42 +++++++++++++++++++++++++++++++++++++----- 1 files changed, 37 insertions(+), 5 deletions(-)
diff --git a/cores/lm32/rtl/lm32_dp_ram.v b/cores/lm32/rtl/lm32_dp_ram.v index bba523e..bc752b0 100644 --- a/cores/lm32/rtl/lm32_dp_ram.v +++ b/cores/lm32/rtl/lm32_dp_ram.v @@ -1,14 +1,29 @@ +///////////////////////////////////////////////////// +// Module interface +///////////////////////////////////////////////////// + module lm32_dp_ram( + // ----- Inputs ----- clk_i, rst_i, we_i, waddr_i, wdata_i, raddr_i, - rdata_o); + // ----- Outputs ----- + rdata_o +); + +///////////////////////////////////////////////////// +// Parameters +///////////////////////////////////////////////////// + +parameter data_width = 1; // Width of the data ports +parameter addr_width = 1; // Width of the address ports -parameter addr_width = 32; -parameter data_width = 8; +///////////////////////////////////////////////////// +// Inputs +///////////////////////////////////////////////////// input clk_i; input rst_i; @@ -16,14 +31,31 @@ input we_i; input [addr_width-1:0] waddr_i; input [data_width-1:0] wdata_i; input [addr_width-1:0] raddr_i; + +///////////////////////////////////////////////////// +// Outputs +///////////////////////////////////////////////////// + output [data_width-1:0] rdata_o; -reg [data_width-1:0] mem[(1<<addr_width)-1:0]; +///////////////////////////////////////////////////// +// Internal nets and registers +///////////////////////////////////////////////////// +reg [data_width-1:0] mem[(1<<addr_width)-1:0]; reg [addr_width-1:0] raddr_r; + +///////////////////////////////////////////////////// +// Combinational logic +///////////////////////////////////////////////////// + assign rdata_o = mem[raddr_r]; -always @ (posedge clk_i) +///////////////////////////////////////////////////// +// Sequential logic +///////////////////////////////////////////////////// + +always @(posedge clk_i) begin if (we_i) mem[waddr_i] <= wdata_i; -- 1.7.2.5 _______________________________________________ http://lists.milkymist.org/listinfo.cgi/devel-milkymist.org IRC: #milkymist@Freenode