m-labs / nmigen

A refreshed Python toolbox for building complex digital hardware. See https://gitlab.com/nmigen/nmigen
https://nmigen.org
Other
646 stars 55 forks source link

Fix `_yosys_version()` #326

Closed hofstee closed 4 years ago

hofstee commented 4 years ago

re.match only matches at the beginning of the string, not each line. This change changes it to do a re.search with the multiline flag. I think this is primarily of use when the user has compiled yosys with verific extensions.

Example of yosys -V output that failed with the prior code:

~/s/nmigen · yosys -V
-- (c) Copyright 1999 - 2020 Verific Design Automation Inc. All rights reserved
-- Compilation time was Fri Feb 28 11:19:43 2020

-- This program will expire on Sun Jun  7 12:19:43 2020

Yosys 0.9+2406 (git sha1 cf716e1f, gcc 8.3.0-6 -Os)

Verilog generation is still borked, for some reason, I'm still seeing the Verific license info at the top of the Verilog generated through nmigen. Not sure why.

-- (c) Copyright 1999 - 2020 Verific Design Automation Inc. All rights reserved
-- Compilation time was Fri Feb 28 11:19:43 2020

-- This program will expire on Sun Jun  7 12:19:43 2020

/* Generated by Yosys 0.9+2406 (git sha1 cf716e1f, gcc 8.3.0-6 -Os) */

(* generator = "nMigen" *)
(* top =  1  *)
(* \nmigen.hierarchy  = "top" *)
module top(clk, rst, o);
hofstee commented 4 years ago

Oh, it's because yosys -q - still outputs the Verific info. Might be a bit more foolproof if the generated Verilog was output to a tempfile and then passed between yosys/nmigen in that manner.