Skip to content

Tutorial: Create a circuit

NOTE: Before starting this tutorial, you should have installed JITX and created your first design.

This document contains all code examples and product actions from Quickstart 2 in a format that's easy to follow along with. Use it as a companion to the video tutorial.

Resources

  • Shared repositories: https://github.com/JITx-Inc/awesome-jitx
  • Tutorial code: https://github.com/JITx-Inc/quickstart-by-phase/tree/main/quickstart-2-files

Development Tips

  • Restart terminal after modifying slm.toml
  • Use Ctrl+Enter to run current file
  • Verify package names and imports match project structure

1. Project Setup

Update Main Module

First, rename the default module in main.stanza:

# Change from:
pcb-module my-design:

# To:
pcb-module top-level:

Update the main module reference:

# Change:
set-main-module(my-design)

# To:
set-main-module(top-level)

2. Creating the Communications Core

Initial Module Setup

Create a new module in main.stanza:

pcb-module communications-core :
  ; Components will be added here

Adding Components

  1. Add Zener Diode:
  2. Open JITX sidebar
  3. Click "Find components"
  4. Search for "MMSZ4689T1G"
  5. Use "Copy to clipboard"

    inst zener : create-part(mpn = "MMSZ4689T1G", manufacturer = "ON Semiconductor")
    

  6. Instantiate in Top Level:

    pcb-module top-level :
      inst core : communications-core
    

3. USB Interface Integration

  1. Add Library Dependency In slm.toml:

    connectors = { git = "JITx-Inc/connectors", version = "0.4.1" }
    

  2. Add USB Connector

    inst usb-if : connectors/components/USB/USBTypeC/USBC-HighSpeed-Iface()
    

  3. Connect Zener to USB Power

    net (zener.A usb-if.VDD-USB.V-)
    net (zener.K usb-if.VDD-USB.V+)
    

4. Controller Module Development

File Structure

Create src/controller.stanza:

#use-added-syntax(jitx)
defpackage ethernet-io/controller :
  import core
  import jitx
  import jitx/commands
  import jitx/parts
  import helpers
  import jsl

public pcb-module controller :
  port rail-3v3 : power
  port USB : usb-data
  port VDD-USB : power
  name = "MCU"

Project Configuration

Update stanza.proj:

packages ethernet-io/* defined-in "src/"

FTDI Integration

  1. Add FTDI Library:

    FTDI = { git = "JITx-Inc/FTDI", version = "0.3.3" }
    

  2. Add Debug Interface:

    inst debug-if : FTDI/DebugIF/circuit(
      FTDI/components/FT2232HL/FT2232H-MPSSE,
      FTDI/components/FT2232HL/FT2232H-RS232,
      R-query = R-query,
      C-query = C-query
    )
    

Debug Interface Connections

net (rail-3v3 debug-if.VDD-3v3)
net (VDD-USB debug-if.VDD-USB)
net (USB debug-if.USB)

5. EEPROM Component Creation

Component Definition

Create src/components/MC-93LC46CT.stanza:

#use-added-syntax(jitx)
defpackage components/MC-93LC46CT:
  import core
  import jitx
  import jitx/commands
  import jitx/parts
  import jsl

public pcb-component component :
  name = "MC-93LC46CT"
  description = "1K 2.5V Microwire Serial EEPROM, SOIC-8 Package"
  mpn = "93LC46CT-I/SN"
  manufacturer = "Microchip Technology"
  datasheet = "https://ww1.microchip.com/downloads/en/DeviceDoc/20001749K.pdf"
  reference-prefix = "U"

  pin-properties:
    [pin:Ref  | pads:Int | side:Dir ]
    [CS       | 1        | Left     ] ; Chip Select
    [CLK      | 2        | Left     ] ; Serial Clock
    [DI       | 3        | Left     ] ; Data Input  
    [DO       | 4        | Left    ] ; Data Output
    [VSS      | 5        | Left     ] ; Ground
    [VCC      | 8        | Right       ] ; Power Supply
    [ORG      | 6        | Right    ] ; Memory Configuration
    [NC       | 7        | Right    ] ; No Connection

  val box = BoxSymbol(self)
  val symb = create-symbol(box)
  assign-symbol(symb)

  val pkg = SOIC-N(
    num-leads = 8,
    lead-span = min-max(5.8, 6.2),
    package-length = min-max(4.8, 5.0)
    density-level = DensityLevelA
  )
  val lp = create-landpattern(pkg)
  assign-landpattern(lp)

EEPROM Module

public pcb-module module :
  port VDD-3v3 : power
  port cfg : microwire-4()

  inst EEPROM : components/MC-93LC46CT/component
  net (EEPROM.CS cfg.cs)
  net (EEPROM.CLK cfg.clk)
  net (EEPROM.DO cfg.do)
  net (EEPROM.DI cfg.di)
  net (EEPROM.VCC VDD-3v3.V+)
  net (EEPROM.VSS VDD-3v3.V-)

  insert-resistor(
    EEPROM.ORG EEPROM.VCC
    helpers/R-query
    resistance = 10.e3
  )

  insert-capacitor(
    EEPROM.VCC EEPROM.VSS
    helpers/C-query
    capacitance = 2.2e-6
    short-trace? = true
  )

Integration

Add to controller:

inst EEPROM : components/MC-93LC46CT/module
net (EEPROM.VDD-3v3 rail-3v3)
net (EEPROM.cfg debug-if.CFG)

Key Concepts Learned

  1. Component Management
  2. Adding from database
  3. Creating custom components
  4. Using library code

  5. Circuit Organization

  6. Module hierarchy
  7. File structure
  8. Package management

  9. Connectivity

  10. Using nets
  11. Port creation
  12. Interface bundles

  13. Library Usage

  14. Adding dependencies
  15. Importing modules
  16. Using parametric circuits