1 # Good case 1: single port.
15 always @(posedge clk) begin
34 select -assert-count 1 t:$mem_v2
35 select -assert-count 1 t:$mem_v2 r:RD_TRANSPARENCY_MASK=1'b1 r:RD_COLLISION_X_MASK=1'b0 %i %i
39 # Good case 2: single port, exclusive.
53 always @(posedge clk) begin
71 select -assert-count 1 t:$mem_v2
72 select -assert-count 1 t:$mem_v2 r:RD_TRANSPARENCY_MASK=1'b0 r:RD_COLLISION_X_MASK=1'b1 %i %i
76 # Good case 3: proper bypass muxes.
94 always @(posedge clk) begin
101 if (we1 && wa1 == ra)
103 if (we2 && wa2 == ra)
118 select -assert-count 1 t:$mem_v2
119 select -assert-count 1 t:$mem_v2 r:RD_TRANSPARENCY_MASK=2'b11 r:RD_COLLISION_X_MASK=2'b00 %i %i
123 # Good case 4: proper bypass mux, but only one.
141 always @(posedge clk) begin
148 if (we1 && wa1 == ra)
163 select -assert-count 1 t:$mem_v2
164 select -assert-count 1 t:$mem_v2 r:RD_TRANSPARENCY_MASK=2'b01 r:RD_COLLISION_X_MASK=2'b00 %i %i
168 # Good case 5: proper bypass mux, but the other one.
186 always @(posedge clk) begin
193 if (we2 && wa2 == ra)
208 select -assert-count 1 t:$mem_v2
209 select -assert-count 1 t:$mem_v2 r:RD_TRANSPARENCY_MASK=2'b10 r:RD_COLLISION_X_MASK=2'b00 %i %i
213 # Good case 6: 'x mux.
231 always @(posedge clk) begin
238 if (we1 && wa1 == ra)
240 if (we2 && wa2 == ra)
255 select -assert-count 1 t:$mem_v2
256 select -assert-count 1 t:$mem_v2 r:RD_TRANSPARENCY_MASK=2'b10 r:RD_COLLISION_X_MASK=2'b01 %i %i
260 # Good case 7: uncollidable addresses.
276 wire [3:0] wa1 = addr;
277 wire [3:0] wa2 = addr + 1;
278 wire [3:0] ra = addr + 2;
280 always @(posedge clk) begin
300 select -assert-count 1 t:$mem_v2
301 select -assert-count 1 t:$mem_v2 r:RD_TRANSPARENCY_MASK=2'b00 r:RD_COLLISION_X_MASK=2'b11 %i %i
305 # Good case 8: uncollidable addresses, but still have soft transparency logic.
321 wire [3:0] wa1 = addr;
322 wire [3:0] wa2 = addr + 1;
323 wire [3:0] ra = addr + 2;
325 always @(posedge clk) begin
332 if (we1 && wa1 == ra)
334 if (we2 && wa2 == ra)
349 select -assert-count 1 t:$mem_v2
350 select -assert-count 1 t:$mem_v2 r:RD_TRANSPARENCY_MASK=2'b00 r:RD_COLLISION_X_MASK=2'b11 %i %i
354 # Bad case 1: broken bypass signal.
372 always @(posedge clk) begin
379 if (we1 && wa1 == ra)
381 if (we2 && wa2 == ra && we1)
394 logger -expect log "FF found, but with a mux select that doesn't seem to correspond to transparency logic" 1
396 logger -check-expected
398 select -assert-count 1 t:$mem_v2
399 select -assert-count 1 t:$mem_v2 r:RD_CLK_ENABLE=1'b0 %i
403 # Bad case 2: bad data signal.
421 always @(posedge clk) begin
428 if (we1 && wa1 == ra)
430 if (we2 && wa2 == ra)
443 logger -expect log "FF found, but with a mux data input that doesn't seem to correspond to transparency logic" 1
445 logger -check-expected
447 select -assert-count 1 t:$mem_v2
448 select -assert-count 1 t:$mem_v2 r:RD_CLK_ENABLE=1'b0 %i
452 # Bad case 3: priority mismatch.
470 always @(posedge clk) begin
477 if (we2 && wa2 == ra)
479 if (we1 && wa1 == ra)
492 logger -expect log "FF found, but transparency logic priority doesn't match write priority." 1
494 logger -check-expected
496 select -assert-count 1 t:$mem_v2
497 select -assert-count 1 t:$mem_v2 r:RD_CLK_ENABLE=1'b0 %i
501 # Good case 10: priority mismatch, but since the second value is 'x, it's still OK.
519 always @(posedge clk) begin
526 if (we2 && wa2 == ra)
528 if (we1 && wa1 == ra)
543 select -assert-count 1 t:$mem_v2
544 select -assert-count 1 t:$mem_v2 r:RD_TRANSPARENCY_MASK=2'b10 r:RD_COLLISION_X_MASK=2'b01 %i %i
548 # Good case 11: priority mismatch, but since three-way collision cannot happen, it's still OK.
563 reg [3:0] wa1, wa2, ra;
592 always @(posedge clk) begin
599 if (we2 && wa2 == ra)
601 if (we1 && wa1 == ra)
616 select -assert-count 1 t:$mem_v2
617 select -assert-count 1 t:$mem_v2 r:RD_TRANSPARENCY_MASK=2'b11 r:RD_COLLISION_X_MASK=2'b00 %i %i
621 # Bad case 4: half of the port is transparent.
639 always @(posedge clk) begin
646 if (we1 && wa1 == ra)
648 if (we2 && wa2 == ra)
661 logger -expect log "FF found, but soft transparency logic is inconsistent for port 1." 1
663 logger -check-expected
665 select -assert-count 1 t:$mem_v2
666 select -assert-count 1 t:$mem_v2 r:RD_CLK_ENABLE=1'b0 %i
670 # Good case 12: like above, but the other bits aren't changed by the port anyway.
688 always @(posedge clk) begin
692 mem[wa2][3:2] <= wd2[3:2];
695 if (we1 && wa1 == ra)
697 if (we2 && wa2 == ra)
712 select -assert-count 1 t:$mem_v2
713 select -assert-count 1 t:$mem_v2 r:RD_TRANSPARENCY_MASK=2'b11 r:RD_COLLISION_X_MASK=2'b00 %i %i
717 # Good case 13: wide read, narrow write.
727 output reg [31:0] rd,
730 reg [7:0] mem[0:255];
732 always @(posedge clk) begin
736 rd[7:0] <= mem[{addr[7:2], 2'b00}];
737 rd[15:8] <= mem[{addr[7:2], 2'b01}];
738 rd[23:16] <= mem[{addr[7:2], 2'b10}];
739 rd[31:24] <= mem[{addr[7:2], 2'b11}];
740 case ({we, addr[1:0]})
741 3'b100: rd[7:0] <= wd;
742 3'b101: rd[15:8] <= wd;
743 3'b110: rd[23:16] <= wd;
744 3'b111: rd[31:24] <= wd;
760 select -assert-count 1 t:$mem_v2
761 select -assert-count 1 t:$mem_v2 r:RD_TRANSPARENCY_MASK=4'b1111 r:RD_COLLISION_X_MASK=4'b0000 %i %i
763 select -assert-count 1 t:$mem_v2
764 select -assert-count 1 t:$mem_v2 r:RD_TRANSPARENCY_MASK=4'b1111 r:RD_COLLISION_X_MASK=4'b0000 %i %i
765 select -assert-count 1 t:$mem_v2 r:RD_WIDE_CONTINUATION=4'b1110 %i
769 # Good case 14: narrow read, wide write.
782 reg [7:0] mem[0:255];
784 always @(posedge clk) begin
786 mem[{addr[7:2], 2'b00}] <= wd[7:0];
787 mem[{addr[7:2], 2'b01}] <= wd[15:8];
788 mem[{addr[7:2], 2'b10}] <= wd[23:16];
789 mem[{addr[7:2], 2'b11}] <= wd[31:24];
793 case ({we, addr[1:0]})
794 3'b100: rd <= wd[7:0];
795 3'b101: rd <= wd[15:8];
796 3'b110: rd <= wd[23:16];
797 3'b111: rd <= wd[31:24];
813 select -assert-count 1 t:$mem_v2
814 select -assert-count 1 t:$mem_v2 r:RD_TRANSPARENCY_MASK=4'b1111 r:RD_COLLISION_X_MASK=4'b0000 %i %i
816 select -assert-count 1 t:$mem_v2
817 select -assert-count 1 t:$mem_v2 r:RD_TRANSPARENCY_MASK=4'b1111 r:RD_COLLISION_X_MASK=4'b0000 %i %i
818 select -assert-count 1 t:$mem_v2 r:WR_WIDE_CONTINUATION=4'b1110 %i
822 # Good case 15: wide read, wide write.
832 output reg [31:0] rd,
835 reg [7:0] mem[0:255];
837 always @(posedge clk) begin
839 mem[{addr[7:2], 2'b00}] <= wd[7:0];
840 mem[{addr[7:2], 2'b01}] <= wd[15:8];
841 mem[{addr[7:2], 2'b10}] <= wd[23:16];
842 mem[{addr[7:2], 2'b11}] <= wd[31:24];
845 rd[7:0] <= mem[{addr[7:2], 2'b00}];
846 rd[15:8] <= mem[{addr[7:2], 2'b01}];
847 rd[23:16] <= mem[{addr[7:2], 2'b10}];
848 rd[31:24] <= mem[{addr[7:2], 2'b11}];
864 select -assert-count 4 t:$memrd_v2
865 select -assert-count 1 t:$memrd_v2 r:TRANSPARENCY_MASK=4'b0001 r:COLLISION_X_MASK=4'b1110 %i %i
866 select -assert-count 1 t:$memrd_v2 r:TRANSPARENCY_MASK=4'b0010 r:COLLISION_X_MASK=4'b1101 %i %i
867 select -assert-count 1 t:$memrd_v2 r:TRANSPARENCY_MASK=4'b0100 r:COLLISION_X_MASK=4'b1011 %i %i
868 select -assert-count 1 t:$memrd_v2 r:TRANSPARENCY_MASK=4'b1000 r:COLLISION_X_MASK=4'b0111 %i %i
870 select -assert-count 1 t:$memrd_v2
871 select -assert-count 1 t:$memwr_v2
872 select -assert-count 1 t:$memrd_v2 r:TRANSPARENCY_MASK=1'b1 r:COLLISION_X_MASK=1'b0 %i %i