Unverified Commit b7ccc29f by Miodrag Milanović Committed by GitHub

Merge pull request #29 from SergeyDegtyar/master

Fix failed tests
parents 4c1b7236 5fee7bf3
...@@ -24,7 +24,7 @@ module top ...@@ -24,7 +24,7 @@ module top
SB_RAM40_4K #( SB_RAM40_4K #(
.READ_MODE(2'h1), .READ_MODE(2'h1),
.WRITE_MODE(2'h1), .WRITE_MODE(2'h1),
.INIT_FILE("init.txt") .INIT_FILE("../init.txt")
) \ram.0.0.0 ( ) \ram.0.0.0 (
.MASK(16'hxxxx), .MASK(16'hxxxx),
.RADDR({ 5'h00, addr_a }), .RADDR({ 5'h00, addr_a }),
......
...@@ -52,7 +52,7 @@ $(eval $(call template,write_firrtl_paramod,write_firrtl)) ...@@ -52,7 +52,7 @@ $(eval $(call template,write_firrtl_paramod,write_firrtl))
#write_ilang #write_ilang
$(eval $(call template,write_ilang,write_ilang write_ilang_selected)) $(eval $(call template,write_ilang,write_ilang write_ilang_selected))
$(eval $(call template,write_ilang_mem,write_ilang write_ilang_selected)) $(eval $(call template,write_ilang_mem,write_ilang_mem))
$(eval $(call template,write_ilang_mux,write_ilang write_ilang_selected)) $(eval $(call template,write_ilang_mux,write_ilang write_ilang_selected))
$(eval $(call template,write_ilang_fsm,write_ilang write_ilang_selected)) $(eval $(call template,write_ilang_fsm,write_ilang write_ilang_selected))
$(eval $(call template,write_ilang_tri,write_ilang write_ilang_selected)) $(eval $(call template,write_ilang_tri,write_ilang write_ilang_selected))
...@@ -79,8 +79,8 @@ $(eval $(call template,write_smt2_shiftx,write_smt2 write_smt2_synth write_smt2_ ...@@ -79,8 +79,8 @@ $(eval $(call template,write_smt2_shiftx,write_smt2 write_smt2_synth write_smt2_
#write_smv #write_smv
$(eval $(call template,write_smv,write_smv write_smv_synth write_smv_noproc write_smv_verbose write_smv_tpl)) $(eval $(call template,write_smv,write_smv write_smv_synth write_smv_noproc write_smv_verbose write_smv_tpl))
$(eval $(call template,write_smv_wide,write_smv write_smv_synth write_smv_noproc write_smv_verbose write_smv_tpl)) $(eval $(call template,write_smv_wide,write_smv write_smv_verbose write_smv_tpl))
$(eval $(call template,write_smv_shift,write_smv write_smv_synth write_smv_noproc write_smv_verbose write_smv_tpl)) $(eval $(call template,write_smv_shift,write_smv_shift))
$(eval $(call template,write_smv_fsm,write_smv write_smv_noproc write_smv_verbose write_smv_tpl)) $(eval $(call template,write_smv_fsm,write_smv write_smv_noproc write_smv_verbose write_smv_tpl))
$(eval $(call template,write_smv_reduce,write_smv_noproc)) $(eval $(call template,write_smv_reduce,write_smv_noproc))
$(eval $(call template,write_smv_logic,write_smv write_smv_synth write_smv_noproc write_smv_verbose write_smv_tpl)) $(eval $(call template,write_smv_logic,write_smv write_smv_synth write_smv_noproc write_smv_verbose write_smv_tpl))
......
read_verilog -sv ../top.v read_verilog -sv ../top.v
aigmap aigmap
write_aiger aiger.aiger write_aiger aiger.aiger
design -reset
read_verilog -sv ../top_clean.v
aigmap
write_aiger aiger.aiger
synth -top top synth -top top
write_verilog synth.v write_verilog synth.v
read_verilog -sv ../top.v read_verilog -sv ../top.v
aigmap aigmap
write_aiger -B aiger.aiger write_aiger -B aiger.aiger
design -reset
read_verilog -sv ../top_clean.v
aigmap
write_aiger aiger.aiger
synth -top top synth -top top
write_verilog synth.v write_verilog synth.v
read_verilog -sv ../top.v read_verilog -sv ../top.v
aigmap aigmap
write_aiger -I aiger.aiger write_aiger -I aiger.aiger
design -reset
read_verilog -sv ../top_clean.v
aigmap
write_aiger aiger.aiger
synth -top top synth -top top
write_verilog synth.v write_verilog synth.v
read_verilog -sv ../top.v read_verilog -sv ../top.v
aigmap aigmap
write_aiger -O aiger.aiger write_aiger -O aiger.aiger
design -reset
read_verilog -sv ../top_clean.v
aigmap
write_aiger aiger.aiger
synth -top top synth -top top
write_verilog synth.v write_verilog synth.v
read_verilog -sv ../top.v read_verilog -sv ../top.v
aigmap aigmap
write_aiger -ascii aiger.aiger write_aiger -ascii aiger.aiger
design -reset
read_verilog -sv ../top_clean.v
aigmap
write_aiger aiger.aiger
synth -top top synth -top top
write_verilog synth.v write_verilog synth.v
read_verilog -sv ../top.v read_verilog -sv ../top.v
aigmap aigmap
write_aiger -map a.map aiger.aiger write_aiger -map a.map aiger.aiger
design -reset
read_verilog -sv ../top_clean.v
aigmap
write_aiger aiger.aiger
synth -top top synth -top top
write_verilog synth.v write_verilog synth.v
...@@ -2,4 +2,9 @@ read_verilog -sv ../top_clean.v ...@@ -2,4 +2,9 @@ read_verilog -sv ../top_clean.v
synth -top top synth -top top
aigmap aigmap
write_aiger -miter aiger.aiger write_aiger -miter aiger.aiger
design -reset
read_verilog -sv ../top_clean.v
aigmap
write_aiger aiger.aiger
synth -top top
write_verilog synth.v write_verilog synth.v
read_verilog -sv ../top.v read_verilog -sv ../top.v
aigmap aigmap
write_aiger -symbols aiger.aiger write_aiger -symbols aiger.aiger
design -reset
read_verilog -sv ../top_clean.v
aigmap
write_aiger aiger.aiger
synth -top top synth -top top
write_verilog synth.v write_verilog synth.v
read_verilog -sv ../top.v read_verilog -sv ../top.v
aigmap aigmap
write_aiger -vmap a.map aiger.aiger write_aiger -vmap a.map aiger.aiger
design -reset
read_verilog -sv ../top_clean.v
aigmap
write_aiger aiger.aiger
synth -top top synth -top top
write_verilog synth.v write_verilog synth.v
...@@ -4,4 +4,5 @@ proc ...@@ -4,4 +4,5 @@ proc
dump -o file.il dump -o file.il
write_ilang ilang.ilang write_ilang ilang.ilang
dump -n -o file1.il dump -n -o file1.il
synth
write_verilog synth.v write_verilog synth.v
read_verilog ../top.v
proc
memory
dump -o file.il
write_ilang ilang.ilang
dump -n -o file1.il
write_verilog synth.v
read_verilog ../top.v read_verilog ../top.v
proc proc
memory
write_smt2 smt2.smt2 write_smt2 smt2.smt2
write_verilog synth.v write_verilog synth.v
read_verilog ../top.v read_verilog ../top.v
proc proc
memory
write_smt2 -bv smt2.smt2 write_smt2 -bv smt2.smt2
write_verilog synth.v write_verilog synth.v
read_verilog ../top.v read_verilog ../top.v
proc proc
memory
write_smt2 -mem smt2.smt2 write_smt2 -mem smt2.smt2
write_verilog synth.v write_verilog synth.v
read_verilog ../top.v read_verilog ../top.v
memory_collect
proc proc
memory
write_smt2 -mem smt2.smt2 write_smt2 -mem smt2.smt2
write_verilog synth.v write_verilog synth.v
read_verilog ../top.v read_verilog ../top.v
memory_collect
proc proc
memory
write_smt2 smt2.smt2 write_smt2 smt2.smt2
write_verilog synth.v write_verilog synth.v
read_verilog ../top.v read_verilog ../top.v
proc proc
memory
write_smt2 -nomem smt2.smt2 write_smt2 -nomem smt2.smt2
write_verilog synth.v write_verilog synth.v
read_verilog ../top.v read_verilog ../top.v
proc proc
memory
write_smt2 -stbv smt2.smt2 write_smt2 -stbv smt2.smt2
write_verilog synth.v write_verilog synth.v
read_verilog ../top.v read_verilog ../top.v
memory_collect
proc proc
memory
write_smt2 -stbv smt2.smt2 write_smt2 -stbv smt2.smt2
write_verilog synth.v write_verilog synth.v
read_verilog ../top.v read_verilog ../top.v
proc proc
memory
write_smt2 -stdt smt2.smt2 write_smt2 -stdt smt2.smt2
write_verilog synth.v write_verilog synth.v
read_verilog ../top.v read_verilog ../top.v
proc proc
memory
write_smt2 -tpl ../top.tpl smt2.smt2 write_smt2 -tpl ../top.tpl smt2.smt2
write_verilog synth.v write_verilog synth.v
read_verilog ../top.v read_verilog ../top.v
proc proc
memory
write_smt2 -verbose smt2.smt2 write_smt2 -verbose smt2.smt2
write_verilog synth.v write_verilog synth.v
read_verilog ../top.v read_verilog ../top.v
proc proc
memory
write_smt2 -wires smt2.smt2 write_smt2 -wires smt2.smt2
write_verilog synth.v write_verilog synth.v
read_verilog ../top.v
proc
write_smv smv.smv
design -reset
read_verilog ../top_clean.v
proc
write_smv smv.smv
write_verilog synth.v
...@@ -39,7 +39,7 @@ $(eval $(call template,read_ilang_tri,read_ilang read_ilang_selected)) ...@@ -39,7 +39,7 @@ $(eval $(call template,read_ilang_tri,read_ilang read_ilang_selected))
$(eval $(call template,read_json,read_json)) $(eval $(call template,read_json,read_json))
$(eval $(call template,read_json_fsm,read_json)) $(eval $(call template,read_json_fsm,read_json))
$(eval $(call template,read_json_logic,read_json)) $(eval $(call template,read_json_logic,read_json))
$(eval $(call template,read_json_mem,read_json)) $(eval $(call template,read_json_mem,read_json_mem))
$(eval $(call template,read_json_mux,read_json)) $(eval $(call template,read_json_mux,read_json))
$(eval $(call template,read_json_tri,read_json)) $(eval $(call template,read_json_tri,read_json))
......
...@@ -27,7 +27,7 @@ module testbench; ...@@ -27,7 +27,7 @@ module testbench;
); );
assign patt_out = in[1] + in[2]; assign patt_out = in[1] + in[2];
assign patt_carry_out = in[1] + patt_out; assign patt_carry_out = in[0] + patt_out;
assert_comb out_test(.A(patt_out), .B(out)); assert_comb out_test(.A(patt_out), .B(out));
assert_comb carry_test(.A(patt_carry_out), .B(carryout)); assert_comb carry_test(.A(patt_carry_out), .B(carryout));
......
...@@ -11,7 +11,7 @@ module top ...@@ -11,7 +11,7 @@ module top
`ifndef BUG `ifndef BUG
assign A = y + cin; assign A = y + cin;
assign cout = y + A; assign cout = x + A;
`else `else
assign {cout,A} = cin - y * x; assign {cout,A} = cin - y * x;
......
...@@ -2,8 +2,8 @@ module testbench; ...@@ -2,8 +2,8 @@ module testbench;
reg en; reg en;
initial begin initial begin
$dumpfile("testbench.vcd"); // $dumpfile("testbench.vcd");
$dumpvars(0, testbench); // $dumpvars(0, testbench);
#5 en = 0; #5 en = 0;
repeat (10000) begin repeat (10000) begin
...@@ -38,6 +38,6 @@ module testbench; ...@@ -38,6 +38,6 @@ module testbench;
assert_dff lat_test(.clk(en), .test(doutB), .pat(lat)); assert_dff lat_test(.clk(en), .test(doutB), .pat(~lat));
endmodule endmodule
read_verilog ../top.v read_verilog ../top.v
proc proc
memory
dump -o file.il dump -o file.il
write_ilang ilang.ilang write_ilang ilang.ilang
design -reset design -reset
......
read_verilog ../top.v read_verilog ../top.v
proc proc
memory
dump -o file.il dump -o file.il
write_ilang -selected ilang.ilang write_ilang -selected ilang.ilang
design -reset design -reset
......
read_verilog ../top.v read_verilog ../top.v
proc
write_json json.json write_json json.json
design -reset design -reset
read_json json.json read_json json.json
......
read_verilog ../top.v
write_json json.json
design -reset
read_json json.json
design -reset
read_verilog ../top.v
proc
memory
write_verilog synth.v
module counter(clk, en); module top(clk, en);
input clk; input clk;
input en; input en;
reg [3:0] X; reg [3:0] X;
......
...@@ -21,7 +21,6 @@ if [ "$1" = "issue_00089" ] ||\ ...@@ -21,7 +21,6 @@ if [ "$1" = "issue_00089" ] ||\
[ "$1" = "issue_00594" ] ||\ [ "$1" = "issue_00594" ] ||\
[ "$1" = "issue_00603" ] ||\ [ "$1" = "issue_00603" ] ||\
[ "$1" = "issue_00635" ] ||\ [ "$1" = "issue_00635" ] ||\
[ "$1" = "issue_00699" ] ||\
[ "$1" = "issue_00763" ] ||\ [ "$1" = "issue_00763" ] ||\
[ "$1" = "issue_00814" ]; then [ "$1" = "issue_00814" ]; then
...@@ -62,6 +61,7 @@ elif [ "$1" = "issue_00502" ] ||\ ...@@ -62,6 +61,7 @@ elif [ "$1" = "issue_00502" ] ||\
[ "$1" = "issue_00675" ] ||\ [ "$1" = "issue_00675" ] ||\
[ "$1" = "issue_00685" ] ||\ [ "$1" = "issue_00685" ] ||\
[ "$1" = "issue_00689" ] ||\ [ "$1" = "issue_00689" ] ||\
[ "$1" = "issue_00699" ] ||\
[ "$1" = "issue_00708" ] ||\ [ "$1" = "issue_00708" ] ||\
[ "$1" = "issue_00737" ] ||\ [ "$1" = "issue_00737" ] ||\
[ "$1" = "issue_00774" ] ||\ [ "$1" = "issue_00774" ] ||\
...@@ -96,6 +96,7 @@ elif [ "$1" = "issue_00502" ] ||\ ...@@ -96,6 +96,7 @@ elif [ "$1" = "issue_00502" ] ||\
elif [ "$1" = "issue_00642" ] ||\ elif [ "$1" = "issue_00642" ] ||\
[ "$1" = "issue_00644" ] ||\ [ "$1" = "issue_00644" ] ||\
[ "$1" = "issue_00689" ] ||\ [ "$1" = "issue_00689" ] ||\
[ "$1" = "issue_00699" ] ||\
[ "$1" = "issue_00708" ] ||\ [ "$1" = "issue_00708" ] ||\
[ "$1" = "issue_00826" ] ||\ [ "$1" = "issue_00826" ] ||\
[ "$1" = "issue_00862" ] ||\ [ "$1" = "issue_00862" ] ||\
......
tee -o result.log read_verilog -sv ../top.v tee -o result.log read_verilog -sv ../top.v
synth -top top
write_verilog synth.v
...@@ -102,9 +102,6 @@ $(eval $(call template,extract,extract_cell_attr extract_compat extract_constpor ...@@ -102,9 +102,6 @@ $(eval $(call template,extract,extract_cell_attr extract_compat extract_constpor
#extract_counter #extract_counter
$(eval $(call template,extract_counter,extract_counter extract_counter_maxwidth extract_counter_pout)) $(eval $(call template,extract_counter,extract_counter extract_counter_maxwidth extract_counter_pout))
$(eval $(call template,extract_counter_down,extract_counter extract_counter_maxwidth extract_counter_pout)) $(eval $(call template,extract_counter_down,extract_counter extract_counter_maxwidth extract_counter_pout))
$(eval $(call template,extract_counter_negative_reset,extract_counter extract_counter_maxwidth extract_counter_pout))
$(eval $(call template,extract_counter_no_reset,extract_counter extract_counter_maxwidth extract_counter_pout))
$(eval $(call template,extract_counter_sync_reset,extract_counter extract_counter_maxwidth extract_counter_pout))
#shregmap #shregmap
$(eval $(call template,shregmap,shregmap shregmap_clkpol_any shregmap_clkpol_neg shregmap_clkpol_pos shregmap_enpol_any shregmap_enpol_any_or_none shregmap_enpol_neg shregmap_enpol_none shregmap_enpol_pos shregmap_init shregmap_keep_after shregmap_keep_before shregmap_match shregmap_maxlen shregmap_minlen shregmap_params shregmap_tech shregmap_zinit)) $(eval $(call template,shregmap,shregmap shregmap_clkpol_any shregmap_clkpol_neg shregmap_clkpol_pos shregmap_enpol_any shregmap_enpol_any_or_none shregmap_enpol_neg shregmap_enpol_none shregmap_enpol_pos shregmap_init shregmap_keep_after shregmap_keep_before shregmap_match shregmap_maxlen shregmap_minlen shregmap_params shregmap_tech shregmap_zinit))
......
...@@ -29,6 +29,6 @@ module testbench; ...@@ -29,6 +29,6 @@ module testbench;
dinA <= !dinA; dinA <= !dinA;
end end
assert_tri b_test(.en(en), .A(dinA), .B(doutB)); assert_tri out_test(.en(en), .A(dinA), .B(doutB));
endmodule endmodule
...@@ -39,7 +39,7 @@ module assert_expr(input clk, input A); ...@@ -39,7 +39,7 @@ module assert_expr(input clk, input A);
always @(posedge clk) always @(posedge clk)
begin begin
//#1; //#1;
if (A == 1'bZ) if (A === 1'bX)
begin begin
$display("ERROR: ASSERTION FAILED in %m:",$time," ",A); $display("ERROR: ASSERTION FAILED in %m:",$time," ",A);
$stop; $stop;
......
...@@ -11,7 +11,11 @@ reset ...@@ -11,7 +11,11 @@ reset
if (reset) begin if (reset) begin
out <= 8'b0 ; out <= 8'b0 ;
end else end else
`ifndef BUG
out <= out + 1; out <= out + 1;
`else
out <= out - 1'bZ;
`endif
endmodule endmodule
...@@ -39,7 +39,7 @@ module assert_expr(input clk, input A); ...@@ -39,7 +39,7 @@ module assert_expr(input clk, input A);
always @(posedge clk) always @(posedge clk)
begin begin
//#1; //#1;
if (A == 1'bZ) if (A === 1'bX)
begin begin
$display("ERROR: ASSERTION FAILED in %m:",$time," ",A); $display("ERROR: ASSERTION FAILED in %m:",$time," ",A);
$stop; $stop;
......
...@@ -11,7 +11,11 @@ reset ...@@ -11,7 +11,11 @@ reset
if (reset) begin if (reset) begin
out <= 8'b11111111; out <= 8'b11111111;
end else end else
`ifndef BUG
out <= out - 1; out <= out - 1;
`else
out <= out + 1'bZ;
`endif
endmodule endmodule
...@@ -37,10 +37,17 @@ module top ...@@ -37,10 +37,17 @@ module top
else if (clken) else if (clken)
begin begin
`ifndef BUG
dataa_reg <= dataa; dataa_reg <= dataa;
datab_reg <= datab; datab_reg <= datab;
sload_reg <= sload; sload_reg <= sload;
adder_out <= old_result + multa; adder_out <= old_result + multa;
`else
dataa_reg <= datab;
datab_reg <= dataa;
sload_reg <= sload;
adder_out <= old_result - multa;
`endif
end end
end end
endmodule endmodule
...@@ -10,9 +10,9 @@ module tristate (en, i, io, o); ...@@ -10,9 +10,9 @@ module tristate (en, i, io, o);
assign o = io; assign o = io;
`else `else
assign io[0] = (en)? ~i : 1'bZ; assign io[0] = (!en)? ~i : 1'bZ;
assign io[1] = (i)? ~en : 1'bZ; assign io[1] = (!i)? ~en : 1'bZ;
assign o = ~io; assign o = ~io;
`endif `endif
......
...@@ -17,10 +17,10 @@ module tristate (en, i, io, o); ...@@ -17,10 +17,10 @@ module tristate (en, i, io, o);
assign o = (en)? io : 2'bZZ; assign o = (en)? io : 2'bZZ;
`else `else
always @(en or i) always @(en or i)
io_buf[0] <= (en)? ~i : 1'bZ; io_buf[0] <= (!en)? ~i : 1'bZ;
always @(en or i) always @(en or i)
io_buf[1] <= (i)? ~en : 1'bZ; io_buf[1] <= (!i)? ~en : 1'bZ;
assign o = (en)? ~io : 2'bZZ; assign o = (en)? ~io : 2'bZZ;
`endif `endif
......
...@@ -13,9 +13,6 @@ module top ...@@ -13,9 +13,6 @@ module top
begin begin
`ifndef BUG `ifndef BUG
if (we_a) if (we_a)
`else
if (we_b)
`endif
begin begin
ram[addr_a] <= data_a; ram[addr_a] <= data_a;
q_a <= data_a; q_a <= data_a;
...@@ -24,6 +21,17 @@ module top ...@@ -24,6 +21,17 @@ module top
begin begin
q_a <= ram[addr_a]; q_a <= ram[addr_a];
end end
`else
if (we_a)
begin
ram[addr_a] <= 8'bXXXXXXXX;
q_a <= 8'bXXXXXXXX;
end
if (re_b)
begin
q_a <= ram[addr_a];
end
`endif
end end
// Port B // Port B
...@@ -31,9 +39,6 @@ module top ...@@ -31,9 +39,6 @@ module top
begin begin
`ifndef BUG `ifndef BUG
if (we_b) if (we_b)
`else
if (we_a)
`endif
begin begin
ram[addr_b] <= data_b; ram[addr_b] <= data_b;
q_b <= data_b; q_b <= data_b;
...@@ -42,6 +47,17 @@ module top ...@@ -42,6 +47,17 @@ module top
begin begin
q_b <= ram[addr_b]; q_b <= ram[addr_b];
end end
`else
if (we_b)
begin
ram[addr_b] <= 8'bXXXXXXXX;
q_b <= 8'bXXXXXXXX;
end
if (re_b)
begin
q_b <= ram[addr_b];
end
`endif
end end
endmodule endmodule
...@@ -3,7 +3,10 @@ input [7:0] S, ...@@ -3,7 +3,10 @@ input [7:0] S,
input [255:0] D, input [255:0] D,
output M256 output M256
); );
`ifndef BUG
assign M256 = D[S]; assign M256 = D[S];
`else
assign M256 = S[D];
`endif
endmodule endmodule
module testbench; module testbench;
reg [2:0] in; reg [6:0] in;
reg patt_out = 0; wire x;
reg patt_carry_out = 0; wire [2:0] y;
reg patt_out1 = 0; wire [2:0] cin;
reg patt_carry_out1 = 0;
wire patt_out = 0;
wire patt_carry_out = 0;
wire patt_out1 = 0;
wire patt_carry_out1 = 0;
wire out = 0; wire out = 0;
wire carryout = 0; wire carryout = 0;
wire control;
wire control_patt;
initial begin initial begin
// $dumpfile("testbench.vcd"); // $dumpfile("testbench.vcd");
...@@ -21,28 +27,30 @@ module testbench; ...@@ -21,28 +27,30 @@ module testbench;
end end
top uut ( top uut (
.x(in[0]), .x(x),
.y(in[1]), .y(y),
.cin(in[2]), .cin(cin),
.A(out), .A(out),
.cout(carryout) .cout(carryout),
.control(control)
); );
always @(posedge in[0]) begin wire A1,cout1;
patt_out1 <= ~in[1] + &in[2]; wire [2:0] n_y;
end
always @(negedge in[0]) begin
patt_carry_out1 <= in[2] ? |in[1] : patt_out;
end
always @(*) begin wire [2:0] n_cin;
if (in[0])
patt_out <= patt_out|in[1]~&in[2]; // initial begin
end // A = 0;
always @(*) begin // cout = 0;
if (~in[0]) // end
patt_carry_out <= patt_carry_out1&in[2]~|in[1];
end assign x = in[0];
assert_Z out_test(.A(out)); assign y = in[3:1];
assign cin = in[6:4];
assign control_patt = x & y & cin;
assert_dff out_test(.clk(in[0]), .test(control),.pat(control_patt));
endmodule endmodule
...@@ -5,7 +5,8 @@ module top ...@@ -5,7 +5,8 @@ module top
input [2:0] cin, input [2:0] cin,
output A, output A,
output cout output cout,
output control
); );
wire A1,cout1; wire A1,cout1;
...@@ -32,8 +33,16 @@ assign cout1 = cin ? |n_y : ^A; ...@@ -32,8 +33,16 @@ assign cout1 = cin ? |n_y : ^A;
assign A = A1|y~&(~cin)~^A1; assign A = A1|y~&(~cin)~^A1;
assign cout = cout1&cin~|(~y); assign cout = cout1&cin~|(~y);
assign control = x & y & cin;
`else `else
assign {cout,A} = 1'bZ; assign A1 = n_y + &(cin);
assign cout1 = cin ? |n_y : ^A;
assign A = A1|y~&(~cin)~^A1;
assign cout = cout1&cin~|(~y);
assign control = x | y | cin;
`endif `endif
endmodule endmodule
...@@ -17,6 +17,8 @@ module testbench; ...@@ -17,6 +17,8 @@ module testbench;
reg dinA = 0; reg dinA = 0;
wire doutB; wire doutB;
wire pre,clr;
reg q = 0;
top uut ( top uut (
.clk (clk ), .clk (clk ),
...@@ -31,6 +33,17 @@ module testbench; ...@@ -31,6 +33,17 @@ module testbench;
dinA <= !dinA; dinA <= !dinA;
end end
assert_dff ff_test(.clk(clk), .test(doutB), .pat(1'b1)); assign pre = 1'b0;
assign clr = 1'b0;
always @( negedge clk, posedge pre, negedge clr )
if ( pre )
q <= 1'b1;
else if ( clr )
q <= 1'b0;
else
q <= dinA;
assert_dff ff_test(.clk(~clk), .test(doutB), .pat(q));
endmodule endmodule
...@@ -23,7 +23,7 @@ dffsr u_dffsr ( ...@@ -23,7 +23,7 @@ dffsr u_dffsr (
.clr (clr), .clr (clr),
.pre (pre), .pre (pre),
`else `else
.clr (1'b0), .clr (1'b1),
.pre (1'b0), .pre (1'b0),
`endif `endif
.d (a ), .d (a ),
......
...@@ -9,10 +9,16 @@ module top( ...@@ -9,10 +9,16 @@ module top(
output [2:0] o4, output [2:0] o4,
input s input s
); );
`ifndef BUG
assign o1 = (s ? 0 : a + b); assign o1 = (s ? 0 : a + b);
assign o2 = (s ? a : a - b); assign o2 = (s ? a : a - b);
assign o3 = (s ? 4'b1111 : d + c); assign o3 = (s ? 4'b1111 : d + c);
assign o4 = (s ? d : c - d); assign o4 = (s ? d : c - d);
`else
assign o1 = (s ? 0 : a * b);
assign o2 = (s ? a : a / b);
assign o3 = (s ? 4'b1111 : d - c);
assign o4 = (s ? d : c + d);
`endif
endmodule endmodule
module testbench; module testbench;
reg [2:0] in; reg [6:0] in;
reg patt_out = 0; wire x;
reg patt_carry_out = 0; wire [2:0] y;
reg patt_out1 = 0; wire [2:0] cin;
reg patt_carry_out1 = 0;
wire patt_out = 0;
wire patt_carry_out = 0;
wire patt_out1 = 0;
wire patt_carry_out1 = 0;
wire out = 0; wire out = 0;
wire carryout = 0; wire carryout = 0;
wire control;
wire control_patt;
initial begin initial begin
// $dumpfile("testbench.vcd"); // $dumpfile("testbench.vcd");
...@@ -21,28 +27,30 @@ module testbench; ...@@ -21,28 +27,30 @@ module testbench;
end end
top uut ( top uut (
.x(in[0]), .x(x),
.y(in[1]), .y(y),
.cin(in[2]), .cin(cin),
.A(out), .A(out),
.cout(carryout) .cout(carryout),
.control(control)
); );
always @(posedge in[0]) begin wire A1,cout1;
patt_out1 <= ~in[1] + &in[2]; wire [2:0] n_y;
end
always @(negedge in[0]) begin
patt_carry_out1 <= in[2] ? |in[1] : patt_out;
end
always @(*) begin wire [2:0] n_cin;
if (in[0])
patt_out <= patt_out|in[1]~&in[2]; // initial begin
end // A = 0;
always @(*) begin // cout = 0;
if (~in[0]) // end
patt_carry_out <= patt_carry_out1&in[2]~|in[1];
end assign x = in[0];
assert_Z out_test(.A(out)); assign y = in[3:1];
assign cin = in[6:4];
assign control_patt = x & y & cin;
assert_dff out_test(.clk(in[0]), .test(control),.pat(control_patt));
endmodule endmodule
...@@ -5,7 +5,8 @@ module top ...@@ -5,7 +5,8 @@ module top
input [2:0] cin, input [2:0] cin,
output A, output A,
output cout output cout,
output control
); );
wire A1,cout1; wire A1,cout1;
...@@ -32,8 +33,16 @@ assign cout1 = cin ? |n_y : ^A; ...@@ -32,8 +33,16 @@ assign cout1 = cin ? |n_y : ^A;
assign A = A1|y~&(~cin)~^A1; assign A = A1|y~&(~cin)~^A1;
assign cout = cout1&cin~|(~y); assign cout = cout1&cin~|(~y);
assign control = x & y & cin;
`else `else
assign {cout,A} = 1'bZ; assign A1 = n_y + &(cin);
assign cout1 = cin ? |n_y : ^A;
assign A = A1|y~&(~cin)~^A1;
assign cout = cout1&cin~|(~y);
assign control = x | y | cin;
`endif `endif
endmodule endmodule
...@@ -14,7 +14,7 @@ module testbench; ...@@ -14,7 +14,7 @@ module testbench;
$display("OKAY"); $display("OKAY");
end end
wire clk_o;
reg [4:0] a; reg [4:0] a;
wire [31:0] c; wire [31:0] c;
...@@ -22,13 +22,13 @@ module testbench; ...@@ -22,13 +22,13 @@ module testbench;
begin begin
a = a + 3; a = a + 3;
end end
top uut (clk, a, c); top uut (clk, a, c,clk_o);
uut_checker c_test(.clk(clk), .A(c), .B(c)); uut_checker c_test(.clk(clk), .A(clk), .B(clk_o));
endmodule endmodule
module uut_checker(input clk, input [31:0] A, input [31:0] B); module uut_checker(input clk, input A, input B);
always @(posedge clk) always @(posedge clk)
begin begin
#1; #1;
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
`define assume(_expr_) `define assume(_expr_)
`endif `endif
module top(input clk, input [4:0] addr, output reg [31:0] data); module top(input clk, input [4:0] addr, output reg [31:0] data, output clk_o);
reg [31:0] mem [0:31]; reg [31:0] mem [0:31];
always @(posedge clk) always @(posedge clk)
data <= mem[addr]; data <= mem[addr];
...@@ -21,4 +21,9 @@ module top(input clk, input [4:0] addr, output reg [31:0] data); ...@@ -21,4 +21,9 @@ module top(input clk, input [4:0] addr, output reg [31:0] data);
//`assume((used_dbits & data) == 0); //`assume((used_dbits & data) == 0);
end end
end end
`ifndef BUG
assign clk_o = clk;
`else
assign clk_o = ~clk;
`endif
endmodule endmodule
...@@ -15,6 +15,7 @@ input clk; ...@@ -15,6 +15,7 @@ input clk;
input rst; input rst;
input [1:0] a; input [1:0] a;
`ifndef BUG
always @(posedge clk, negedge rst) begin: DESIGN_PROCESSOR always @(posedge clk, negedge rst) begin: DESIGN_PROCESSOR
reg i; reg i;
if (!rst) begin if (!rst) begin
...@@ -43,5 +44,34 @@ always @(posedge clk, negedge rst) begin: DESIGN_PROCESSOR ...@@ -43,5 +44,34 @@ always @(posedge clk, negedge rst) begin: DESIGN_PROCESSOR
endcase endcase
end end
end end
`else
always @(posedge clk, negedge rst) begin: DESIGN_PROCESSOR
reg i;
if (!rst) begin
i = 0;
x = 0;
end
else begin
case (a)
2'b00: begin
x = 1'bZ;
i = 0;
end
2'b01: begin
x = 1'bZ;
end
2'b10: begin
i = 1;
end
2'b11: begin
i = 0;
end
default: begin
x = 1'bZ;
i = 0;
end
endcase
end
end
`endif
endmodule endmodule
...@@ -18,7 +18,7 @@ input [1:0] a; ...@@ -18,7 +18,7 @@ input [1:0] a;
wire rst_or; wire rst_or;
assign rst_or = |rst; assign rst_or = |rst;
`ifndef BUG
always @(posedge clk, negedge rst_or) begin: DESIGN_PROCESSOR always @(posedge clk, negedge rst_or) begin: DESIGN_PROCESSOR
reg i; reg i;
if (!rst_or) begin if (!rst_or) begin
...@@ -48,4 +48,34 @@ always @(posedge clk, negedge rst_or) begin: DESIGN_PROCESSOR ...@@ -48,4 +48,34 @@ always @(posedge clk, negedge rst_or) begin: DESIGN_PROCESSOR
end end
end end
`else
always @(posedge clk, negedge rst_or) begin: DESIGN_PROCESSOR
reg i;
if (!rst_or) begin
i = 0;
x = 0;
end
else begin
case (a)
2'b00: begin
x = 1'bZ;
i = 0;
end
2'b01: begin
x = 1'bZ;
end
2'b10: begin
i = 1;
end
2'b11: begin
i = 0;
end
default: begin
x = 1'bZ;
i = 0;
end
endcase
end
end
`endif
endmodule endmodule
...@@ -13,9 +13,6 @@ module top ...@@ -13,9 +13,6 @@ module top
begin begin
`ifndef BUG `ifndef BUG
if (we_a) if (we_a)
`else
if (we_b)
`endif
begin begin
ram[addr_a] <= data_a; ram[addr_a] <= data_a;
q_a <= data_a; q_a <= data_a;
...@@ -24,6 +21,17 @@ module top ...@@ -24,6 +21,17 @@ module top
begin begin
q_a <= ram[addr_a]; q_a <= ram[addr_a];
end end
`else
if (we_a)
begin
ram[addr_a] <= 8'bXXXXXXXX;
q_a <= 8'bXXXXXXXX;
end
if (re_b)
begin
q_a <= ram[addr_a];
end
`endif
end end
// Port B // Port B
...@@ -31,9 +39,6 @@ module top ...@@ -31,9 +39,6 @@ module top
begin begin
`ifndef BUG `ifndef BUG
if (we_b) if (we_b)
`else
if (we_a)
`endif
begin begin
ram[addr_b] <= data_b; ram[addr_b] <= data_b;
q_b <= data_b; q_b <= data_b;
...@@ -42,6 +47,17 @@ module top ...@@ -42,6 +47,17 @@ module top
begin begin
q_b <= ram[addr_b]; q_b <= ram[addr_b];
end end
`else
if (we_b)
begin
ram[addr_b] <= 8'bXXXXXXXX;
q_b <= 8'bXXXXXXXX;
end
if (re_b)
begin
q_b <= ram[addr_b];
end
`endif
end end
endmodule endmodule
...@@ -15,7 +15,7 @@ module testbench; ...@@ -15,7 +15,7 @@ module testbench;
end end
reg in; reg in = 0;
wire [7:0] f; wire [7:0] f;
...@@ -39,7 +39,7 @@ module assert_expr(input clk, input A); ...@@ -39,7 +39,7 @@ module assert_expr(input clk, input A);
always @(posedge clk) always @(posedge clk)
begin begin
//#1; //#1;
if (A == 1'bZ) if (A === 1'bZ)
begin begin
$display("ERROR: ASSERTION FAILED in %m:",$time," ",A); $display("ERROR: ASSERTION FAILED in %m:",$time," ",A);
$stop; $stop;
......
...@@ -12,8 +12,12 @@ in ...@@ -12,8 +12,12 @@ in
always @(posedge clk) always @(posedge clk)
begin begin
`ifndef BUG
out <= out >> 1; out <= out >> 1;
out[7] <= in; out[7] <= in;
`else
out <= 8'bZZZZZZZZ;
`endif
end end
always @(posedge clk) always @(posedge clk)
......
...@@ -15,7 +15,7 @@ module testbench; ...@@ -15,7 +15,7 @@ module testbench;
end end
reg in; reg in = 0;
wire [7:0] f; wire [7:0] f;
...@@ -39,7 +39,7 @@ module assert_expr(input clk, input A); ...@@ -39,7 +39,7 @@ module assert_expr(input clk, input A);
always @(posedge clk) always @(posedge clk)
begin begin
//#1; //#1;
if (A == 1'bZ) if (A === 1'bZ)
begin begin
$display("ERROR: ASSERTION FAILED in %m:",$time," ",A); $display("ERROR: ASSERTION FAILED in %m:",$time," ",A);
$stop; $stop;
......
...@@ -9,8 +9,12 @@ in ...@@ -9,8 +9,12 @@ in
always @(posedge clk) always @(posedge clk)
begin begin
`ifndef BUG
out <= out << 1; out <= out << 1;
out[0] <= in; out[0] <= in;
`else
out <= 8'bZZZZZZZZ;
`endif
end end
endmodule endmodule
...@@ -47,7 +47,7 @@ module assert_expr(input clk, input A); ...@@ -47,7 +47,7 @@ module assert_expr(input clk, input A);
always @(posedge clk) always @(posedge clk)
begin begin
//#1; //#1;
if (A == 1'bZ) if (A === 1'bZ)
begin begin
$display("ERROR: ASSERTION FAILED in %m:",$time," ",A); $display("ERROR: ASSERTION FAILED in %m:",$time," ",A);
$stop; $stop;
......
...@@ -19,7 +19,11 @@ module top ...@@ -19,7 +19,11 @@ module top
end end
assign r_next = {s_in, r_reg[N-1:1]}; assign r_next = {s_in, r_reg[N-1:1]};
`ifndef BUG
assign s_out = r_reg[0]; assign s_out = r_reg[0];
`else
assign s_out = 1'bZ;
`endif
endmodule endmodule
...@@ -13,9 +13,6 @@ module top ...@@ -13,9 +13,6 @@ module top
begin begin
`ifndef BUG `ifndef BUG
if (we_a) if (we_a)
`else
if (we_b)
`endif
begin begin
ram[addr_a] <= data_a; ram[addr_a] <= data_a;
q_a <= data_a; q_a <= data_a;
...@@ -24,6 +21,17 @@ module top ...@@ -24,6 +21,17 @@ module top
begin begin
q_a <= ram[addr_a]; q_a <= ram[addr_a];
end end
`else
if (we_a)
begin
ram[addr_a] <= 8'bXXXXXXXX;
q_a <= 8'bXXXXXXXX;
end
if (re_b)
begin
q_a <= ram[addr_a];
end
`endif
end end
// Port B // Port B
...@@ -31,9 +39,6 @@ module top ...@@ -31,9 +39,6 @@ module top
begin begin
`ifndef BUG `ifndef BUG
if (we_b) if (we_b)
`else
if (we_a)
`endif
begin begin
ram[addr_b] <= data_b; ram[addr_b] <= data_b;
q_b <= data_b; q_b <= data_b;
...@@ -42,6 +47,17 @@ module top ...@@ -42,6 +47,17 @@ module top
begin begin
q_b <= ram[addr_b]; q_b <= ram[addr_b];
end end
`else
if (we_b)
begin
ram[addr_b] <= 8'bXXXXXXXX;
q_b <= 8'bXXXXXXXX;
end
if (re_b)
begin
q_b <= ram[addr_b];
end
`endif
end end
endmodule endmodule
...@@ -13,9 +13,6 @@ module top ...@@ -13,9 +13,6 @@ module top
begin begin
`ifndef BUG `ifndef BUG
if (we_a) if (we_a)
`else
if (we_b)
`endif
begin begin
ram[addr_a] <= data_a; ram[addr_a] <= data_a;
q_a <= data_a; q_a <= data_a;
...@@ -24,6 +21,17 @@ module top ...@@ -24,6 +21,17 @@ module top
begin begin
q_a <= ram[addr_a]; q_a <= ram[addr_a];
end end
`else
if (we_a)
begin
ram[addr_a] <= 8'bXXXXXXXX;
q_a <= 8'bXXXXXXXX;
end
if (re_b)
begin
q_a <= ram[addr_a];
end
`endif
end end
// Port B // Port B
...@@ -31,9 +39,6 @@ module top ...@@ -31,9 +39,6 @@ module top
begin begin
`ifndef BUG `ifndef BUG
if (we_b) if (we_b)
`else
if (we_a)
`endif
begin begin
ram[addr_b] <= data_b; ram[addr_b] <= data_b;
q_b <= data_b; q_b <= data_b;
...@@ -42,6 +47,17 @@ module top ...@@ -42,6 +47,17 @@ module top
begin begin
q_b <= ram[addr_b]; q_b <= ram[addr_b];
end end
`else
if (we_b)
begin
ram[addr_b] <= 8'bXXXXXXXX;
q_b <= 8'bXXXXXXXX;
end
if (re_b)
begin
q_b <= ram[addr_b];
end
`endif
end end
endmodule endmodule
...@@ -17,7 +17,11 @@ module testbench; ...@@ -17,7 +17,11 @@ module testbench;
reg [2:0] dinA = 0; reg [2:0] dinA = 0;
wire doutB,doutB1,doutB2,doutB3,doutB4; wire doutB,doutB1,doutB2,doutB3,doutB4;
reg dff,ndff,adff,adffn,dffe = 0; reg dff = 0;
reg ndff= 1;
reg adff= 0;
reg adffn = 1'bX;
reg dffe = 1'bZ;
top uut ( top uut (
.clk (clk ), .clk (clk ),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment