Created
December 22, 2025 13:58
-
-
Save ADITYATIWARI342005/8f8dbe1bd0b7219fce8ee14b5d3f05eb to your computer and use it in GitHub Desktop.
visualizationExampleGist
This file contains hidden or 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
| \m5_TLV_version 1d: tl-x.org | |
| \SV | |
| module top(input wire clk, input wire reset, input wire [31:0] cyc_cnt, output wire passed, output wire failed); | |
| \TLV | |
| $reset = *reset; | |
| $cnt[3:0] = $reset ? 0 : >>1$cnt + 1; | |
| /inv | |
| $in = $cnt[0]; | |
| $out = ! $in; | |
| \viz_js | |
| box: {width: 140, height: 75, strokeWidth: 1, stroke: "black"}, | |
| init() { | |
| return { | |
| title: new fabric.Text("Inverter", { | |
| left: 10, top: 8, | |
| fontSize: 15, fontFamily: "Courier New" | |
| }), | |
| inLabel: new fabric.Text("in:", {left: 15, top: 32, fontSize: 13, fontFamily: "Courier New"}), | |
| inVal: new fabric.Text("", {left: 45, top: 32, fontSize: 13, fontFamily: "Courier New"}), | |
| outLabel: new fabric.Text("out:", {left: 15, top: 50, fontSize: 13, fontFamily: "Courier New"}), | |
| outVal: new fabric.Text("", {left: 50, top: 50, fontSize: 13, fontFamily: "Courier New"}) | |
| } | |
| }, | |
| render() { | |
| let objs = this.getObjects() | |
| objs.inVal.set({text: '$in'.asBinaryStr()}) | |
| objs.outVal.set({text: '$out'.asBinaryStr()}) | |
| return [] | |
| }, | |
| where: {left: 30, top: 30} | |
| /and | |
| $in1 = $cnt[0]; | |
| $in2 = $cnt[1]; | |
| $out = $in1 && $in2; | |
| \viz_js | |
| box: {width: 140, height: 95, strokeWidth: 1, stroke: "black"}, | |
| init() { | |
| return { | |
| title: new fabric.Text("AND", { | |
| left: 10, top: 8, | |
| fontSize: 15, fontFamily: "Courier New" | |
| }), | |
| in1Label: new fabric.Text("in1:", {left: 15, top: 32, fontSize: 13, fontFamily: "Courier New"}), | |
| in1Val: new fabric.Text("", {left: 50, top: 32, fontSize: 13, fontFamily: "Courier New"}), | |
| in2Label: new fabric.Text("in2:", {left: 15, top: 48, fontSize: 13, fontFamily: "Courier New"}), | |
| in2Val: new fabric.Text("", {left: 50, top: 48, fontSize: 13, fontFamily: "Courier New"}), | |
| outLabel: new fabric.Text("out:", {left: 15, top: 68, fontSize: 13, fontFamily: "Courier New"}), | |
| outVal: new fabric.Text("", {left: 50, top: 68, fontSize: 13, fontFamily: "Courier New"}) | |
| } | |
| }, | |
| render() { | |
| let objs = this.getObjects() | |
| objs.in1Val.set({text: '$in1'.asBinaryStr()}) | |
| objs.in2Val.set({text: '$in2'.asBinaryStr()}) | |
| objs.outVal.set({text: '$out'.asBinaryStr()}) | |
| return [] | |
| }, | |
| where: {left: 200, top: 30} | |
| /sum | |
| $in1[2:0] = $cnt[2:0]; | |
| $in2[2:0] = $cnt[3:1]; | |
| $out[3:0] = $in1[2:0] + $in2[2:0]; | |
| \viz_js | |
| box: {width: 160, height: 115, strokeWidth: 1, stroke: "black"}, | |
| init() { | |
| return { | |
| title: new fabric.Text("3-bit Adder", { | |
| left: 10, top: 8, | |
| fontSize: 15, fontFamily: "Courier New" | |
| }), | |
| in1Label: new fabric.Text("in1:", {left: 15, top: 32, fontSize: 13, fontFamily: "Courier New"}), | |
| in1Val: new fabric.Text("", {left: 50, top: 32, fontSize: 13, fontFamily: "Courier New"}), | |
| in2Label: new fabric.Text("in2:", {left: 15, top: 50, fontSize: 13, fontFamily: "Courier New"}), | |
| in2Val: new fabric.Text("", {left: 50, top: 50, fontSize: 13, fontFamily: "Courier New"}), | |
| outLabel: new fabric.Text("out:", {left: 15, top: 72, fontSize: 13, fontFamily: "Courier New"}), | |
| outVal: new fabric.Text("", {left: 50, top: 72, fontSize: 13, fontFamily: "Courier New"}), | |
| calc: new fabric.Text("", {left: 15, top: 92, fontSize: 11, fontFamily: "Courier New", fill: "gray"}) | |
| } | |
| }, | |
| render() { | |
| let objs = this.getObjects() | |
| objs.in1Val.set({text: '$in1'.asBinaryStr()}) | |
| objs.in2Val.set({text: '$in2'.asBinaryStr()}) | |
| objs.outVal.set({text: '$out'.asBinaryStr()}) | |
| objs.calc.set({text: '$in1'.asInt() + " + " + '$in2'.asInt() + " = " + '$out'.asInt()}) | |
| return [] | |
| }, | |
| where: {left: 30, top: 150} | |
| /mux | |
| $out = $cond ? $case1 : $case0; | |
| /wide_mux | |
| $out[7:0] = | |
| $sel[0] | |
| ? $case0[7:0] : | |
| $sel[1] | |
| ? $case1[7:0] : | |
| //default | |
| $default[7:0]; | |
| /consts | |
| $eight[7:0] = 16'd8; | |
| $five[4:0] = 7'b101; | |
| $nine[31:0] = 9; | |
| $ones[7:2] = '1; | |
| /concat | |
| $digits[11:0] = {$digit2[3:0], 4'hf, $digit0[3:0]}; | |
| /repl | |
| $value[11:0] = {3{$digit[3:0]}}; | |
| /sign_extend_example | |
| $word[15:0] = {{8{$byte[7]}}, $byte[7:0]}; | |
| // Assert these to end simulation (before Makerchip cycle limit). | |
| *passed = *cyc_cnt > 40; | |
| *failed = 1'b0; | |
| \SV | |
| endmodule |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment