Memristor Mapper¶
Memristive crossbar array mapper with non-linear conductance, device aging simulation, and power/area estimation.
Quick Start¶
from sc_neurocore.memristor.memristor_mapper import (
CrossbarArray, ConductanceModel, AgingSimulator, CrossbarEstimator,
)
sc_neurocore.memristor.memristor_mapper
¶
Variability-aware memristor crossbar mapper for stochastic computing.
Takes SC bitstreams + per-device conductance variability models (from real fab data distributions) and emits optimised crossbar-aware SystemVerilog with compensation LUTs or stochastic encoding that absorbs read/write noise at design time.
Supports Monte Carlo variability injection for co-simulation, enabling fab-ready crossbar SC deployment on emerging memristor arrays (Mythic, Weebit, 2D-material ReRAM, phase-change, etc.).
MemristorTechnology
¶
Bases: Enum
Supported memristor fabrication technologies.
Source code in src/sc_neurocore/memristor/memristor_mapper.py
| Python | |
|---|---|
34 35 36 37 38 39 40 41 | |
ConductanceModel
dataclass
¶
Per-device conductance variability model.
Models both device-to-device (D2D) fabrication variability and cycle-to-cycle (C2C) read/write noise as Gaussian distributions.
Source code in src/sc_neurocore/memristor/memristor_mapper.py
| Python | |
|---|---|
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 | |
dynamic_range
property
¶
ON/OFF conductance ratio.
level_step
property
¶
Conductance step between adjacent levels.
__post_init__()
¶
Fill any unset conductance parameters from the technology presets.
Source code in src/sc_neurocore/memristor/memristor_mapper.py
| Python | |
|---|---|
111 112 113 114 115 116 117 118 119 120 121 122 123 | |
target_conductance(level)
¶
Nominal conductance for a given quantisation level.
Source code in src/sc_neurocore/memristor/memristor_mapper.py
| Python | |
|---|---|
135 136 137 138 | |
sample_d2d(level, rng)
¶
Sample actual conductance with device-to-device variability.
Source code in src/sc_neurocore/memristor/memristor_mapper.py
| Python | |
|---|---|
140 141 142 143 | |
sample_rw(conductance, rng)
¶
Apply read/write noise to a conductance value.
Source code in src/sc_neurocore/memristor/memristor_mapper.py
| Python | |
|---|---|
145 146 147 | |
drift(conductance, elapsed_s, alpha=0.1)
¶
Model conductance drift over time.
Uses power-law drift: G(t) = G₀ × (t/t₀)^(-α)
Source code in src/sc_neurocore/memristor/memristor_mapper.py
| Python | |
|---|---|
149 150 151 152 153 154 155 156 157 158 | |
thermal_shift(conductance, temp_c, ref_c=25.0)
¶
Temperature-dependent conductance shift.
Linear TC model: ΔG/G ≈ tc_ppm × ΔT × 1e-6.
Source code in src/sc_neurocore/memristor/memristor_mapper.py
| Python | |
|---|---|
160 161 162 163 164 165 166 167 | |
SneakPathModel
¶
Estimates sneak-path leakage in passive crossbar arrays.
In an M×N passive crossbar, selecting cell (r,c) exposes parallel leakage paths through unselected devices. Worst-case sneak current is proportional to (M+N-2) × G_off.
Source code in src/sc_neurocore/memristor/memristor_mapper.py
| Python | |
|---|---|
173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 | |
worst_case_sneak(rows, cols, g_off, v_read=0.2)
staticmethod
¶
Worst-case sneak current (A) through unselected paths.
Source code in src/sc_neurocore/memristor/memristor_mapper.py
| Python | |
|---|---|
181 182 183 184 185 | |
signal_to_sneak_ratio(g_on, g_off, rows, cols)
staticmethod
¶
Ratio of desired signal current to sneak current.
Source code in src/sc_neurocore/memristor/memristor_mapper.py
| Python | |
|---|---|
187 188 189 190 191 192 193 | |
IRDropModel
dataclass
¶
Models interconnect wire resistance and voltage drop.
Source code in src/sc_neurocore/memristor/memristor_mapper.py
| Python | |
|---|---|
199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 | |
voltage_drop(row, col)
¶
Accumulated IR drop at cell (row, col) from corner.
Source code in src/sc_neurocore/memristor/memristor_mapper.py
| Python | |
|---|---|
205 206 207 | |
effective_conductance(g_nominal, row, col, v_read=0.2)
¶
Conductance seen at read amplifier after IR drop.
Source code in src/sc_neurocore/memristor/memristor_mapper.py
| Python | |
|---|---|
209 210 211 212 213 214 215 | |
StuckFaultMap
dataclass
¶
Map of stuck-at ON/OFF devices in a crossbar.
Source code in src/sc_neurocore/memristor/memristor_mapper.py
| Python | |
|---|---|
221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 | |
num_faults
property
¶
Return the total count of stuck-on and stuck-off devices.
fault_rate
property
¶
Return the fraction of crossbar cells that are faulty.
generate(rows, cols, fault_rate=0.001, seed=42)
classmethod
¶
Generate random stuck faults at given rate.
Source code in src/sc_neurocore/memristor/memristor_mapper.py
| Python | |
|---|---|
230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 | |
is_stuck(row, col)
¶
Return 'on', 'off', or None.
Source code in src/sc_neurocore/memristor/memristor_mapper.py
| Python | |
|---|---|
253 254 255 256 257 258 259 | |
AgingReport
dataclass
¶
Results of aging simulation.
Source code in src/sc_neurocore/memristor/memristor_mapper.py
| Python | |
|---|---|
276 277 278 279 280 281 282 283 | |
AgingSimulator
¶
Simulates conductance drift over device lifetime.
Source code in src/sc_neurocore/memristor/memristor_mapper.py
| Python | |
|---|---|
286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 | |
simulate(conductances, elapsed_s)
¶
Apply drift to all conductances, return (drifted, report).
Source code in src/sc_neurocore/memristor/memristor_mapper.py
| Python | |
|---|---|
293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 | |
SCAbsorbEncoder
¶
Adjusts SC encoding thresholds to absorb known device variability.
Instead of compensating post-silicon, pre-distorts the bitstream encoding thresholds so that the effective computation matches ideal.
Source code in src/sc_neurocore/memristor/memristor_mapper.py
| Python | |
|---|---|
315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 | |
compute_adjusted_thresholds(ideal_weights, actual_conductances, model, q_bits=8)
staticmethod
¶
Return Q8.8 adjusted thresholds that absorb device error.
Source code in src/sc_neurocore/memristor/memristor_mapper.py
| Python | |
|---|---|
322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 | |
WriteVerifyResult
dataclass
¶
Outcome of iterative write-verify programming.
Source code in src/sc_neurocore/memristor/memristor_mapper.py
| Python | |
|---|---|
356 357 358 359 360 361 362 363 364 | |
WriteVerifyProtocol
¶
Iterative program-verify loop for memristor cells.
Source code in src/sc_neurocore/memristor/memristor_mapper.py
| Python | |
|---|---|
367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 | |
program_cell(target_level)
¶
Program a single cell to target level with verify.
Source code in src/sc_neurocore/memristor/memristor_mapper.py
| Python | |
|---|---|
382 383 384 385 386 387 388 389 390 391 392 393 394 395 | |
CrossbarPowerEstimate
dataclass
¶
Power and performance estimate for a crossbar tile.
Source code in src/sc_neurocore/memristor/memristor_mapper.py
| Python | |
|---|---|
401 402 403 404 405 406 407 408 409 410 411 | |
CrossbarEstimator
¶
Estimates power, latency, and area for crossbar arrays.
Source code in src/sc_neurocore/memristor/memristor_mapper.py
| Python | |
|---|---|
414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 | |
estimate(crossbar)
classmethod
¶
Estimate read/write power, latency and area for a crossbar array.
Source code in src/sc_neurocore/memristor/memristor_mapper.py
| Python | |
|---|---|
455 456 457 458 459 460 461 462 463 464 465 466 467 468 | |
CrossbarTopology
¶
Bases: Enum
Physical wiring topology of a memristor crossbar array.
Source code in src/sc_neurocore/memristor/memristor_mapper.py
| Python | |
|---|---|
474 475 476 477 478 479 480 | |
CrossbarArray
dataclass
¶
Physical crossbar array specification.
Source code in src/sc_neurocore/memristor/memristor_mapper.py
| Python | |
|---|---|
483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 | |
VariabilityInjector
¶
Injects fab-realistic conductance variability into weight matrices.
Source code in src/sc_neurocore/memristor/memristor_mapper.py
| Python | |
|---|---|
508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 | |
quantize_weights(weights)
¶
Map floating-point weights [0, 1] to conductance levels.
Source code in src/sc_neurocore/memristor/memristor_mapper.py
| Python | |
|---|---|
515 516 517 518 519 520 521 522 | |
inject_d2d(levels)
¶
Apply device-to-device variability to quantised levels.
Source code in src/sc_neurocore/memristor/memristor_mapper.py
| Python | |
|---|---|
524 525 526 527 528 529 | |
inject_rw(conductances)
¶
Apply read/write noise to conductance values.
Source code in src/sc_neurocore/memristor/memristor_mapper.py
| Python | |
|---|---|
531 532 533 534 535 536 | |
inject_full(weights)
¶
Full pipeline: quantise → D2D → R/W noise. Returns (levels, conductances).
Source code in src/sc_neurocore/memristor/memristor_mapper.py
| Python | |
|---|---|
538 539 540 541 542 543 544 545 | |
compute_error(weights, conductances)
¶
Compute variability-induced error statistics.
Source code in src/sc_neurocore/memristor/memristor_mapper.py
| Python | |
|---|---|
547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 | |
CompensationStrategy
¶
Bases: Enum
Strategy for compensating memristor conductance non-idealities.
Source code in src/sc_neurocore/memristor/memristor_mapper.py
| Python | |
|---|---|
568 569 570 571 572 573 574 | |
CompensationLUT
dataclass
¶
Per-device compensation lookup table.
Maps nominal level → compensated threshold to absorb known D2D variability at design time (program-verify or digital pre-distortion).
Source code in src/sc_neurocore/memristor/memristor_mapper.py
| Python | |
|---|---|
577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 | |
max_compensation
property
¶
Maximum compensation ratio (deviation from 1.0).
build(device_id, model, measured_g=None)
classmethod
¶
Build compensation LUT from measured or modelled conductances.
If measured_g is None, generates from the model's nominal values.
Source code in src/sc_neurocore/memristor/memristor_mapper.py
| Python | |
|---|---|
589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 | |
CrossbarMapping
dataclass
¶
Mapping of a weight matrix to a crossbar array.
Source code in src/sc_neurocore/memristor/memristor_mapper.py
| Python | |
|---|---|
623 624 625 626 627 628 629 630 631 | |
MappingResult
dataclass
¶
Full result of a memristor mapping pass.
Source code in src/sc_neurocore/memristor/memristor_mapper.py
| Python | |
|---|---|
634 635 636 637 638 639 640 641 642 643 | |
MemristorMapper
¶
Maps SC network weight matrices to physical crossbar arrays.
Source code in src/sc_neurocore/memristor/memristor_mapper.py
| Python | |
|---|---|
646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 | |
map_weights(weights)
¶
Map a weight matrix (or list of matrices) to crossbar arrays.
Source code in src/sc_neurocore/memristor/memristor_mapper.py
| Python | |
|---|---|
664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 | |
MonteCarloReport
dataclass
¶
Results from Monte Carlo variability co-simulation.
Source code in src/sc_neurocore/memristor/memristor_mapper.py
| Python | |
|---|---|
722 723 724 725 726 727 728 729 730 731 732 | |
MonteCarloSimulator
¶
Monte Carlo co-simulation with variability injection.
Runs N trials of a crossbar multiply-accumulate operation with independently sampled D2D + R/W variability to estimate output error distributions and yield.
Source code in src/sc_neurocore/memristor/memristor_mapper.py
| Python | |
|---|---|
735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 | |
simulate_mac(weights, inputs)
¶
Simulate multiply-accumulate with variability.
Parameters¶
weights : ndarray, shape (M, N) Ideal weight matrix in [0, 1]. inputs : ndarray, shape (N,) Input vector in [0, 1].
Source code in src/sc_neurocore/memristor/memristor_mapper.py
| Python | |
|---|---|
755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 | |
VerilogEmitter
¶
Generates crossbar-aware SystemVerilog with compensation LUTs.
Source code in src/sc_neurocore/memristor/memristor_mapper.py
| Python | |
|---|---|
812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 | |
emit_crossbar(mapping, module_name='sc_memristor_crossbar')
¶
Generate SystemVerilog for a single crossbar tile.
Source code in src/sc_neurocore/memristor/memristor_mapper.py
| Python | |
|---|---|
819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 | |
emit_top(result, module_name='sc_memristor_array')
¶
Generate top-level module instantiating all crossbar tiles.
Source code in src/sc_neurocore/memristor/memristor_mapper.py
| Python | |
|---|---|
895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 | |