//////////////////////////////////////////////////////////////////////////////// // // Filename: sim/rtl/memdev.v // {{{ // Project: 10Gb Ethernet switch // // Purpose: This file is really simple: it creates an on-chip memory, // accessible via the wishbone bus, that can be used in this // project. The memory has single cycle pipeline access, although the // memory pipeline here still costs a cycle and there may be other cycles // lost between the ZipCPU (or whatever is the master of the bus) and this, // thus costing more cycles in access. Either way, operations can be // pipelined for single cycle access on subsequent transactions. // // // Creator: Dan Gisselquist, Ph.D. // Gisselquist Technology, LLC // //////////////////////////////////////////////////////////////////////////////// // }}} // Copyright (C) 2023, Gisselquist Technology, LLC // {{{ // This file is part of the ETH10G project. // // The ETH10G project contains free software and gateware, licensed under the // Apache License, Version 2.0 (the "License"). You may not use this project, // or this file, except in compliance with the License. You may obtain a copy // of the License at // }}} // http://www.apache.org/licenses/LICENSE-2.0 // {{{ // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, WITHOUT // WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the // License for the specific language governing permissions and limitations // under the License. // //////////////////////////////////////////////////////////////////////////////// // `default_nettype none // }}} module memdev #( // {{{ parameter LGMEMSZ=15, DW=32, EXTRACLOCK= 1, parameter HEXFILE="", parameter [0:0] OPT_ROM = 1'b0, localparam AW = LGMEMSZ - $clog2(DW/8) // }}} ) ( // {{{ input wire i_clk, i_reset, input wire i_wb_cyc, i_wb_stb, i_wb_we, input wire [(AW-1):0] i_wb_addr, input wire [(DW-1):0] i_wb_data, input wire [(DW/8-1):0] i_wb_sel, output wire o_wb_stall, output reg o_wb_ack, output reg [(DW-1):0] o_wb_data // }}} ); // Local declarations // {{{ wire w_wstb, w_stb; wire [(DW-1):0] w_data; wire [(AW-1):0] w_addr; wire [(DW/8-1):0] w_sel; reg [(DW-1):0] mem [0:((1< 0) assert(o_wb_ack); always @(posedge i_clk) assert(f_outstanding <= 1); always @(posedge i_clk) if ((f_past_valid)&&(!i_reset)&&(i_wb_cyc)&&($past(i_wb_stb))) assert(f_outstanding == 1); end endgenerate always @(*) assert(!o_wb_stall); assign f_addr = $anyconst; initial assume(mem[f_addr] == f_data); generate if (!OPT_ROM) begin : F_MATCH_WRITES integer ik; always @(posedge i_clk) if (w_wstb && f_addr == w_addr) for(ik=0; ik < DW/8; ik=ik+1) if (w_sel[ik]) f_data[ik * 8 +: 8] <= w_data[ik*8 +: 8]; end endgenerate always @(*) assert(mem[f_addr] == f_data); always @(posedge i_clk) if ((f_past_valid)&&(OPT_ROM)) assert($stable(f_data)); `endif // }}} endmodule