aboutsummaryrefslogtreecommitdiffstats
path: root/backends/verilog/verilog_backend.cc
Commit message (Collapse)AuthorAgeFilesLines
* Add flooring division operatorXiretza2020-05-281-0/+55
| | | | | | | | | | The $div and $mod cells use truncating division semantics (rounding towards 0), as defined by e.g. Verilog. Another rounding mode, flooring (rounding towards negative infinity), can be used in e.g. VHDL. The new $divfloor cell provides this flooring division. This commit also fixes the handling of $div in opt_expr, which was previously optimized as if it was $divfloor.
* Add flooring modulo operatorXiretza2020-05-281-0/+34
| | | | | | | | | | | The $div and $mod cells use truncating division semantics (rounding towards 0), as defined by e.g. Verilog. Another rounding mode, flooring (rounding towards negative infinity), can be used in e.g. VHDL. The new $modfloor cell provides this flooring modulo (also known as "remainder" in several languages, but this name is ambiguous). This commit also fixes the handling of $mod in opt_expr, which was previously optimized as if it was $modfloor.
* write_verilog: fix precondition check.whitequark2020-04-141-1/+1
|
* kernel: big fat patch to use more ID::*, otherwise ID(*)Eddie Hung2020-04-021-221/+221
|
* kernel: use more ID::*Eddie Hung2020-04-021-41/+41
|
* Clean up pseudo-private member usage in `backends/verilog/verilog_backend.cc`.Alberto Gonzalez2020-04-011-22/+19
|
* specify: system timing checks to accept min:typ:max tripleEddie Hung2020-02-131-2/+10
|
* write_verilog: dump $mem cell attributes.whitequark2020-02-061-0/+1
| | | | | The Verilog backend already dumps attributes on RTLIL::Memory objects but not on `$mem` cells.
* write_verilog: add -extmem option, to write split memory init files.whitequark2019-11-181-10/+80
| | | | | Some toolchains (in particular Quartus) are pathologically slow if a large amount of assignments in `initial` blocks are used.
* write_verilog: do not print (*init*) attributes on regs.whitequark2019-09-221-4/+5
| | | | | | | | | | If an init value is emitted for a reg, an (*init*) attribute is never necessary, since it is exactly equivalent. On the other hand, some tools that consume Verilog (ISE, Vivado, Quartus) complain about (*init*) attributes because their interpretation differs from Yosys. All (*init*) attributes that would not become reg init values anyway are emitted as before.
* substr() -> compare()Eddie Hung2019-08-071-2/+2
|
* RTLIL::S{0,1} -> State::S{0,1}Eddie Hung2019-08-071-6/+6
|
* Use State::S{0,1}Eddie Hung2019-08-061-2/+2
|
* Make liberal use of IdString.in()Eddie Hung2019-08-061-1/+1
|
* Add $_NMUX_, add "abc -g cmos", add proper cmos cell costsClifford Wolf2019-08-061-0/+14
| | | | Signed-off-by: Clifford Wolf <clifford@clifford.at>
* Merge pull request #1203 from whitequark/write_verilog-zero-width-valuesClifford Wolf2019-07-181-1/+2
|\ | | | | write_verilog: dump zero width constants correctly
| * write_verilog: dump zero width constants correctly.whitequark2019-07-161-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | Before this commit, zero width constants were dumped as "" (empty string). Unfortunately, 1364-2005 5.2.3.3 indicates that an empty string is equivalent to "\0", and is 8 bits wide, so that's wrong. After this commit, a replication operation with a count of zero is used instead, which is explicitly permitted per 1364-2005 5.1.14, and is defined to have size zero. (Its operand has to have a non-zero size for it to be legal, though.) Fixes #948 (again).
* | Remove old $pmux_safe code from write_verilogClifford Wolf2019-07-171-5/+4
|/ | | | Signed-off-by: Clifford Wolf <clifford@clifford.at>
* Merge pull request #1172 from whitequark/write_verilog-Sa-as-qmarkClifford Wolf2019-07-111-2/+8
|\ | | | | write_verilog: write RTLIL::Sa aka - as Verilog ?
| * write_verilog: write RTLIL::Sa aka - as Verilog ?.whitequark2019-07-091-2/+8
| | | | | | | | | | | | | | Currently, the only ways (determined by grepping for regex \bSa\b) to end up with RTLIL::Sa in a netlist is by reading a Verilog constant with ? in it as a part of case, or by running certain FSM passes. Both of these cases should be round-tripped back to ? in Verilog.
* | write_verilog: fix placement of case attributes. NFC.whitequark2019-07-091-3/+2
|/
* verilog_backend: dump attributes on SwitchRule.whitequark2019-07-081-0/+1
| | | | This appears to be an omission.
* verilog_backend: dump attributes on CaseRule, as comments.whitequark2019-07-081-6/+10
| | | | Attributes are not permitted in that position by Verilog grammar.
* Fix handling of partial init attributes in write_verilog, fixes #997Clifford Wolf2019-05-071-1/+2
| | | | Signed-off-by: Clifford Wolf <clifford@clifford.at>
* Improve write_verilog specify supportClifford Wolf2019-05-041-15/+71
| | | | Signed-off-by: Clifford Wolf <clifford@clifford.at>
* Rename T_{RISE,FALL}_AVG to T_{RISE,FALL}_TYP to better match verilog std ↵Clifford Wolf2019-04-231-2/+2
| | | | | | nomenclature Signed-off-by: Clifford Wolf <clifford@clifford.at>
* Add $specify2/$specify3 support to write_verilogClifford Wolf2019-04-231-0/+47
| | | | Signed-off-by: Clifford Wolf <clifford@clifford.at>
* Add support for $assert/$assume/$cover to write_verilogClifford Wolf2019-04-231-0/+10
| | | | Signed-off-by: Clifford Wolf <clifford@clifford.at>
* Add support for zero-width signals to Verilog back-end, fixes #948Clifford Wolf2019-04-221-0/+8
| | | | Signed-off-by: Clifford Wolf <clifford@clifford.at>
* Add "whitebox" attribute, add "read_verilog -wb"Clifford Wolf2019-04-181-1/+1
| | | | Signed-off-by: Clifford Wolf <clifford@clifford.at>
* Improve determinism of IdString DB for similar scriptsClifford Wolf2019-03-111-0/+4
| | | | Signed-off-by: Clifford Wolf <clifford@clifford.at>
* Add "write_verilog -siminit"Clifford Wolf2019-02-281-2/+11
| | | | Signed-off-by: Clifford Wolf <clifford@clifford.at>
* Instead of INIT param on cells, use initial statement with hier ref asEddie Hung2019-02-171-18/+13
| | | | per @cliffordwolf
* Merge https://github.com/YosysHQ/yosys into dff_initEddie Hung2019-02-171-38/+41
|\
| * write_verilog: correctly emit asynchronous transparent ports.whitequark2019-01-291-38/+41
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit fixes two related issues: * For asynchronous ports, clock is no longer added to domain list. (This would lead to absurd constructs like `always @(posedge 0)`. * The logic to distinguish synchronous and asynchronous ports is changed to correctly use or avoid clock in all cases. Before this commit, the following RTLIL snippet (after memory_collect) cell $memrd $2 parameter \MEMID "\\mem" parameter \ABITS 2 parameter \WIDTH 4 parameter \CLK_ENABLE 0 parameter \CLK_POLARITY 1 parameter \TRANSPARENT 1 connect \CLK 1'0 connect \EN 1'1 connect \ADDR \mem_r_addr connect \DATA \mem_r_data end would lead to invalid Verilog: reg [1:0] _0_; always @(posedge 1'h0) begin _0_ <= mem_r_addr; end assign mem_r_data = mem[_0_]; Note that there are two potential pitfalls remaining after this change: * For asynchronous ports, the \EN input and \TRANSPARENT parameter are silently ignored. (Per discussion in #760 this is the correct behavior.) * For synchronous transparent ports, the \EN input is ignored. This matches the behavior of the $mem simulation cell. Again, see #760.
* | Remove check for cell->name[0] == '$'Eddie Hung2019-02-061-1/+1
| |
* | RefactorEddie Hung2019-02-061-21/+5
| |
* | write_verilog to cope with init attr on q when -noexprEddie Hung2019-02-061-2/+32
|/
* Merge pull request #800 from whitequark/write_verilog_tribufClifford Wolf2019-01-271-0/+12
|\ | | | | write_verilog: write $tribuf cell as ternary
| * write_verilog: write $tribuf cell as ternary.whitequark2019-01-271-0/+12
| |
* | write_verilog: escape names that match SystemVerilog keywords.whitequark2019-01-271-0/+27
|/
* Fix handling of $shiftx in Verilog back-endClifford Wolf2019-01-151-3/+6
| | | | Signed-off-by: Clifford Wolf <clifford@clifford.at>
* Fix typographical and grammatical errors and inconsistencies.whitequark2019-01-021-1/+1
| | | | | | | | | | | | The initial list of hits was generated with the codespell command below, and each hit was evaluated and fixed manually while taking context into consideration. DIRS="kernel/ frontends/ backends/ passes/ techlibs/" DIRS="${DIRS} libs/ezsat/ libs/subcircuit" codespell $DIRS -S *.o -L upto,iff,thru,synopsys,uint More hits were found by looking through comments and strings manually.
* write_verilog: handle the $shift cell.whitequark2018-12-161-0/+29
| | | | | | | | | | | | | | | | | | | | | | | | | | | The implementation corresponds to the following Verilog, which is lifted straight from simlib.v: module \\$shift (A, B, Y); parameter A_SIGNED = 0; parameter B_SIGNED = 0; parameter A_WIDTH = 0; parameter B_WIDTH = 0; parameter Y_WIDTH = 0; input [A_WIDTH-1:0] A; input [B_WIDTH-1:0] B; output [Y_WIDTH-1:0] Y; generate if (B_SIGNED) begin:BLOCK1 assign Y = $signed(B) < 0 ? A << -B : A >> B; end else begin:BLOCK2 assign Y = A >> B; end endgenerate endmodule
* Merge pull request #736 from whitequark/select_assert_listClifford Wolf2018-12-161-1/+1
|\ | | | | select: print selection if a -assert-* flag causes an error
| * write_verilog: add a missing newline.whitequark2018-12-161-1/+1
| |
* | write_verilog: correctly map RTLIL `sync init`.whitequark2018-12-071-0/+2
|/
* adding offset info to memoriesrafaeltp2018-10-181-1/+1
|
* adding offset info to memoriesrafaeltp2018-10-181-2/+3
|
* Fixed typo in "verilog_write" help messageacw12512018-09-181-3/+3
|
class="o">=set_int, default=128, use="Domain memory in MB.") gopts.var('ssidref', val='SSIDREF', fn=set_u32, default=-1, use="Security Identifier.") gopts.var('maxmem', val='MEMORY', fn=set_int, default=None, use="Maximum domain memory in MB.") gopts.var('cpu', val='CPU', fn=set_int, default=None, use="CPU to run the domain on.") gopts.var('vcpus', val='VCPUS', fn=set_int, default=1, use="# of Virtual CPUS in domain.") gopts.var('cpu_weight', val='WEIGHT', fn=set_float, default=None, use="""Set the new domain's cpu weight. WEIGHT is a float that controls the domain's share of the cpu.""") gopts.var('console', val='PORT', fn=set_int, default=None, use="Console port to use. Default is 9600 + domain id.") gopts.var('restart', val='onreboot|always|never', fn=set_value, default=None, use="""Whether the domain should be restarted on exit. - onreboot: restart on exit with shutdown code reboot - always: always restart on exit, ignore exit code - never: never restart on exit, ignore exit code""") gopts.var('blkif', val='no|yes', fn=set_bool, default=0, use="Make the domain a block device backend.") gopts.var('netif', val='no|yes', fn=set_bool, default=0, use="Make the domain a network interface backend.") gopts.var('disk', val='phy:DEV,VDEV,MODE[,DOM]', fn=append_value, default=[], use="""Add a disk device to a domain. The physical device is DEV, which is exported to the domain as VDEV. The disk is read-only if MODE is 'r', read-write if MODE is 'w'. If DOM is specified it defines the backend driver domain to use for the disk. The option may be repeated to add more than one disk.""") gopts.var('pci', val='BUS,DEV,FUNC', fn=append_value, default=[], use="""Add a PCI device to a domain, using given params (in hex). For example '-pci c0,02,1a'. The option may be repeated to add more than one pci device.""") gopts.var('usb', val='PATH', fn=append_value, default=[], use="""Add a physical USB port to a domain, as specified by the path to that port. This option may be repeated to add more than one port.""") gopts.var('ipaddr', val="IPADDR", fn=append_value, default=[], use="Add an IP address to the domain.") gopts.var('vif', val="mac=MAC,be_mac=MAC,bridge=BRIDGE,script=SCRIPT,backend=DOM,vifname=NAME", fn=append_value, default=[], use="""Add a network interface with the given MAC address and bridge. The vif is configured by calling the given configuration script. If mac is not specified a random MAC address is used. The MAC address of the backend interface can be selected with be_mac. If not specified then the network backend chooses it's own MAC address. If bridge is not specified the default bridge is used. If script is not specified the default script is used. If backend is not specified the default backend driver domain is used. If vifname is not specified the backend virtual interface will have name vifD.N where D is the domain id and N is the interface id. This option may be repeated to add more than one vif. Specifying vifs will increase the number of interfaces as needed.""") gopts.var('nics', val="NUM", fn=set_int, default=1, use="""Set the number of network interfaces. Use the vif option to define interface parameters, otherwise defaults are used. Specifying vifs will increase the number of interfaces as needed.""") gopts.var('root', val='DEVICE', fn=set_value, default='', use="""Set the root= parameter on the kernel command line. Use a device, e.g. /dev/sda1, or /dev/nfs for NFS root.""") gopts.var('extra', val="ARGS", fn=set_value, default='', use="Set extra arguments to append to the kernel command line.") gopts.var('ip', val='IPADDR', fn=set_value, default='', use="Set the kernel IP interface address.") gopts.var('gateway', val="IPADDR", fn=set_value, default='', use="Set the kernel IP gateway.") gopts.var('netmask', val="MASK", fn=set_value, default = '', use="Set the kernel IP netmask.") gopts.var('hostname', val="NAME", fn=set_value, default='', use="Set the kernel IP hostname.") gopts.var('interface', val="INTF", fn=set_value, default="eth0", use="Set the kernel IP interface name.") gopts.var('dhcp', val="off|dhcp", fn=set_value, default='off', use="Set the kernel dhcp option.") gopts.var('nfs_server', val="IPADDR", fn=set_value, default=None, use="Set the address of the NFS server for NFS root.") gopts.var('nfs_root', val="PATH", fn=set_value, default=None, use="Set the path of the root NFS directory.") gopts.var('memmap', val='FILE', fn=set_value, default='', use="Path to memap SXP file.") gopts.var('device_model', val='FILE', fn=set_value, default='', use="Path to device model program.") gopts.var('device_config', val='FILE', fn=set_value, default='', use="Path to device model configuration.") def strip(pre, s): """Strip prefix 'pre' if present. """ if s.startswith(pre): return s[len(pre):] else: return s def configure_image(opts, config, vals): """Create the image config. """ config_image = [ vals.builder ] config_image.append([ 'kernel', os.path.abspath(vals.kernel) ]) if vals.ramdisk: config_image.append([ 'ramdisk', os.path.abspath(vals.ramdisk) ]) if vals.cmdline_ip: cmdline_ip = strip('ip=', vals.cmdline_ip) config_image.append(['ip', cmdline_ip]) if vals.root: cmdline_root = strip('root=', vals.root) config_image.append(['root', cmdline_root]) if vals.extra: config_image.append(['args', vals.extra]) if vals.vcpus: config_image.append(['vcpus', vals.vcpus]) config.append(['image', config_image ]) def configure_disks(opts, config_devs, vals): """Create the config for disks (virtual block devices). """ for (uname, dev, mode, backend) in vals.disk: config_vbd = ['vbd', ['uname', uname], ['dev', dev ], ['mode', mode ] ] if backend: config_vbd.append(['backend', backend]) config_devs.append(['device', config_vbd]) def configure_pci(opts, config_devs, vals): """Create the config for pci devices. """ for (bus, dev, func) in vals.pci: config_pci = ['pci', ['bus', bus], ['dev', dev], ['func', func]] config_devs.append(['device', config_pci]) def configure_usb(opts, config_devs, vals): for path in vals.usb: config_usb = ['usb', ['path', path]] config_devs.append(['device', config_usb]) def randomMAC(): """Generate a random MAC address. Uses OUI (Organizationally Unique Identifier) AA:00:00, an unassigned one that used to belong to DEC. The OUI list is available at 'standards.ieee.org'. The remaining 3 fields are random, with the first bit of the first random field set 0. @return: MAC address string """ random.seed() mac = [ 0xaa, 0x00, 0x00, random.randint(0x00, 0x7f), random.randint(0x00, 0xff), random.randint(0x00, 0xff) ] return ':'.join(map(lambda x: "%02x" % x, mac)) def configure_vifs(opts, config_devs, vals): """Create the config for virtual network interfaces. """ vifs = vals.vif vifs_n = max(vals.nics, len(vifs)) for idx in range(0, vifs_n): if idx < len(vifs): d = vifs[idx] mac = d.get('mac') if not mac: mac = randomMAC() be_mac = d.get('be_mac') bridge = d.get('bridge') script = d.get('script') backend = d.get('backend') ip = d.get('ip') vifname = d.get('vifname') else: mac = randomMAC() be_mac = None bridge = None script = None