mirror of
https://github.com/YosysHQ/yosys
synced 2025-04-23 00:55:32 +00:00
Merge pull request #4678 from povik/tcl-rtlil-api
Start Tcl design inspection methods
This commit is contained in:
commit
b0708a38bf
6 changed files with 655 additions and 124 deletions
63
tests/various/tcl_apis.tcl
Normal file
63
tests/various/tcl_apis.tcl
Normal file
|
@ -0,0 +1,63 @@
|
|||
yosys read_verilog tcl_apis.v
|
||||
|
||||
if {[rtlil::get_attr -string -mod top foo] != "bar"} {
|
||||
error "bad top module attribute"
|
||||
}
|
||||
|
||||
if {[rtlil::get_attr -int -mod top val] != 4294967295} {
|
||||
error "bad top module attribute 2"
|
||||
}
|
||||
|
||||
if {[rtlil::get_attr -sint -mod top val] != -1} {
|
||||
error "bad top module attribute 3"
|
||||
}
|
||||
|
||||
if {[rtlil::get_attr -bool top w dont_touch] != 1} {
|
||||
error "bad w wire attribute"
|
||||
}
|
||||
|
||||
if {[rtlil::get_param -int top inst PARAM] != -3} {
|
||||
error "bad parameter"
|
||||
}
|
||||
if {[rtlil::get_param -uint top inst PARAM] != 4294967293} {
|
||||
error "bad parameter 2"
|
||||
}
|
||||
|
||||
rtlil::set_attr -true -mod top marked
|
||||
yosys select -assert-any A:marked
|
||||
|
||||
# write a 32-bit constant with most bits set
|
||||
rtlil::set_attr -mod -uint top f 4294967294
|
||||
# read it back as a signed integer
|
||||
if {[rtlil::get_attr -mod -sint top f] != -2} {
|
||||
error "bad int roundtrip"
|
||||
}
|
||||
# read it back as an unsigned integer (no signedness flag)
|
||||
if {[rtlil::get_attr -mod -int top f] != 4294967294} {
|
||||
error "bad int roundtrip 2"
|
||||
}
|
||||
# read it back as an unsigned integer
|
||||
if {[rtlil::get_attr -mod -uint top f] != 4294967294} {
|
||||
error "bad int roundtrip 3"
|
||||
}
|
||||
|
||||
# write a signed 32-bit constant
|
||||
rtlil::set_attr -mod -sint top f -3
|
||||
# read it back as a signed integer
|
||||
if {[rtlil::get_attr -mod -sint top f] != -3} {
|
||||
error "bad int roundtrip 4"
|
||||
}
|
||||
# read it back as a signed integer (due to signedness flag)
|
||||
if {[rtlil::get_attr -mod -int top f] != -3} {
|
||||
error "bad int roundtrip 5"
|
||||
}
|
||||
# read it back as an unsigned integer
|
||||
if {[rtlil::get_attr -mod -uint top f] != 4294967293} {
|
||||
error "bad int roundtrip 6"
|
||||
}
|
||||
|
||||
# write a constant larger than 32 bits
|
||||
rtlil::set_attr -mod -sint top prime 87178291199
|
||||
if {[rtlil::get_attr -mod -int top prime] != 87178291199} {
|
||||
error "bad int roundtrip 7"
|
||||
}
|
12
tests/various/tcl_apis.v
Normal file
12
tests/various/tcl_apis.v
Normal file
|
@ -0,0 +1,12 @@
|
|||
module m;
|
||||
parameter PARAM = 0;
|
||||
endmodule
|
||||
|
||||
(* foo="bar" *)
|
||||
(* val=32'hffffffff *)
|
||||
module top;
|
||||
(* dont_touch *)
|
||||
wire w;
|
||||
|
||||
m #(.PARAM(-3)) inst();
|
||||
endmodule
|
1
tests/various/tcl_apis.ys
Normal file
1
tests/various/tcl_apis.ys
Normal file
|
@ -0,0 +1 @@
|
|||
tcl tcl_apis.tcl
|
Loading…
Add table
Add a link
Reference in a new issue