mirror of
https://github.com/YosysHQ/yosys
synced 2025-04-23 00:55:32 +00:00
cxxrtl: WIP: adjust comb display cells to only fire on change
Naming and use of statics to be possibly revised.
This commit is contained in:
parent
7f7c61c9f0
commit
843ad9331b
8 changed files with 95 additions and 16 deletions
24
tests/fmt/always_comb.v
Normal file
24
tests/fmt/always_comb.v
Normal file
|
@ -0,0 +1,24 @@
|
|||
module top(input clk);
|
||||
reg a = 0;
|
||||
reg b = 0;
|
||||
wire y;
|
||||
|
||||
sub s (.a(a), .b(b), .y(y));
|
||||
|
||||
always @(posedge clk) begin
|
||||
a <= (!a && !b) || (a && !b);
|
||||
b <= (a && !b) || (a && b);
|
||||
end
|
||||
endmodule
|
||||
|
||||
module sub(input a, input b, output wire y);
|
||||
assign y = a & b;
|
||||
|
||||
// Not fit for our purposes: always @* if (a) $display(a, b, y);
|
||||
//
|
||||
// We compare output against iverilog, but async iverilog $display fires
|
||||
// even before values have propagated -- i.e. combinations of a/b/y will be
|
||||
// shown where a & b are both 1, but y has not yet taken the value 1. We
|
||||
// don't, so we specify it in the conditional.
|
||||
always @* if (y & (y == (a & b))) $display(a, b, y);
|
||||
endmodule
|
14
tests/fmt/always_comb_tb.cc
Normal file
14
tests/fmt/always_comb_tb.cc
Normal file
|
@ -0,0 +1,14 @@
|
|||
#include <iostream>
|
||||
#include "yosys-always_comb.cc"
|
||||
|
||||
int main()
|
||||
{
|
||||
cxxrtl_design::p_top uut;
|
||||
|
||||
for (int i = 0; i < 20; ++i) {
|
||||
uut.p_clk.set(!uut.p_clk);
|
||||
uut.step();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
8
tests/fmt/always_comb_tb.v
Normal file
8
tests/fmt/always_comb_tb.v
Normal file
|
@ -0,0 +1,8 @@
|
|||
module tb;
|
||||
reg clk = 0;
|
||||
|
||||
top uut (.clk(clk));
|
||||
|
||||
always #1 clk <= ~clk;
|
||||
initial #20 $finish;
|
||||
endmodule
|
|
@ -8,8 +8,6 @@ module always_full(input clk, output reg fin);
|
|||
|
||||
if (counter == 0) fin <= 0;
|
||||
|
||||
if (counter == 1) $display("<<<BEGIN>>>");
|
||||
|
||||
if (counter == 2) $display("==> small unsigned %%d");
|
||||
if (counter == 3) $display(":%d:", 16'haa);
|
||||
if (counter == 4) $display(":%-d:", 16'haa);
|
||||
|
@ -239,10 +237,7 @@ module always_full(input clk, output reg fin);
|
|||
if (counter == 207) $display("==> write/format");
|
||||
if (counter == 208) $display("%d", 1, "%d", 1);
|
||||
|
||||
if (counter == 209) begin
|
||||
$display("<<<END>>>");
|
||||
fin <= 1;
|
||||
end
|
||||
if (counter == 209) fin <= 1;
|
||||
|
||||
end
|
||||
|
||||
|
|
|
@ -47,12 +47,19 @@ test_roundtrip oct_signed -DBASE_HEX -DSIGN="signed"
|
|||
test_roundtrip bin_unsigned -DBASE_HEX -DSIGN=""
|
||||
test_roundtrip bin_signed -DBASE_HEX -DSIGN="signed"
|
||||
|
||||
../../yosys -p "read_verilog always_full.v; write_cxxrtl -print-output std::cerr yosys-always_full.cc"
|
||||
${CC:-gcc} -std=c++11 -o yosys-always_full -I../.. always_full_tb.cc -lstdc++
|
||||
./yosys-always_full 2>yosys-always_full.log
|
||||
iverilog -o iverilog-always_full always_full.v always_full_tb.v
|
||||
./iverilog-always_full | awk '/<<<BEGIN>>>/,/<<<END>>>/ {print $0}' >iverilog-always_full.log
|
||||
diff iverilog-always_full.log yosys-always_full.log
|
||||
test_cxxrtl () {
|
||||
local subtest=$1; shift
|
||||
|
||||
../../yosys -p "read_verilog ${subtest}.v; write_cxxrtl -print-output std::cerr yosys-${subtest}.cc"
|
||||
${CC:-gcc} -std=c++11 -o yosys-${subtest} -I../.. ${subtest}_tb.cc -lstdc++
|
||||
./yosys-${subtest} 2>yosys-${subtest}.log
|
||||
iverilog -o iverilog-${subtest} ${subtest}.v ${subtest}_tb.v
|
||||
./iverilog-${subtest} |grep -v '\$finish called' >iverilog-${subtest}.log
|
||||
diff iverilog-${subtest}.log yosys-${subtest}.log
|
||||
}
|
||||
|
||||
test_cxxrtl always_full
|
||||
test_cxxrtl always_comb
|
||||
|
||||
../../yosys -p "read_verilog display_lm.v" >yosys-display_lm.log
|
||||
../../yosys -p "read_verilog display_lm.v; write_cxxrtl yosys-display_lm.cc"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue