Module prelude

Source
Expand description

! Prelude module defines common symbols to make importing RustHDL easier.

Re-exports§

pub use crate::docs::vcd2svg::vcd_to_svg;

Modules§

ast
block
clock
logic
probe
sim_time
synth
type_descriptor

Macros§

bus_address_strobe
bus_write_strobe
clock
The [clock!] macro is used to connect a set of devices to a common clock. The macro takes a variable number of arguments:
declare_async_fifo
declare_expanding_fifo
declare_narrowing_fifo
declare_sync_fifo
dff_setup
hls_fifo_read
hls_fifo_read_lazy
hls_fifo_write
hls_fifo_write_lazy
hls_host_drain
hls_host_get_word
hls_host_get_words
hls_host_issue_read
hls_host_noop
hls_host_ping
hls_host_put_word
hls_host_write
i2c_begin_read
i2c_begin_write
i2c_end_transmission
i2c_read
i2c_read_last
i2c_write
sim_assert
sim_assert_eq
simple_sim
target_path
vcd_path
wait_clock_cycle
wait_clock_cycles
wait_clock_false
wait_clock_true

Structs§

AD7193Config
AD7193Simulator
ADS868XSimulator
AsyncFIFO
AsynchronousFIFO
AutoReset
BaseController
BidiBusD
BidiBusM
BidiMaster
BidiSimulatedDevice
BitSynchronizer
A BitSynchronizer is used to move signals that are asynchronous to a clock into that clock domain using a pair of back-to-back flip-flops. While the first flip flop may become metastable, the second one is likely to be stable.
BlackBox
The BlackBox struct provides a way to wrap a blackbox, externally provided IP core.
Bridge
Clock
Fundamentally a Clock signal in RustHDL is simply a transparent wrapper around a boolean valued signal. So it could be thought of as a simple 1-bit wide signal. However, semantically, clocks are rarely treated like other signals, and typically connect only to dedicated clock ports on synchronous logic (like [DFF] or [RAM]).
Constant
The Constant wrapper can hold any Synth type and store it in a circuit for use by the HDL kernel. This is the easiest way to compute complex constants in your RustHDL constructors, and then store the results inside the circuit for later use. Unlike Signal, Constant does not have a .next field, so you cannot assign to a Constant in the HDL kernel (blocked at compile time). Note that Constant does not impl Default. You must construct it with the appropriate value when the circuit is built.
CrossNarrow
CrossNarrowFIFO
CrossWiden
CrossWidenFIFO
DFF
DFFWithInit
DelayLine
EdgeDetector
Expander
FIFOExpanderN
FIFOLink
FIFOReadController
FIFOReadResponder
FIFOReducer
FIFOReducerN
FIFOWriteController
FIFOWriteResponder
FaderWithSyncROM
FalsePathRegexp
HLSSPIMaster
HLSSPIMasterDynamicMode
HLSSPIMuxMasters
HLSSPIMuxSlaves
Host
I2CBusDriver
I2CBusReceiver
I2CConfig
I2CTarget
I2CTestBus
I2CTestTarget
In
This direction marker is used for a [Signal] that is an input with respect to a circuit. That means that we do not expect to write to the input, but that the value will be set by external components to the circuit.
InOut
InputTimingConstraint
LFSRSimple
LazyFIFOFeeder
LazyFIFOReader
Local
MAX31856Simulator
MISOFIFOPort
MISOPort
MISOWidePort
MOSIFIFOPort
MOSIPort
MOSIWidePort
MemoryTimings
ModuleDefines
MultiplyAccumulateSymmetricFiniteImpulseResponseFilter
MuxMasters
MuxSlaves
MuxedAD7193Simulators
MuxedADS868XSimulators
NamedPath
OpenDrainBuffer
OpenDrainDriver
OpenDrainReceiver
Out
This direction marker is used for a [Signal] that leaves a circuit as an output. That means we expect this circuit to drive the signal using its internal logic. It is an error in RustHDL to leave an output undriven.
OutputTimingConstraint
PeriodicTiming
PinConstraint
PulseWidthModulator
Pulser
RAM
ROM
Reducer
RegisterFIFO
Router
RouterROM
SDRAMBaseController
SDRAMBurstController
SDRAMController
SDRAMControllerTester
SDRAMDriver
SDRAMFIFO
SDRAMFIFOController
SDRAMOnChipBuffer
SDRAMSimulator
SPIConfig
SPIConfigDynamicMode
SPIMaster
SPIMasterDynamicMode
SPISlave
The SPISlave is mostly meant for testing the [SPIMaster], but you can use it to implement a SPI endpoint in the FPGA if you want to. This SPISlave is not very robust, so be cautious with using it. In particular, with a very badly behaved SPI master, it may not operate as expected.
SPIWiresMaster
SPIWiresSlave
Shot
Signal
Signed
Sim
The Sim struct is used to communicate with a simulation. Every testbench will be provided with a copy of this struct, and will use it to communicate with the core simulation.
Simulation
This type represents a simulation over a circuit T. To simulate a circuit, you will need to construct one of these structs.
SoCBusController
SoCBusResponder
SoCPortController
SoCPortResponder
SoCTestChip
Strobe
A Strobe generates a periodic pulse train, with a single clock-cycle wide pulse at the prescribed frequency. The argument [N] of the generic Strobe is used to size the counter that stores the internal delay value. Unfortunately, Rust const generics are currently not good enough to compute [N] on the fly. However, a compile time assert ensures that the number of clock cycles between pulses does not overflow the [N]-bit wide register inside the Strobe.
SyncFIFO
SyncROM
SyncReceiver
A SyncReceiver works together with a SyncSender to transmit data from one clock domain to another (in one direction). To use a SyncReceiver wire up the [sig_cross], [flag_in] and [ack_out] signals between the two.
SyncSender
When you need to send many bits between two clock domains, it is risky to use a vector of BitSynchronizer structs. That is because, you cannot guarantee at any given moment that all of the bits of your multi-bit signal will cross into the new clock domain at once. So to synchronize a multi-bit signal, use a SyncSender and SyncReceiver pair. These widgets will use a set of handshake signals to move a value from one clock domain to another safely. Note that while the state machine is executing, the synchronizer will indicate it is busy. Crossing clock domains with greater ease is best done with an [AsynchronousFIFO].
SynchronousFIFO
TimingInfo
TopWrap
TristateBuffer
Tristate Buffer
TypeDescriptor
TypeField
VectorSynchronizer
A VectorSynchronizer uses a SyncSender and SyncReceiver in a matched pair to transmit a vector of bits (or any Synth type from one clock domain to a second clock domain without metastability or data corruption. You can think of a VectorSynchronizer as a single-element asynchronous FIFO, and indeed [AsynchronousFIFO] uses the VectorSynchronizer internally.
VivadoInputTimingConstraint
VivadoOutputTimingConstraint
Wrapper
The Wrapper struct provides a more convenient and flexible way to wrap external IP cores than BlackBox.

Enums§

Bits
The Bits type holds a bit array of size [N].
Constraint
OutputBuffer
SDRAMCommand
SignalType
SimError
The error type returned by a simulation
SlewType
SynthError
Timing
TimingRelative
TimingRelativeEdge
TypeKind
VCDValue
Verilog
The Verilog type is used to represent the Verilog translation of a RustHDL kernel. You will only need it if implementing blackbox cores or wrapping external Verilog code.
WordOrder

Constants§

AD7193_REG_WIDTHS
NANOS_PER_FEMTO
The number of nanoseconds per femtosecond.
SIMULATION_TIME_ONE_SECOND

Traits§

Block
The Block trait is required for all circuitry that can be simulated by RustHDL. If you want to be able to simulate a circuit, the corresponding struct must impl Block. Normally, this is done via the #[derive(LogicBlock)] construct, and you will rarely, if ever, need to impl the Block trait yourself.
HLSNamedPorts
Logic
LogicJoin
LogicLink
Probe
Synth
ToBits
The ToBits trait is used to provide a way to convert Rust standard unsigned types (currently u8, u16, u32, u64, u128) into Bits of different lengths. Note that RustHDL will panic if you attempt to convert an unsigned type into a Bits that is too small to hold the value.
ToSignedBits
VerilogVisitor

Functions§

bit_cast
Cast from one bit width to another with truncation or zero padding The bit_cast function allows you to convert from one bit width to another. It handles the different widths in the following simplified manner: - if casting to a narrower bit width, the most significant bits are discarded until the new value fits into the specified bits - if casting to a wider bit width, the most significant bits are padded with zeros until the new value occupies the specified bits This may seem a bit counterintuitive, but it fits logical circuitry behavior. Narrowing is usually done by preserving the least significant bits (so that the carry bits are discarded when adding, for example). Widening is also usually done (for unsigned values) by zero extending the most significant bits. The bit_cast operation does both of these operations depending on the arguments.
bits
Convenience function to construct Bits from an unsigned literal Sometimes, you know you will be working with a value that is smaller than 128 bits (the current maximum sized built-in unsigned integer in Rust). In those cases, the bits function can make construction slightly simpler.
bursty_rand
bursty_vec
check_all
This is a helper function used to check a Block for connection, loops, and writes to the inputs.
check_connected
Check to see if a circuit is properly connected (no undriven inputs, or multiply-driven outputs). You can call this directly on a circuit of yours if you want to check that it is correctly connected internally.
check_timing
clog2
Compute the minimum number of bits to represent a container with t items. This is basically ceil(log2(t)) as a constant (compile time computable) function. You can use it where a const generic (bit width) argument is required.
filter_blackbox_directives
freq_hz_to_period_femto
Convert a frequency in Hz to a period in femtoseconds.
generate_verilog
generate_verilog_unchecked
signed
signed_bit_cast
signed_cast
simulate
Update changes to a circuit until it stabilizes
snore
unsigned_bit_cast
unsigned_cast
write_vcd_change
write_vcd_dump
write_vcd_header
yosys_validate

Type Aliases§

Bit
A type alias for a simple bool. You can use them interchangeably.
LiteralType
The LiteralType is used to set the type for literals that appear in RustHDL expressions. Because of how Rust’s type inference currently works, an expression like

Attribute Macros§

hdl_gen

Derive Macros§

LogicBlock
LogicInterface
LogicState
LogicStruct