File size: 1,730 Bytes
055c19b | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
read_rtlil << EOF
module \top
wire input 1 \clk
wire input 2 width 2 \addr
wire output 1 \o
memory size 3 offset 0 \my_array
# potentially dangerous - requires external control to avoid illegal access
cell $memrd \bad_rd
parameter \MEMID "\\my_array"
parameter \CLK_ENABLE 0
parameter \CLK_POLARITY 1
parameter \TRANSPARENT 0
parameter \ABITS 2
parameter \WIDTH 1
connect \CLK 1'x
connect \EN 1'x
connect \ADDR \addr
connect \DATA \o
end
wire width 2 \n_addr
cell $not \not_addr
parameter \A_SIGNED 0
parameter \A_WIDTH 2
parameter \Y_WIDTH 2
connect \A \addr
connect \Y \n_addr
end
# address is partially const, making the illegal access of 2'11 impossible
cell $memrd \partial_const_rd
parameter \MEMID "\\my_array"
parameter \CLK_ENABLE 0
parameter \CLK_POLARITY 1
parameter \TRANSPARENT 0
parameter \ABITS 2
parameter \WIDTH 1
connect \CLK 1'x
connect \EN 1'x
connect \ADDR { 1'0 \addr [0] }
connect \DATA \o
end
# address is non-const but limited to 2'10 and 2'01 - both of which are valid
cell $memrd \limited_rd
parameter \MEMID "\\my_array"
parameter \CLK_ENABLE 0
parameter \CLK_POLARITY 1
parameter \TRANSPARENT 0
parameter \ABITS 2
parameter \WIDTH 1
connect \CLK 1'x
connect \EN 1'x
connect \ADDR { \n_addr [0] \addr [0] }
connect \DATA \o
end
end
EOF
logger -expect warning "potentially dangerous non-const input \\addr" 1
# unhandled false-positives
# logger -werror "potentially dangerous non-const input \{ 1'0"
# logger -werror "potentially dangerous non-const input \{ \\n_addr"
check_mem -non-const
logger -check-expected
design -reset
|