-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Several bug fixes and improvements (#192)
* Don't recompile HDL code when switching between 2 builtin chips * Allow comipling test seperately from hdl to not overrite builtin chips * Add missing await for chip compilation * Reset pin values after switching chip * Omit visualization label for chips without visualizations * Change builtin chip display to better reflect the book * Fix inconsistent HDL templates * Don't await useBuiltin inside switch toggle * Correctly load the first project on startup * Change "Visualizations" text to "Visualization" * Enable decimal inputs * Handle negative decimal inputs * Disable eval button when decimal input is invalid * Fix inconsistencies between chip names and file names * Line order change * Set some of the decimal fields to be unsigned according to function * Fix builtin chip syntax * Change invalid HDL error message * Remove ALUNoStat * Disable eval button when decimal input overflows * Fix virtual scroll * Add register visualization * Add Nand and DFF as builtin only chips * Add missing semicolons * Hide internal pins for builtin only chips * Fix DFF hdl interface & description * Add Screen and Keyboard builtin chips * Change keyboard output pins to update immediately * Fix builtin RAM reset * Fix true and false busses evaluation Signed-off-by: Neta London <[email protected]>
- Loading branch information
1 parent
42ad025
commit 611d235
Showing
28 changed files
with
502 additions
and
121 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import { Ok, isOk } from "@davidsouther/jiffies/lib/esm/result.js"; | ||
import { | ||
REGISTRY as BUILTIN_REGISTRY, | ||
getBuiltinChip, | ||
} from "@nand2tetris/simulator/chip/builtins/index.js"; | ||
|
||
export class ChipDisplayInfo { | ||
signBehaviors: Map<string, boolean> = new Map(); | ||
|
||
public constructor(chipName: string, unsigned?: string[]) { | ||
if (BUILTIN_REGISTRY.has(chipName)) { | ||
const chip = getBuiltinChip(chipName); | ||
if (isOk(chip)) { | ||
const pins = Array.from(Ok(chip).ins.entries()).concat( | ||
Array.from(Ok(chip).outs.entries()) | ||
); | ||
for (const pin of pins) { | ||
this.signBehaviors.set( | ||
pin.name, | ||
!unsigned || !unsigned.includes(pin.name) | ||
); | ||
} | ||
} | ||
} | ||
} | ||
|
||
public isSigned(pin: string) { | ||
return this.signBehaviors.get(pin); | ||
} | ||
} | ||
|
||
const UNSIGNED_PINS = new Map<string, string[]>([ | ||
["Mux4Way16", ["sel"]], | ||
["Mux8Way16", ["sel"]], | ||
["DMux4Way", ["sel"]], | ||
["DMux8Way", ["sel"]], | ||
["RAM8", ["address"]], | ||
["RAM64", ["address"]], | ||
["RAM512", ["address"]], | ||
["RAM4K", ["address"]], | ||
["RAM16K", ["address"]], | ||
["Screen", ["address"]], | ||
["Memory", ["address"]], | ||
["CPU", ["addressM", "pc"]], | ||
]); | ||
|
||
export const getDisplayInfo = (chipName: string) => | ||
new ChipDisplayInfo(chipName, UNSIGNED_PINS.get(chipName)); |
Oops, something went wrong.