mirror of https://github.com/zachjs/sv2v.git
fix package and interface warnings in verbose mode
- warnings were skipped because verbose about was technically not empty - add test suite for these warnings in both modes
This commit is contained in:
parent
5aea0ee95e
commit
c656cbb977
14
src/sv2v.hs
14
src/sv2v.hs
|
|
@ -30,15 +30,19 @@ isPackage :: Description -> Bool
|
||||||
isPackage Package{} = True
|
isPackage Package{} = True
|
||||||
isPackage _ = False
|
isPackage _ = False
|
||||||
|
|
||||||
emptyWarnings :: [AST] -> [AST] -> IO ()
|
isComment :: Description -> Bool
|
||||||
|
isComment (PackageItem (Decl CommentDecl{})) = True
|
||||||
|
isComment _ = False
|
||||||
|
|
||||||
|
emptyWarnings :: AST -> AST -> IO ()
|
||||||
emptyWarnings before after =
|
emptyWarnings before after =
|
||||||
if all null before || any (not . null) after then
|
if all isComment before || not (all isComment after) then
|
||||||
return ()
|
return ()
|
||||||
else if any (any isInterface) before then
|
else if any isInterface before then
|
||||||
hPutStrLn stderr $ "Warning: Source includes an interface but output is"
|
hPutStrLn stderr $ "Warning: Source includes an interface but output is"
|
||||||
++ " empty because there is no top-level module which has no ports"
|
++ " empty because there is no top-level module which has no ports"
|
||||||
++ " which are interfaces."
|
++ " which are interfaces."
|
||||||
else if any (any isPackage) before then
|
else if any isPackage before then
|
||||||
hPutStrLn stderr $ "Warning: Source includes packages but no modules."
|
hPutStrLn stderr $ "Warning: Source includes packages but no modules."
|
||||||
++ " Please convert packages alongside the modules that use them."
|
++ " Please convert packages alongside the modules that use them."
|
||||||
else
|
else
|
||||||
|
|
@ -82,7 +86,7 @@ main = do
|
||||||
Right asts -> do
|
Right asts -> do
|
||||||
-- convert the files
|
-- convert the files
|
||||||
let asts' = convert (exclude job) asts
|
let asts' = convert (exclude job) asts
|
||||||
emptyWarnings asts asts'
|
emptyWarnings (concat asts) (concat asts')
|
||||||
-- write the converted files out
|
-- write the converted files out
|
||||||
writeOutput (write job) (files job) asts'
|
writeOutput (write job) (files job) asts'
|
||||||
exitSuccess
|
exitSuccess
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
interface Interface;
|
||||||
|
logic x;
|
||||||
|
endinterface
|
||||||
|
|
@ -0,0 +1,4 @@
|
||||||
|
module Module;
|
||||||
|
Interface intf();
|
||||||
|
assign intf.x = Package::X;
|
||||||
|
endmodule
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
package Package;
|
||||||
|
localparam X = 1;
|
||||||
|
endpackage
|
||||||
|
|
@ -0,0 +1,43 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
PACKAGE_WARNING="Warning: Source includes packages but no modules. Please convert packages alongside the modules that use them."
|
||||||
|
INTERFACE_WARNING="Warning: Source includes an interface but output is empty because there is no top-level module which has no ports which are interfaces."
|
||||||
|
|
||||||
|
test_default() {
|
||||||
|
runAndCapture *.sv
|
||||||
|
assertTrue "default conversion should succeed" $result
|
||||||
|
assertNotNull "stdout should not be empty" "$stdout"
|
||||||
|
assertNull "stderr should be empty" "$stderr"
|
||||||
|
}
|
||||||
|
|
||||||
|
test_only_package() {
|
||||||
|
runAndCapture package.sv
|
||||||
|
assertTrue "conversion should succeed" $result
|
||||||
|
assertNull "stdout should be empty" "$stdout"
|
||||||
|
assertEquals "stderr should have warning" "$PACKAGE_WARNING" "$stderr"
|
||||||
|
}
|
||||||
|
|
||||||
|
test_only_package_verbose() {
|
||||||
|
runAndCapture -v package.sv
|
||||||
|
assertTrue "conversion should succeed" $result
|
||||||
|
assertNotNull "stdout should not be empty" "$stdout"
|
||||||
|
assertEquals "stderr should have warning" "$PACKAGE_WARNING" "$stderr"
|
||||||
|
}
|
||||||
|
|
||||||
|
test_only_interface() {
|
||||||
|
runAndCapture interface.sv
|
||||||
|
assertTrue "conversion should succeed" $result
|
||||||
|
assertNull "stdout should be empty" "$stdout"
|
||||||
|
assertEquals "stderr should have warning" "$INTERFACE_WARNING" "$stderr"
|
||||||
|
}
|
||||||
|
|
||||||
|
test_only_interface_verbose() {
|
||||||
|
runAndCapture -v interface.sv
|
||||||
|
assertTrue "conversion should succeed" $result
|
||||||
|
assertNotNull "stdout should not be empty" "$stdout"
|
||||||
|
assertEquals "stderr should have warning" "$INTERFACE_WARNING" "$stderr"
|
||||||
|
}
|
||||||
|
|
||||||
|
source ../lib/functions.sh
|
||||||
|
|
||||||
|
. shunit2
|
||||||
Loading…
Reference in New Issue