aboutsummaryrefslogtreecommitdiffstats
path: root/techlibs
diff options
context:
space:
mode:
authorJim Lawson <ucbjrl@berkeley.edu>2018-09-17 14:31:57 -0700
committerJim Lawson <ucbjrl@berkeley.edu>2018-09-17 14:31:57 -0700
commit6a809a1bb15327dfa0134b872455d47b0ebef73c (patch)
tree1f65cca24d5309f79b19e399210d5545d2010e3c /techlibs
parent036e3f9c1b62f42812cd3bdd933af7d6a8e2209c (diff)
parent592a82c0ad8beb6de023aa2a131aab6472f949e8 (diff)
downloadyosys-6a809a1bb15327dfa0134b872455d47b0ebef73c.tar.gz
yosys-6a809a1bb15327dfa0134b872455d47b0ebef73c.tar.bz2
yosys-6a809a1bb15327dfa0134b872455d47b0ebef73c.zip
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'techlibs')
-rw-r--r--techlibs/ice40/cells_sim.v39
1 files changed, 30 insertions, 9 deletions
diff --git a/techlibs/ice40/cells_sim.v b/techlibs/ice40/cells_sim.v
index 9f73aeb07..e0a07af32 100644
--- a/techlibs/ice40/cells_sim.v
+++ b/techlibs/ice40/cells_sim.v
@@ -920,19 +920,40 @@ parameter A_SIGNED = 1'b0;
parameter B_SIGNED = 1'b0;
endmodule
-(* blackbox *)
-module SB_SPRAM256KA(
+module SB_SPRAM256KA (
input [13:0] ADDRESS,
input [15:0] DATAIN,
input [3:0] MASKWREN,
- input WREN,
- input CHIPSELECT,
- input CLOCK,
- input STANDBY,
- input SLEEP,
- input POWEROFF,
- output [15:0] DATAOUT
+ input WREN, CHIPSELECT, CLOCK, STANDBY, SLEEP, POWEROFF,
+ output reg [15:0] DATAOUT
);
+`ifndef BLACKBOX
+ reg [15:0] mem [0:16383];
+ wire off = SLEEP || !POWEROFF;
+ integer i;
+
+ always @(negedge POWEROFF) begin
+ for (i = 0; i <= 16383; i = i+1)
+ mem[i] = 'bx;
+ end
+
+ always @(posedge CLOCK, posedge off) begin
+ if (off) begin
+ DATAOUT <= 0;
+ end else
+ if (CHIPSELECT && !STANDBY && !WREN) begin
+ DATAOUT <= mem[ADDRESS];
+ end else begin
+ if (CHIPSELECT && !STANDBY && WREN) begin
+ if (MASKWREN[0]) mem[ADDRESS][ 3: 0] = DATAIN[ 3: 0];
+ if (MASKWREN[1]) mem[ADDRESS][ 7: 4] = DATAIN[ 7: 4];
+ if (MASKWREN[2]) mem[ADDRESS][11: 8] = DATAIN[11: 8];
+ if (MASKWREN[3]) mem[ADDRESS][15:12] = DATAIN[15:12];
+ end
+ DATAOUT <= 'bx;
+ end
+ end
+`endif
endmodule
(* blackbox *)