Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yosys-tests
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lvzhengyang
yosys-tests
Commits
050cc693
Commit
050cc693
authored
Dec 19, 2018
by
SergeyDegtyar
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix all review comments form Clifford Wolf
parent
957b69f0
Hide whitespace changes
Inline
Side-by-side
Showing
39 changed files
with
338 additions
and
417 deletions
+338
-417
simple/Makefile
+1
-1
simple/common.v
+34
-0
simple/dff_d0/testbench.v
+9
-22
simple/dff_d0/top.v
+4
-0
simple/dffc/testbench.v
+19
-33
simple/dffc/top.v
+4
-0
simple/dffcp/testbench.v
+8
-21
simple/dffcp/top.v
+5
-0
simple/dffr/testbench.v
+9
-22
simple/dffr/top.v
+4
-0
simple/dffsr/testbench.v
+9
-22
simple/dffsr/top.v
+5
-0
simple/fsm/testbench.v
+18
-28
simple/fsm/top.v
+4
-0
simple/fsm_opt/testbench.v
+18
-28
simple/fsm_opt/top.v
+4
-0
simple/fsm_unreach/testbench.v
+20
-11
simple/fsm_unreach/top.v
+6
-0
simple/inout_port/testbench.v
+12
-26
simple/inout_port/top.v
+11
-5
simple/inout_port_demote/testbench.v
+12
-26
simple/inout_port_demote/top.v
+10
-1
simple/macc/testbench.v
+19
-14
simple/macc/top.v
+4
-0
simple/run.sh
+1
-1
simple/tristate/testbench.v
+8
-22
simple/tristate/top.v
+7
-1
simple/tristate_case/testbench.v
+8
-22
simple/tristate_case/top.v
+4
-0
simple/tristate_const_0/testbench.v
+8
-22
simple/tristate_const_0/top.v
+4
-0
simple/tristate_const_1/testbench.v
+8
-22
simple/tristate_const_1/top.v
+4
-0
simple/tristate_const_data/testbench.v
+8
-22
simple/tristate_const_data/top.v
+5
-1
simple/tristate_if/testbench.v
+8
-22
simple/tristate_if/top.v
+4
-0
simple/tristate_proc_asmt/testbench.v
+8
-22
simple/tristate_proc_asmt/top.v
+4
-0
No files found.
simple/Makefile
View file @
050cc693
...
...
@@ -20,7 +20,7 @@ endef
$(eval
$(call
template,alu,gates
luts))
# DFF with constant drivers
$(eval
$(call
template,dff,
dff))
$(eval
$(call
template,dff
_d0
,
dff))
$(eval
$(call
template,dffr,
dff))
$(eval
$(call
template,dffc,
dff))
$(eval
$(call
template,dffcp,
dff))
...
...
simple/common.v
0 → 100644
View file @
050cc693
module
assert_dff
(
input
clk
,
input
test
,
input
pat
)
;
always
@
(
posedge
clk
)
begin
if
(
test
!=
pat
)
begin
$
display
(
"ERROR: ASSERTION FAILED in %m:"
,
$
time
)
;
$
stop
;
end
end
endmodule
module
assert_tri
(
input
en
,
input
A
,
input
B
)
;
always
@
(
posedge
en
)
begin
//#1;
if
(
A
!==
B
)
begin
$
display
(
"ERROR: ASSERTION FAILED in %m:"
,
$
time
,
" "
,
A
,
" "
,
B
)
;
$
stop
;
end
end
endmodule
module
assert_Z
(
input
clk
,
input
A
)
;
always
@
(
posedge
clk
)
begin
//#1;
if
(
A
===
1
'
bZ
)
begin
$
display
(
"ERROR: ASSERTION FAILED in %m:"
,
$
time
,
" "
,
A
)
;
$
stop
;
end
end
endmodule
simple/dff/testbench.v
→
simple/dff
_d0
/testbench.v
View file @
050cc693
...
...
@@ -15,33 +15,20 @@ module testbench;
end
reg
dinA
;
wire
d
in
B
;
reg
dinA
=
0
;
wire
d
out
B
;
top
uut
(
.
clk
(
clk
)
,
.
a
(
dinA
)
,
.
b
(
d
in
B
)
.
b
(
d
out
B
)
)
;
initial
begin
dinA
<=
0
;
repeat
(
20000
)
#
3
dinA
=
!
dinA
;
end
assert
ff_test
(
.
clk
(
clk
)
,
.
test
(
dinB
))
;
endmodule
module
assert
(
input
clk
,
input
test
)
;
always
@
(
posedge
clk
)
begin
if
(
test
==
1
)
begin
$
display
(
"ASSERTION FAILED in %m:"
,
$
time
)
;
//$finish;
end
always
@
(
posedge
clk
)
begin
#
3
;
dinA
<=
!
dinA
;
end
assert_dff
ff_test
(
.
clk
(
clk
)
,
.
test
(
doutB
)
,
.
pat
(
1'b0
))
;
endmodule
simple/dff/top.v
→
simple/dff
_d0
/top.v
View file @
050cc693
...
...
@@ -16,7 +16,11 @@ output b
dff
u_dff
(
.
clk
(
clk
)
,
`ifndef
BUG
.
d
(
1'b0
)
,
`else
.
d
(
a
)
,
`endif
.
q
(
b
)
)
;
...
...
simple/dffc/testbench.v
View file @
050cc693
...
...
@@ -14,46 +14,32 @@ module testbench;
$
display
(
"OKAY"
)
;
end
function
[
31
:
0
]
xorshift32
;
input
[
31
:
0
]
arg
;
begin
xorshift32
=
arg
;
// Xorshift32 RNG, doi:10.18637/jss.v008.i14
xorshift32
=
xorshift32
^
(
xorshift32
<<
13
)
;
xorshift32
=
xorshift32
^
(
xorshift32
>>
17
)
;
xorshift32
=
xorshift32
^
(
xorshift32
<<
5
)
;
end
endfunction
reg
[
31
:
0
]
rng
=
123456789
;
always
@
(
posedge
clk
)
rng
<=
xorshift32
(
rng
)
;
wire
dinA
=
xorshift32
(
rng
*
5
)
;
wire
dinC
=
xorshift32
(
rng
*
7
)
;
reg
dinA
;
reg
dinC
;
wire
dinB
;
wire
doutB
;
top
uut
(
.
clk
(
clk
)
,
.
a
(
dinA
)
,
.
c
(
dinC
)
,
.
b
(
d
in
B
)
.
b
(
d
out
B
)
)
;
initial
begin
dinC
<=
1
;
#
5
dinC
<=
0
;
#
10
dinC
<=
1
;
#
10
dinC
<=
0
;
end
initial
begin
dinA
<=
0
;
repeat
(
20000
)
#
3
dinA
=
!
dinA
;
end
assert
ff_test
(
.
clk
(
clk
)
,
.
test
(
dinB
))
;
assert_dff
ff_test
(
.
clk
(
clk
)
,
.
test
(
doutB
)
,
.
pat
(
1'b1
))
;
endmodule
module
assert
(
input
clk
,
input
test
)
;
always
@
(
posedge
clk
)
begin
if
(
test
==
0
)
begin
$
display
(
"ASSERTION FAILED in %m:"
,
$
time
)
;
//$finish;
end
end
endmodule
simple/dffc/top.v
View file @
050cc693
...
...
@@ -20,7 +20,11 @@ output b
dffcp
u_dffcp
(
.
clk
(
clk
)
,
.
clr
(
c
)
,
`ifndef
BUG
.
pre
(
1'b1
)
,
`else
.
pre
(
1'b0
)
,
`endif
.
d
(
a
)
,
.
q
(
b
)
)
;
...
...
simple/dffcp/testbench.v
View file @
050cc693
...
...
@@ -15,33 +15,20 @@ module testbench;
end
reg
dinA
;
wire
d
in
B
;
reg
dinA
=
0
;
wire
d
out
B
;
top
uut
(
.
clk
(
clk
)
,
.
a
(
dinA
)
,
.
b
(
d
in
B
)
.
b
(
d
out
B
)
)
;
initial
begin
dinA
<=
0
;
repeat
(
20000
)
#
3
dinA
=
!
dinA
;
end
always
@
(
posedge
clk
)
begin
#
3
;
dinA
<=
!
dinA
;
end
assert
ff_test
(
.
clk
(
clk
)
,
.
test
(
dinB
))
;
assert
_dff
ff_test
(
.
clk
(
clk
)
,
.
test
(
doutB
)
,
.
pat
(
1'b1
))
;
endmodule
module
assert
(
input
clk
,
input
test
)
;
always
@
(
posedge
clk
)
begin
if
(
test
==
0
)
begin
$
display
(
"ASSERTION FAILED in %m:"
,
$
time
)
;
//$finish;
end
end
endmodule
simple/dffcp/top.v
View file @
050cc693
...
...
@@ -17,8 +17,13 @@ output b
dffcp
u_dffcp
(
.
clk
(
clk
)
,
`ifndef
BUG
.
clr
(
1'b0
)
,
.
pre
(
1'b1
)
,
`else
.
clr
(
1'b1
)
,
.
pre
(
1'b0
)
,
`endif
.
d
(
a
)
,
.
q
(
b
)
)
;
...
...
simple/dffr/testbench.v
View file @
050cc693
...
...
@@ -15,33 +15,20 @@ module testbench;
end
reg
dinA
;
wire
d
in
B
;
reg
dinA
=
0
;
wire
d
out
B
;
top
uut
(
.
clk
(
clk
)
,
.
a
(
dinA
)
,
.
b
(
d
in
B
)
.
b
(
d
out
B
)
)
;
initial
begin
dinA
<=
0
;
repeat
(
20000
)
#
3
dinA
=
!
dinA
;
end
assert
ff_test
(
.
clk
(
clk
)
,
.
test
(
dinB
))
;
endmodule
module
assert
(
input
clk
,
input
test
)
;
always
@
(
posedge
clk
)
begin
if
(
test
==
1
)
begin
$
display
(
"ASSERTION FAILED in %m:"
,
$
time
)
;
//$finish;
end
always
@
(
posedge
clk
)
begin
#
3
;
dinA
<=
!
dinA
;
end
assert_dff
ff_test
(
.
clk
(
clk
)
,
.
test
(
doutB
)
,
.
pat
(
1'b0
))
;
endmodule
simple/dffr/top.v
View file @
050cc693
...
...
@@ -16,7 +16,11 @@ output b
dffr
u_dffr
(
.
clk
(
clk
)
,
`ifndef
BUG
.
rst
(
1'b1
)
,
`else
.
rst
(
1'b0
)
,
`endif
.
d
(
a
)
,
.
q
(
b
)
)
;
...
...
simple/dffsr/testbench.v
View file @
050cc693
...
...
@@ -15,33 +15,20 @@ module testbench;
end
reg
dinA
;
wire
d
in
B
;
reg
dinA
=
0
;
wire
d
out
B
;
top
uut
(
.
clk
(
clk
)
,
.
a
(
dinA
)
,
.
b
(
d
in
B
)
.
b
(
d
out
B
)
)
;
initial
begin
dinA
<=
0
;
repeat
(
20000
)
#
3
dinA
=
!
dinA
;
end
assert
ff_test
(
.
clk
(
clk
)
,
.
test
(
dinB
))
;
endmodule
module
assert
(
input
clk
,
input
test
)
;
always
@
(
posedge
clk
)
begin
if
(
test
==
0
)
begin
$
display
(
"ASSERTION FAILED in %m:"
,
$
time
)
;
//$finish;
end
always
@
(
posedge
clk
)
begin
#
3
;
dinA
<=
!
dinA
;
end
assert_dff
ff_test
(
.
clk
(
clk
)
,
.
test
(
doutB
)
,
.
pat
(
1'b1
))
;
endmodule
simple/dffsr/top.v
View file @
050cc693
...
...
@@ -17,8 +17,13 @@ output b
dffsr
u_dffsr
(
.
clk
(
clk
)
,
`ifndef
BUG
.
clr
(
1'b1
)
,
.
pre
(
1'b1
)
,
`else
.
clr
(
1'b0
)
,
.
pre
(
1'b0
)
,
`endif
.
d
(
a
)
,
.
q
(
b
)
)
;
...
...
simple/fsm/testbench.v
View file @
050cc693
...
...
@@ -14,9 +14,22 @@ module testbench;
$
display
(
"OKAY"
)
;
end
reg
a
;
reg
b
;
function
[
31
:
0
]
xorshift32
;
input
[
31
:
0
]
arg
;
begin
xorshift32
=
arg
;
// Xorshift32 RNG, doi:10.18637/jss.v008.i14
xorshift32
=
xorshift32
^
(
xorshift32
<<
13
)
;
xorshift32
=
xorshift32
^
(
xorshift32
>>
17
)
;
xorshift32
=
xorshift32
^
(
xorshift32
<<
5
)
;
end
endfunction
reg
[
31
:
0
]
rng
=
123456789
;
always
@
(
posedge
clk
)
rng
<=
xorshift32
(
rng
)
;
wire
a
=
xorshift32
(
rng
*
5
)
;
wire
b
=
xorshift32
(
rng
*
7
)
;
reg
rst
;
wire
g0
;
wire
g1
;
...
...
@@ -36,30 +49,7 @@ module testbench;
rst
<=
0
;
end
initial
begin
a
<=
0
;
repeat
(
20000
)
#
3
a
=
!
a
;
end
initial
begin
b
<=
0
;
repeat
(
20000
)
#
4
b
=
!
b
;
end
assert
g0_test
(
.
clk
(
clk
)
,
.
A
(
g0
))
;
assert
g1_test
(
.
clk
(
clk
)
,
.
A
(
g1
))
;
assert_Z
g0_test
(
.
clk
(
clk
)
,
.
A
(
g0
))
;
assert_Z
g1_test
(
.
clk
(
clk
)
,
.
A
(
g1
))
;
endmodule
module
assert
(
input
clk
,
input
A
)
;
always
@
(
posedge
clk
)
begin
//#1;
if
(
A
==
1
'
bZ
)
begin
$
display
(
"ASSERTION FAILED in %m:"
,
$
time
,
" "
,
A
)
;
//$finish;
end
end
endmodule
simple/fsm/top.v
View file @
050cc693
...
...
@@ -27,7 +27,11 @@
case
(
state
)
IDLE
:
if
(
req_0
==
1'b1
)
begin
state
<=
#
1
GNT0
;
`ifndef
BUG
gnt_0
<=
1
;
`else
gnt_0
<=
1
'
bZ
;
`endif
end
else
if
(
req_1
==
1'b1
)
begin
gnt_1
<=
1
;
state
<=
#
1
GNT0
;
...
...
simple/fsm_opt/testbench.v
View file @
050cc693
...
...
@@ -14,9 +14,22 @@ module testbench;
$
display
(
"OKAY"
)
;
end
reg
a
;
reg
b
;
function
[
31
:
0
]
xorshift32
;
input
[
31
:
0
]
arg
;
begin
xorshift32
=
arg
;
// Xorshift32 RNG, doi:10.18637/jss.v008.i14
xorshift32
=
xorshift32
^
(
xorshift32
<<
13
)
;
xorshift32
=
xorshift32
^
(
xorshift32
>>
17
)
;
xorshift32
=
xorshift32
^
(
xorshift32
<<
5
)
;
end
endfunction
reg
[
31
:
0
]
rng
=
123456789
;
always
@
(
posedge
clk
)
rng
<=
xorshift32
(
rng
)
;
wire
a
=
xorshift32
(
rng
*
5
)
;
wire
b
=
xorshift32
(
rng
*
7
)
;
reg
rst
;
wire
g0
;
wire
g1
;
...
...
@@ -36,30 +49,7 @@ module testbench;
rst
<=
0
;
end
initial
begin
a
<=
0
;
repeat
(
20000
)
#
3
a
=
!
a
;
end
initial
begin
b
<=
0
;
repeat
(
20000
)
#
4
b
=
!
b
;
end
assert
g0_test
(
.
clk
(
clk
)
,
.
A
(
g0
))
;
assert
g1_test
(
.
clk
(
clk
)
,
.
A
(
g1
))
;
assert_Z
g0_test
(
.
clk
(
clk
)
,
.
A
(
g0
))
;
assert_Z
g1_test
(
.
clk
(
clk
)
,
.
A
(
g1
))
;
endmodule
module
assert
(
input
clk
,
input
A
)
;
always
@
(
posedge
clk
)
begin
//#1;
if
(
A
==
1
'
bZ
)
begin
$
display
(
"ASSERTION FAILED in %m:"
,
$
time
,
" "
,
A
)
;
//$finish;
end
end
endmodule
simple/fsm_opt/top.v
View file @
050cc693
...
...
@@ -27,7 +27,11 @@
case
(
state
)
IDLE
:
if
(
req
[
0
]
==
1'b1
)
begin
state
<=
#
1
GNT0
;
`ifndef
BUG
gnt
[
0
]
<=
1
;
`else
gnt
[
0
]
<=
1
'
bZ
;
`endif
end
else
if
(
req
[
1
]
==
1'b1
)
begin
gnt
[
1
]
<=
1
;
state
<=
#
1
GNT0
;
...
...
simple/fsm_unreach/testbench.v
View file @
050cc693
...
...
@@ -23,7 +23,7 @@ module testbench;
wire
[
4
:
0
]
y
;
wire
[
4
:
0
]
z
;
top
uut
(
top
uut
_fsm
(
.
clk
(
clk
)
,
.
rst
(
rst
)
,
.
a
(
a
)
,
...
...
@@ -35,44 +35,53 @@ module testbench;
)
;
initial
begin
rst
<=
0
;
rst
<=
0
;
#
5
rst
<=
1
;
#
5
rst
<=
0
;
#
5
@
(
posedge
clk
)
;
a
<=
4'b1111
;
b
<=
4'b1010
;
c
<=
4'b1011
;
#
50
repeat
(
10
)
@
(
posedge
clk
)
;
a
<=
4'b1000
;
b
<=
4'b1100
;
c
<=
4'b1010
;
#
50
repeat
(
10
)
@
(
posedge
clk
)
;
a
<=
4'b1100
;
b
<=
4'b0100
;
c
<=
4'b1011
;
#
50
repeat
(
10
)
@
(
posedge
clk
)
;
a
<=
4'b1101
;
b
<=
4'b1110
;
c
<=
4'b0000
;
end
assert
x_test
(
.
clk
(
clk
)
,
.
A
(
x
))
;
assert
y_test
(
.
clk
(
clk
)
,
.
A
(
y
))
;
assert
z_test
(
.
clk
(
clk
)
,
.
A
(
z
))
;
uut_fsm_checker
x_test
(
.
clk
(
clk
)
,
.
A
(
x
))
;
uut_fsm_checker
y_test
(
.
clk
(
clk
)
,
.
A
(
y
))
;
uut_fsm_checker
z_test
(
.
clk
(
clk
)
,
.
A
(
z
))
;
endmodule
module
assert
(
input
clk
,
input
[
4
:
0
]
A
)
;
module
uut_fsm_checker
(
input
clk
,
input
[
4
:
0
]
A
)
;
always
@
(
posedge
clk
)
begin
//#1;
if
(
A
==
4'b0000
)
begin
$
display
(
"ASSERTION FAILED in %m:"
,
$
time
,
" "
,
A
)
;
//$finish
;
$
display
(
"
ERROR:
ASSERTION FAILED in %m:"
,
$
time
,
" "
,
A
)
;
$
stop
;
end
end
endmodule
simple/fsm_unreach/top.v
View file @
050cc693
...
...
@@ -16,9 +16,15 @@ module top(clk, rst, a, b, c, x, y, z);
end
else
begin
case
(
state
)
1
:
begin
`ifndef
BUG
x
<=
x
;
y
<=
b
;
z
<=
1
;
`else
x
<=
5'd0
;
y
<=
5'd0
;
z
<=
5'd0
;
`endif
end
2
:
begin
x
<=
a
;
...
...
simple/inout_port/testbench.v
View file @
050cc693
...
...
@@ -15,40 +15,26 @@ module testbench;
end
reg
dinA
;
wire
[
1
:
0
]
di
n
B
;
wire
[
1
:
0
]
d
in
C
;
reg
dinA
=
0
;
wire
[
1
:
0
]
di
o
B
;
wire
[
1
:
0
]
d
out
C
;
top
uut
(
.
en
(
en
)
,
.
a
(
dinA
)
,
.
b
(
di
n
B
)
,
.
c
(
d
in
C
)
.
b
(
di
o
B
)
,
.
c
(
d
out
C
)
)
;
initial
begin
dinA
<=
0
;
repeat
(
20000
)
#
3
dinA
=
!
dinA
;
end
always
@
(
posedge
en
)
begin
#
3
;
dinA
<=
!
dinA
;
end
assert
b_test
(
.
en
(
en
)
,
.
A
(
dinA
)
,
.
B
(
din
B
[
0
]))
;
assert
_dff
b_test
(
.
clk
(
en
)
,
.
test
(
dinA
)
,
.
pat
(
dio
B
[
0
]))
;
assert
c_test
(
.
en
(
en
)
,
.
A
(
dinA
)
,
.
B
(
din
C
[
0
]))
;
assert
_dff
c_test
(
.
clk
(
en
)
,
.
test
(
dinA
)
,
.
pat
(
dout
C
[
0
]))
;
assert
cz_test
(
.
en
(
!
en
)
,
.
A
(
1
'
bZ
)
,
.
B
(
din
C
[
0
]))
;
assert
_dff
cz_test
(
.
clk
(
!
en
)
,
.
test
(
1
'
bZ
)
,
.
pat
(
dout
C
[
0
]))
;
endmodule
module
assert
(
input
en
,
input
A
,
input
B
)
;
always
@
(
posedge
en
)
begin
//#1;
if
(
A
!=
B
)
begin
$
display
(
"ASSERTION FAILED in %m:"
,
$
time
,
" "
,
A
,
" "
,
B
)
;
//$finish;
end
end
endmodule
simple/inout_port/top.v
View file @
050cc693
...
...
@@ -3,14 +3,20 @@ module tristate (en, i, io, o);
input
i
;
inout
[
1
:
0
]
io
;
output
[
1
:
0
]
o
;
always
@
(
en
or
i
)
io
[
0
]
<=
(
en
)
?
i
:
1
'
bZ
;
`ifndef
BUG
assign
io
[
0
]
=
(
en
)
?
i
:
1
'
bZ
;
always
@
(
en
or
i
)
io
[
1
]
<=
(
i
)
?
en
:
1
'
bZ
;
assign
io
[
1
]
=
(
i
)
?
en
:
1
'
bZ
;
assign
o
=
io
;
`else
assign
io
[
0
]
=
(
en
)
?
~
i
:
1
'
bZ
;
assign
io
[
1
]
=
(
i
)
?
~
en
:
1
'
bZ
;
assign
o
=
~
io
;
`endif
endmodule
...
...
simple/inout_port_demote/testbench.v
View file @
050cc693
...
...
@@ -15,41 +15,27 @@ module testbench;
end
reg
dinA
;
wire
[
1
:
0
]
di
n
B
;
wire
[
1
:
0
]
d
in
C
;
reg
dinA
=
0
;
wire
[
1
:
0
]
di
o
B
;
wire
[
1
:
0
]
d
out
C
;
top
uut
(
.
en
(
en
)
,
.
a
(
dinA
)
,
.
b
(
di
n
B
)
,
.
c
(
d
in
C
)
.
b
(
di
o
B
)
,
.
c
(
d
out
C
)
)
;
initial
begin
dinA
<=
0
;
repeat
(
20000
)
#
3
dinA
=
!
dinA
;
end
always
@
(
posedge
en
)
begin
#
3
;
dinA
<=
!
dinA
;
end
assert
b_test
(
.
en
(
en
)
,
.
A
(
dinA
)
,
.
B
(
din
B
[
0
]))
;
assert
_dff
b_test
(
.
clk
(
en
)
,
.
test
(
dinA
)
,
.
pat
(
dio
B
[
0
]))
;
assert
c_test
(
.
en
(
en
)
,
.
A
(
dinA
)
,
.
B
(
din
C
[
0
]))
;
assert
_dff
c_test
(
.
clk
(
en
)
,
.
test
(
dinA
)
,
.
pat
(
dout
C
[
0
]))
;
assert
cz_test
(
.
en
(
!
en
)
,
.
A
(
1
'
bZ
)
,
.
B
(
din
C
[
0
]))
;
assert
_dff
cz_test
(
.
clk
(
!
en
)
,
.
test
(
1
'
bZ
)
,
.
pat
(
dout
C
[
0
]))
;
endmodule
module
assert
(
input
en
,
input
A
,
input
B
)
;
always
@
(
posedge
en
)
begin
//#1;
if
(
A
!=
B
)
begin
$
display
(
"ASSERTION FAILED in %m:"
,
$
time
,
" "
,
A
,
" "
,
B
)
;
//$finish;
end
end
endmodule
simple/inout_port_demote/top.v
View file @
050cc693
...
...
@@ -3,7 +3,7 @@ module tristate (en, i, io, o);
input
i
;
inout
[
1
:
0
]
io
;
output
[
1
:
0
]
o
;
`ifndef
BUG
always
@
(
en
or
i
)
io
[
0
]
<=
(
en
)
?
i
:
1
'
bZ
;
...
...
@@ -11,6 +11,15 @@ module tristate (en, i, io, o);
io
[
1
]
<=
(
i
)
?
en
:
1
'
bZ
;
assign
o
=
(
en
)
?
io
:
2
'
bZZ
;
`else
always
@
(
en
or
i
)
io
[
0
]
<=
(
en
)
?
~
i
:
1
'
bZ
;
always
@
(
en
or
i
)
io
[
1
]
<=
(
i
)
?
~
en
:
1
'
bZ
;
assign
o
=
(
en
)
?
~
io
:
2
'
bZZ
;
`endif
endmodule
...
...
simple/macc/testbench.v
View file @
050cc693
...
...
@@ -21,7 +21,7 @@ module testbench;
reg
rst
;
wire
[
47
:
0
]
p
;
top
uut
(
top
uut
_macc
(
.
p
(
p
)
,
.
a
(
dinA
)
,
.
b
(
dinB
)
,
...
...
@@ -35,42 +35,47 @@ module testbench;
#
5
rst
<=
1
;
#
5
@
(
posedge
clk
)
;
dinA
<=
38
;
dinB
<=
22
;
carryin
<=
1
;
#
50
repeat
(
10
)
@
(
posedge
clk
)
;
dinA
<=
0
;
dinB
<=
0
;
carryin
<=
0
;
#
50
repeat
(
10
)
@
(
posedge
clk
)
;
dinA
<=
33
;
dinB
<=
12
;
carryin
<=
0
;
#
50
repeat
(
10
)
@
(
posedge
clk
)
;
dinA
<=
0
;
dinB
<=
0
;
carryin
<=
0
;
end
assert
macc_test
(
.
clk
(
clk
)
,
.
A
(
dinA
)
,
.
B
(
dinB
)
,
.
C
(
carryin
)
,
.
P
(
p
))
;
uut_macc_checker
macc_check
(
.
clk
(
clk
)
,
.
A
(
dinA
)
,
.
B
(
dinB
)
,
.
C
(
carryin
)
,
.
P
(
p
))
;
endmodule
module
assert
(
input
clk
,
input
[
24
:
0
]
A
,
input
[
17
:
0
]
B
,
input
C
,
input
[
47
:
0
]
P
)
;
module
uut_macc_checker
(
input
clk
,
input
[
24
:
0
]
A
,
input
[
17
:
0
]
B
,
input
C
,
input
[
47
:
0
]
P
)
;
reg
[
47
:
0
]
p
;
always
@
(
posedge
clk
)
begin
//#1;
@
(
posedge
clk
)
;
@
(
posedge
clk
)
;
@
(
posedge
clk
)
;
@
(
posedge
clk
)
;
assign
p
=
(
A
*
B
)
+
C
;
#
20
p
<=
(
A
*
B
)
+
C
;
if
(
P
!=
p
)
begin
$
display
(
"ASSERTION FAILED in %m:"
,
$
time
,
" "
,
P
,
" "
,
p
)
;
//$
finish
;
$
display
(
"
ERROR:
ASSERTION FAILED in %m:"
,
$
time
,
" "
,
P
,
" "
,
p
)
;
//$
stop
;
end
end
endmodule
simple/macc/top.v
View file @
050cc693
...
...
@@ -22,7 +22,11 @@ module MACC (P, A, B, CARRYIN, CLK, RST);
if
(
!
RST
)
P
<=
'b0
;
else
`ifndef
BUG
P
<=
mult_reg
+
CARRYIN
;
`else
P
<=
mult_reg
-
CARRYIN
;
`endif
end
endmodule
...
...
simple/run.sh
View file @
050cc693
...
...
@@ -9,7 +9,7 @@ mkdir $1/work_$2
cd
$1
/work_
$2
yosys
-ql
yosys.log ../../scripts/
$2
.ys
iverilog
-o
testbench ../testbench.v synth.v ../../../../../techlibs/common/simcells.v
iverilog
-o
testbench ../testbench.v synth.v ../../
common.v ../../
../../../techlibs/common/simcells.v
if
!
vvp
-N
testbench
>
testbench.log 2>&1
;
then
grep
'ERROR'
testbench.log
...
...
simple/tristate/testbench.v
View file @
050cc693
...
...
@@ -15,34 +15,20 @@ module testbench;
end
reg
dinA
;
wire
d
in
B
;
reg
dinA
=
0
;
wire
d
out
B
;
top
uut
(
.
en
(
en
)
,
.
a
(
dinA
)
,
.
b
(
d
in
B
)
.
b
(
d
out
B
)
)
;
initial
begin
dinA
<=
0
;
repeat
(
20000
)
#
3
dinA
=
!
dinA
;
end
always
@
(
posedge
en
)
begin
#
3
;
dinA
<=
!
dinA
;
end
assert
b_test
(
.
en
(
en
)
,
.
A
(
dinA
)
,
.
B
(
din
B
))
;
assert
_tri
b_test
(
.
en
(
en
)
,
.
A
(
dinA
)
,
.
B
(
dout
B
))
;
endmodule
module
assert
(
input
en
,
input
A
,
input
B
)
;
always
@
(
posedge
en
)
begin
//#1;
if
(
A
!=
B
)
begin
$
display
(
"ASSERTION FAILED in %m:"
,
$
time
,
" "
,
A
,
" "
,
B
)
;
//$finish;
end
end
endmodule
simple/tristate/top.v
View file @
050cc693
...
...
@@ -2,9 +2,15 @@ module tristate (en, i, o);
input
en
;
input
i
;
output
o
;
`ifndef
BUG
always
@
(
en
or
i
)
o
<=
(
en
)
?
i
:
1
'
bZ
;
`else
always
@
(
en
or
i
)
o
<=
(
en
)
?
~
i
:
1
'
bZ
;
`endif
endmodule
...
...
simple/tristate_case/testbench.v
View file @
050cc693
...
...
@@ -15,34 +15,20 @@ module testbench;
end
reg
dinA
;
wire
d
in
B
;
reg
dinA
=
0
;
wire
d
out
B
;
top
uut
(
.
en
(
en
)
,
.
a
(
dinA
)
,
.
b
(
d
in
B
)
.
b
(
d
out
B
)
)
;
initial
begin
dinA
<=
0
;
repeat
(
20000
)
#
3
dinA
=
!
dinA
;
end
always
@
(
posedge
en
)
begin
#
3
;
dinA
<=
!
dinA
;
end
assert
b_test
(
.
en
(
en
)
,
.
A
(
dinA
)
,
.
B
(
din
B
))
;
assert
_tri
b_test
(
.
en
(
en
)
,
.
A
(
dinA
)
,
.
B
(
dout
B
))
;
endmodule
module
assert
(
input
en
,
input
A
,
input
B
)
;
always
@
(
posedge
en
)
begin
//#1;
if
(
A
!=
B
)
begin
$
display
(
"ASSERTION FAILED in %m:"
,
$
time
,
" "
,
A
,
" "
,
B
)
;
//$finish;
end
end
endmodule
simple/tristate_case/top.v
View file @
050cc693
...
...
@@ -6,7 +6,11 @@ module tristate (en, i, o);
always
@
(
en
or
i
)
begin
case
(
en
)
`ifndef
BUG
1
:
o
<=
i
;
`else
1
:
o
<=
~
i
;
`endif
default
:
o
<=
1
'
bZ
;
endcase
end
...
...
simple/tristate_const_0/testbench.v
View file @
050cc693
...
...
@@ -15,34 +15,20 @@ module testbench;
end
reg
dinA
;
wire
d
in
B
;
reg
dinA
=
0
;
wire
d
out
B
;
top
uut
(
.
en
(
en
)
,
.
a
(
dinA
)
,
.
b
(
d
in
B
)
.
b
(
d
out
B
)
)
;
initial
begin
dinA
<=
0
;
repeat
(
20000
)
#
3
dinA
=
!
dinA
;
end
always
@
(
posedge
en
)
begin
#
3
;
dinA
<=
!
dinA
;
end
assert
b_test
(
.
en
(
en
)
,
.
A
(
dinA
)
,
.
B
(
din
B
))
;
assert
_tri
b_test
(
.
en
(
en
)
,
.
A
(
1
'
bZ
)
,
.
B
(
dout
B
))
;
endmodule
module
assert
(
input
en
,
input
A
,
input
B
)
;
always
@
(
posedge
en
)
begin
//#1;
if
(
A
===
B
)
begin
$
display
(
"ASSERTION FAILED in %m:"
,
$
time
,
" "
,
A
,
" "
,
B
)
;
//$finish;
end
end
endmodule
simple/tristate_const_0/top.v
View file @
050cc693
...
...
@@ -4,7 +4,11 @@ module tristate (en, i, o);
output
o
;
always
@
(
en
or
i
)
`ifndef
BUG
o
<=
(
en
)
?
i
:
1
'
bZ
;
`else
o
<=
(
en
)
?
~
i
:
1
'
bZ
;
`endif
endmodule
...
...
simple/tristate_const_1/testbench.v
View file @
050cc693
...
...
@@ -15,34 +15,20 @@ module testbench;
end
reg
dinA
;
wire
d
in
B
;
reg
dinA
=
0
;
wire
d
out
B
;
top
uut
(
.
en
(
en
)
,
.
a
(
dinA
)
,
.
b
(
d
in
B
)
.
b
(
d
out
B
)
)
;
initial
begin
dinA
<=
0
;
repeat
(
20000
)
#
3
dinA
=
!
dinA
;
end
always
@
(
posedge
en
)
begin
#
3
;
dinA
<=
!
dinA
;
end
assert
b_test
(
.
en
(
en
)
,
.
A
(
dinA
)
,
.
B
(
din
B
))
;
assert
_tri
b_test
(
.
en
(
en
)
,
.
A
(
dinA
)
,
.
B
(
dout
B
))
;
endmodule
module
assert
(
input
en
,
input
A
,
input
B
)
;
always
@
(
posedge
en
)
begin
//#1;
if
(
A
!==
B
)
begin
$
display
(
"ASSERTION FAILED in %m:"
,
$
time
,
" "
,
A
,
" "
,
B
)
;
//$finish;
end
end
endmodule
simple/tristate_const_1/top.v
View file @
050cc693
...
...
@@ -4,7 +4,11 @@ module tristate (en, i, o);
output
o
;
always
@
(
en
or
i
)
`ifndef
BUG
o
<=
(
en
)
?
i
:
1
'
bZ
;
`else
o
<=
(
en
)
?
~
i
:
1
'
bZ
;
`endif
endmodule
...
...
simple/tristate_const_data/testbench.v
View file @
050cc693
...
...
@@ -15,34 +15,20 @@ module testbench;
end
reg
dinA
;
wire
d
in
B
;
reg
dinA
=
0
;
wire
d
out
B
;
top
uut
(
.
en
(
en
)
,
.
a
(
dinA
)
,
.
b
(
d
in
B
)
.
b
(
d
out
B
)
)
;
initial
begin
dinA
<=
0
;
repeat
(
20000
)
#
3
dinA
=
!
dinA
;
end
always
@
(
posedge
en
)
begin
#
3
;
dinA
<=
!
dinA
;
end
assert
b_test
(
.
en
(
en
)
,
.
A
(
dinA
)
,
.
B
(
din
B
))
;
assert
_tri
b_test
(
.
en
(
en
)
,
.
A
(
1'b0
)
,
.
B
(
dout
B
))
;
endmodule
module
assert
(
input
en
,
input
A
,
input
B
)
;
always
@
(
posedge
en
)
begin
//#1;
if
(
A
!=
B
)
begin
$
display
(
"ASSERTION FAILED in %m:"
,
$
time
,
" "
,
A
,
" "
,
B
)
;
//$finish;
end
end
endmodule
simple/tristate_const_data/top.v
View file @
050cc693
...
...
@@ -16,7 +16,11 @@ output b
tristate
u_tri
(
.
en
(
en
)
,
.
i
(
1
'
bZ
)
,
`ifndef
BUG
.
i
(
1'b0
)
,
`else
.
i
(
a
)
,
`endif
.
o
(
b
)
)
;
...
...
simple/tristate_if/testbench.v
View file @
050cc693
...
...
@@ -15,34 +15,20 @@ module testbench;
end
reg
dinA
;
wire
d
in
B
;
reg
dinA
=
0
;
wire
d
out
B
;
top
uut
(
.
en
(
en
)
,
.
a
(
dinA
)
,
.
b
(
d
in
B
)
.
b
(
d
out
B
)
)
;
initial
begin
dinA
<=
0
;
repeat
(
20000
)
#
3
dinA
=
!
dinA
;
end
always
@
(
posedge
en
)
begin
#
3
;
dinA
<=
!
dinA
;
end
assert
b_test
(
.
en
(
en
)
,
.
A
(
dinA
)
,
.
B
(
din
B
))
;
assert
_tri
b_test
(
.
en
(
en
)
,
.
A
(
dinA
)
,
.
B
(
dout
B
))
;
endmodule
module
assert
(
input
en
,
input
A
,
input
B
)
;
always
@
(
posedge
en
)
begin
//#1;
if
(
A
!=
B
)
begin
$
display
(
"ASSERTION FAILED in %m:"
,
$
time
,
" "
,
A
,
" "
,
B
)
;
//$finish;
end
end
endmodule
simple/tristate_if/top.v
View file @
050cc693
...
...
@@ -6,7 +6,11 @@ module tribuf (en, i, o);
always
@*
begin
if
(
en
)
`ifndef
BUG
o
=
i
;
`else
o
=
~
i
;
`endif
else
o
=
1
'
bZ
;
end
...
...
simple/tristate_proc_asmt/testbench.v
View file @
050cc693
...
...
@@ -15,34 +15,20 @@ module testbench;
end
reg
dinA
;
wire
d
in
B
;
reg
dinA
=
0
;
wire
d
out
B
;
top
uut
(
.
en
(
en
)
,
.
a
(
dinA
)
,
.
b
(
d
in
B
)
.
b
(
d
out
B
)
)
;
initial
begin
dinA
<=
0
;
repeat
(
20000
)
#
3
dinA
=
!
dinA
;
end
always
@
(
posedge
en
)
begin
#
3
;
dinA
<=
!
dinA
;
end
assert
b_test
(
.
en
(
en
)
,
.
A
(
dinA
)
,
.
B
(
din
B
))
;
assert
_tri
b_test
(
.
en
(
en
)
,
.
A
(
dinA
)
,
.
B
(
dout
B
))
;
endmodule
module
assert
(
input
en
,
input
A
,
input
B
)
;
always
@
(
posedge
en
)
begin
//#1;
if
(
A
!=
B
)
begin
$
display
(
"ASSERTION FAILED in %m:"
,
$
time
,
" "
,
A
,
" "
,
B
)
;
//$finish;
end
end
endmodule
simple/tristate_proc_asmt/top.v
View file @
050cc693
...
...
@@ -3,7 +3,11 @@ module tristate (en, i, o);
input
i
;
output
o
;
`ifndef
BUG
assign
o
=
(
en
)
?
i
:
1
'
bZ
;
`else
assign
o
=
(
en
)
?
~
i
:
1
'
bZ
;
`endif
endmodule
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment