Require
require
can be used in coordination with supports
statements to automate pin assignment. When we use a require
statement it creates a bundle which we can use like it already exists and the concrete pins it maps to are determined later.
Syntax
The general form of a require statement is:
require name-of-bundle:bundle-type from supporting-inst
pcb-module my-module :
inst stm32 : stm32f405G7
require data:i2c from stm32
require lots-of-data:i2c[10] from stm32
port p : pin[10]
pcb-bundle io-pin :
pin p
for i in pins(p) do :
supports io-pin:
io-pin.p => i
require dummy:io-pin[4] from self
pcb-component my-component :
port p : pin[10]
pcb-bundle io-pin :
pin p
for i in pins(p) do :
supports io-pin:
io-pin.p => i
require dummy:io-pin[4]
supports i2c :
require sda-pin:io-pin
require scl-pin:io-pin
i2c.sda => sda-pin.p
i2c.scl => scl-pin.p
Description
pcb-module my-module :
inst stm32 : stm32f405G7
require data:i2c from stm32
require lots-of-data:i2c[10] from stm32
require data:i2c from stm32
Create a bundle named data
of type i2c
and specify that it needs to come from the stm32
instance. We can now use data
in other code like net
statements.
require lots-of-data:i2c[10] from stm32
Create a bundle array named lots-of-data
of type i2c[10]
and specify that it needs to come from the stm32
instance.
We can use require amd supports inside a module to use pin assignment more flexible (e.g. allow pin swaps for routability for any set of bundles or pins). Here we define a dummy bundle io-pin
, add supports
for it in the context of the current module, and can then use require dummy:io-pin[4] from self
to access those supports.
port p : pin[10]
pcb-bundle io-pin :
pin p
for i in pins(p) do :
supports io-pin:
io-pin.p => i
require dummy:io-pin[4] from self
Similarly we can use require
inside a component definition, and we leave off the from
because it can only be from the component itself:
pcb-component my-component :
port p : pin[10]
pcb-bundle io-pin :
pin p
for i in pins(p) do :
supports io-pin:
io-pin.p => i
require dummy:io-pin[4]
And this can be used to simplify supports
for bundles that can be supported on many possible pins. e.g. when a processor or FPGA has a full cross bar for all of its digital interfaces, and i2c could appear on any of the pins, we can capture that full flexibility with a require
inside a supports statement:
supports i2c :
require sda-pin:io-pin
require scl-pin:io-pin
i2c.sda => sda-pin.p
i2c.scl => scl-pin.p
We require two io-pin
dummy pins (which can map to any component pin), and then map the i2c pins sda and scl to those pins. Now i2c can be mapped to any pin on the component.