Back to features

Component Library

Gates, flip-flops, registers, ALU, memory modules, and more. Build complex designs from proven, tested primitives.

Gates Flip-Flops Registers ALU Memory

Primitive Catalog

Ready-to-use building blocks organized by category. Each component is fully tested and synthesizable.

CategoryComponentsDescription
Logic GatesAND, OR, XOR, NOT, NAND, NOR, XNORBasic combinational logic, parameterized width
MultiplexersMux2, Mux4, MuxN2-input, 4-input, and N-input select
ArithmeticAdder, Subtractor, Comparator, ShifterParameterized width arithmetic units
Flip-FlopsDFF, DFFE, DFFR, DFFERD flip-flop with enable and reset variants
RegistersRegister, ShiftRegister, LFSRMulti-bit storage with load, shift, feedback
CountersCounter, UpDownCounter, RingCounterConfigurable width, wrap, and direction
MemoryRAM, ROM, RegisterFileConfigurable depth and width storage
ALUSimpleALU, ALUArithmetic logic units with selectable ops

Usage Patterns

Instantiate and wire library components directly into your design. All components support parameterized widths.

using_primitives.rb
class Datapath < RHDL::Sim::Component
  input  :clk, :rst
  input  :a, :b, width: 8
  input  :op, width: 2
  output :result, width: 8

  component :alu,
    SimpleALU, width: 8

  component :out_reg,
    Register, width: 8

  wire :alu, :a => :a
  wire :alu, :b => :b
  wire :alu, :op => :op
  wire :out_reg, :d => :alu.result
  wire :result => :out_reg.q
end

Compose primitives into larger building blocks. A register file uses individual registers and a decoder.

register_file.rb
class RegFile8x8 < RHDL::Sim::Component
  input  :clk, :we
  input  :rd_addr, width: 3
  input  :wr_addr, width: 3
  input  :wr_data, width: 8
  output :rd_data, width: 8

  8.times do |i|
    component "r#{i}",
      Register, width: 8
  end

  component :rd_mux,
    MuxN,
    inputs: 8, width: 8
end