Skip to content

001 Power Net ​

001-power-net.mc creates a 5 V source and names its positive and ground nets. It introduces the basic shape of a runnable MCode file:

text
module main
{
    io GND
    io V5V

    DC.SRC PWR(5V, 500mA)
    PWR.1 -> V5V
    PWR.2 -> GND
}
  • // starts a line comment.
  • module main declares the entry module that MCC runs. { and } delimit its body; indentation is for readability.
  • io V5V and io GND explicitly declare named bidirectional connection points in the module. A name alone does not establish a voltage or a ground contract; the source pins and wiring establish the circuit connections.
  • DC.SRC is the SRC component type in the DC namespace. PWR is this source instance's local name.
  • (5V, 500mA) supplies positional arguments. V and mA are physical unit suffixes, and the comma separates arguments.
  • PWR.1 selects physical pin 1 of PWR. The dot selects a member of an instance.
  • -> connects its left and right operands. V5V and GND give readable names to the two electrical nodes.

Pin 1 of DC.SRC is positive and pin 2 is ground, so the two connection statements create the expected supply rails.

bash
eval "$(../mcc/scripts/mcc-slot.sh)"
MCC_SYSTEM_ROOT="$(cd .. && pwd)" "$MCC_BIN" --local parse 00-getting-started/001-power-net.mc --lib mcode --pass1 --pass2
MCC_SYSTEM_ROOT="$(cd .. && pwd)" "$MCC_BIN" --local parse 00-getting-started/001-power-net.mc --lib mcode --viz -o 00-getting-started/001-power-net.html

Source ​

text
// Example: Power Net
// Goal: Introduce a minimal module, a source component, and named power nets.
// Library focus: DC.

module main
{
    io GND
    io V5V

    DC.SRC PWR(5V, 500mA)

    PWR.1 -> V5V
    PWR.2 -> GND
}

MCode Bench is the public face of the MCode stack. Closed capabilities are served through the MCode gateway.